Revision: 7037
Author: [email protected]
Date: Thu Mar  3 01:33:08 2011
Log: Add lithium support for %_GetCachedArrayIndex for IA32 and X64

BUG=v8:1093
Review URL: http://codereview.chromium.org/6611014
http://code.google.com/p/v8/source/detail?r=7037

Modified:
 /branches/bleeding_edge/src/arm/lithium-arm.cc
 /branches/bleeding_edge/src/arm/lithium-arm.h
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-ia32.h
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
 /branches/bleeding_edge/src/x64/lithium-x64.cc
 /branches/bleeding_edge/src/x64/lithium-x64.h

=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc      Wed Mar  2 07:04:20 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc      Thu Mar  3 01:33:08 2011
@@ -1519,7 +1519,7 @@
 LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
     HGetCachedArrayIndex* instr)  {
   ASSERT(instr->value()->representation().IsTagged());
-  LOperand* value = UseRegister(instr->value());
+  LOperand* value = UseRegisterAtStart(instr->value());

   return DefineAsRegister(new LGetCachedArrayIndex(value));
 }
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h       Wed Feb 23 03:19:50 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.h       Thu Mar  3 01:33:08 2011
@@ -728,25 +728,25 @@
 };


-class LHasCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
+class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
  public:
-  explicit LHasCachedArrayIndex(LOperand* value) {
+  explicit LGetCachedArrayIndex(LOperand* value) {
     inputs_[0] = value;
   }

- DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has-cached-array-index")
-  DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndex)
+ DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
+  DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
 };


-class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
+class LHasCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
  public:
-  explicit LGetCachedArrayIndex(LOperand* value) {
+  explicit LHasCachedArrayIndex(LOperand* value) {
     inputs_[0] = value;
   }

- DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
-  DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
+ DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has-cached-array-index")
+  DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndex)
 };


=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Wed Mar 2 06:40:38 2011 +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Mar 3 01:33:08 2011
@@ -1711,10 +1711,13 @@
 void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) {
   Register input = ToRegister(instr->InputAt(0));
   Register result = ToRegister(instr->result());
-  Register scratch = scratch0();
-
-  __ ldr(scratch, FieldMemOperand(input, String::kHashFieldOffset));
-  __ IndexFromHash(scratch, result);
+
+  if (FLAG_debug_code) {
+    __ AbortIfNotString(input);
+  }
+
+  __ ldr(result, FieldMemOperand(input, String::kHashFieldOffset));
+  __ IndexFromHash(result, result);
 }


=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Wed Mar 2 07:04:20 2011 +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu Mar 3 01:33:08 2011
@@ -1652,6 +1652,19 @@
   __ CmpObjectType(input, TestType(instr->hydrogen()), temp);
   EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen()));
 }
+
+
+void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) {
+  Register input = ToRegister(instr->InputAt(0));
+  Register result = ToRegister(instr->result());
+
+  if (FLAG_debug_code) {
+    __ AbortIfNotString(input);
+  }
+
+  __ mov(result, FieldOperand(input, String::kHashFieldOffset));
+  __ IndexFromHash(result, result);
+}


 void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) {
@@ -1663,7 +1676,7 @@
   __ test(FieldOperand(input, String::kHashFieldOffset),
           Immediate(String::kContainsCachedArrayIndexMask));
   NearLabel done;
-  __ j(not_zero, &done);
+  __ j(zero, &done);
   __ mov(result, Factory::false_value());
   __ bind(&done);
 }
@@ -1678,7 +1691,7 @@

   __ test(FieldOperand(input, String::kHashFieldOffset),
           Immediate(String::kContainsCachedArrayIndexMask));
-  EmitBranch(true_block, false_block, not_equal);
+  EmitBranch(true_block, false_block, equal);
 }


=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Wed Mar 2 07:04:20 2011 +++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Thu Mar 3 01:33:08 2011
@@ -1541,8 +1541,10 @@

 LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
     HGetCachedArrayIndex* instr)  {
-  Abort("Unimplemented: %s", "DoGetCachedArrayIndex");
-  return NULL;
+  ASSERT(instr->value()->representation().IsTagged());
+  LOperand* value = UseRegisterAtStart(instr->value());
+
+  return DefineAsRegister(new LGetCachedArrayIndex(value));
 }


=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h     Wed Feb 23 03:19:50 2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h     Thu Mar  3 01:33:08 2011
@@ -92,6 +92,7 @@
   V(FixedArrayLength)                           \
   V(FunctionLiteral)                            \
   V(Gap)                                        \
+  V(GetCachedArrayIndex)                        \
   V(GlobalObject)                               \
   V(GlobalReceiver)                             \
   V(Goto)                                       \
@@ -743,6 +744,17 @@
 };


+class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
+ public:
+  explicit LGetCachedArrayIndex(LOperand* value) {
+    inputs_[0] = value;
+  }
+
+ DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
+  DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
+};
+
+
 class LHasCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
  public:
   explicit LHasCachedArrayIndex(LOperand* value) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Wed Mar 2 07:04:20 2011 +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu Mar 3 01:33:08 2011
@@ -1635,6 +1635,20 @@
   __ CmpObjectType(input, TestType(instr->hydrogen()), kScratchRegister);
   EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen()));
 }
+
+
+void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) {
+  Register input = ToRegister(instr->InputAt(0));
+  Register result = ToRegister(instr->result());
+
+  if (FLAG_debug_code) {
+    __ AbortIfNotString(input);
+  }
+
+  __ movl(result, FieldOperand(input, String::kHashFieldOffset));
+  ASSERT(String::kHashShift >= kSmiTagSize);
+  __ IndexFromHash(result, result);
+}


 void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) {
@@ -1646,7 +1660,7 @@
   __ testl(FieldOperand(input, String::kHashFieldOffset),
            Immediate(String::kContainsCachedArrayIndexMask));
   NearLabel done;
-  __ j(not_zero, &done);
+  __ j(zero, &done);
   __ LoadRoot(result, Heap::kFalseValueRootIndex);
   __ bind(&done);
 }
@@ -1661,7 +1675,7 @@

   __ testl(FieldOperand(input, String::kHashFieldOffset),
            Immediate(String::kContainsCachedArrayIndexMask));
-  EmitBranch(true_block, false_block, not_equal);
+  EmitBranch(true_block, false_block, equal);
 }


=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc      Wed Mar  2 07:04:20 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc      Thu Mar  3 01:33:08 2011
@@ -1522,8 +1522,10 @@

 LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
     HGetCachedArrayIndex* instr)  {
-  Abort("Unimplemented: %s", "DoGetCachedArrayIndex");
-  return NULL;
+  ASSERT(instr->value()->representation().IsTagged());
+  LOperand* value = UseRegisterAtStart(instr->value());
+
+  return DefineAsRegister(new LGetCachedArrayIndex(value));
 }


=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h       Wed Feb 23 05:26:28 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.h       Thu Mar  3 01:33:08 2011
@@ -89,6 +89,7 @@
   V(DoubleToI)                                  \
   V(FunctionLiteral)                            \
   V(Gap)                                        \
+  V(GetCachedArrayIndex)                        \
   V(GlobalObject)                               \
   V(GlobalReceiver)                             \
   V(Goto)                                       \
@@ -730,6 +731,17 @@
 };


+class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
+ public:
+  explicit LGetCachedArrayIndex(LOperand* value) {
+    inputs_[0] = value;
+  }
+
+ DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
+  DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
+};
+
+
 class LHasCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
  public:
   explicit LHasCachedArrayIndex(LOperand* value) {

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to