Commit 80ec11d2 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: [wasm] Use the modules runtime stub for {DoubleToI}.

Port 98d7b23e

Original Commit Message:

    This uses a WebAssembly runtime stub for the out-of-line {DoubleToI}
    computation instead of a builtin specific to a certain Isolate. It is
    another step towards making {WasmCode} independent of the Isolate.

R=mstarzinger@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=v8:7424
LOG=N

Change-Id: I2f78432134ea150bb00bea339a6e71c11aa625b0
Reviewed-on: https://chromium-review.googlesource.com/1099877Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#53723}
parent 0091973e
......@@ -2624,6 +2624,8 @@ void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
Label out_of_range, only_low, negate, done, fastpath_done;
Register result_reg = r3;
TrapOnAbortScope trap_on_abort_scope(masm); // Avoid calls to Abort.
// Immediate values for this stub fit in instructions, so it's safe to use ip.
Register scratch = GetRegisterThatIsNotOneOf(result_reg);
Register scratch_low = GetRegisterThatIsNotOneOf(result_reg, scratch);
......
......@@ -2618,6 +2618,8 @@ void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
Label out_of_range, only_low, negate, done, fastpath_done;
Register result_reg = r2;
TrapOnAbortScope trap_on_abort_scope(masm); // Avoid calls to Abort.
// Immediate values for this stub fit in instructions, so it's safe to use ip.
Register scratch = GetRegisterThatIsNotOneOf(result_reg);
Register scratch_low = GetRegisterThatIsNotOneOf(result_reg, scratch);
......
......@@ -1156,7 +1156,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
case kArchTruncateDoubleToI:
__ TruncateDoubleToI(isolate(), zone(), i.OutputRegister(),
i.InputDoubleRegister(0));
i.InputDoubleRegister(0), DetermineStubCallMode());
DCHECK_EQ(LeaveRC, i.OutputRCBit());
break;
case kArchStoreWithWriteBarrier: {
......
......@@ -1577,7 +1577,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
case kArchTruncateDoubleToI:
__ TruncateDoubleToI(isolate(), zone(), i.OutputRegister(),
i.InputDoubleRegister(0));
i.InputDoubleRegister(0), DetermineStubCallMode());
break;
case kArchStoreWithWriteBarrier: {
RecordWriteMode mode =
......
......@@ -1635,7 +1635,8 @@ void MacroAssembler::TryDoubleToInt32Exact(Register result,
void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone,
Register result,
DoubleRegister double_input) {
DoubleRegister double_input,
StubCallMode stub_mode) {
Label done;
TryInlineTruncateDoubleToI(result, double_input, &done);
......@@ -1646,7 +1647,11 @@ void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone,
// Put input on stack.
stfdu(double_input, MemOperand(sp, -kDoubleSize));
Call(BUILTIN_CODE(isolate, DoubleToI), RelocInfo::CODE_TARGET);
if (stub_mode == StubCallMode::kCallWasmRuntimeStub) {
Call(wasm::WasmCode::kDoubleToI, RelocInfo::WASM_STUB_CALL);
} else {
Call(BUILTIN_CODE(isolate, DoubleToI), RelocInfo::CODE_TARGET);
}
LoadP(result, MemOperand(sp));
addi(sp, sp, Operand(kDoubleSize));
......
......@@ -659,7 +659,7 @@ class TurboAssembler : public TurboAssemblerBase {
void TryInlineTruncateDoubleToI(Register result, DoubleRegister input,
Label* done);
void TruncateDoubleToI(Isolate* isolate, Zone* zone, Register result,
DoubleRegister double_input);
DoubleRegister double_input, StubCallMode stub_mode);
// Call a code stub.
void CallStubDelayed(CodeStub* stub);
......
......@@ -1583,7 +1583,8 @@ void MacroAssembler::TryDoubleToInt32Exact(Register result,
void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone,
Register result,
DoubleRegister double_input) {
DoubleRegister double_input,
StubCallMode stub_mode) {
Label done;
TryInlineTruncateDoubleToI(result, double_input, &done);
......@@ -1594,7 +1595,11 @@ void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone,
lay(sp, MemOperand(sp, -kDoubleSize));
StoreDouble(double_input, MemOperand(sp));
Call(BUILTIN_CODE(isolate, DoubleToI), RelocInfo::CODE_TARGET);
if (stub_mode == StubCallMode::kCallWasmRuntimeStub) {
Call(wasm::WasmCode::kDoubleToI, RelocInfo::WASM_STUB_CALL);
} else {
Call(BUILTIN_CODE(isolate, DoubleToI), RelocInfo::CODE_TARGET);
}
LoadP(result, MemOperand(sp, 0));
la(sp, MemOperand(sp, kDoubleSize));
......
......@@ -894,7 +894,7 @@ class TurboAssembler : public TurboAssemblerBase {
// Emit code for a truncating division by a constant. The dividend register is
// unchanged and ip gets clobbered. Dividend and result must be different.
void TruncateDoubleToI(Isolate* isolate, Zone* zone, Register result,
DoubleRegister double_input);
DoubleRegister double_input, StubCallMode stub_mode);
void TryInlineTruncateDoubleToI(Register result, DoubleRegister double_input,
Label* done);
......
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