Revision: 19114
Author: [email protected]
Date: Wed Feb 5 17:11:05 2014 UTC
Log: A64: Implement Smi support in MathAbs
BUG=
[email protected]
Review URL: https://codereview.chromium.org/141593005
http://code.google.com/p/v8/source/detail?r=19114
Modified:
/branches/experimental/a64/src/a64/lithium-a64.cc
/branches/experimental/a64/src/a64/lithium-codegen-a64.cc
/branches/experimental/a64/src/a64/macro-assembler-a64.cc
/branches/experimental/a64/src/a64/macro-assembler-a64.h
/branches/experimental/a64/src/a64/stub-cache-a64.cc
/branches/experimental/a64/test/cctest/test-assembler-a64.cc
=======================================
--- /branches/experimental/a64/src/a64/lithium-a64.cc Wed Feb 5 14:26:40
2014 UTC
+++ /branches/experimental/a64/src/a64/lithium-a64.cc Wed Feb 5 17:11:05
2014 UTC
@@ -2377,8 +2377,7 @@
switch (instr->op()) {
case kMathAbs: {
Representation r = instr->representation();
- // TODO(jbramley): Support smis in LMathAbs and use that.
- if (r.IsTagged() || r.IsSmi()) {
+ if (r.IsTagged()) {
// The tagged case might need to allocate a HeapNumber for the
result,
// so it is handled by a separate LInstruction.
LOperand* input = UseRegister(instr->value());
@@ -2395,9 +2394,9 @@
// The Double case can never fail so it doesn't need an
environment.
return DefineAsRegister(result);
} else {
- ASSERT(r.IsInteger32());
- // The Integer32 case needs an environment because it can
deoptimize
- // on INT_MIN.
+ ASSERT(r.IsInteger32() || r.IsSmi());
+ // The Integer32 and Smi cases need an environment because they
can
+ // deoptimize on minimum representable number.
return AssignEnvironment(DefineAsRegister(result));
}
}
=======================================
--- /branches/experimental/a64/src/a64/lithium-codegen-a64.cc Wed Feb 5
16:57:28 2014 UTC
+++ /branches/experimental/a64/src/a64/lithium-codegen-a64.cc Wed Feb 5
17:11:05 2014 UTC
@@ -3492,10 +3492,11 @@
DoubleRegister input = ToDoubleRegister(instr->value());
DoubleRegister result = ToDoubleRegister(instr->result());
__ Fabs(result, input);
- } else {
- ASSERT(r.IsInteger32());
- Register input = ToRegister32(instr->value());
- Register result = ToRegister32(instr->result());
+ } else if (r.IsSmi() || r.IsInteger32()) {
+ Register input = r.IsSmi() ? ToRegister(instr->value())
+ : ToRegister32(instr->value());
+ Register result = r.IsSmi() ? ToRegister(instr->result())
+ : ToRegister32(instr->result());
Label done;
__ Abs(result, input, NULL, &done);
Deoptimize(instr->environment());
=======================================
--- /branches/experimental/a64/src/a64/macro-assembler-a64.cc Wed Feb 5
16:05:11 2014 UTC
+++ /branches/experimental/a64/src/a64/macro-assembler-a64.cc Wed Feb 5
17:11:05 2014 UTC
@@ -523,15 +523,15 @@
void MacroAssembler::Abs(const Register& rd, const Register& rm,
- Label * is_not_representable,
- Label * is_representable) {
+ Label* is_not_representable,
+ Label* is_representable) {
ASSERT(allow_macro_instructions_);
ASSERT(AreSameSizeAndType(rd, rm));
Cmp(rm, 1);
Cneg(rd, rm, lt);
- // If the comparison set the v flag, the input was the smallest value
+ // If the comparison sets the v flag, the input was the smallest value
// representable by rm, and the mathematical result of abs(rm) is not
// representable using two's complement.
if ((is_not_representable != NULL) && (is_representable != NULL)) {
@@ -1129,31 +1129,9 @@
}
-void MacroAssembler::SmiAbs(Register smi, Register scratch, Label *slow) {
- // TODO(all): There is another possible implementation of this function
- // which would consist of:
- // * Comparing the smi with 0.
- // * Performing a conditional negate (cneg).
- // * Testing if the result is still negative.
- //
- // This other implementation uses 1 more instruction but uses one of the
new
- // A64 conditional instruction and doesn't use shifted registers.
- //
- // This two versions should be profiled on real hardware as we have no
idea
- // which one will be the fastest.
- ASSERT(!AreAliased(smi, scratch));
-
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiShift == 32);
-
- // Do bitwise not or do nothing depending on the sign of the argument.
- __ Eor(scratch, smi, Operand(smi, ASR, kXRegSize - 1));
- // Add 1 or do nothing depending on the sign of the argument.
- __ Adds(smi, scratch, Operand(smi, LSR, kXRegSize - 1));
-
- // If the result is still negative, go to the slow case.
- // This only happens for the most negative smi.
- __ B(mi, slow);
+void MacroAssembler::SmiAbs(const Register& smi, Label* slow) {
+ ASSERT(smi.Is64Bits());
+ Abs(smi, smi, slow);
}
=======================================
--- /branches/experimental/a64/src/a64/macro-assembler-a64.h Wed Feb 5
16:05:11 2014 UTC
+++ /branches/experimental/a64/src/a64/macro-assembler-a64.h Wed Feb 5
17:11:05 2014 UTC
@@ -753,7 +753,7 @@
// Compute the absolute value of 'smi' and leave the result in 'smi'
// register. If 'smi' is the most negative SMI, the absolute value cannot
// be represented as a SMI and a jump to 'slow' is done.
- void SmiAbs(Register smi, Register scratch, Label *slow);
+ void SmiAbs(const Register& smi, Label* slow);
inline void JumpIfSmi(Register value,
Label* smi_label,
=======================================
--- /branches/experimental/a64/src/a64/stub-cache-a64.cc Wed Feb 5
16:05:11 2014 UTC
+++ /branches/experimental/a64/src/a64/stub-cache-a64.cc Wed Feb 5
17:11:05 2014 UTC
@@ -2504,7 +2504,7 @@
Label not_smi;
__ JumpIfNotSmi(arg, ¬_smi);
- __ SmiAbs(arg, x1, &slow);
+ __ SmiAbs(arg, &slow);
// Smi case done.
__ Drop(argc + 1);
__ Ret();
=======================================
--- /branches/experimental/a64/test/cctest/test-assembler-a64.cc Wed Feb 5
10:26:23 2014 UTC
+++ /branches/experimental/a64/test/cctest/test-assembler-a64.cc Wed Feb 5
17:11:05 2014 UTC
@@ -9164,7 +9164,7 @@
__ Mov(x2, 0xc001c0de);
__ Mov(x1, value);
__ SmiTag(x1);
- __ SmiAbs(x1, x0, &slow);
+ __ SmiAbs(x1, &slow);
__ SmiUntag(x1);
__ B(&end);
--
--
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.