Commit 5f9dfee5 authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[wasm] Clean up export processing for asm.js

Defers some work in the non-asm.js case

Change-Id: Id20863fb2af83148271408b0242d49e03be29d3b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1682213
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62580}
parent ef332f7a
......@@ -1457,6 +1457,7 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
}
Handle<JSObject> exports_object;
MaybeHandle<String> single_function_name;
bool is_asm_js = false;
switch (module_->origin) {
case kWasmOrigin: {
......@@ -1468,6 +1469,8 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
Handle<JSFunction> object_function = Handle<JSFunction>(
isolate_->native_context()->object_function(), isolate_);
exports_object = isolate_->factory()->NewJSObject(object_function);
single_function_name = isolate_->factory()->InternalizeUtf8String(
AsmJs::kSingleFunctionName);
is_asm_js = true;
break;
}
......@@ -1476,9 +1479,6 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
}
instance->set_exports_object(*exports_object);
Handle<String> single_function_name =
isolate_->factory()->InternalizeUtf8String(AsmJs::kSingleFunctionName);
PropertyDescriptor desc;
desc.set_writable(is_asm_js);
desc.set_enumerable(true);
......@@ -1489,14 +1489,7 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
Handle<String> name = WasmModuleObject::ExtractUtf8StringFromModuleBytes(
isolate_, module_object_, exp.name)
.ToHandleChecked();
Handle<JSObject> export_to;
if (is_asm_js && exp.kind == kExternalFunction &&
String::Equals(isolate_, name, single_function_name)) {
export_to = instance;
} else {
export_to = exports_object;
}
Handle<JSObject> export_to = exports_object;
switch (exp.kind) {
case kExternalFunction: {
// Wrap and export the code as a JSFunction.
......@@ -1504,8 +1497,13 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
MaybeHandle<WasmExportedFunction> wasm_exported_function =
WasmInstanceObject::GetOrCreateWasmExportedFunction(
isolate_, instance, exp.index);
desc.set_value(wasm_exported_function.ToHandleChecked());
if (is_asm_js &&
String::Equals(isolate_, name,
single_function_name.ToHandleChecked())) {
export_to = instance;
}
break;
}
case kExternalTable: {
......
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