__ Ldr(double_scratch, MemOperand(input, double_offset));
// Try to convert with a FPU convert instruction. This handles all
// non-saturating cases.
- __ TryInlineTruncateDoubleToI(result, double_scratch, &done);
+ __ TryConvertDoubleToInt64(result, double_scratch, &done);
__ Fmov(result, double_scratch);
} else {
__ Ldr(result, MemOperand(input, double_offset));
Register output = ToRegister(instr->result());
if (instr->hydrogen()->value()->representation().IsSmi()) {
- __ SmiUntag(input);
+ __ SmiUntag(output, input);
} else {
DeferredTaggedToI* deferred = new(zone()) DeferredTaggedToI(this, instr);
- // TODO(jbramley): We can't use JumpIfNotSmi here because the tbz it uses
- // doesn't always have enough range. Consider making a variant of it, or a
- // TestIsSmi helper.
- STATIC_ASSERT(kSmiTag == 0);
- __ Tst(input, kSmiTagMask);
- __ B(ne, deferred->entry());
-
+ __ JumpIfNotSmi(input, deferred->entry());
__ SmiUntag(output, input);
__ Bind(deferred->exit());
}
}
-void MacroAssembler::TryInlineTruncateDoubleToI(Register result,
- DoubleRegister double_input,
- Label* done) {
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiValueSize == 32);
-
- // Try to convert with a FPU convert instruction. It's trivial to compute
+void MacroAssembler::TryConvertDoubleToInt64(Register result,
+ DoubleRegister double_input,
+ Label* done) {
+ // Try to convert with an FPU convert instruction. It's trivial to compute
// the modulo operation on an integer register so we convert to a 64-bit
- // integer, then find the 32-bit result from that.
+ // integer.
//
// Fcvtzs will saturate to INT64_MIN (0x800...00) or INT64_MAX (0x7ff...ff)
// when the double is out of range. NaNs and infinities will be converted to 0
// (as ECMA-262 requires).
- Fcvtzs(result, double_input);
+ Fcvtzs(result.X(), double_input);
// The values INT64_MIN (0x800...00) or INT64_MAX (0x7ff...ff) are not
// representable using a double, so if the result is one of those then we know
//
// It is easy to detect INT64_MIN and INT64_MAX because adding or subtracting
// 1 will cause signed overflow.
- Cmp(result, 1);
- Ccmp(result, -1, VFlag, vc);
+ Cmp(result.X(), 1);
+ Ccmp(result.X(), -1, VFlag, vc);
B(vc, done);
}
Label done;
ASSERT(jssp.Is(StackPointer()));
- TryInlineTruncateDoubleToI(result, double_input, &done);
+ // Try to convert the double to an int64. If successful, the bottom 32 bits
+ // contain our truncated int32 result.
+ TryConvertDoubleToInt64(result, double_input, &done);
// If we fell through then inline version didn't succeed - call stub instead.
Push(lr);
ASSERT(jssp.Is(StackPointer()));
Ldr(fp_scratch, FieldMemOperand(object, HeapNumber::kValueOffset));
- TryInlineTruncateDoubleToI(result, fp_scratch, &done);
+
+ // Try to convert the double to an int64. If successful, the bottom 32 bits
+ // contain our truncated int32 result.
+ TryConvertDoubleToInt64(result, fp_scratch, &done);
// If we fell through then inline version didn't succeed - call stub instead.
Push(lr);
// ---- Floating point helpers ----
-
- // 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.
+ // Perform a conversion from a double to a signed int64. If the input fits in
+ // range of the 64-bit result, execution branches to done. Otherwise,
+ // execution falls through, and the sign of the result can be used to
+ // determine if overflow was towards positive or negative infinity.
+ //
+ // On successful conversion, the least significant 32 bits of the result are
+ // equivalent to the ECMA-262 operation "ToInt32".
//
// Only public for the test code in test-code-stubs-a64.cc.
- void TryInlineTruncateDoubleToI(Register result,
- DoubleRegister input,
- Label* done);
+ void TryConvertDoubleToInt64(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.
// Call through to the actual stub
if (inline_fastpath) {
__ Ldr(d0, MemOperand(source_reg));
- __ TryInlineTruncateDoubleToI(destination_reg, d0, &done);
+ __ TryConvertDoubleToInt64(destination_reg, d0, &done);
if (destination_reg.is(source_reg)) {
// Restore clobbered source_reg.
__ add(source_reg, jssp, Operand(source_reg_offset));