diff options
author | Michaël Zasso <targos@protonmail.com> | 2016-12-23 16:30:57 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-01-26 22:46:17 +0100 |
commit | 2739185b790e040c3b044c577327f5d44bffad4a (patch) | |
tree | 29a466999212f4c85958379d9d400eec8a185ba5 /deps/v8/src/asmjs/asm-js.cc | |
parent | a67a04d7654faaa04c8da00e42981ebc9fd0911c (diff) | |
download | node-new-2739185b790e040c3b044c577327f5d44bffad4a.tar.gz |
deps: update V8 to 5.5.372.40
PR-URL: https://github.com/nodejs/node/pull/9618
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/src/asmjs/asm-js.cc')
-rw-r--r-- | deps/v8/src/asmjs/asm-js.cc | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/deps/v8/src/asmjs/asm-js.cc b/deps/v8/src/asmjs/asm-js.cc index e94d91730e..a1af1af368 100644 --- a/deps/v8/src/asmjs/asm-js.cc +++ b/deps/v8/src/asmjs/asm-js.cc @@ -16,9 +16,9 @@ #include "src/objects.h" #include "src/parsing/parse-info.h" -#include "src/wasm/encoder.h" #include "src/wasm/module-decoder.h" #include "src/wasm/wasm-js.h" +#include "src/wasm/wasm-module-builder.h" #include "src/wasm/wasm-module.h" #include "src/wasm/wasm-result.h" @@ -30,29 +30,6 @@ namespace v8 { namespace internal { namespace { -i::MaybeHandle<i::FixedArray> CompileModule( - i::Isolate* isolate, const byte* start, const byte* end, - ErrorThrower* thrower, - internal::wasm::ModuleOrigin origin = i::wasm::kWasmOrigin) { - // Decode but avoid a redundant pass over function bodies for verification. - // Verification will happen during compilation. - i::Zone zone(isolate->allocator()); - internal::wasm::ModuleResult result = internal::wasm::DecodeWasmModule( - isolate, &zone, start, end, false, origin); - - i::MaybeHandle<i::FixedArray> compiled_module; - if (result.failed() && origin == internal::wasm::kAsmJsOrigin) { - thrower->Error("Asm.js converted module failed to decode"); - } else if (result.failed()) { - thrower->Failed("", result); - } else { - compiled_module = result.val->CompileFunctions(isolate, thrower); - } - - if (result.val) delete result.val; - return compiled_module; -} - Handle<i::Object> StdlibMathMember(i::Isolate* isolate, Handle<JSReceiver> stdlib, Handle<Name> name) { @@ -187,9 +164,9 @@ MaybeHandle<FixedArray> AsmJs::ConvertAsmToWasm(ParseInfo* info) { i::Handle<i::FixedArray> foreign_globals; auto module = builder.Run(&foreign_globals); - i::MaybeHandle<i::FixedArray> compiled = - CompileModule(info->isolate(), module->begin(), module->end(), &thrower, - internal::wasm::kAsmJsOrigin); + i::MaybeHandle<i::JSObject> compiled = wasm::CreateModuleObjectFromBytes( + info->isolate(), module->begin(), module->end(), &thrower, + internal::wasm::kAsmJsOrigin); DCHECK(!compiled.is_null()); wasm::AsmTyper::StdlibSet uses = typer.StdlibUses(); @@ -223,24 +200,25 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate, Handle<FixedArray> wasm_data, Handle<JSArrayBuffer> memory, Handle<JSReceiver> foreign) { - i::Handle<i::FixedArray> compiled(i::FixedArray::cast(wasm_data->get(0))); + i::Handle<i::JSObject> module(i::JSObject::cast(wasm_data->get(0))); i::Handle<i::FixedArray> foreign_globals( i::FixedArray::cast(wasm_data->get(1))); ErrorThrower thrower(isolate, "Asm.js -> WebAssembly instantiation"); i::MaybeHandle<i::JSObject> maybe_module_object = - i::wasm::WasmModule::Instantiate(isolate, compiled, foreign, memory); + i::wasm::WasmModule::Instantiate(isolate, &thrower, module, foreign, + memory); if (maybe_module_object.is_null()) { return MaybeHandle<Object>(); } - i::Handle<i::Name> name(isolate->factory()->InternalizeOneByteString( - STATIC_CHAR_VECTOR("__foreign_init__"))); + i::Handle<i::Name> init_name(isolate->factory()->InternalizeUtf8String( + wasm::AsmWasmBuilder::foreign_init_name)); i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); i::MaybeHandle<i::Object> maybe_init = - i::Object::GetProperty(module_object, name); + i::Object::GetProperty(module_object, init_name); DCHECK(!maybe_init.is_null()); i::Handle<i::Object> init = maybe_init.ToHandleChecked(); @@ -265,10 +243,18 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate, i::MaybeHandle<i::Object> retval = i::Execution::Call( isolate, init, undefined, foreign_globals->length(), foreign_args_array); delete[] foreign_args_array; - DCHECK(!retval.is_null()); - return maybe_module_object; + i::Handle<i::Name> single_function_name( + isolate->factory()->InternalizeUtf8String( + wasm::AsmWasmBuilder::single_function_name)); + i::MaybeHandle<i::Object> single_function = + i::Object::GetProperty(module_object, single_function_name); + if (!single_function.is_null() && + !single_function.ToHandleChecked()->IsUndefined(isolate)) { + return single_function; + } + return module_object; } } // namespace internal |