Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: src/wasm/wasm-js.cc

Issue 1581393003: Reland of [wasm] Add tests for JS wrappers to test-run-wasm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-js.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-js.cc
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc
index d8b2822c9b0c2e2bdaac4724d9be4987667f30b2..80d8bdb2369e1b87e4fbf3427c19660f4a3e3bb6 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -307,18 +307,15 @@ static void InstallFunc(Isolate* isolate, Handle<JSObject> object,
void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) {
// Setup wasm function map.
- Handle<Map> wasm_function_map = isolate->factory()->NewMap(
- JS_FUNCTION_TYPE, JSFunction::kSize + kPointerSize);
- wasm_function_map->set_is_callable();
- global->native_context()->set_wasm_function_map(*wasm_function_map);
+ Handle<Context> context(global->native_context(), isolate);
+ InstallWasmFunctionMap(isolate, context);
// Bind the WASM object.
Factory* factory = isolate->factory();
Handle<String> name = v8_str(isolate, "_WASMEXP_");
Handle<JSFunction> cons = factory->NewFunction(name);
JSFunction::SetInstancePrototype(
- cons, Handle<Object>(global->native_context()->initial_object_prototype(),
- isolate));
+ cons, Handle<Object>(context->initial_object_prototype(), isolate));
cons->shared()->set_instance_class_name(*name);
Handle<JSObject> wasm_object = factory->NewJSObject(cons, TENURED);
PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM);
@@ -333,5 +330,16 @@ void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) {
InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm",
InstantiateModuleFromAsm);
}
+
+
+void WasmJs::InstallWasmFunctionMap(Isolate* isolate, Handle<Context> context) {
+ if (!context->get(Context::WASM_FUNCTION_MAP_INDEX)->IsMap()) {
+ Handle<Map> wasm_function_map = isolate->factory()->NewMap(
+ JS_FUNCTION_TYPE, JSFunction::kSize + kPointerSize);
+ wasm_function_map->set_is_callable();
+ context->set_wasm_function_map(*wasm_function_map);
+ }
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/wasm/wasm-js.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698