| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/runtime/runtime-compiler.h" |
| 8 |
| 7 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 8 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
| 9 #include "src/compiler.h" | 11 #include "src/compiler.h" |
| 10 #include "src/deoptimizer.h" | 12 #include "src/deoptimizer.h" |
| 11 #include "src/frames-inl.h" | 13 #include "src/frames-inl.h" |
| 12 #include "src/full-codegen/full-codegen.h" | 14 #include "src/full-codegen/full-codegen.h" |
| 13 #include "src/isolate-inl.h" | 15 #include "src/isolate-inl.h" |
| 14 #include "src/messages.h" | 16 #include "src/messages.h" |
| 15 #include "src/v8threads.h" | 17 #include "src/v8threads.h" |
| 16 #include "src/vm-state-inl.h" | 18 #include "src/vm-state-inl.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); | 77 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
| 76 if (!Compiler::CompileOptimized(function, Compiler::NOT_CONCURRENT)) { | 78 if (!Compiler::CompileOptimized(function, Compiler::NOT_CONCURRENT)) { |
| 77 return isolate->heap()->exception(); | 79 return isolate->heap()->exception(); |
| 78 } | 80 } |
| 79 DCHECK(function->is_compiled()); | 81 DCHECK(function->is_compiled()); |
| 80 return function->code(); | 82 return function->code(); |
| 81 } | 83 } |
| 82 | 84 |
| 83 RUNTIME_FUNCTION(Runtime_InstantiateAsmJs) { | 85 RUNTIME_FUNCTION(Runtime_InstantiateAsmJs) { |
| 84 HandleScope scope(isolate); | 86 HandleScope scope(isolate); |
| 85 DCHECK_EQ(args.length(), 4); | 87 DCHECK_GE(args.length(), 1); |
| 86 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 88 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 87 | 89 |
| 88 Handle<JSObject> foreign; | 90 Handle<JSObject> foreign; |
| 89 if (args[2]->IsJSObject()) { | 91 if (args.length() > 2 && args[2]->IsJSObject()) { |
| 90 foreign = args.at<i::JSObject>(2); | 92 foreign = args.at<i::JSObject>(2); |
| 91 } | 93 } |
| 92 Handle<JSArrayBuffer> memory; | 94 Handle<JSArrayBuffer> memory; |
| 93 if (args[3]->IsJSArrayBuffer()) { | 95 if (args.length() > 3 && args[3]->IsJSArrayBuffer()) { |
| 94 memory = args.at<i::JSArrayBuffer>(3); | 96 memory = args.at<i::JSArrayBuffer>(3); |
| 95 } | 97 } |
| 96 if (args[1]->IsJSObject()) { | 98 if (args.length() > 1 && args[1]->IsJSObject() && |
| 99 function->shared()->HasAsmWasmData()) { |
| 97 MaybeHandle<Object> result; | 100 MaybeHandle<Object> result; |
| 98 result = AsmJs::InstantiateAsmWasm( | 101 result = AsmJs::InstantiateAsmWasm( |
| 99 isolate, handle(function->shared()->asm_wasm_data()), memory, foreign); | 102 isolate, handle(function->shared()->asm_wasm_data()), memory, foreign); |
| 100 if (!result.is_null()) { | 103 if (!result.is_null()) { |
| 101 return *result.ToHandleChecked(); | 104 return *result.ToHandleChecked(); |
| 102 } | 105 } |
| 103 } | 106 } |
| 104 // Remove wasm data and return a smi 0 to indicate failure. | 107 // Remove wasm data and return a smi 0 to indicate failure. |
| 105 function->shared()->ClearAsmWasmData(); | 108 function->shared()->ClearAsmWasmData(); |
| 106 return Smi::FromInt(0); | 109 return Smi::FromInt(0); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 DCHECK(is_valid_language_mode(args.smi_at(3))); | 432 DCHECK(is_valid_language_mode(args.smi_at(3))); |
| 430 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); | 433 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); |
| 431 DCHECK(args[4]->IsSmi()); | 434 DCHECK(args[4]->IsSmi()); |
| 432 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 435 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
| 433 isolate); | 436 isolate); |
| 434 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 437 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
| 435 language_mode, args.smi_at(4), args.smi_at(5)); | 438 language_mode, args.smi_at(4), args.smi_at(5)); |
| 436 } | 439 } |
| 437 } // namespace internal | 440 } // namespace internal |
| 438 } // namespace v8 | 441 } // namespace v8 |
| OLD | NEW |