Reviewers: Søren Gjesse,
Description:
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.
Please review this at http://codereview.chromium.org/6499014/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/arm/lithium-arm.h
M src/arm/lithium-arm.cc
M src/arm/lithium-codegen-arm.cc
M src/hydrogen-instructions.h
M src/hydrogen.cc
M src/ia32/lithium-ia32.cc
M src/x64/lithium-x64.cc
Index: src/arm/lithium-arm.cc
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc
index
82de5d3e186b0601eae6b344bcb7daf88b559712..903f77bbf0469497e0dace4aba4cccbd8b64b227
100644
--- a/src/arm/lithium-arm.cc
+++ b/src/arm/lithium-arm.cc
@@ -1491,6 +1491,15 @@ LInstruction*
LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) {
}
+LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
+ HGetCachedArrayIndex* instr) {
+ ASSERT(instr->value()->representation().IsTagged());
+ LOperand* value = UseRegister(instr->value());
+
+ return DefineAsRegister(new LGetCachedArrayIndex(value));
+}
+
+
LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
HHasCachedArrayIndex* instr) {
ASSERT(instr->value()->representation().IsTagged());
Index: src/arm/lithium-arm.h
diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h
index
8d2573d96c76a0bcfbdf82e23e3316cd6856b1e0..57338f16d5557cca4f7d8fe08fd6d29bca805b1e
100644
--- a/src/arm/lithium-arm.h
+++ b/src/arm/lithium-arm.h
@@ -94,6 +94,7 @@ class LCodeGen;
V(FixedArrayLength) \
V(FunctionLiteral) \
V(Gap) \
+ V(GetCachedArrayIndex) \
V(GlobalObject) \
V(GlobalReceiver) \
V(Goto) \
@@ -739,6 +740,17 @@ class LHasCachedArrayIndex: public
LTemplateInstruction<1, 1, 0> {
};
+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) {
Index: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index
68d3f49a9436dee52899b339f368ed2fb8a32cb3..1bfb3ad943ade2294688c7e0c090c35c0cdb1fd2
100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -1896,6 +1896,16 @@ void
LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) {
}
+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) {
Register input = ToRegister(instr->InputAt(0));
Register result = ToRegister(instr->result());
@@ -1903,10 +1913,10 @@ void
LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) {
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 @@ void LCodeGen::DoHasCachedArrayIndexAndBranch(
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);
}
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
a0d932fbd24311f8eeb613edc706e6002cadd60b..9f5170ca2bcc9e5f9d7dcdd9d5fccdbf1f2eb910
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -107,6 +107,7 @@ class LChunkBuilder;
V(EnterInlined) \
V(FixedArrayLength) \
V(FunctionLiteral) \
+ V(GetCachedArrayIndex) \
V(GlobalObject) \
V(GlobalReceiver) \
V(Goto) \
@@ -2331,6 +2332,17 @@ class HHasCachedArrayIndex: public HUnaryPredicate {
};
+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)
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
41f17223ad504c202c70175d56c318fd36076a86..ef055cc8b027739591c8a272800245b785bcbe9b
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5456,7 +5456,10 @@ void HGraphBuilder::GenerateIsRegExpEquivalent(int
argument_count,
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);
}
Index: src/ia32/lithium-ia32.cc
diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc
index
0ad3819292b047037b2e43e64265babaf4b38d2d..a57e8c928c31f26ef15a85e359ee6602638f36e1
100644
--- a/src/ia32/lithium-ia32.cc
+++ b/src/ia32/lithium-ia32.cc
@@ -1521,6 +1521,13 @@ LInstruction*
LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) {
}
+LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
+ HGetCachedArrayIndex* instr) {
+ Abort("Unimplemented: %s", "DoGetCachedArrayIndex");
+ return NULL;
+}
+
+
LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
HHasCachedArrayIndex* instr) {
ASSERT(instr->value()->representation().IsTagged());
Index: src/x64/lithium-x64.cc
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc
index
a6635adf97e3368d04a09ed03f15399df823d2c6..fba29a69e5842f25a083cd99a2f186994055874e
100644
--- a/src/x64/lithium-x64.cc
+++ b/src/x64/lithium-x64.cc
@@ -1422,6 +1422,13 @@ LInstruction*
LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) {
}
+LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
+ HGetCachedArrayIndex* instr) {
+ Abort("Unimplemented: %s", "DoGetCachedArrayIndex");
+ return NULL;
+}
+
+
LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
HHasCachedArrayIndex* instr) {
Abort("Unimplemented: %s", "DoHasCachedArrayIndex");
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev