[wasm] Acquire the context for TrapIf from a wasm frame
This is the first step to reduce the size of the out-of-line code of TrapIf. Instead of passing the context to the runtime call as a parameter, we pass Smi::kZero to the runtime call and then get the actual context from the WasmFrame on the stack. BUG=v8:5908 R=titzer@chromium.org, clemensh@chromium.org Review-Url: https://codereview.chromium.org/2664273002 Cr-Commit-Position: refs/heads/master@{#42853}
This commit is contained in:
parent
58611d0115
commit
87d309dadd
@ -1930,7 +1930,7 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
|
||||
ExternalReference::wasm_call_trap_callback_for_testing(isolate()),
|
||||
0);
|
||||
} else {
|
||||
__ Move(cp, isolate()->native_context());
|
||||
__ Move(cp, Smi::kZero);
|
||||
gen_->AssembleSourcePosition(instr_);
|
||||
__ CallRuntime(trap_id);
|
||||
}
|
||||
|
@ -1739,7 +1739,7 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
|
||||
0);
|
||||
} else {
|
||||
DCHECK(csp.Is(__ StackPointer()));
|
||||
__ Move(cp, isolate()->native_context());
|
||||
__ Move(cp, Smi::kZero);
|
||||
// Initialize the jssp because it is required for the runtime call.
|
||||
__ Mov(jssp, csp);
|
||||
gen_->AssembleSourcePosition(instr_);
|
||||
|
@ -1714,7 +1714,7 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
|
||||
ExternalReference::wasm_call_trap_callback_for_testing(isolate()),
|
||||
0);
|
||||
} else {
|
||||
__ Move(esi, isolate()->native_context());
|
||||
__ Move(esi, Smi::kZero);
|
||||
gen_->AssembleSourcePosition(instr_);
|
||||
__ CallRuntime(trap_id);
|
||||
}
|
||||
|
@ -1778,7 +1778,7 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
|
||||
ExternalReference::wasm_call_trap_callback_for_testing(isolate()),
|
||||
0);
|
||||
} else {
|
||||
__ Move(cp, isolate()->native_context());
|
||||
__ Move(cp, Smi::kZero);
|
||||
gen_->AssembleSourcePosition(instr_);
|
||||
__ CallRuntime(trap_id);
|
||||
}
|
||||
|
@ -2113,7 +2113,7 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
|
||||
ExternalReference::wasm_call_trap_callback_for_testing(isolate()),
|
||||
0);
|
||||
} else {
|
||||
__ Move(cp, isolate()->native_context());
|
||||
__ Move(cp, Smi::kZero);
|
||||
gen_->AssembleSourcePosition(instr_);
|
||||
__ CallRuntime(trap_id);
|
||||
}
|
||||
|
@ -91,7 +91,9 @@ Node* BuildCallToRuntime(Runtime::FunctionId f, JSGraph* jsgraph,
|
||||
inputs[count++] = jsgraph->ExternalConstant(
|
||||
ExternalReference(f, jsgraph->isolate())); // ref
|
||||
inputs[count++] = jsgraph->Int32Constant(fun->nargs); // arity
|
||||
inputs[count++] = jsgraph->HeapConstant(context); // context
|
||||
inputs[count++] = context.is_null()
|
||||
? jsgraph->SmiConstant(0)
|
||||
: jsgraph->HeapConstant(context); // context
|
||||
inputs[count++] = *effect_ptr;
|
||||
inputs[count++] = control;
|
||||
|
||||
@ -328,7 +330,7 @@ class WasmTrapHelper : public ZoneObject {
|
||||
Node* parameters[] = {trap_reason_smi, // message id
|
||||
trap_position_smi}; // byte position
|
||||
BuildCallToRuntime(Runtime::kThrowWasmError, jsgraph(),
|
||||
module->instance->context, parameters,
|
||||
Handle<Context>::null(), parameters,
|
||||
arraysize(parameters), effect_ptr, *control_ptr);
|
||||
}
|
||||
if (false) {
|
||||
|
@ -2342,7 +2342,7 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
|
||||
ExternalReference::wasm_call_trap_callback_for_testing(isolate()),
|
||||
0);
|
||||
} else {
|
||||
__ Move(rsi, isolate()->native_context());
|
||||
__ Move(rsi, Smi::kZero);
|
||||
gen_->AssembleSourcePosition(instr_);
|
||||
__ CallRuntime(trap_id);
|
||||
}
|
||||
|
@ -55,6 +55,14 @@ RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
|
||||
Object* ThrowRuntimeError(Isolate* isolate, int message_id, int byte_offset,
|
||||
bool patch_source_position) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_NULL(isolate->context());
|
||||
StackFrameIterator it(isolate);
|
||||
it.Advance();
|
||||
CHECK(it.frame()->is_wasm_compiled());
|
||||
isolate->set_context(*WasmCompiledFrame::cast(it.frame())
|
||||
->wasm_instance()
|
||||
->compiled_module()
|
||||
->native_context());
|
||||
Handle<Object> error_obj = isolate->factory()->NewWasmRuntimeError(
|
||||
static_cast<MessageTemplate::Template>(message_id));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user