[cleanup] Delete unused MacroAssembler HeapNumber helpers
All of these were dead; many existed only on some platforms: SlowTruncateToI TestDoubleIsInt32 TestDoubleIsMinusZero TruncateNumberToI TruncateHeapNumberToI TruncateDoubleToI TryInt32Floor Change-Id: Ic55fdadcfa851f5aa04dce8cacd5658d2d6315e8 Reviewed-on: https://chromium-review.googlesource.com/578674 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#46800}
This commit is contained in:
parent
f24b6f96f8
commit
bdfd69a07e
@ -2244,16 +2244,6 @@ void MacroAssembler::SmiToDouble(LowDwVfpRegister value, Register smi) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TestDoubleIsInt32(DwVfpRegister double_input,
|
||||
LowDwVfpRegister double_scratch) {
|
||||
DCHECK(!double_input.is(double_scratch));
|
||||
vcvt_s32_f64(double_scratch.low(), double_input);
|
||||
vcvt_f64_s32(double_scratch, double_scratch.low());
|
||||
VFPCompareAndSetFlags(double_input, double_scratch);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TryDoubleToInt32Exact(Register result,
|
||||
DwVfpRegister double_input,
|
||||
LowDwVfpRegister double_scratch) {
|
||||
@ -2264,53 +2254,6 @@ void MacroAssembler::TryDoubleToInt32Exact(Register result,
|
||||
VFPCompareAndSetFlags(double_input, double_scratch);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TryInt32Floor(Register result,
|
||||
DwVfpRegister double_input,
|
||||
Register input_high,
|
||||
LowDwVfpRegister double_scratch,
|
||||
Label* done,
|
||||
Label* exact) {
|
||||
DCHECK(!result.is(input_high));
|
||||
DCHECK(!double_input.is(double_scratch));
|
||||
Label negative, exception;
|
||||
|
||||
VmovHigh(input_high, double_input);
|
||||
|
||||
// Test for NaN and infinities.
|
||||
Sbfx(result, input_high,
|
||||
HeapNumber::kExponentShift, HeapNumber::kExponentBits);
|
||||
cmp(result, Operand(-1));
|
||||
b(eq, &exception);
|
||||
// Test for values that can be exactly represented as a
|
||||
// signed 32-bit integer.
|
||||
TryDoubleToInt32Exact(result, double_input, double_scratch);
|
||||
// If exact, return (result already fetched).
|
||||
b(eq, exact);
|
||||
cmp(input_high, Operand::Zero());
|
||||
b(mi, &negative);
|
||||
|
||||
// Input is in ]+0, +inf[.
|
||||
// If result equals 0x7fffffff input was out of range or
|
||||
// in ]0x7fffffff, 0x80000000[. We ignore this last case which
|
||||
// could fits into an int32, that means we always think input was
|
||||
// out of range and always go to exception.
|
||||
// If result < 0x7fffffff, go to done, result fetched.
|
||||
cmn(result, Operand(1));
|
||||
b(mi, &exception);
|
||||
b(done);
|
||||
|
||||
// Input is in ]-inf, -0[.
|
||||
// If x is a non integer negative number,
|
||||
// floor(x) <=> round_to_zero(x) - 1.
|
||||
bind(&negative);
|
||||
sub(result, result, Operand(1), SetCC);
|
||||
// If result is still negative, go to done, result fetched.
|
||||
// Else, we had an overflow and we fall through exception.
|
||||
b(mi, done);
|
||||
bind(&exception);
|
||||
}
|
||||
|
||||
void TurboAssembler::TryInlineTruncateDoubleToI(Register result,
|
||||
DwVfpRegister double_input,
|
||||
Label* done) {
|
||||
|
@ -1001,11 +1001,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
// The register value must be between d0 and d15.
|
||||
void SmiToDouble(LowDwVfpRegister value, Register smi);
|
||||
|
||||
// Check if a double can be exactly represented as a signed 32-bit integer.
|
||||
// Z flag set to one if true.
|
||||
void TestDoubleIsInt32(DwVfpRegister double_input,
|
||||
LowDwVfpRegister double_scratch);
|
||||
|
||||
// Try to convert a double to a signed 32-bit integer.
|
||||
// Z flag set to one and result assigned if the conversion is exact.
|
||||
void TryDoubleToInt32Exact(Register result,
|
||||
|
@ -279,29 +279,6 @@ void TurboAssembler::SlowTruncateToIDelayed(Zone* zone, Register result_reg,
|
||||
new (zone) DoubleToIStub(nullptr, input_reg, result_reg, offset, true));
|
||||
}
|
||||
|
||||
void MacroAssembler::SlowTruncateToI(Register result_reg,
|
||||
Register input_reg,
|
||||
int offset) {
|
||||
DoubleToIStub stub(isolate(), input_reg, result_reg, offset, true);
|
||||
CallStub(&stub);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateDoubleToI(Register result_reg,
|
||||
XMMRegister input_reg) {
|
||||
Label done;
|
||||
cvttsd2si(result_reg, Operand(input_reg));
|
||||
cmp(result_reg, 0x1);
|
||||
j(no_overflow, &done, Label::kNear);
|
||||
|
||||
sub(esp, Immediate(kDoubleSize));
|
||||
movsd(MemOperand(esp, 0), input_reg);
|
||||
SlowTruncateToI(result_reg, esp, 0);
|
||||
add(esp, Immediate(kDoubleSize));
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::DoubleToI(Register result_reg, XMMRegister input_reg,
|
||||
XMMRegister scratch,
|
||||
MinusZeroMode minus_zero_mode,
|
||||
@ -329,73 +306,6 @@ void MacroAssembler::DoubleToI(Register result_reg, XMMRegister input_reg,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateHeapNumberToI(Register result_reg,
|
||||
Register input_reg) {
|
||||
Label done, slow_case;
|
||||
|
||||
if (CpuFeatures::IsSupported(SSE3)) {
|
||||
CpuFeatureScope scope(this, SSE3);
|
||||
Label convert;
|
||||
// Use more powerful conversion when sse3 is available.
|
||||
// Load x87 register with heap number.
|
||||
fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset));
|
||||
// Get exponent alone and check for too-big exponent.
|
||||
mov(result_reg, FieldOperand(input_reg, HeapNumber::kExponentOffset));
|
||||
and_(result_reg, HeapNumber::kExponentMask);
|
||||
const uint32_t kTooBigExponent =
|
||||
(HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift;
|
||||
cmp(Operand(result_reg), Immediate(kTooBigExponent));
|
||||
j(greater_equal, &slow_case, Label::kNear);
|
||||
|
||||
// Reserve space for 64 bit answer.
|
||||
sub(Operand(esp), Immediate(kDoubleSize));
|
||||
// Do conversion, which cannot fail because we checked the exponent.
|
||||
fisttp_d(Operand(esp, 0));
|
||||
mov(result_reg, Operand(esp, 0)); // Low word of answer is the result.
|
||||
add(Operand(esp), Immediate(kDoubleSize));
|
||||
jmp(&done, Label::kNear);
|
||||
|
||||
// Slow case.
|
||||
bind(&slow_case);
|
||||
if (input_reg.is(result_reg)) {
|
||||
// Input is clobbered. Restore number from fpu stack
|
||||
sub(Operand(esp), Immediate(kDoubleSize));
|
||||
fstp_d(Operand(esp, 0));
|
||||
SlowTruncateToI(result_reg, esp, 0);
|
||||
add(esp, Immediate(kDoubleSize));
|
||||
} else {
|
||||
fstp(0);
|
||||
SlowTruncateToI(result_reg, input_reg);
|
||||
}
|
||||
} else {
|
||||
movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
|
||||
cvttsd2si(result_reg, Operand(xmm0));
|
||||
cmp(result_reg, 0x1);
|
||||
j(no_overflow, &done, Label::kNear);
|
||||
// Check if the input was 0x8000000 (kMinInt).
|
||||
// If no, then we got an overflow and we deoptimize.
|
||||
ExternalReference min_int = ExternalReference::address_of_min_int();
|
||||
ucomisd(xmm0, Operand::StaticVariable(min_int));
|
||||
j(not_equal, &slow_case, Label::kNear);
|
||||
j(parity_even, &slow_case, Label::kNear); // NaN.
|
||||
jmp(&done, Label::kNear);
|
||||
|
||||
// Slow case.
|
||||
bind(&slow_case);
|
||||
if (input_reg.is(result_reg)) {
|
||||
// Input is clobbered. Restore number from double scratch.
|
||||
sub(esp, Immediate(kDoubleSize));
|
||||
movsd(MemOperand(esp, 0), xmm0);
|
||||
SlowTruncateToI(result_reg, esp, 0);
|
||||
add(esp, Immediate(kDoubleSize));
|
||||
} else {
|
||||
SlowTruncateToI(result_reg, input_reg);
|
||||
}
|
||||
}
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
void TurboAssembler::LoadUint32(XMMRegister dst, const Operand& src) {
|
||||
Label done;
|
||||
cmp(src, Immediate(0));
|
||||
|
@ -580,12 +580,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
void ClampDoubleToUint8(XMMRegister input_reg, XMMRegister scratch_reg,
|
||||
Register result_reg);
|
||||
|
||||
void SlowTruncateToI(Register result_reg, Register input_reg,
|
||||
int offset = HeapNumber::kValueOffset - kHeapObjectTag);
|
||||
|
||||
void TruncateHeapNumberToI(Register result_reg, Register input_reg);
|
||||
void TruncateDoubleToI(Register result_reg, XMMRegister input_reg);
|
||||
|
||||
void DoubleToI(Register result_reg, XMMRegister input_reg,
|
||||
XMMRegister scratch, MinusZeroMode minus_zero_mode,
|
||||
Label* lost_precision, Label* is_nan, Label* minus_zero,
|
||||
|
@ -2510,47 +2510,6 @@ void TurboAssembler::TruncateDoubleToIDelayed(Zone* zone, Register result,
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateHeapNumberToI(Register result, Register object) {
|
||||
Label done;
|
||||
DoubleRegister double_scratch = f12;
|
||||
DCHECK(!result.is(object));
|
||||
|
||||
Ldc1(double_scratch,
|
||||
MemOperand(object, HeapNumber::kValueOffset - kHeapObjectTag));
|
||||
TryInlineTruncateDoubleToI(result, double_scratch, &done);
|
||||
|
||||
// If we fell through then inline version didn't succeed - call stub instead.
|
||||
push(ra);
|
||||
DoubleToIStub stub(isolate(),
|
||||
object,
|
||||
result,
|
||||
HeapNumber::kValueOffset - kHeapObjectTag,
|
||||
true,
|
||||
true);
|
||||
CallStub(&stub);
|
||||
pop(ra);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateNumberToI(Register object,
|
||||
Register result,
|
||||
Register heap_number_map,
|
||||
Register scratch,
|
||||
Label* not_number) {
|
||||
Label done;
|
||||
DCHECK(!result.is(object));
|
||||
|
||||
UntagAndJumpIfSmi(result, object, &done);
|
||||
JumpIfNotHeapNumber(object, heap_number_map, scratch, not_number);
|
||||
TruncateHeapNumberToI(result, object);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::GetLeastBitsFromSmi(Register dst,
|
||||
Register src,
|
||||
int num_least_bits) {
|
||||
|
@ -1120,21 +1120,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
DoubleRegister double_scratch, Register except_flag,
|
||||
CheckForInexactConversion check_inexact = kDontCheckForInexactConversion);
|
||||
|
||||
// Performs a truncating conversion of a heap number as used by
|
||||
// the JS bitwise operations. See ECMA-262 9.5: ToInt32. 'result' and 'input'
|
||||
// must be different registers. Exits with 'result' holding the answer.
|
||||
void TruncateHeapNumberToI(Register result, Register object);
|
||||
|
||||
// Converts the smi or heap number in object to an int32 using the rules
|
||||
// for ToInt32 as described in ECMAScript 9.5.: the value is truncated
|
||||
// and brought into the range -2^31 .. +2^31 - 1. 'result' and 'input' must be
|
||||
// different registers.
|
||||
void TruncateNumberToI(Register object,
|
||||
Register result,
|
||||
Register heap_number_map,
|
||||
Register scratch,
|
||||
Label* not_int32);
|
||||
|
||||
// Loads the number from object into dst register.
|
||||
// If |object| is neither smi nor heap number, |not_number| is jumped to
|
||||
// with |object| still intact.
|
||||
|
@ -2926,47 +2926,6 @@ void TurboAssembler::TruncateDoubleToIDelayed(Zone* zone, Register result,
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateHeapNumberToI(Register result, Register object) {
|
||||
Label done;
|
||||
DoubleRegister double_scratch = f12;
|
||||
DCHECK(!result.is(object));
|
||||
|
||||
Ldc1(double_scratch,
|
||||
MemOperand(object, HeapNumber::kValueOffset - kHeapObjectTag));
|
||||
TryInlineTruncateDoubleToI(result, double_scratch, &done);
|
||||
|
||||
// If we fell through then inline version didn't succeed - call stub instead.
|
||||
push(ra);
|
||||
DoubleToIStub stub(isolate(),
|
||||
object,
|
||||
result,
|
||||
HeapNumber::kValueOffset - kHeapObjectTag,
|
||||
true,
|
||||
true);
|
||||
CallStub(&stub);
|
||||
pop(ra);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateNumberToI(Register object,
|
||||
Register result,
|
||||
Register heap_number_map,
|
||||
Register scratch,
|
||||
Label* not_number) {
|
||||
Label done;
|
||||
DCHECK(!result.is(object));
|
||||
|
||||
UntagAndJumpIfSmi(result, object, &done);
|
||||
JumpIfNotHeapNumber(object, heap_number_map, scratch, not_number);
|
||||
TruncateHeapNumberToI(result, object);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::GetLeastBitsFromSmi(Register dst,
|
||||
Register src,
|
||||
int num_least_bits) {
|
||||
|
@ -1226,21 +1226,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
DoubleRegister double_scratch, Register except_flag,
|
||||
CheckForInexactConversion check_inexact = kDontCheckForInexactConversion);
|
||||
|
||||
// Performs a truncating conversion of a heap number as used by
|
||||
// the JS bitwise operations. See ECMA-262 9.5: ToInt32. 'result' and 'input'
|
||||
// must be different registers. Exits with 'result' holding the answer.
|
||||
void TruncateHeapNumberToI(Register result, Register object);
|
||||
|
||||
// Converts the smi or heap number in object to an int32 using the rules
|
||||
// for ToInt32 as described in ECMAScript 9.5.: the value is truncated
|
||||
// and brought into the range -2^31 .. +2^31 - 1. 'result' and 'input' must be
|
||||
// different registers.
|
||||
void TruncateNumberToI(Register object,
|
||||
Register result,
|
||||
Register heap_number_map,
|
||||
Register scratch,
|
||||
Label* not_int32);
|
||||
|
||||
// Loads the number from object into dst register.
|
||||
// If |object| is neither smi nor heap number, |not_number| is jumped to
|
||||
// with |object| still intact.
|
||||
|
@ -2007,31 +2007,6 @@ void MacroAssembler::SmiToDouble(DoubleRegister value, Register smi) {
|
||||
ConvertIntToDouble(ip, value);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TestDoubleIsInt32(DoubleRegister double_input,
|
||||
Register scratch1, Register scratch2,
|
||||
DoubleRegister double_scratch) {
|
||||
TryDoubleToInt32Exact(scratch1, double_input, scratch2, double_scratch);
|
||||
}
|
||||
|
||||
void MacroAssembler::TestDoubleIsMinusZero(DoubleRegister input,
|
||||
Register scratch1,
|
||||
Register scratch2) {
|
||||
#if V8_TARGET_ARCH_PPC64
|
||||
MovDoubleToInt64(scratch1, input);
|
||||
rotldi(scratch1, scratch1, 1);
|
||||
cmpi(scratch1, Operand(1));
|
||||
#else
|
||||
MovDoubleToInt64(scratch1, scratch2, input);
|
||||
Label done;
|
||||
cmpi(scratch2, Operand::Zero());
|
||||
bne(&done);
|
||||
lis(scratch2, Operand(SIGN_EXT_IMM16(0x8000)));
|
||||
cmp(scratch1, scratch2);
|
||||
bind(&done);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MacroAssembler::TestDoubleSign(DoubleRegister input, Register scratch) {
|
||||
#if V8_TARGET_ARCH_PPC64
|
||||
MovDoubleToInt64(scratch, input);
|
||||
@ -2076,47 +2051,6 @@ void MacroAssembler::TryDoubleToInt32Exact(Register result,
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TryInt32Floor(Register result, DoubleRegister double_input,
|
||||
Register input_high, Register scratch,
|
||||
DoubleRegister double_scratch, Label* done,
|
||||
Label* exact) {
|
||||
DCHECK(!result.is(input_high));
|
||||
DCHECK(!double_input.is(double_scratch));
|
||||
Label exception;
|
||||
|
||||
MovDoubleHighToInt(input_high, double_input);
|
||||
|
||||
// Test for NaN/Inf
|
||||
ExtractBitMask(result, input_high, HeapNumber::kExponentMask);
|
||||
cmpli(result, Operand(0x7ff));
|
||||
beq(&exception);
|
||||
|
||||
// Convert (rounding to -Inf)
|
||||
ConvertDoubleToInt64(double_input,
|
||||
#if !V8_TARGET_ARCH_PPC64
|
||||
scratch,
|
||||
#endif
|
||||
result, double_scratch, kRoundToMinusInf);
|
||||
|
||||
// Test for overflow
|
||||
#if V8_TARGET_ARCH_PPC64
|
||||
TestIfInt32(result, r0);
|
||||
#else
|
||||
TestIfInt32(scratch, result, r0);
|
||||
#endif
|
||||
bne(&exception);
|
||||
|
||||
// Test for exactness
|
||||
fcfid(double_scratch, double_scratch);
|
||||
fcmpu(double_scratch, double_input);
|
||||
beq(exact);
|
||||
b(done);
|
||||
|
||||
bind(&exception);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TryInlineTruncateDoubleToI(Register result,
|
||||
DoubleRegister double_input,
|
||||
Label* done) {
|
||||
@ -2140,65 +2074,6 @@ void MacroAssembler::TryInlineTruncateDoubleToI(Register result,
|
||||
beq(done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateDoubleToI(Register result,
|
||||
DoubleRegister double_input) {
|
||||
Label done;
|
||||
|
||||
TryInlineTruncateDoubleToI(result, double_input, &done);
|
||||
|
||||
// If we fell through then inline version didn't succeed - call stub instead.
|
||||
mflr(r0);
|
||||
push(r0);
|
||||
// Put input on stack.
|
||||
stfdu(double_input, MemOperand(sp, -kDoubleSize));
|
||||
|
||||
DoubleToIStub stub(isolate(), sp, result, 0, true, true);
|
||||
CallStub(&stub);
|
||||
|
||||
addi(sp, sp, Operand(kDoubleSize));
|
||||
pop(r0);
|
||||
mtlr(r0);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateHeapNumberToI(Register result, Register object) {
|
||||
Label done;
|
||||
DoubleRegister double_scratch = kScratchDoubleReg;
|
||||
DCHECK(!result.is(object));
|
||||
|
||||
lfd(double_scratch, FieldMemOperand(object, HeapNumber::kValueOffset));
|
||||
TryInlineTruncateDoubleToI(result, double_scratch, &done);
|
||||
|
||||
// If we fell through then inline version didn't succeed - call stub instead.
|
||||
mflr(r0);
|
||||
push(r0);
|
||||
DoubleToIStub stub(isolate(), object, result,
|
||||
HeapNumber::kValueOffset - kHeapObjectTag, true, true);
|
||||
CallStub(&stub);
|
||||
pop(r0);
|
||||
mtlr(r0);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateNumberToI(Register object, Register result,
|
||||
Register heap_number_map,
|
||||
Register scratch1, Label* not_number) {
|
||||
Label done;
|
||||
DCHECK(!result.is(object));
|
||||
|
||||
UntagAndJumpIfSmi(result, object, &done);
|
||||
JumpIfNotHeapNumber(object, heap_number_map, scratch1, not_number);
|
||||
TruncateHeapNumberToI(result, object);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::GetLeastBitsFromSmi(Register dst, Register src,
|
||||
int num_least_bits) {
|
||||
#if V8_TARGET_ARCH_PPC64
|
||||
|
@ -819,16 +819,6 @@ class MacroAssembler : public Assembler {
|
||||
// Load the value of a smi object into a double register.
|
||||
void SmiToDouble(DoubleRegister value, Register smi);
|
||||
|
||||
// Check if a double can be exactly represented as a signed 32-bit integer.
|
||||
// CR_EQ in cr7 is set if true.
|
||||
void TestDoubleIsInt32(DoubleRegister double_input, Register scratch1,
|
||||
Register scratch2, DoubleRegister double_scratch);
|
||||
|
||||
// Check if a double is equal to -0.0.
|
||||
// CR_EQ in cr7 holds the result.
|
||||
void TestDoubleIsMinusZero(DoubleRegister input, Register scratch1,
|
||||
Register scratch2);
|
||||
|
||||
// Check the sign of a double.
|
||||
// CR_LT in cr7 holds the result.
|
||||
void TestDoubleSign(DoubleRegister input, Register scratch);
|
||||
@ -839,14 +829,6 @@ class MacroAssembler : public Assembler {
|
||||
void TryDoubleToInt32Exact(Register result, DoubleRegister double_input,
|
||||
Register scratch, DoubleRegister double_scratch);
|
||||
|
||||
// Floor a double and writes the value to the result register.
|
||||
// Go to exact if the conversion is exact (to be able to test -0),
|
||||
// fall through calling code if an overflow occurred, else go to done.
|
||||
// In return, input_high is loaded with high bits of input.
|
||||
void TryInt32Floor(Register result, DoubleRegister double_input,
|
||||
Register input_high, Register scratch,
|
||||
DoubleRegister double_scratch, Label* done, Label* exact);
|
||||
|
||||
// Performs a truncating conversion of a floating point number as used by
|
||||
// the JS bitwise operations. See ECMA-262 9.5: ToInt32. Goes to 'done' if it
|
||||
// succeeds, otherwise falls through if result is saturated. On return
|
||||
@ -856,24 +838,6 @@ class MacroAssembler : public Assembler {
|
||||
void TryInlineTruncateDoubleToI(Register result, DoubleRegister input,
|
||||
Label* done);
|
||||
|
||||
// Performs a truncating conversion of a floating point number as used by
|
||||
// the JS bitwise operations. See ECMA-262 9.5: ToInt32.
|
||||
// Exits with 'result' holding the answer.
|
||||
void TruncateDoubleToI(Register result, DoubleRegister double_input);
|
||||
|
||||
// Performs a truncating conversion of a heap number as used by
|
||||
// the JS bitwise operations. See ECMA-262 9.5: ToInt32. 'result' and 'input'
|
||||
// must be different registers. Exits with 'result' holding the answer.
|
||||
void TruncateHeapNumberToI(Register result, Register object);
|
||||
|
||||
// Converts the smi or heap number in object to an int32 using the rules
|
||||
// for ToInt32 as described in ECMAScript 9.5.: the value is truncated
|
||||
// and brought into the range -2^31 .. +2^31 - 1. 'result' and 'input' must be
|
||||
// different registers.
|
||||
void TruncateNumberToI(Register object, Register result,
|
||||
Register heap_number_map, Register scratch1,
|
||||
Label* not_int32);
|
||||
|
||||
// Overflow handling functions.
|
||||
// Usage: call the appropriate arithmetic function and then call one of the
|
||||
// flow control functions with the corresponding label.
|
||||
|
@ -1818,30 +1818,6 @@ bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
|
||||
return has_frame_ || !stub->SometimesSetsUpAFrame();
|
||||
}
|
||||
|
||||
void MacroAssembler::TestDoubleIsInt32(DoubleRegister double_input,
|
||||
Register scratch1, Register scratch2,
|
||||
DoubleRegister double_scratch) {
|
||||
TryDoubleToInt32Exact(scratch1, double_input, scratch2, double_scratch);
|
||||
}
|
||||
|
||||
void MacroAssembler::TestDoubleIsMinusZero(DoubleRegister input,
|
||||
Register scratch1,
|
||||
Register scratch2) {
|
||||
lgdr(scratch1, input);
|
||||
#if V8_TARGET_ARCH_S390X
|
||||
llihf(scratch2, Operand(0x80000000)); // scratch2 = 0x80000000_00000000
|
||||
CmpP(scratch1, scratch2);
|
||||
#else
|
||||
Label done;
|
||||
CmpP(scratch1, Operand::Zero());
|
||||
bne(&done, Label::kNear);
|
||||
|
||||
srlg(scratch1, scratch1, Operand(32));
|
||||
CmpP(scratch1, Operand(HeapNumber::kSignMask));
|
||||
bind(&done);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MacroAssembler::TestDoubleSign(DoubleRegister input, Register scratch) {
|
||||
lgdr(scratch, input);
|
||||
cgfi(scratch, Operand::Zero());
|
||||
@ -1871,41 +1847,6 @@ void MacroAssembler::TryDoubleToInt32Exact(Register result,
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
void MacroAssembler::TryInt32Floor(Register result, DoubleRegister double_input,
|
||||
Register input_high, Register scratch,
|
||||
DoubleRegister double_scratch, Label* done,
|
||||
Label* exact) {
|
||||
DCHECK(!result.is(input_high));
|
||||
DCHECK(!double_input.is(double_scratch));
|
||||
Label exception;
|
||||
|
||||
// Move high word into input_high
|
||||
lay(sp, MemOperand(sp, -kDoubleSize));
|
||||
StoreDouble(double_input, MemOperand(sp));
|
||||
LoadlW(input_high, MemOperand(sp, Register::kExponentOffset));
|
||||
la(sp, MemOperand(sp, kDoubleSize));
|
||||
|
||||
// Test for NaN/Inf
|
||||
ExtractBitMask(result, input_high, HeapNumber::kExponentMask);
|
||||
CmpLogicalP(result, Operand(0x7ff));
|
||||
beq(&exception);
|
||||
|
||||
// Convert (rounding to -Inf)
|
||||
ConvertDoubleToInt64(result, double_input, kRoundToMinusInf);
|
||||
|
||||
// Test for overflow
|
||||
TestIfInt32(result);
|
||||
bne(&exception);
|
||||
|
||||
// Test for exactness
|
||||
cdfbr(double_scratch, result);
|
||||
cdbr(double_scratch, double_input);
|
||||
beq(exact);
|
||||
b(done);
|
||||
|
||||
bind(&exception);
|
||||
}
|
||||
|
||||
void MacroAssembler::TryInlineTruncateDoubleToI(Register result,
|
||||
DoubleRegister double_input,
|
||||
Label* done) {
|
||||
@ -1916,58 +1857,6 @@ void MacroAssembler::TryInlineTruncateDoubleToI(Register result,
|
||||
beq(done);
|
||||
}
|
||||
|
||||
void MacroAssembler::TruncateDoubleToI(Register result,
|
||||
DoubleRegister double_input) {
|
||||
Label done;
|
||||
|
||||
TryInlineTruncateDoubleToI(result, double_input, &done);
|
||||
|
||||
// If we fell through then inline version didn't succeed - call stub instead.
|
||||
push(r14);
|
||||
// Put input on stack.
|
||||
lay(sp, MemOperand(sp, -kDoubleSize));
|
||||
StoreDouble(double_input, MemOperand(sp));
|
||||
|
||||
DoubleToIStub stub(isolate(), sp, result, 0, true, true);
|
||||
CallStub(&stub);
|
||||
|
||||
la(sp, MemOperand(sp, kDoubleSize));
|
||||
pop(r14);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
void MacroAssembler::TruncateHeapNumberToI(Register result, Register object) {
|
||||
Label done;
|
||||
DoubleRegister double_scratch = kScratchDoubleReg;
|
||||
DCHECK(!result.is(object));
|
||||
|
||||
LoadDouble(double_scratch, FieldMemOperand(object, HeapNumber::kValueOffset));
|
||||
TryInlineTruncateDoubleToI(result, double_scratch, &done);
|
||||
|
||||
// If we fell through then inline version didn't succeed - call stub instead.
|
||||
push(r14);
|
||||
DoubleToIStub stub(isolate(), object, result,
|
||||
HeapNumber::kValueOffset - kHeapObjectTag, true, true);
|
||||
CallStub(&stub);
|
||||
pop(r14);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
void MacroAssembler::TruncateNumberToI(Register object, Register result,
|
||||
Register heap_number_map,
|
||||
Register scratch1, Label* not_number) {
|
||||
Label done;
|
||||
DCHECK(!result.is(object));
|
||||
|
||||
UntagAndJumpIfSmi(result, object, &done);
|
||||
JumpIfNotHeapNumber(object, heap_number_map, scratch1, not_number);
|
||||
TruncateHeapNumberToI(result, object);
|
||||
|
||||
bind(&done);
|
||||
}
|
||||
|
||||
void MacroAssembler::GetLeastBitsFromSmi(Register dst, Register src,
|
||||
int num_least_bits) {
|
||||
if (CpuFeatures::IsSupported(GENERAL_INSTR_EXT)) {
|
||||
|
@ -1143,16 +1143,6 @@ class MacroAssembler : public Assembler {
|
||||
// untagged value afterwards.
|
||||
void SmiToDouble(DoubleRegister value, Register smi);
|
||||
|
||||
// Check if a double can be exactly represented as a signed 32-bit integer.
|
||||
// CR_EQ in cr7 is set if true.
|
||||
void TestDoubleIsInt32(DoubleRegister double_input, Register scratch1,
|
||||
Register scratch2, DoubleRegister double_scratch);
|
||||
|
||||
// Check if a double is equal to -0.0.
|
||||
// CR_EQ in cr7 holds the result.
|
||||
void TestDoubleIsMinusZero(DoubleRegister input, Register scratch1,
|
||||
Register scratch2);
|
||||
|
||||
// Check the sign of a double.
|
||||
// CR_LT in cr7 holds the result.
|
||||
void TestDoubleSign(DoubleRegister input, Register scratch);
|
||||
@ -1163,41 +1153,6 @@ class MacroAssembler : public Assembler {
|
||||
void TryDoubleToInt32Exact(Register result, DoubleRegister double_input,
|
||||
Register scratch, DoubleRegister double_scratch);
|
||||
|
||||
// Floor a double and writes the value to the result register.
|
||||
// Go to exact if the conversion is exact (to be able to test -0),
|
||||
// fall through calling code if an overflow occurred, else go to done.
|
||||
// In return, input_high is loaded with high bits of input.
|
||||
void TryInt32Floor(Register result, DoubleRegister double_input,
|
||||
Register input_high, Register scratch,
|
||||
DoubleRegister double_scratch, Label* done, Label* exact);
|
||||
|
||||
// Performs a truncating conversion of a floating point number as used by
|
||||
// the JS bitwise operations. See ECMA-262 9.5: ToInt32. Goes to 'done' if it
|
||||
// succeeds, otherwise falls through if result is saturated. On return
|
||||
// 'result' either holds answer, or is clobbered on fall through.
|
||||
//
|
||||
// Only public for the test code in test-code-stubs-arm.cc.
|
||||
void TryInlineTruncateDoubleToI(Register result, DoubleRegister input,
|
||||
Label* done);
|
||||
|
||||
// Performs a truncating conversion of a floating point number as used by
|
||||
// the JS bitwise operations. See ECMA-262 9.5: ToInt32.
|
||||
// Exits with 'result' holding the answer.
|
||||
void TruncateDoubleToI(Register result, DoubleRegister double_input);
|
||||
|
||||
// Performs a truncating conversion of a heap number as used by
|
||||
// the JS bitwise operations. See ECMA-262 9.5: ToInt32. 'result' and 'input'
|
||||
// must be different registers. Exits with 'result' holding the answer.
|
||||
void TruncateHeapNumberToI(Register result, Register object);
|
||||
|
||||
// Converts the smi or heap number in object to an int32 using the rules
|
||||
// for ToInt32 as described in ECMAScript 9.5.: the value is truncated
|
||||
// and brought into the range -2^31 .. +2^31 - 1. 'result' and 'input' must be
|
||||
// different registers.
|
||||
void TruncateNumberToI(Register object, Register result,
|
||||
Register heap_number_map, Register scratch1,
|
||||
Label* not_int32);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Runtime calls
|
||||
|
||||
|
@ -3452,56 +3452,6 @@ void TurboAssembler::SlowTruncateToIDelayed(Zone* zone, Register result_reg,
|
||||
new (zone) DoubleToIStub(nullptr, input_reg, result_reg, offset, true));
|
||||
}
|
||||
|
||||
void MacroAssembler::SlowTruncateToI(Register result_reg,
|
||||
Register input_reg,
|
||||
int offset) {
|
||||
DoubleToIStub stub(isolate(), input_reg, result_reg, offset, true);
|
||||
call(stub.GetCode(), RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateHeapNumberToI(Register result_reg,
|
||||
Register input_reg) {
|
||||
Label done;
|
||||
Movsd(kScratchDoubleReg, FieldOperand(input_reg, HeapNumber::kValueOffset));
|
||||
Cvttsd2siq(result_reg, kScratchDoubleReg);
|
||||
cmpq(result_reg, Immediate(1));
|
||||
j(no_overflow, &done, Label::kNear);
|
||||
|
||||
// Slow case.
|
||||
if (input_reg.is(result_reg)) {
|
||||
subp(rsp, Immediate(kDoubleSize));
|
||||
Movsd(MemOperand(rsp, 0), kScratchDoubleReg);
|
||||
SlowTruncateToI(result_reg, rsp, 0);
|
||||
addp(rsp, Immediate(kDoubleSize));
|
||||
} else {
|
||||
SlowTruncateToI(result_reg, input_reg);
|
||||
}
|
||||
|
||||
bind(&done);
|
||||
// Keep our invariant that the upper 32 bits are zero.
|
||||
movl(result_reg, result_reg);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::TruncateDoubleToI(Register result_reg,
|
||||
XMMRegister input_reg) {
|
||||
Label done;
|
||||
Cvttsd2siq(result_reg, input_reg);
|
||||
cmpq(result_reg, Immediate(1));
|
||||
j(no_overflow, &done, Label::kNear);
|
||||
|
||||
subp(rsp, Immediate(kDoubleSize));
|
||||
Movsd(MemOperand(rsp, 0), input_reg);
|
||||
SlowTruncateToI(result_reg, rsp, 0);
|
||||
addp(rsp, Immediate(kDoubleSize));
|
||||
|
||||
bind(&done);
|
||||
// Keep our invariant that the upper 32 bits are zero.
|
||||
movl(result_reg, result_reg);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::DoubleToI(Register result_reg, XMMRegister input_reg,
|
||||
XMMRegister scratch,
|
||||
MinusZeroMode minus_zero_mode,
|
||||
|
@ -1194,12 +1194,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
XMMRegister temp_xmm_reg,
|
||||
Register result_reg);
|
||||
|
||||
void SlowTruncateToI(Register result_reg, Register input_reg,
|
||||
int offset = HeapNumber::kValueOffset - kHeapObjectTag);
|
||||
|
||||
void TruncateHeapNumberToI(Register result_reg, Register input_reg);
|
||||
void TruncateDoubleToI(Register result_reg, XMMRegister input_reg);
|
||||
|
||||
void DoubleToI(Register result_reg, XMMRegister input_reg,
|
||||
XMMRegister scratch, MinusZeroMode minus_zero_mode,
|
||||
Label* lost_precision, Label* is_nan, Label* minus_zero,
|
||||
|
Loading…
Reference in New Issue
Block a user