Revision: 19527
Author:   [email protected]
Date:     Fri Feb 21 11:36:04 2014 UTC
Log:      A64: Tidy up register use in TaggedToI

Fix bug where input register was potentially corrupted, tidy up register use in
TruncateDoubleToI and rename TryInlineTruncateDoubleToI.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/173663002
http://code.google.com/p/v8/source/detail?r=19527

Modified:
 /branches/bleeding_edge/src/a64/code-stubs-a64.cc
 /branches/bleeding_edge/src/a64/lithium-codegen-a64.cc
 /branches/bleeding_edge/src/a64/macro-assembler-a64.cc
 /branches/bleeding_edge/src/a64/macro-assembler-a64.h
 /branches/bleeding_edge/test/cctest/test-code-stubs-a64.cc

=======================================
--- /branches/bleeding_edge/src/a64/code-stubs-a64.cc Thu Feb 20 10:08:04 2014 UTC +++ /branches/bleeding_edge/src/a64/code-stubs-a64.cc Fri Feb 21 11:36:04 2014 UTC
@@ -565,7 +565,7 @@
     __ 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));
=======================================
--- /branches/bleeding_edge/src/a64/lithium-codegen-a64.cc Thu Feb 20 16:40:53 2014 UTC +++ /branches/bleeding_edge/src/a64/lithium-codegen-a64.cc Fri Feb 21 11:36:04 2014 UTC
@@ -5346,17 +5346,11 @@
   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());
   }
=======================================
--- /branches/bleeding_edge/src/a64/macro-assembler-a64.cc Thu Feb 20 16:36:53 2014 UTC +++ /branches/bleeding_edge/src/a64/macro-assembler-a64.cc Fri Feb 21 11:36:04 2014 UTC
@@ -2806,20 +2806,17 @@
 }


-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
@@ -2827,8 +2824,8 @@
   //
// 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);
 }
@@ -2839,7 +2836,9 @@
   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);
@@ -2870,7 +2869,10 @@
   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);
=======================================
--- /branches/bleeding_edge/src/a64/macro-assembler-a64.h Fri Feb 21 09:32:57 2014 UTC +++ /branches/bleeding_edge/src/a64/macro-assembler-a64.h Fri Feb 21 11:36:04 2014 UTC
@@ -1179,16 +1179,18 @@

   // ---- 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.
=======================================
--- /branches/bleeding_edge/test/cctest/test-code-stubs-a64.cc Wed Feb 19 09:43:45 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-code-stubs-a64.cc Fri Feb 21 11:36:04 2014 UTC
@@ -87,7 +87,7 @@
   // 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));

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to