Commit 77705776 authored by mtrofin's avatar mtrofin Committed by Commit bot

[wasm] JSAPI conformance: instance.exports has null prototype.

BUG=v8:5885

Review-Url: https://codereview.chromium.org/2649163004
Cr-Commit-Position: refs/heads/master@{#42636}
parent a76e9f38
...@@ -1723,9 +1723,9 @@ Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, ...@@ -1723,9 +1723,9 @@ Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor,
isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject);
} }
Handle<JSObject> Factory::NewJSObjectWithNullProto(PretenureFlag pretenure) {
Handle<JSObject> Factory::NewJSObjectWithNullProto() { Handle<JSObject> result =
Handle<JSObject> result = NewJSObject(isolate()->object_function()); NewJSObject(isolate()->object_function(), pretenure);
Handle<Map> new_map = Handle<Map> new_map =
Map::Copy(Handle<Map>(result->map()), "ObjectWithNullProto"); Map::Copy(Handle<Map>(result->map()), "ObjectWithNullProto");
Map::SetPrototype(new_map, null_value()); Map::SetPrototype(new_map, null_value());
......
...@@ -475,7 +475,8 @@ class V8_EXPORT_PRIVATE Factory final { ...@@ -475,7 +475,8 @@ class V8_EXPORT_PRIVATE Factory final {
Handle<JSObject> NewJSObject(Handle<JSFunction> constructor, Handle<JSObject> NewJSObject(Handle<JSFunction> constructor,
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
// JSObject without a prototype. // JSObject without a prototype.
Handle<JSObject> NewJSObjectWithNullProto(); Handle<JSObject> NewJSObjectWithNullProto(
PretenureFlag pretenure = NOT_TENURED);
// Global objects are pretenured and initialized based on a constructor. // Global objects are pretenured and initialized based on a constructor.
Handle<JSGlobalObject> NewJSGlobalObject(Handle<JSFunction> constructor); Handle<JSGlobalObject> NewJSGlobalObject(Handle<JSFunction> constructor);
......
...@@ -1912,10 +1912,7 @@ class WasmInstanceBuilder { ...@@ -1912,10 +1912,7 @@ class WasmInstanceBuilder {
Handle<JSObject> exports_object = instance; Handle<JSObject> exports_object = instance;
if (module_->origin == kWasmOrigin) { if (module_->origin == kWasmOrigin) {
// Create the "exports" object. // Create the "exports" object.
Handle<JSFunction> object_function = Handle<JSFunction>( exports_object = isolate_->factory()->NewJSObjectWithNullProto();
isolate_->native_context()->object_function(), isolate_);
exports_object =
isolate_->factory()->NewJSObject(object_function, TENURED);
Handle<String> exports_name = Handle<String> exports_name =
isolate_->factory()->InternalizeUtf8String("exports"); isolate_->factory()->InternalizeUtf8String("exports");
JSObject::AddProperty(instance, exports_name, exports_object, NONE); JSObject::AddProperty(instance, exports_name, exports_object, NONE);
......
...@@ -371,6 +371,12 @@ assertTrue(instanceExportsDesc.writable); ...@@ -371,6 +371,12 @@ assertTrue(instanceExportsDesc.writable);
assertTrue(instanceExportsDesc.enumerable); assertTrue(instanceExportsDesc.enumerable);
assertTrue(instanceExportsDesc.configurable); assertTrue(instanceExportsDesc.configurable);
exportsObj = exportingInstance.exports;
assertEq(typeof exportsObj, 'object');
assertFalse(Object.isExtensible(exportsObj));
assertEq(Object.getPrototypeOf(exportsObj), null);
assertEq(Object.keys(exportsObj).join(), 'f');
// Exported WebAssembly functions // Exported WebAssembly functions
let f = exportingInstance.exports.f; let f = exportingInstance.exports.f;
assertTrue(f instanceof Function); assertTrue(f instanceof Function);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment