Revision: 6803
Author: [email protected]
Date: Wed Feb 16 00:21:45 2011
Log: ARM: Implement GetCachedArrayIndex in the lithium code generator.
Add GetCachedArrayIndex to the Hydrogen instruction set and implement
GetCachedArrayIndex in the lithium code generator. The x64 and ia32 code
generators implementations abort in the chunk builder.
Review URL: http://codereview.chromium.org/6499014
http://code.google.com/p/v8/source/detail?r=6803
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/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/x64/lithium-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Fri Feb 11 06:34:02 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Wed Feb 16 00:21:45 2011
@@ -1489,6 +1489,15 @@
return DefineAsRegister(new LHasInstanceType(value));
}
+
+
+LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
+ HGetCachedArrayIndex* instr) {
+ ASSERT(instr->value()->representation().IsTagged());
+ LOperand* value = UseRegister(instr->value());
+
+ return DefineAsRegister(new LGetCachedArrayIndex(value));
+}
LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h Thu Feb 10 04:02:36 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.h Wed Feb 16 00:21:45 2011
@@ -94,6 +94,7 @@
V(FixedArrayLength) \
V(FunctionLiteral) \
V(Gap) \
+ V(GetCachedArrayIndex) \
V(GlobalObject) \
V(GlobalReceiver) \
V(Goto) \
@@ -739,6 +740,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 LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
public:
explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Feb 15
02:50:09 2011
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Wed Feb 16
00:21:45 2011
@@ -1894,6 +1894,16 @@
__ CompareObjectType(input, scratch, scratch,
TestType(instr->hydrogen()));
EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen()));
}
+
+
+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);
+}
void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) {
@@ -1903,10 +1913,10 @@
ASSERT(instr->hydrogen()->value()->representation().IsTagged());
__ ldr(scratch,
- FieldMemOperand(input, String::kContainsCachedArrayIndexMask));
+ FieldMemOperand(input, String::kHashFieldOffset));
__ tst(scratch, Operand(String::kContainsCachedArrayIndexMask));
- __ LoadRoot(result, Heap::kTrueValueRootIndex, ne);
- __ LoadRoot(result, Heap::kFalseValueRootIndex, eq);
+ __ LoadRoot(result, Heap::kTrueValueRootIndex, eq);
+ __ LoadRoot(result, Heap::kFalseValueRootIndex, ne);
}
@@ -1919,9 +1929,9 @@
int false_block = chunk_->LookupDestination(instr->false_block_id());
__ ldr(scratch,
- FieldMemOperand(input, String::kContainsCachedArrayIndexMask));
+ FieldMemOperand(input, String::kHashFieldOffset));
__ tst(scratch, Operand(String::kContainsCachedArrayIndexMask));
- EmitBranch(true_block, false_block, ne);
+ EmitBranch(true_block, false_block, eq);
}
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Mon Feb 14 01:23:26
2011
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Wed Feb 16 00:21:45
2011
@@ -107,6 +107,7 @@
V(EnterInlined) \
V(FixedArrayLength) \
V(FunctionLiteral) \
+ V(GetCachedArrayIndex) \
V(GlobalObject) \
V(GlobalReceiver) \
V(Goto) \
@@ -2331,6 +2332,17 @@
};
+class HGetCachedArrayIndex: public HUnaryPredicate {
+ public:
+ explicit HGetCachedArrayIndex(HValue* value) : HUnaryPredicate(value) { }
+
+
DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get_cached_array_index")
+
+ protected:
+ virtual bool DataEquals(HValue* other) const { return true; }
+};
+
+
class HClassOfTest: public HUnaryPredicate {
public:
HClassOfTest(HValue* value, Handle<String> class_name)
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Tue Feb 15 08:37:40 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Wed Feb 16 00:21:45 2011
@@ -5463,7 +5463,10 @@
void HGraphBuilder::GenerateGetCachedArrayIndex(int argument_count,
int ast_id) {
- BAILOUT("inlined runtime function: GetCachedArrayIndex");
+ ASSERT(argument_count == 1);
+ HValue* value = Pop();
+ HGetCachedArrayIndex* result = new HGetCachedArrayIndex(value);
+ ast_context()->ReturnInstruction(result, ast_id);
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Fri Feb 11 06:34:02
2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Wed Feb 16 00:21:45
2011
@@ -1519,6 +1519,13 @@
return DefineAsRegister(new LHasInstanceType(value));
}
+
+
+LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
+ HGetCachedArrayIndex* instr) {
+ Abort("Unimplemented: %s", "DoGetCachedArrayIndex");
+ return NULL;
+}
LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Mon Feb 14 04:34:11 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Wed Feb 16 00:21:45 2011
@@ -1420,6 +1420,13 @@
Abort("Unimplemented: %s", "DoHasInstanceType");
return NULL;
}
+
+
+LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
+ HGetCachedArrayIndex* instr) {
+ Abort("Unimplemented: %s", "DoGetCachedArrayIndex");
+ return NULL;
+}
LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev