Commit 0a059c3c authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm][interpreter] Store code entry as raw pointer

We are currently wrapping the pointer to the instruction start in a
Foreign. The argument buffer, which is also a raw pointer, is passed
directly though.
This CL changes this to also pass the code entry as a raw pointer.

R=mstarzinger@chromium.org

Change-Id: Id7344efa589a5297339ec01c3cfa7688bcc706b3
Reviewed-on: https://chromium-review.googlesource.com/1226970Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55895}
parent 3b9d9e03
......@@ -4704,12 +4704,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
SetEffect(SetControl(Start(CWasmEntryParameters::kNumParameters + 5)));
// Create parameter nodes (offset by 1 for the receiver parameter).
Node* foreign_code_obj = Param(CWasmEntryParameters::kCodeObject + 1);
MachineOperatorBuilder* machine = mcgraph()->machine();
Node* code_obj = graph()->NewNode(
machine->Load(MachineType::Pointer()), foreign_code_obj,
Int32Constant(Foreign::kForeignAddressOffset - kHeapObjectTag),
Effect(), Control());
Node* code_entry = Param(CWasmEntryParameters::kCodeEntry + 1);
Node* instance_node = Param(CWasmEntryParameters::kWasmInstance + 1);
Node* arg_buffer = Param(CWasmEntryParameters::kArgumentsBuffer + 1);
......@@ -4718,7 +4713,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
Node** args = Buffer(arg_count);
int pos = 0;
args[pos++] = code_obj;
args[pos++] = code_entry;
args[pos++] = instance_node;
int offset = 0;
......
......@@ -88,7 +88,7 @@ MaybeHandle<Code> CompileWasmInterpreterEntry(Isolate*, uint32_t func_index,
wasm::FunctionSig*);
enum CWasmEntryParameters {
kCodeObject,
kCodeEntry,
kWasmInstance,
kArgumentsBuffer,
// marker:
......
......@@ -2762,17 +2762,19 @@ class ThreadImpl {
arg_buffer.resize(return_size);
}
// Wrap the arg_buffer data pointer in a handle. As
// this is an aligned pointer, to the GC it will look like a Smi.
// Wrap the arg_buffer and the code target data pointers in handles. As
// these are aligned pointers, to the GC it will look like Smis.
Handle<Object> arg_buffer_obj(reinterpret_cast<Object*>(arg_buffer.data()),
isolate);
DCHECK(!arg_buffer_obj->IsHeapObject());
Handle<Object> code_entry_obj(
reinterpret_cast<Object*>(code->instruction_start()), isolate);
DCHECK(!code_entry_obj->IsHeapObject());
static_assert(compiler::CWasmEntryParameters::kNumParameters == 3,
"code below needs adaption");
Handle<Object> args[compiler::CWasmEntryParameters::kNumParameters];
args[compiler::CWasmEntryParameters::kCodeObject] = Handle<Object>::cast(
isolate->factory()->NewForeign(code->instruction_start(), TENURED));
args[compiler::CWasmEntryParameters::kCodeEntry] = code_entry_obj;
args[compiler::CWasmEntryParameters::kWasmInstance] = instance;
args[compiler::CWasmEntryParameters::kArgumentsBuffer] = arg_buffer_obj;
......
......@@ -62,10 +62,11 @@ class CWasmEntryArgTester {
Handle<Object> buffer_obj(reinterpret_cast<Object*>(arg_buffer.data()),
isolate_);
CHECK(!buffer_obj->IsHeapObject());
Handle<Object> call_args[]{
Handle<Object>::cast(isolate_->factory()->NewForeign(
wasm_code_->instruction_start(), TENURED)),
runner_.builder().instance_object(), buffer_obj};
Handle<Object> code_entry_obj(
reinterpret_cast<Object*>(wasm_code_->instruction_start()), isolate_);
CHECK(!code_entry_obj->IsHeapObject());
Handle<Object> call_args[]{code_entry_obj,
runner_.builder().instance_object(), buffer_obj};
static_assert(
arraysize(call_args) == compiler::CWasmEntryParameters::kNumParameters,
"adapt this test");
......
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