Reviewers: danno,

Message:
For the SmiSubConstant call-sites in the current src/:

code-stubs-x64.cc:2206:  __ SmiSubConstant(r9, r9, Smi::FromInt(1));
full-codegen-x64.cc:4426:      __ SmiSubConstant(rax, rax, Smi::FromInt(1));
full-codegen-x64.cc:4436:      __ SmiSubConstant(rax, rax, Smi::FromInt(1));
ic-x64.cc:1178:  __ SmiSubConstant(scratch2, scratch2, Smi::FromInt(2));

   1) void SmiSubConstant(Register dst,

                      Register src,
                      Smi* constant,
                      Label* on_not_smi_result,
                      Label::Distance near_jump = Label::kFar);
   is not used.
   2) The overflow is checked at CountOperation
(https://codereview.chromium.org/22935005/).

I will continue working on 22935005 to tweak SmiSubConstants further.

Description:
Tweak SmiSubConstant for X64

Please review this at https://codereview.chromium.org/24986002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+9, -16 lines):
  M src/x64/macro-assembler-x64.cc


Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index 96fa4fc49630424093eaa29874c118e95c34a115..bd1933e4f190e3ac59866886844eefcbe1d887fe 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -1584,20 +1584,14 @@ void MacroAssembler::SmiSubConstant(Register dst,
     }
   } else if (dst.is(src)) {
     ASSERT(!dst.is(kScratchRegister));
-    if (constant->value() == Smi::kMinValue) {
-      // Subtracting min-value from any non-negative value will overflow.
-      // We test the non-negativeness before doing the subtraction.
-      testq(src, src);
-      j(not_sign, on_not_smi_result, near_jump);
-      LoadSmiConstant(kScratchRegister, constant);
-      subq(dst, kScratchRegister);
-    } else {
-      // Subtract by adding the negation.
-      LoadSmiConstant(kScratchRegister, Smi::FromInt(-constant->value()));
-      addq(kScratchRegister, dst);
-      j(overflow, on_not_smi_result, near_jump);
-      movq(dst, kScratchRegister);
-    }
+    Label done;
+    LoadSmiConstant(kScratchRegister, constant);
+    subq(dst, kScratchRegister);
+    j(no_overflow, &done, Label::kNear);
+    // Restore src.
+    addq(dst, kScratchRegister);
+    jmp(on_not_smi_result, near_jump);
+    bind(&done);
   } else {
     if (constant->value() == Smi::kMinValue) {
       // Subtracting min-value from any non-negative value will overflow.
@@ -1605,8 +1599,7 @@ void MacroAssembler::SmiSubConstant(Register dst,
       testq(src, src);
       j(not_sign, on_not_smi_result, near_jump);
       LoadSmiConstant(dst, constant);
- // Adding and subtracting the min-value gives the same result, it only
-      // differs on the overflow bit, which we don't check here.
+      // No overflow.
       addq(dst, src);
     } else {
       // Subtract by adding the negation.


--
--
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