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

[wasm] Remove redundant parameter

The signature is already set on the {WasmGraphBuilder}, so we don't
need to pass it again to the {Build*} functions.

R=titzer@chromium.org

Change-Id: I21e93f78211e84a9960b3fd5dffc1c94778b85e5
Reviewed-on: https://chromium-review.googlesource.com/602034Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47162}
parent 943651b7
...@@ -2670,9 +2670,8 @@ Node* WasmGraphBuilder::BuildHeapNumberValueIndexConstant() { ...@@ -2670,9 +2670,8 @@ Node* WasmGraphBuilder::BuildHeapNumberValueIndexConstant() {
return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag); return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag);
} }
void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code, void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code) {
wasm::FunctionSig* sig) { int wasm_count = static_cast<int>(sig_->parameter_count());
int wasm_count = static_cast<int>(sig->parameter_count());
int count = wasm_count + 3; int count = wasm_count + 3;
Node** args = Buffer(count); Node** args = Buffer(count);
...@@ -2720,7 +2719,7 @@ void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code, ...@@ -2720,7 +2719,7 @@ void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code,
// Convert JS parameters to wasm numbers. // Convert JS parameters to wasm numbers.
for (int i = 0; i < wasm_count; ++i) { for (int i = 0; i < wasm_count; ++i) {
Node* param = Param(i + 1); Node* param = Param(i + 1);
Node* wasm_param = FromJS(param, context, sig->GetParam(i)); Node* wasm_param = FromJS(param, context, sig_->GetParam(i));
args[pos++] = wasm_param; args[pos++] = wasm_param;
} }
...@@ -2728,7 +2727,7 @@ void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code, ...@@ -2728,7 +2727,7 @@ void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code,
args[pos++] = *control_; args[pos++] = *control_;
// Call the wasm code. // Call the wasm code.
CallDescriptor* desc = GetWasmCallDescriptor(jsgraph()->zone(), sig); CallDescriptor* desc = GetWasmCallDescriptor(jsgraph()->zone(), sig_);
Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args); Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args);
*effect_ = call; *effect_ = call;
...@@ -2738,7 +2737,7 @@ void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code, ...@@ -2738,7 +2737,7 @@ void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code,
Node* retval = call; Node* retval = call;
Node* jsval = ToJS( Node* jsval = ToJS(
retval, sig->return_count() == 0 ? wasm::kWasmStmt : sig->GetReturn()); retval, sig_->return_count() == 0 ? wasm::kWasmStmt : sig_->GetReturn());
Return(jsval); Return(jsval);
} }
...@@ -2753,11 +2752,10 @@ int WasmGraphBuilder::AddParameterNodes(Node** args, int pos, int param_count, ...@@ -2753,11 +2752,10 @@ int WasmGraphBuilder::AddParameterNodes(Node** args, int pos, int param_count,
return pos; return pos;
} }
void WasmGraphBuilder::BuildWasmToJSWrapper(Handle<JSReceiver> target, void WasmGraphBuilder::BuildWasmToJSWrapper(Handle<JSReceiver> target) {
wasm::FunctionSig* sig) {
DCHECK(target->IsCallable()); DCHECK(target->IsCallable());
int wasm_count = static_cast<int>(sig->parameter_count()); int wasm_count = static_cast<int>(sig_->parameter_count());
// Build the start and the parameter nodes. // Build the start and the parameter nodes.
Isolate* isolate = jsgraph()->isolate(); Isolate* isolate = jsgraph()->isolate();
...@@ -2804,7 +2802,7 @@ void WasmGraphBuilder::BuildWasmToJSWrapper(Handle<JSReceiver> target, ...@@ -2804,7 +2802,7 @@ void WasmGraphBuilder::BuildWasmToJSWrapper(Handle<JSReceiver> target,
graph()->zone(), false, wasm_count + 1, CallDescriptor::kNoFlags); graph()->zone(), false, wasm_count + 1, CallDescriptor::kNoFlags);
// Convert wasm numbers to JS values. // Convert wasm numbers to JS values.
pos = AddParameterNodes(args, pos, wasm_count, sig); pos = AddParameterNodes(args, pos, wasm_count, sig_);
args[pos++] = jsgraph()->UndefinedConstant(); // new target args[pos++] = jsgraph()->UndefinedConstant(); // new target
args[pos++] = jsgraph()->Int32Constant(wasm_count); // argument count args[pos++] = jsgraph()->Int32Constant(wasm_count); // argument count
...@@ -2831,7 +2829,7 @@ void WasmGraphBuilder::BuildWasmToJSWrapper(Handle<JSReceiver> target, ...@@ -2831,7 +2829,7 @@ void WasmGraphBuilder::BuildWasmToJSWrapper(Handle<JSReceiver> target,
CallDescriptor::kNoFlags); CallDescriptor::kNoFlags);
// Convert wasm numbers to JS values. // Convert wasm numbers to JS values.
pos = AddParameterNodes(args, pos, wasm_count, sig); pos = AddParameterNodes(args, pos, wasm_count, sig_);
// The native_context is sufficient here, because all kind of callables // The native_context is sufficient here, because all kind of callables
// which depend on the context provide their own context. The context here // which depend on the context provide their own context. The context here
...@@ -2851,20 +2849,19 @@ void WasmGraphBuilder::BuildWasmToJSWrapper(Handle<JSReceiver> target, ...@@ -2851,20 +2849,19 @@ void WasmGraphBuilder::BuildWasmToJSWrapper(Handle<JSReceiver> target,
BuildModifyThreadInWasmFlag(true); BuildModifyThreadInWasmFlag(true);
// Convert the return value back. // Convert the return value back.
Node* val = sig->return_count() == 0 Node* val = sig_->return_count() == 0
? jsgraph()->Int32Constant(0) ? jsgraph()->Int32Constant(0)
: FromJS(call, HeapConstant(isolate->native_context()), : FromJS(call, HeapConstant(isolate->native_context()),
sig->GetReturn()); sig_->GetReturn());
Return(val); Return(val);
} }
void WasmGraphBuilder::BuildWasmInterpreterEntry( void WasmGraphBuilder::BuildWasmInterpreterEntry(
uint32_t function_index, wasm::FunctionSig* sig, uint32_t function_index, Handle<WasmInstanceObject> instance) {
Handle<WasmInstanceObject> instance) { int wasm_count = static_cast<int>(sig_->parameter_count());
int wasm_count = static_cast<int>(sig->parameter_count());
int param_count = jsgraph()->machine()->Is64() int param_count = jsgraph()->machine()->Is64()
? wasm_count ? wasm_count
: Int64Lowering::GetParameterCountAfterLowering(sig); : Int64Lowering::GetParameterCountAfterLowering(sig_);
// Build the start and the parameter nodes. // Build the start and the parameter nodes.
Node* start = Start(param_count + 3); Node* start = Start(param_count + 3);
...@@ -2874,15 +2871,15 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry( ...@@ -2874,15 +2871,15 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry(
// Compute size for the argument buffer. // Compute size for the argument buffer.
int args_size_bytes = 0; int args_size_bytes = 0;
for (int i = 0; i < wasm_count; i++) { for (int i = 0; i < wasm_count; i++) {
args_size_bytes += 1 << ElementSizeLog2Of(sig->GetParam(i)); args_size_bytes += 1 << ElementSizeLog2Of(sig_->GetParam(i));
} }
// The return value is also passed via this buffer: // The return value is also passed via this buffer:
DCHECK_GE(wasm::kV8MaxWasmFunctionReturns, sig->return_count()); DCHECK_GE(wasm::kV8MaxWasmFunctionReturns, sig_->return_count());
// TODO(wasm): Handle multi-value returns. // TODO(wasm): Handle multi-value returns.
DCHECK_EQ(1, wasm::kV8MaxWasmFunctionReturns); DCHECK_EQ(1, wasm::kV8MaxWasmFunctionReturns);
int return_size_bytes = int return_size_bytes =
sig->return_count() == 0 ? 0 : 1 << ElementSizeLog2Of(sig->GetReturn(0)); sig_->return_count() == 0 ? 0 : 1 << ElementSizeLog2Of(sig_->GetReturn());
// Get a stack slot for the arguments. // Get a stack slot for the arguments.
Node* arg_buffer = Node* arg_buffer =
...@@ -2898,7 +2895,7 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry( ...@@ -2898,7 +2895,7 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry(
for (int i = 0; i < wasm_count; i++) { for (int i = 0; i < wasm_count; i++) {
Node* param = Param(param_index++); Node* param = Param(param_index++);
if (Int64Lowering::IsI64AsTwoParameters(jsgraph()->machine(), if (Int64Lowering::IsI64AsTwoParameters(jsgraph()->machine(),
sig->GetParam(i))) { sig_->GetParam(i))) {
int lower_half_offset = offset + kInt64LowerHalfMemoryOffset; int lower_half_offset = offset + kInt64LowerHalfMemoryOffset;
int upper_half_offset = offset + kInt64UpperHalfMemoryOffset; int upper_half_offset = offset + kInt64UpperHalfMemoryOffset;
...@@ -2913,7 +2910,7 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry( ...@@ -2913,7 +2910,7 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry(
offset += 8; offset += 8;
} else { } else {
MachineRepresentation param_rep = sig->GetParam(i); MachineRepresentation param_rep = sig_->GetParam(i);
*effect_ = *effect_ =
graph()->NewNode(GetSafeStoreOperator(offset, param_rep), arg_buffer, graph()->NewNode(GetSafeStoreOperator(offset, param_rep), arg_buffer,
Int32Constant(offset), param, *effect_, *control_); Int32Constant(offset), param, *effect_, *control_);
...@@ -2935,10 +2932,10 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry( ...@@ -2935,10 +2932,10 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry(
arraysize(parameters)); arraysize(parameters));
// Read back the return value. // Read back the return value.
if (sig->return_count() == 0) { if (sig_->return_count() == 0) {
Return(Int32Constant(0)); Return(Int32Constant(0));
} else if (Int64Lowering::IsI64AsTwoParameters(jsgraph()->machine(), } else if (Int64Lowering::IsI64AsTwoParameters(jsgraph()->machine(),
sig->GetReturn())) { sig_->GetReturn())) {
MachineType load_rep = wasm::WasmOpcodes::MachineTypeFor(wasm::kWasmI32); MachineType load_rep = wasm::WasmOpcodes::MachineTypeFor(wasm::kWasmI32);
Node* lower = Node* lower =
graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer, graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer,
...@@ -2951,7 +2948,7 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry( ...@@ -2951,7 +2948,7 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry(
*effect_ = upper; *effect_ = upper;
Return(lower, upper); Return(lower, upper);
} else { } else {
MachineType load_rep = wasm::WasmOpcodes::MachineTypeFor(sig->GetReturn()); MachineType load_rep = wasm::WasmOpcodes::MachineTypeFor(sig_->GetReturn());
Node* val = Node* val =
graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer, graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer,
Int32Constant(0), *effect_, *control_); Int32Constant(0), *effect_, *control_);
...@@ -3842,7 +3839,7 @@ Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module, ...@@ -3842,7 +3839,7 @@ Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module,
CEntryStub(isolate, 1).GetCode(), func->sig); CEntryStub(isolate, 1).GetCode(), func->sig);
builder.set_control_ptr(&control); builder.set_control_ptr(&control);
builder.set_effect_ptr(&effect); builder.set_effect_ptr(&effect);
builder.BuildJSToWasmWrapper(wasm_code, func->sig); builder.BuildJSToWasmWrapper(wasm_code);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Run the compilation pipeline. // Run the compilation pipeline.
...@@ -3923,7 +3920,7 @@ Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, ...@@ -3923,7 +3920,7 @@ Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target,
source_position_table); source_position_table);
builder.set_control_ptr(&control); builder.set_control_ptr(&control);
builder.set_effect_ptr(&effect); builder.set_effect_ptr(&effect);
builder.BuildWasmToJSWrapper(target, sig); builder.BuildWasmToJSWrapper(target);
Handle<Code> code = Handle<Code>::null(); Handle<Code> code = Handle<Code>::null();
{ {
...@@ -4007,7 +4004,7 @@ Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index, ...@@ -4007,7 +4004,7 @@ Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index,
CEntryStub(isolate, 1).GetCode(), sig); CEntryStub(isolate, 1).GetCode(), sig);
builder.set_control_ptr(&control); builder.set_control_ptr(&control);
builder.set_effect_ptr(&effect); builder.set_effect_ptr(&effect);
builder.BuildWasmInterpreterEntry(func_index, sig, instance); builder.BuildWasmInterpreterEntry(func_index, instance);
Handle<Code> code = Handle<Code>::null(); Handle<Code> code = Handle<Code>::null();
{ {
......
...@@ -217,9 +217,9 @@ class WasmGraphBuilder { ...@@ -217,9 +217,9 @@ class WasmGraphBuilder {
Node* CallIndirect(uint32_t index, Node** args, Node*** rets, Node* CallIndirect(uint32_t index, Node** args, Node*** rets,
wasm::WasmCodePosition position); wasm::WasmCodePosition position);
void BuildJSToWasmWrapper(Handle<Code> wasm_code, wasm::FunctionSig* sig); void BuildJSToWasmWrapper(Handle<Code> wasm_code);
void BuildWasmToJSWrapper(Handle<JSReceiver> target, wasm::FunctionSig* sig); void BuildWasmToJSWrapper(Handle<JSReceiver> target);
void BuildWasmInterpreterEntry(uint32_t func_index, wasm::FunctionSig* sig, void BuildWasmInterpreterEntry(uint32_t func_index,
Handle<WasmInstanceObject> instance); Handle<WasmInstanceObject> instance);
Node* ToJS(Node* node, wasm::ValueType type); Node* ToJS(Node* node, wasm::ValueType type);
......
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