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 GetWasmFromResolvedPromise( | |
115 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
116 CHECK(args.Length() == 1); | |
117 v8::Local<v8::Promise> promise = v8::Local<v8::Promise>::Cast(args[0]); | |
118 CHECK(promise->State() == v8::Promise::PromiseState::kFulfilled); | |
119 args.GetReturnValue().Set(promise); | |
120 return true; | |
121 } | |
122 | |
123 } // namespace | 114 } // namespace |
124 | 115 |
125 namespace v8 { | 116 namespace v8 { |
126 namespace internal { | 117 namespace internal { |
127 | 118 |
128 RUNTIME_FUNCTION(Runtime_ConstructDouble) { | 119 RUNTIME_FUNCTION(Runtime_ConstructDouble) { |
129 HandleScope scope(isolate); | 120 HandleScope scope(isolate); |
130 DCHECK_EQ(2, args.length()); | 121 DCHECK_EQ(2, args.length()); |
131 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); | 122 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
132 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); | 123 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 DCHECK_EQ(1, args.length()); | 438 DCHECK_EQ(1, args.length()); |
448 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 439 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
449 function->ClearTypeFeedbackInfo(); | 440 function->ClearTypeFeedbackInfo(); |
450 Code* unoptimized = function->shared()->code(); | 441 Code* unoptimized = function->shared()->code(); |
451 if (unoptimized->kind() == Code::FUNCTION) { | 442 if (unoptimized->kind() == Code::FUNCTION) { |
452 unoptimized->ClearInlineCaches(); | 443 unoptimized->ClearInlineCaches(); |
453 } | 444 } |
454 return isolate->heap()->undefined_value(); | 445 return isolate->heap()->undefined_value(); |
455 } | 446 } |
456 | 447 |
457 RUNTIME_FUNCTION(Runtime_SetWasmCompileFromPromiseOverload) { | |
458 v8::ExtensionCallback old = isolate->wasm_compile_callback(); | |
459 HandleScope scope(isolate); | |
460 Handle<Foreign> ret = | |
461 isolate->factory()->NewForeign(reinterpret_cast<Address>(old)); | |
462 isolate->set_wasm_compile_callback(GetWasmFromResolvedPromise); | |
463 return *ret; | |
464 } | |
465 | |
466 RUNTIME_FUNCTION(Runtime_ResetWasmOverloads) { | |
467 HandleScope scope(isolate); | |
468 DCHECK_EQ(1, args.length()); | |
469 CONVERT_ARG_HANDLE_CHECKED(Foreign, old, 0); | |
470 isolate->set_wasm_compile_callback( | |
471 reinterpret_cast<v8::ExtensionCallback>(old->foreign_address())); | |
472 return isolate->heap()->undefined_value(); | |
473 } | |
474 | |
475 RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { | 448 RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { |
476 // This only supports the case where the function being exported | 449 // This only supports the case where the function being exported |
477 // calls an intermediate function, and the intermediate function | 450 // calls an intermediate function, and the intermediate function |
478 // calls exactly one imported function | 451 // calls exactly one imported function |
479 HandleScope scope(isolate); | 452 HandleScope scope(isolate); |
480 CHECK(args.length() == 2); | 453 CHECK(args.length() == 2); |
481 // It takes two parameters, the first one is the JSFunction, | 454 // It takes two parameters, the first one is the JSFunction, |
482 // The second one is the type | 455 // The second one is the type |
483 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 456 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
484 // If type is 0, it means that it is supposed to be a direct call into a WASM | 457 // If type is 0, it means that it is supposed to be a direct call into a WASM |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 isolate->IncrementWaitCountForTesting(); | 995 isolate->IncrementWaitCountForTesting(); |
1023 return isolate->heap()->undefined_value(); | 996 return isolate->heap()->undefined_value(); |
1024 } | 997 } |
1025 | 998 |
1026 RUNTIME_FUNCTION(Runtime_DecrementWaitCount) { | 999 RUNTIME_FUNCTION(Runtime_DecrementWaitCount) { |
1027 isolate->DecrementWaitCountForTesting(); | 1000 isolate->DecrementWaitCountForTesting(); |
1028 return isolate->heap()->undefined_value(); | 1001 return isolate->heap()->undefined_value(); |
1029 } | 1002 } |
1030 } // namespace internal | 1003 } // namespace internal |
1031 } // namespace v8 | 1004 } // namespace v8 |
OLD | NEW |