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

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

Issue 2625133005: Add @@toStringTag for WebAssembly classes (Closed)
Patch Set: Rebase once more Created 3 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 | « no previous file | test/mjsunit/wasm/js-api.js » ('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 6a9dde732e8e2ebdb4321e34e10c98ff088bfadb..21bcc0dc9d204e6ff12bec230099ed1f04864cea 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -778,14 +778,12 @@ void WasmJs::Install(Isolate* isolate) {
Handle<JSObject> webassembly = factory->NewJSObject(cons, TENURED);
PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM);
JSObject::AddProperty(global, name, webassembly, attributes);
-
- // Setup compile
+ PropertyAttributes ro_attributes =
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
+ JSObject::AddProperty(webassembly, factory->to_string_tag_symbol(),
+ v8_str(isolate, "WebAssembly"), ro_attributes);
InstallFunc(isolate, webassembly, "compile", WebAssemblyCompile, 1);
-
- // Setup validate
InstallFunc(isolate, webassembly, "validate", WebAssemblyValidate, 1);
-
- // Setup instantiate
InstallFunc(isolate, webassembly, "instantiate", WebAssemblyInstantiate, 1);
// Setup Module
@@ -798,12 +796,14 @@ void WasmJs::Install(Isolate* isolate) {
i::JS_API_OBJECT_TYPE, i::JSObject::kHeaderSize +
WasmModuleObject::kFieldCount * i::kPointerSize);
JSFunction::SetInitialMap(module_constructor, module_map, module_proto);
- JSObject::AddProperty(module_proto, isolate->factory()->constructor_string(),
- module_constructor, DONT_ENUM);
InstallFunc(isolate, module_constructor, "imports", WebAssemblyModuleImports,
1);
InstallFunc(isolate, module_constructor, "exports", WebAssemblyModuleExports,
1);
+ JSObject::AddProperty(module_proto, isolate->factory()->constructor_string(),
+ module_constructor, DONT_ENUM);
+ JSObject::AddProperty(module_proto, factory->to_string_tag_symbol(),
+ v8_str(isolate, "WebAssembly.Module"), ro_attributes);
// Setup Instance
Handle<JSFunction> instance_constructor =
@@ -818,6 +818,8 @@ void WasmJs::Install(Isolate* isolate) {
JSObject::AddProperty(instance_proto,
isolate->factory()->constructor_string(),
instance_constructor, DONT_ENUM);
+ JSObject::AddProperty(instance_proto, factory->to_string_tag_symbol(),
+ v8_str(isolate, "WebAssembly.Instance"), ro_attributes);
// Setup Table
Handle<JSFunction> table_constructor =
@@ -835,6 +837,8 @@ void WasmJs::Install(Isolate* isolate) {
InstallFunc(isolate, table_proto, "grow", WebAssemblyTableGrow, 1);
InstallFunc(isolate, table_proto, "get", WebAssemblyTableGet, 1);
InstallFunc(isolate, table_proto, "set", WebAssemblyTableSet, 2);
+ JSObject::AddProperty(table_proto, factory->to_string_tag_symbol(),
+ v8_str(isolate, "WebAssembly.Table"), ro_attributes);
// Setup Memory
Handle<JSFunction> memory_constructor =
@@ -850,6 +854,8 @@ void WasmJs::Install(Isolate* isolate) {
memory_constructor, DONT_ENUM);
InstallFunc(isolate, memory_proto, "grow", WebAssemblyMemoryGrow, 1);
InstallGetter(isolate, memory_proto, "buffer", WebAssemblyMemoryGetBuffer);
+ JSObject::AddProperty(memory_proto, factory->to_string_tag_symbol(),
+ v8_str(isolate, "WebAssembly.Memory"), ro_attributes);
// Setup errors
attributes = static_cast<PropertyAttributes>(DONT_ENUM);
« no previous file with comments | « no previous file | test/mjsunit/wasm/js-api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698