diff options
Diffstat (limited to 'deps/v8/src/runtime/runtime-test.cc')
-rw-r--r-- | deps/v8/src/runtime/runtime-test.cc | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/deps/v8/src/runtime/runtime-test.cc b/deps/v8/src/runtime/runtime-test.cc index 94376e1364..bcc36e9d87 100644 --- a/deps/v8/src/runtime/runtime-test.cc +++ b/deps/v8/src/runtime/runtime-test.cc @@ -10,6 +10,7 @@ #include "src/api-inl.h" #include "src/arguments-inl.h" #include "src/assembler-inl.h" +#include "src/base/platform/mutex.h" #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" #include "src/compiler.h" #include "src/deoptimizer.h" @@ -25,6 +26,9 @@ #include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-serialization.h" +namespace v8 { +namespace internal { + namespace { struct WasmCompileControls { uint32_t MaxWasmBufferSize = std::numeric_limits<uint32_t>::max(); @@ -32,14 +36,16 @@ struct WasmCompileControls { }; // We need per-isolate controls, because we sometimes run tests in multiple -// isolates -// concurrently. +// isolates concurrently. Methods need to hold the accompanying mutex on access. // To avoid upsetting the static initializer count, we lazy initialize this. -v8::base::LazyInstance<std::map<v8::Isolate*, WasmCompileControls>>::type +base::LazyInstance<std::map<v8::Isolate*, WasmCompileControls>>::type g_PerIsolateWasmControls = LAZY_INSTANCE_INITIALIZER; +base::LazyInstance<base::Mutex>::type g_PerIsolateWasmControlsMutex = + LAZY_INSTANCE_INITIALIZER; bool IsWasmCompileAllowed(v8::Isolate* isolate, v8::Local<v8::Value> value, bool is_async) { + base::LockGuard<base::Mutex> guard(g_PerIsolateWasmControlsMutex.Pointer()); DCHECK_GT(g_PerIsolateWasmControls.Get().count(isolate), 0); const WasmCompileControls& ctrls = g_PerIsolateWasmControls.Get().at(isolate); return (is_async && ctrls.AllowAnySizeForAsync) || @@ -52,6 +58,7 @@ bool IsWasmCompileAllowed(v8::Isolate* isolate, v8::Local<v8::Value> value, bool IsWasmInstantiateAllowed(v8::Isolate* isolate, v8::Local<v8::Value> module_or_bytes, bool is_async) { + base::LockGuard<base::Mutex> guard(g_PerIsolateWasmControlsMutex.Pointer()); DCHECK_GT(g_PerIsolateWasmControls.Get().count(isolate), 0); const WasmCompileControls& ctrls = g_PerIsolateWasmControls.Get().at(isolate); if (is_async && ctrls.AllowAnySizeForAsync) return true; @@ -91,9 +98,6 @@ bool WasmInstanceOverride(const v8::FunctionCallbackInfo<v8::Value>& args) { } // namespace -namespace v8 { -namespace internal { - RUNTIME_FUNCTION(Runtime_ConstructDouble) { HandleScope scope(isolate); DCHECK_EQ(2, args.length()); @@ -477,6 +481,7 @@ RUNTIME_FUNCTION(Runtime_SetWasmCompileControls) { CHECK_EQ(args.length(), 2); CONVERT_ARG_HANDLE_CHECKED(Smi, block_size, 0); CONVERT_BOOLEAN_ARG_CHECKED(allow_async, 1); + base::LockGuard<base::Mutex> guard(g_PerIsolateWasmControlsMutex.Pointer()); WasmCompileControls& ctrl = (*g_PerIsolateWasmControls.Pointer())[v8_isolate]; ctrl.AllowAnySizeForAsync = allow_async; ctrl.MaxWasmBufferSize = static_cast<uint32_t>(block_size->value()); @@ -533,17 +538,18 @@ RUNTIME_FUNCTION(Runtime_DebugPrint) { MaybeObject* maybe_object = reinterpret_cast<MaybeObject*>(args[0]); StdoutStream os; - if (maybe_object->IsClearedWeakHeapObject()) { + if (maybe_object->IsCleared()) { os << "[weak cleared]"; } else { Object* object; + HeapObject* heap_object; bool weak = false; - if (maybe_object->IsWeakHeapObject()) { + if (maybe_object->GetHeapObjectIfWeak(&heap_object)) { weak = true; - object = maybe_object->ToWeakHeapObject(); + object = heap_object; } else { // Strong reference or SMI. - object = maybe_object->ToObject(); + object = maybe_object->cast<Object>(); } #ifdef DEBUG @@ -830,12 +836,39 @@ RUNTIME_FUNCTION(Runtime_IsWasmTrapHandlerEnabled) { } RUNTIME_FUNCTION(Runtime_GetWasmRecoveredTrapCount) { - HandleScope shs(isolate); + HandleScope scope(isolate); DCHECK_EQ(0, args.length()); size_t trap_count = trap_handler::GetRecoveredTrapCount(); return *isolate->factory()->NewNumberFromSize(trap_count); } +RUNTIME_FUNCTION(Runtime_GetWasmExceptionId) { + HandleScope scope(isolate); + DCHECK_EQ(2, args.length()); + CONVERT_ARG_HANDLE_CHECKED(JSReceiver, exception, 0); + CONVERT_ARG_HANDLE_CHECKED(WasmInstanceObject, instance, 1); + Handle<Object> tag; + if (JSReceiver::GetProperty(isolate, exception, + isolate->factory()->wasm_exception_tag_symbol()) + .ToHandle(&tag)) { + Handle<FixedArray> exceptions_table(instance->exceptions_table(), isolate); + for (int index = 0; index < exceptions_table->length(); ++index) { + if (exceptions_table->get(index) == *tag) return Smi::FromInt(index); + } + } + return ReadOnlyRoots(isolate).undefined_value(); +} + +RUNTIME_FUNCTION(Runtime_GetWasmExceptionValues) { + HandleScope scope(isolate); + DCHECK_EQ(1, args.length()); + CONVERT_ARG_HANDLE_CHECKED(JSReceiver, exception, 0); + RETURN_RESULT_OR_FAILURE( + isolate, JSReceiver::GetProperty( + isolate, exception, + isolate->factory()->wasm_exception_values_symbol())); +} + namespace { bool EnableWasmThreads(v8::Local<v8::Context> context) { return true; } @@ -902,6 +935,13 @@ RUNTIME_FUNCTION(Runtime_PromiseSpeciesProtector) { isolate->IsPromiseSpeciesLookupChainIntact()); } +RUNTIME_FUNCTION(Runtime_StringIteratorProtector) { + SealHandleScope shs(isolate); + DCHECK_EQ(0, args.length()); + return isolate->heap()->ToBoolean( + isolate->IsStringIteratorLookupChainIntact()); +} + // Take a compiled wasm module and serialize it into an array buffer, which is // then returned. RUNTIME_FUNCTION(Runtime_SerializeWasmModule) { @@ -937,9 +977,9 @@ RUNTIME_FUNCTION(Runtime_DeserializeWasmModule) { wasm::DeserializeNativeModule( isolate, {reinterpret_cast<uint8_t*>(buffer->backing_store()), - static_cast<size_t>(buffer->byte_length()->Number())}, + buffer->byte_length()}, {reinterpret_cast<uint8_t*>(wire_bytes->backing_store()), - static_cast<size_t>(wire_bytes->byte_length()->Number())}); + wire_bytes->byte_length()}); Handle<WasmModuleObject> module_object; if (!maybe_module_object.ToHandle(&module_object)) { return ReadOnlyRoots(isolate).undefined_value(); @@ -971,7 +1011,7 @@ RUNTIME_FUNCTION(Runtime_WasmGetNumberOfInstances) { int instance_count = 0; WeakArrayList* weak_instance_list = module_obj->weak_instance_list(); for (int i = 0; i < weak_instance_list->length(); ++i) { - if (weak_instance_list->Get(i)->IsWeakHeapObject()) instance_count++; + if (weak_instance_list->Get(i)->IsWeak()) instance_count++; } return Smi::FromInt(instance_count); } @@ -980,7 +1020,7 @@ RUNTIME_FUNCTION(Runtime_WasmNumInterpretedCalls) { DCHECK_EQ(1, args.length()); HandleScope scope(isolate); CONVERT_ARG_HANDLE_CHECKED(WasmInstanceObject, instance, 0); - if (!instance->has_debug_info()) return 0; + if (!instance->has_debug_info()) return nullptr; uint64_t num = instance->debug_info()->NumInterpretedCalls(); return *isolate->factory()->NewNumberFromSize(static_cast<size_t>(num)); } |