Commit fa569391 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Disambiguate {ImportedFunctionEntry::set} methods

{ImportedFunctionEntry} offers two {set} methods: One takes a
{JSReceiver*}, the other one a {WasmInstanceObject*}. Since
{WasmInstanceObject} inherits from {JSReceiver}, it's quite easy to
confuse the two if the instance is hold as e.g. {JSObject}.
Hence, rename the methods to remove this ambiguity.

R=titzer@chromium.org

Bug: v8:7758
Change-Id: I06617a565faa561d3afc70085e0df3b528c715bb
Reviewed-on: https://chromium-review.googlesource.com/1059147Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53185}
parent 7696972e
......@@ -394,7 +394,7 @@ class IndirectPatcher {
DCHECK_EQ(
func_index,
code_manager->GetCodeFromStartAddress(entry.target())->index());
entry.set(*target_instance, new_code);
entry.set_wasm_to_wasm(*target_instance, new_code);
patched++;
}
} else {
......@@ -436,7 +436,7 @@ class IndirectPatcher {
code->index());
if (new_code->kind() != WasmCode::kLazyStub) {
// Patch an imported function entry which is already compiled.
entry.set(target_instance, new_code);
entry.set_wasm_to_wasm(target_instance, new_code);
} else {
int key = code->index();
int index = -1 - i;
......@@ -2111,7 +2111,7 @@ int InstanceBuilder::ProcessImports(Handle<WasmInstanceObject> instance) {
// The import reference is the instance object itself.
auto wasm_code = imported_function->GetWasmCode();
ImportedFunctionEntry(instance, func_index)
.set(*imported_instance, wasm_code);
.set_wasm_to_wasm(*imported_instance, wasm_code);
native_module->set_code(func_index, wasm_code);
} else {
// The imported function is a callable.
......@@ -2124,7 +2124,7 @@ int InstanceBuilder::ProcessImports(Handle<WasmInstanceObject> instance) {
WasmCode* wasm_code = native_module->AddCodeCopy(
wrapper_code, wasm::WasmCode::kWasmToJsWrapper, func_index);
ImportedFunctionEntry(instance, func_index)
.set(*js_receiver, wasm_code);
.set_wasm_to_js(*js_receiver, wasm_code);
}
num_imported_functions++;
break;
......
......@@ -695,8 +695,8 @@ Address IndirectFunctionTableEntry::target() {
return instance_->indirect_function_table_targets()[index_];
}
void ImportedFunctionEntry::set(JSReceiver* callable,
const wasm::WasmCode* wasm_to_js_wrapper) {
void ImportedFunctionEntry::set_wasm_to_js(
JSReceiver* callable, const wasm::WasmCode* wasm_to_js_wrapper) {
TRACE_IFT("Import callable %p[%d] = {callable=%p, target=%p}\n", *instance_,
index_, callable, wasm_to_js_wrapper->instructions().start());
DCHECK_EQ(wasm::WasmCode::kWasmToJsWrapper, wasm_to_js_wrapper->kind());
......@@ -706,8 +706,8 @@ void ImportedFunctionEntry::set(JSReceiver* callable,
wasm_to_js_wrapper->instruction_start();
}
void ImportedFunctionEntry::set(WasmInstanceObject* instance,
const wasm::WasmCode* wasm_code) {
void ImportedFunctionEntry::set_wasm_to_wasm(WasmInstanceObject* instance,
const wasm::WasmCode* wasm_code) {
TRACE_IFT("Import WASM %p[%d] = {instance=%p, target=%p}\n", *instance_,
index_, instance, wasm_code->instructions().start());
instance_->imported_function_instances()->set(index_, instance);
......
......@@ -85,10 +85,11 @@ class ImportedFunctionEntry {
inline ImportedFunctionEntry(Handle<WasmInstanceObject>, int index);
// Initialize this entry as a {JSReceiver} call.
void set(JSReceiver* callable, const wasm::WasmCode* wasm_to_js_wrapper);
void set_wasm_to_js(JSReceiver* callable,
const wasm::WasmCode* wasm_to_js_wrapper);
// Initialize this entry as a WASM to WASM call.
void set(WasmInstanceObject* target_instance,
const wasm::WasmCode* wasm_function);
void set_wasm_to_wasm(WasmInstanceObject* target_instance,
const wasm::WasmCode* wasm_function);
WasmInstanceObject* instance();
JSReceiver* callable();
......
......@@ -54,7 +54,7 @@ TestingModuleBuilder::TestingModuleBuilder(
code, wasm::WasmCode::kWasmToJsWrapper, maybe_import_index);
ImportedFunctionEntry(instance_object_, maybe_import_index)
.set(*maybe_import->js_function, wasm_to_js_wrapper);
.set_wasm_to_js(*maybe_import->js_function, wasm_to_js_wrapper);
}
if (mode == kExecuteInterpreter) {
......
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