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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/assembler-inl.h" | 10 #include "src/assembler-inl.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 ThrowRangeException(args.GetIsolate(), "Sync instantiate not allowed"); | 104 ThrowRangeException(args.GetIsolate(), "Sync instantiate not allowed"); |
105 return true; | 105 return true; |
106 } | 106 } |
107 | 107 |
108 bool WasmInstantiateOverride(const v8::FunctionCallbackInfo<v8::Value>& args) { | 108 bool WasmInstantiateOverride(const v8::FunctionCallbackInfo<v8::Value>& args) { |
109 if (IsWasmInstantiateAllowed(args.GetIsolate(), args[0], true)) return false; | 109 if (IsWasmInstantiateAllowed(args.GetIsolate(), args[0], true)) return false; |
110 RejectPromiseWithRangeError(args, "Async instantiate not allowed"); | 110 RejectPromiseWithRangeError(args, "Async instantiate not allowed"); |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
| 114 bool GetWasmFromArray(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 115 CHECK(args.Length() == 1); |
| 116 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); |
| 117 v8::Local<v8::Value> module = |
| 118 v8::Local<v8::Object>::Cast(args[0])->Get(context, 0).ToLocalChecked(); |
| 119 |
| 120 v8::Local<v8::Promise::Resolver> resolver = |
| 121 v8::Promise::Resolver::New(context).ToLocalChecked(); |
| 122 args.GetReturnValue().Set(resolver->GetPromise()); |
| 123 USE(resolver->Resolve(context, module)); |
| 124 return true; |
| 125 } |
| 126 |
| 127 bool NoExtension(const v8::FunctionCallbackInfo<v8::Value>&) { return false; } |
| 128 |
114 } // namespace | 129 } // namespace |
115 | 130 |
116 namespace v8 { | 131 namespace v8 { |
117 namespace internal { | 132 namespace internal { |
118 | 133 |
119 RUNTIME_FUNCTION(Runtime_ConstructDouble) { | 134 RUNTIME_FUNCTION(Runtime_ConstructDouble) { |
120 HandleScope scope(isolate); | 135 HandleScope scope(isolate); |
121 DCHECK_EQ(2, args.length()); | 136 DCHECK_EQ(2, args.length()); |
122 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); | 137 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
123 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); | 138 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 DCHECK_EQ(1, args.length()); | 460 DCHECK_EQ(1, args.length()); |
446 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 461 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
447 function->ClearTypeFeedbackInfo(); | 462 function->ClearTypeFeedbackInfo(); |
448 Code* unoptimized = function->shared()->code(); | 463 Code* unoptimized = function->shared()->code(); |
449 if (unoptimized->kind() == Code::FUNCTION) { | 464 if (unoptimized->kind() == Code::FUNCTION) { |
450 unoptimized->ClearInlineCaches(); | 465 unoptimized->ClearInlineCaches(); |
451 } | 466 } |
452 return isolate->heap()->undefined_value(); | 467 return isolate->heap()->undefined_value(); |
453 } | 468 } |
454 | 469 |
| 470 RUNTIME_FUNCTION(Runtime_SetWasmCompileFromPromiseOverload) { |
| 471 isolate->set_wasm_compile_callback(GetWasmFromArray); |
| 472 return isolate->heap()->undefined_value(); |
| 473 } |
| 474 |
| 475 RUNTIME_FUNCTION(Runtime_ResetWasmOverloads) { |
| 476 isolate->set_wasm_compile_callback(NoExtension); |
| 477 return isolate->heap()->undefined_value(); |
| 478 } |
| 479 |
455 RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { | 480 RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { |
456 // This only supports the case where the function being exported | 481 // This only supports the case where the function being exported |
457 // calls an intermediate function, and the intermediate function | 482 // calls an intermediate function, and the intermediate function |
458 // calls exactly one imported function | 483 // calls exactly one imported function |
459 HandleScope scope(isolate); | 484 HandleScope scope(isolate); |
460 CHECK(args.length() == 2); | 485 CHECK(args.length() == 2); |
461 // It takes two parameters, the first one is the JSFunction, | 486 // It takes two parameters, the first one is the JSFunction, |
462 // The second one is the type | 487 // The second one is the type |
463 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 488 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
464 // If type is 0, it means that it is supposed to be a direct call into a WASM | 489 // If type is 0, it means that it is supposed to be a direct call into a WASM |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 | 1025 |
1001 RUNTIME_FUNCTION(Runtime_IncrementWaitCount) { | 1026 RUNTIME_FUNCTION(Runtime_IncrementWaitCount) { |
1002 isolate->IncrementWaitCountForTesting(); | 1027 isolate->IncrementWaitCountForTesting(); |
1003 return isolate->heap()->undefined_value(); | 1028 return isolate->heap()->undefined_value(); |
1004 } | 1029 } |
1005 | 1030 |
1006 RUNTIME_FUNCTION(Runtime_DecrementWaitCount) { | 1031 RUNTIME_FUNCTION(Runtime_DecrementWaitCount) { |
1007 isolate->DecrementWaitCountForTesting(); | 1032 isolate->DecrementWaitCountForTesting(); |
1008 return isolate->heap()->undefined_value(); | 1033 return isolate->heap()->undefined_value(); |
1009 } | 1034 } |
| 1035 |
1010 } // namespace internal | 1036 } // namespace internal |
1011 } // namespace v8 | 1037 } // namespace v8 |
OLD | NEW |