diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-03-07 08:54:53 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-03-07 16:48:52 +0100 |
commit | 88786fecff336342a56e6f2e7ff3b286be716e47 (patch) | |
tree | 92e6ba5b8ac8dae1a058988d20c9d27bfa654390 /deps/v8/src/runtime/runtime-test.cc | |
parent | 4e86f9b5ab83cbabf43839385bf383e6a7ef7d19 (diff) | |
download | node-new-88786fecff336342a56e6f2e7ff3b286be716e47.tar.gz |
deps: update V8 to 6.5.254.31
PR-URL: https://github.com/nodejs/node/pull/18453
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'deps/v8/src/runtime/runtime-test.cc')
-rw-r--r-- | deps/v8/src/runtime/runtime-test.cc | 128 |
1 files changed, 62 insertions, 66 deletions
diff --git a/deps/v8/src/runtime/runtime-test.cc b/deps/v8/src/runtime/runtime-test.cc index b3cdf3fe67..01e2b198a6 100644 --- a/deps/v8/src/runtime/runtime-test.cc +++ b/deps/v8/src/runtime/runtime-test.cc @@ -15,10 +15,11 @@ #include "src/frames-inl.h" #include "src/isolate-inl.h" #include "src/runtime-profiler.h" -#include "src/snapshot/code-serializer.h" #include "src/snapshot/natives.h" #include "src/trap-handler/trap-handler.h" #include "src/wasm/memory-tracing.h" +#include "src/wasm/module-compiler.h" +#include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-module.h" #include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-serialization.h" @@ -41,8 +42,9 @@ bool IsWasmCompileAllowed(v8::Isolate* isolate, v8::Local<v8::Value> value, DCHECK_GT(g_PerIsolateWasmControls.Get().count(isolate), 0); const WasmCompileControls& ctrls = g_PerIsolateWasmControls.Get().at(isolate); return (is_async && ctrls.AllowAnySizeForAsync) || - (v8::Local<v8::ArrayBuffer>::Cast(value)->ByteLength() <= - ctrls.MaxWasmBufferSize); + (value->IsArrayBuffer() && + v8::Local<v8::ArrayBuffer>::Cast(value)->ByteLength() <= + ctrls.MaxWasmBufferSize); } // Use the compile controls for instantiation, too @@ -307,7 +309,8 @@ RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { return isolate->heap()->undefined_value(); } Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); - function->shared()->DisableOptimization(kOptimizationDisabledForTest); + function->shared()->DisableOptimization( + BailoutReason::kOptimizationDisabledForTest); return isolate->heap()->undefined_value(); } @@ -499,8 +502,8 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { : rinfo->target_address(); if (FLAG_wasm_jit_to_native) { wasm::WasmCode* target = - isolate->wasm_code_manager()->LookupCode(target_address); - if (target->kind() == wasm::WasmCode::Function) { + isolate->wasm_engine()->code_manager()->LookupCode(target_address); + if (target->kind() == wasm::WasmCode::kFunction) { ++count; export_fct = target; } @@ -523,8 +526,8 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { RelocInfo* rinfo = it.rinfo(); Address target_address = rinfo->target_address(); wasm::WasmCode* target = - isolate->wasm_code_manager()->LookupCode(target_address); - if (target->kind() == wasm::WasmCode::Function) { + isolate->wasm_engine()->code_manager()->LookupCode(target_address); + if (target->kind() == wasm::WasmCode::kFunction) { ++count; intermediate_fct = target; } @@ -549,8 +552,8 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { count = 0; if (FLAG_wasm_jit_to_native) { wasm::WasmCode::Kind target_kind = type->value() == 0 - ? wasm::WasmCode::WasmToWasmWrapper - : wasm::WasmCode::WasmToJsWrapper; + ? wasm::WasmCode::kWasmToWasmWrapper + : wasm::WasmCode::kWasmToJsWrapper; for (RelocIterator it(intermediate_fct->instructions(), intermediate_fct->reloc_info(), intermediate_fct->constant_pool(), @@ -559,7 +562,7 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { RelocInfo* rinfo = it.rinfo(); Address target_address = rinfo->target_address(); wasm::WasmCode* target = - isolate->wasm_code_manager()->LookupCode(target_address); + isolate->wasm_engine()->code_manager()->LookupCode(target_address); if (target->kind() == target_kind) { ++count; } @@ -614,10 +617,12 @@ RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { SealHandleScope shs(isolate); DCHECK(args.length() == 2 || args.length() == 3); -#ifdef DEBUG - CONVERT_INT32_ARG_CHECKED(interval, 0); +#ifdef V8_ENABLE_ALLOCATION_TIMEOUT CONVERT_INT32_ARG_CHECKED(timeout, 1); isolate->heap()->set_allocation_timeout(timeout); +#endif +#ifdef DEBUG + CONVERT_INT32_ARG_CHECKED(interval, 0); FLAG_gc_interval = interval; if (args.length() == 3) { // Enable/disable inline allocation if requested. @@ -757,8 +762,7 @@ RUNTIME_FUNCTION(Runtime_Abort) { SealHandleScope shs(isolate); DCHECK_EQ(1, args.length()); CONVERT_SMI_ARG_CHECKED(message_id, 0); - const char* message = - GetBailoutReason(static_cast<BailoutReason>(message_id)); + const char* message = GetAbortReason(static_cast<AbortReason>(message_id)); base::OS::PrintError("abort: %s\n", message); isolate->PrintStack(stderr); base::OS::Abort(); @@ -936,8 +940,7 @@ RUNTIME_FUNCTION(Runtime_IsWasmCode) { RUNTIME_FUNCTION(Runtime_IsWasmTrapHandlerEnabled) { DisallowHeapAllocation no_gc; DCHECK_EQ(0, args.length()); - bool is_enabled = trap_handler::UseTrapHandler(); - return isolate->heap()->ToBoolean(is_enabled); + return isolate->heap()->ToBoolean(trap_handler::IsTrapHandlerEnabled()); } RUNTIME_FUNCTION(Runtime_GetWasmRecoveredTrapCount) { @@ -993,24 +996,14 @@ RUNTIME_FUNCTION(Runtime_SerializeWasmModule) { CONVERT_ARG_HANDLE_CHECKED(WasmModuleObject, module_obj, 0); Handle<WasmCompiledModule> orig(module_obj->compiled_module()); - if (FLAG_wasm_jit_to_native) { - std::pair<std::unique_ptr<byte[]>, size_t> serialized_module = - wasm::NativeModuleSerializer::SerializeWholeModule(isolate, orig); - int data_size = static_cast<int>(serialized_module.second); - void* buff = isolate->array_buffer_allocator()->Allocate(data_size); - Handle<JSArrayBuffer> ret = isolate->factory()->NewJSArrayBuffer(); - JSArrayBuffer::Setup(ret, isolate, false, buff, data_size); - memcpy(buff, serialized_module.first.get(), data_size); - return *ret; - } else { - std::unique_ptr<ScriptData> data = - WasmCompiledModuleSerializer::SerializeWasmModule(isolate, orig); - void* buff = isolate->array_buffer_allocator()->Allocate(data->length()); - Handle<JSArrayBuffer> ret = isolate->factory()->NewJSArrayBuffer(); - JSArrayBuffer::Setup(ret, isolate, false, buff, data->length()); - memcpy(buff, data->data(), data->length()); - return *ret; - } + std::pair<std::unique_ptr<const byte[]>, size_t> serialized_module = + wasm::SerializeNativeModule(isolate, orig); + int data_size = static_cast<int>(serialized_module.second); + void* buff = isolate->array_buffer_allocator()->Allocate(data_size); + Handle<JSArrayBuffer> ret = isolate->factory()->NewJSArrayBuffer(); + JSArrayBuffer::Setup(ret, isolate, false, buff, data_size); + memcpy(buff, serialized_module.first.get(), data_size); + return *ret; } // Take an array buffer and attempt to reconstruct a compiled wasm module. @@ -1024,39 +1017,28 @@ RUNTIME_FUNCTION(Runtime_DeserializeWasmModule) { Address mem_start = static_cast<Address>(buffer->backing_store()); size_t mem_size = static_cast<size_t>(buffer->byte_length()->Number()); - // DeserializeWasmModule will allocate. We assume JSArrayBuffer doesn't - // get relocated. + // Note that {wasm::DeserializeNativeModule} will allocate. We assume the + // JSArrayBuffer doesn't get relocated. bool already_external = wire_bytes->is_external(); if (!already_external) { wire_bytes->set_is_external(true); isolate->heap()->UnregisterArrayBuffer(*wire_bytes); } - MaybeHandle<FixedArray> maybe_compiled_module; - if (FLAG_wasm_jit_to_native) { - maybe_compiled_module = - wasm::NativeModuleDeserializer::DeserializeFullBuffer( - isolate, {mem_start, mem_size}, - Vector<const uint8_t>( - reinterpret_cast<uint8_t*>(wire_bytes->backing_store()), - static_cast<int>(wire_bytes->byte_length()->Number()))); - } else { - ScriptData sc(mem_start, static_cast<int>(mem_size)); - maybe_compiled_module = WasmCompiledModuleSerializer::DeserializeWasmModule( - isolate, &sc, - Vector<const uint8_t>( - reinterpret_cast<uint8_t*>(wire_bytes->backing_store()), - static_cast<int>(wire_bytes->byte_length()->Number()))); - } + MaybeHandle<WasmCompiledModule> maybe_compiled_module = + wasm::DeserializeNativeModule( + isolate, {mem_start, mem_size}, + Vector<const uint8_t>( + reinterpret_cast<uint8_t*>(wire_bytes->backing_store()), + static_cast<int>(wire_bytes->byte_length()->Number()))); if (!already_external) { wire_bytes->set_is_external(false); isolate->heap()->RegisterNewArrayBuffer(*wire_bytes); } - Handle<FixedArray> compiled_module; + Handle<WasmCompiledModule> compiled_module; if (!maybe_compiled_module.ToHandle(&compiled_module)) { return isolate->heap()->undefined_value(); } - return *WasmModuleObject::New( - isolate, Handle<WasmCompiledModule>::cast(compiled_module)); + return *WasmModuleObject::New(isolate, compiled_module); } RUNTIME_FUNCTION(Runtime_ValidateWasmInstancesChain) { @@ -1125,11 +1107,11 @@ RUNTIME_FUNCTION(Runtime_RedirectToWasmInterpreter) { RUNTIME_FUNCTION(Runtime_WasmTraceMemory) { HandleScope hs(isolate); - DCHECK_EQ(4, args.length()); - CONVERT_SMI_ARG_CHECKED(is_store, 0); - CONVERT_SMI_ARG_CHECKED(mem_rep, 1); - CONVERT_SMI_ARG_CHECKED(addr_low, 2); - CONVERT_SMI_ARG_CHECKED(addr_high, 3); + DCHECK_EQ(1, args.length()); + CONVERT_ARG_CHECKED(Smi, info_addr, 0); + + wasm::MemoryTracingInfo* info = + reinterpret_cast<wasm::MemoryTracingInfo*>(info_addr); // Find the caller wasm frame. StackTraceFrameIterator it(isolate); @@ -1137,8 +1119,6 @@ RUNTIME_FUNCTION(Runtime_WasmTraceMemory) { DCHECK(it.is_wasm()); WasmCompiledFrame* frame = WasmCompiledFrame::cast(it.frame()); - uint32_t addr = (static_cast<uint32_t>(addr_low) & 0xffff) | - (static_cast<uint32_t>(addr_high) << 16); uint8_t* mem_start = reinterpret_cast<uint8_t*>(frame->wasm_instance() ->memory_object() ->array_buffer() @@ -1148,9 +1128,11 @@ RUNTIME_FUNCTION(Runtime_WasmTraceMemory) { // TODO(titzer): eliminate dependency on WasmModule definition here. int func_start = frame->wasm_instance()->module()->functions[func_index].code.offset(); - tracing::TraceMemoryOperation(tracing::kWasmCompiled, is_store, - MachineRepresentation(mem_rep), addr, - func_index, pos - func_start, mem_start); + wasm::ExecutionEngine eng = frame->wasm_code().is_liftoff() + ? wasm::ExecutionEngine::kLiftoff + : wasm::ExecutionEngine::kTurbofan; + wasm::TraceMemoryOperation(eng, info, func_index, pos - func_start, + mem_start); return isolate->heap()->undefined_value(); } @@ -1180,5 +1162,19 @@ RUNTIME_FUNCTION(Runtime_CompleteInobjectSlackTracking) { return isolate->heap()->undefined_value(); } +RUNTIME_FUNCTION(Runtime_FreezeWasmLazyCompilation) { + DCHECK_EQ(1, args.length()); + DisallowHeapAllocation no_gc; + CONVERT_ARG_CHECKED(WasmInstanceObject, instance, 0); + + WasmSharedModuleData* shared = instance->compiled_module()->shared(); + CHECK(shared->has_lazy_compilation_orchestrator()); + auto* orchestrator = Managed<wasm::LazyCompilationOrchestrator>::cast( + shared->lazy_compilation_orchestrator()) + ->get(); + orchestrator->FreezeLazyCompilationForTesting(); + return isolate->heap()->undefined_value(); +} + } // namespace internal } // namespace v8 |