Commit f8158cdb authored by bjaideep's avatar bjaideep Committed by Commit bot

PPC/s390: [wasm] Use builtins wrappers for traps

Port 73d45c96

Original Commit Message:

    With this CL the out-of-line code of TrapIf will call a builtin instead
    of doing a direct runtime call, which is cheaper. In the best case, the
    out-of-line code now consists of a single call instruction. The builtin
    will load the trapID and then call the runtime to throw a trap.

R=ahaas@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Review-Url: https://codereview.chromium.org/2713433003
Cr-Commit-Position: refs/heads/master@{#43382}
parent d1160fb1
......@@ -2028,8 +2028,8 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
void Generate() final {
PPCOperandConverter i(gen_, instr_);
Runtime::FunctionId trap_id = static_cast<Runtime::FunctionId>(
i.InputInt32(instr_->InputCount() - 1));
Builtins::Name trap_id =
static_cast<Builtins::Name>(i.InputInt32(instr_->InputCount() - 1));
bool old_has_frame = __ has_frame();
if (frame_elided_) {
__ set_has_frame(true);
......@@ -2042,8 +2042,8 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
}
private:
void GenerateCallToTrap(Runtime::FunctionId trap_id) {
if (trap_id == Runtime::kNumFunctions) {
void GenerateCallToTrap(Builtins::Name trap_id) {
if (trap_id == Builtins::builtin_count) {
// We cannot test calls to the runtime in cctest/test-run-wasm.
// Therefore we emit a call to C here instead of a call to the runtime.
// We use the context register as the scratch register, because we do
......@@ -2055,9 +2055,9 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
__ LeaveFrame(StackFrame::WASM_COMPILED);
__ Ret();
} else {
__ Move(cp, Smi::kZero);
gen_->AssembleSourcePosition(instr_);
__ CallRuntime(trap_id);
__ Call(handle(isolate()->builtins()->builtin(trap_id), isolate()),
RelocInfo::CODE_TARGET);
ReferenceMap* reference_map =
new (gen_->zone()) ReferenceMap(gen_->zone());
gen_->RecordSafepoint(reference_map, Safepoint::kSimple, 0,
......
......@@ -2407,8 +2407,8 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
void Generate() final {
S390OperandConverter i(gen_, instr_);
Runtime::FunctionId trap_id = static_cast<Runtime::FunctionId>(
i.InputInt32(instr_->InputCount() - 1));
Builtins::Name trap_id =
static_cast<Builtins::Name>(i.InputInt32(instr_->InputCount() - 1));
bool old_has_frame = __ has_frame();
if (frame_elided_) {
__ set_has_frame(true);
......@@ -2421,8 +2421,8 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
}
private:
void GenerateCallToTrap(Runtime::FunctionId trap_id) {
if (trap_id == Runtime::kNumFunctions) {
void GenerateCallToTrap(Builtins::Name trap_id) {
if (trap_id == Builtins::builtin_count) {
// We cannot test calls to the runtime in cctest/test-run-wasm.
// Therefore we emit a call to C here instead of a call to the runtime.
// We use the context register as the scratch register, because we do
......@@ -2434,9 +2434,9 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
__ LeaveFrame(StackFrame::WASM_COMPILED);
__ Ret();
} else {
__ Move(cp, Smi::kZero);
gen_->AssembleSourcePosition(instr_);
__ CallRuntime(trap_id);
__ Call(handle(isolate()->builtins()->builtin(trap_id), isolate()),
RelocInfo::CODE_TARGET);
ReferenceMap* reference_map =
new (gen_->zone()) ReferenceMap(gen_->zone());
gen_->RecordSafepoint(reference_map, Safepoint::kSimple, 0,
......
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