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

Side by Side Diff: src/wasm/wasm-js.cc

Issue 1581643004: [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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/api.h" 5 #include "src/api.h"
6 #include "src/api-natives.h" 6 #include "src/api-natives.h"
7 #include "src/assert-scope.h" 7 #include "src/assert-scope.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 Handle<JSFunction> function = 300 Handle<JSFunction> function =
301 ApiNatives::InstantiateFunction(temp).ToHandleChecked(); 301 ApiNatives::InstantiateFunction(temp).ToHandleChecked();
302 PropertyAttributes attributes = 302 PropertyAttributes attributes =
303 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 303 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
304 JSObject::AddProperty(object, name, function, attributes); 304 JSObject::AddProperty(object, name, function, attributes);
305 } 305 }
306 306
307 307
308 void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) { 308 void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) {
309 // Setup wasm function map. 309 // Setup wasm function map.
310 Handle<Map> wasm_function_map = isolate->factory()->NewMap( 310 Handle<Context> context(global->native_context(), isolate);
311 JS_FUNCTION_TYPE, JSFunction::kSize + kPointerSize); 311 InstallWasmFunctionMap(isolate, context);
312 wasm_function_map->set_is_callable();
313 global->native_context()->set_wasm_function_map(*wasm_function_map);
314 312
315 // Bind the WASM object. 313 // Bind the WASM object.
316 Factory* factory = isolate->factory(); 314 Factory* factory = isolate->factory();
317 Handle<String> name = v8_str(isolate, "_WASMEXP_"); 315 Handle<String> name = v8_str(isolate, "_WASMEXP_");
318 Handle<JSFunction> cons = factory->NewFunction(name); 316 Handle<JSFunction> cons = factory->NewFunction(name);
319 JSFunction::SetInstancePrototype( 317 JSFunction::SetInstancePrototype(
320 cons, Handle<Object>(global->native_context()->initial_object_prototype(), 318 cons, Handle<Object>(context->initial_object_prototype(), isolate));
321 isolate));
322 cons->shared()->set_instance_class_name(*name); 319 cons->shared()->set_instance_class_name(*name);
323 Handle<JSObject> wasm_object = factory->NewJSObject(cons, TENURED); 320 Handle<JSObject> wasm_object = factory->NewJSObject(cons, TENURED);
324 PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM); 321 PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM);
325 JSObject::AddProperty(global, name, wasm_object, attributes); 322 JSObject::AddProperty(global, name, wasm_object, attributes);
326 323
327 // Install functions on the WASM object. 324 // Install functions on the WASM object.
328 InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule); 325 InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule);
329 InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule); 326 InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule);
330 InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction); 327 InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction);
331 InstallFunc(isolate, wasm_object, "compileRun", CompileRun); 328 InstallFunc(isolate, wasm_object, "compileRun", CompileRun);
332 InstallFunc(isolate, wasm_object, "asmCompileRun", AsmCompileRun); 329 InstallFunc(isolate, wasm_object, "asmCompileRun", AsmCompileRun);
333 InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm", 330 InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm",
334 InstantiateModuleFromAsm); 331 InstantiateModuleFromAsm);
335 } 332 }
333
334
335 void WasmJs::InstallWasmFunctionMap(Isolate* isolate, Handle<Context> context) {
336 if (!context->get(Context::WASM_FUNCTION_MAP_INDEX)->IsMap()) {
337 Handle<Map> wasm_function_map = isolate->factory()->NewMap(
338 JS_FUNCTION_TYPE, JSFunction::kSize + kPointerSize);
339 wasm_function_map->set_is_callable();
340 context->set_wasm_function_map(*wasm_function_map);
341 }
342 }
343
336 } // namespace internal 344 } // namespace internal
337 } // namespace v8 345 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-js.h ('k') | test/cctest/cctest.gyp » ('j') | test/cctest/wasm/test-run-wasm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698