| 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 |
| 114 } // namespace | 123 } // namespace |
| 115 | 124 |
| 116 namespace v8 { | 125 namespace v8 { |
| 117 namespace internal { | 126 namespace internal { |
| 118 | 127 |
| 119 RUNTIME_FUNCTION(Runtime_ConstructDouble) { | 128 RUNTIME_FUNCTION(Runtime_ConstructDouble) { |
| 120 HandleScope scope(isolate); | 129 HandleScope scope(isolate); |
| 121 DCHECK_EQ(2, args.length()); | 130 DCHECK_EQ(2, args.length()); |
| 122 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); | 131 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
| 123 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); | 132 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 DCHECK_EQ(1, args.length()); | 447 DCHECK_EQ(1, args.length()); |
| 439 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 448 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 440 function->ClearTypeFeedbackInfo(); | 449 function->ClearTypeFeedbackInfo(); |
| 441 Code* unoptimized = function->shared()->code(); | 450 Code* unoptimized = function->shared()->code(); |
| 442 if (unoptimized->kind() == Code::FUNCTION) { | 451 if (unoptimized->kind() == Code::FUNCTION) { |
| 443 unoptimized->ClearInlineCaches(); | 452 unoptimized->ClearInlineCaches(); |
| 444 } | 453 } |
| 445 return isolate->heap()->undefined_value(); | 454 return isolate->heap()->undefined_value(); |
| 446 } | 455 } |
| 447 | 456 |
| 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 |
| 448 RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { | 475 RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { |
| 449 // This only supports the case where the function being exported | 476 // This only supports the case where the function being exported |
| 450 // calls an intermediate function, and the intermediate function | 477 // calls an intermediate function, and the intermediate function |
| 451 // calls exactly one imported function | 478 // calls exactly one imported function |
| 452 HandleScope scope(isolate); | 479 HandleScope scope(isolate); |
| 453 CHECK(args.length() == 2); | 480 CHECK(args.length() == 2); |
| 454 // It takes two parameters, the first one is the JSFunction, | 481 // It takes two parameters, the first one is the JSFunction, |
| 455 // The second one is the type | 482 // The second one is the type |
| 456 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 483 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 457 // If type is 0, it means that it is supposed to be a direct call into a WASM | 484 // 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... |
| 995 isolate->IncrementWaitCountForTesting(); | 1022 isolate->IncrementWaitCountForTesting(); |
| 996 return isolate->heap()->undefined_value(); | 1023 return isolate->heap()->undefined_value(); |
| 997 } | 1024 } |
| 998 | 1025 |
| 999 RUNTIME_FUNCTION(Runtime_DecrementWaitCount) { | 1026 RUNTIME_FUNCTION(Runtime_DecrementWaitCount) { |
| 1000 isolate->DecrementWaitCountForTesting(); | 1027 isolate->DecrementWaitCountForTesting(); |
| 1001 return isolate->heap()->undefined_value(); | 1028 return isolate->heap()->undefined_value(); |
| 1002 } | 1029 } |
| 1003 } // namespace internal | 1030 } // namespace internal |
| 1004 } // namespace v8 | 1031 } // namespace v8 |
| OLD | NEW |