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

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

Issue 2664493002: [wasm][asm.js] Make asm.js->wasm return a regular object. (Closed)
Patch Set: fix 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
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index e4188da72a3bf1b0545c5a712c18c218ff5da8ba..0577f7e759924735c39733a9f39955cc5c0e92d4 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -1142,13 +1142,15 @@ class WasmInstanceBuilder {
public:
WasmInstanceBuilder(Isolate* isolate, ErrorThrower* thrower,
Handle<WasmModuleObject> module_object,
- Handle<JSReceiver> ffi, Handle<JSArrayBuffer> memory)
+ Handle<JSReceiver> ffi, Handle<JSArrayBuffer> memory,
+ Handle<JSObject> export_to)
: isolate_(isolate),
module_(module_object->compiled_module()->module()),
thrower_(thrower),
module_object_(module_object),
ffi_(ffi),
- memory_(memory) {}
+ memory_(memory),
+ export_to_(export_to) {}
// Build an instance, in all of its glory.
MaybeHandle<WasmInstanceObject> Build() {
@@ -1382,7 +1384,7 @@ class WasmInstanceBuilder {
//--------------------------------------------------------------------------
// Set up the exports object for the new instance.
//--------------------------------------------------------------------------
- ProcessExports(code_table, instance, compiled_module_);
+ ProcessExports(code_table, instance, export_to_, compiled_module_);
//--------------------------------------------------------------------------
// Add instance to Memory object
@@ -1531,6 +1533,7 @@ class WasmInstanceBuilder {
Handle<WasmModuleObject> module_object_;
Handle<JSReceiver> ffi_;
Handle<JSArrayBuffer> memory_;
+ Handle<JSObject> export_to_;
Handle<JSArrayBuffer> globals_;
Handle<WasmCompiledModule> compiled_module_;
std::vector<TableInstance> table_instances_;
@@ -1911,6 +1914,7 @@ class WasmInstanceBuilder {
// and globals.
void ProcessExports(Handle<FixedArray> code_table,
Handle<WasmInstanceObject> instance,
+ Handle<JSObject> exports,
Handle<WasmCompiledModule> compiled_module) {
if (NeedsWrappers()) {
// Fill the table to cache the exported JSFunction wrappers.
@@ -1918,7 +1922,7 @@ class WasmInstanceBuilder {
Handle<JSFunction>::null());
}
- Handle<JSObject> exports_object = instance;
+ Handle<JSObject> exports_object = exports;
if (module_->origin == kWasmOrigin) {
// Create the "exports" object.
exports_object = isolate_->factory()->NewJSObjectWithNullProto();
@@ -1928,7 +1932,7 @@ class WasmInstanceBuilder {
}
PropertyDescriptor desc;
- desc.set_writable(false);
+ desc.set_writable(module_->origin == kAsmJsOrigin);
desc.set_enumerable(true);
// Count up export indexes.
@@ -2223,8 +2227,9 @@ class WasmInstanceBuilder {
MaybeHandle<WasmInstanceObject> WasmModule::Instantiate(
Isolate* isolate, ErrorThrower* thrower,
Handle<WasmModuleObject> wasm_module, Handle<JSReceiver> ffi,
- Handle<JSArrayBuffer> memory) {
- WasmInstanceBuilder builder(isolate, thrower, wasm_module, ffi, memory);
+ Handle<JSArrayBuffer> memory, Handle<JSObject> export_to) {
+ WasmInstanceBuilder builder(isolate, thrower, wasm_module, ffi, memory,
+ export_to);
return builder.Build();
}

Powered by Google App Engine
This is Rietveld 408576698