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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6803 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9ec16dfe
...@@ -1491,6 +1491,15 @@ LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) { ...@@ -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( LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
HHasCachedArrayIndex* instr) { HHasCachedArrayIndex* instr) {
ASSERT(instr->value()->representation().IsTagged()); ASSERT(instr->value()->representation().IsTagged());
......
...@@ -94,6 +94,7 @@ class LCodeGen; ...@@ -94,6 +94,7 @@ class LCodeGen;
V(FixedArrayLength) \ V(FixedArrayLength) \
V(FunctionLiteral) \ V(FunctionLiteral) \
V(Gap) \ V(Gap) \
V(GetCachedArrayIndex) \
V(GlobalObject) \ V(GlobalObject) \
V(GlobalReceiver) \ V(GlobalReceiver) \
V(Goto) \ V(Goto) \
...@@ -739,6 +740,17 @@ class LHasCachedArrayIndex: public LTemplateInstruction<1, 1, 0> { ...@@ -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> { class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
public: public:
explicit LHasCachedArrayIndexAndBranch(LOperand* value) { explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
......
...@@ -1896,6 +1896,16 @@ void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) { ...@@ -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) { void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) {
Register input = ToRegister(instr->InputAt(0)); Register input = ToRegister(instr->InputAt(0));
Register result = ToRegister(instr->result()); Register result = ToRegister(instr->result());
...@@ -1903,10 +1913,10 @@ void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) { ...@@ -1903,10 +1913,10 @@ void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) {
ASSERT(instr->hydrogen()->value()->representation().IsTagged()); ASSERT(instr->hydrogen()->value()->representation().IsTagged());
__ ldr(scratch, __ ldr(scratch,
FieldMemOperand(input, String::kContainsCachedArrayIndexMask)); FieldMemOperand(input, String::kHashFieldOffset));
__ tst(scratch, Operand(String::kContainsCachedArrayIndexMask)); __ tst(scratch, Operand(String::kContainsCachedArrayIndexMask));
__ LoadRoot(result, Heap::kTrueValueRootIndex, ne); __ LoadRoot(result, Heap::kTrueValueRootIndex, eq);
__ LoadRoot(result, Heap::kFalseValueRootIndex, eq); __ LoadRoot(result, Heap::kFalseValueRootIndex, ne);
} }
...@@ -1919,9 +1929,9 @@ void LCodeGen::DoHasCachedArrayIndexAndBranch( ...@@ -1919,9 +1929,9 @@ void LCodeGen::DoHasCachedArrayIndexAndBranch(
int false_block = chunk_->LookupDestination(instr->false_block_id()); int false_block = chunk_->LookupDestination(instr->false_block_id());
__ ldr(scratch, __ ldr(scratch,
FieldMemOperand(input, String::kContainsCachedArrayIndexMask)); FieldMemOperand(input, String::kHashFieldOffset));
__ tst(scratch, Operand(String::kContainsCachedArrayIndexMask)); __ tst(scratch, Operand(String::kContainsCachedArrayIndexMask));
EmitBranch(true_block, false_block, ne); EmitBranch(true_block, false_block, eq);
} }
......
...@@ -107,6 +107,7 @@ class LChunkBuilder; ...@@ -107,6 +107,7 @@ class LChunkBuilder;
V(EnterInlined) \ V(EnterInlined) \
V(FixedArrayLength) \ V(FixedArrayLength) \
V(FunctionLiteral) \ V(FunctionLiteral) \
V(GetCachedArrayIndex) \
V(GlobalObject) \ V(GlobalObject) \
V(GlobalReceiver) \ V(GlobalReceiver) \
V(Goto) \ V(Goto) \
...@@ -2331,6 +2332,17 @@ class HHasCachedArrayIndex: public HUnaryPredicate { ...@@ -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 { class HClassOfTest: public HUnaryPredicate {
public: public:
HClassOfTest(HValue* value, Handle<String> class_name) HClassOfTest(HValue* value, Handle<String> class_name)
......
...@@ -5463,7 +5463,10 @@ void HGraphBuilder::GenerateIsRegExpEquivalent(int argument_count, ...@@ -5463,7 +5463,10 @@ void HGraphBuilder::GenerateIsRegExpEquivalent(int argument_count,
void HGraphBuilder::GenerateGetCachedArrayIndex(int argument_count, void HGraphBuilder::GenerateGetCachedArrayIndex(int argument_count,
int ast_id) { 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);
} }
......
...@@ -1521,6 +1521,13 @@ LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) { ...@@ -1521,6 +1521,13 @@ LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) {
} }
LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
HGetCachedArrayIndex* instr) {
Abort("Unimplemented: %s", "DoGetCachedArrayIndex");
return NULL;
}
LInstruction* LChunkBuilder::DoHasCachedArrayIndex( LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
HHasCachedArrayIndex* instr) { HHasCachedArrayIndex* instr) {
ASSERT(instr->value()->representation().IsTagged()); ASSERT(instr->value()->representation().IsTagged());
......
...@@ -1422,6 +1422,13 @@ LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) { ...@@ -1422,6 +1422,13 @@ LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) {
} }
LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
HGetCachedArrayIndex* instr) {
Abort("Unimplemented: %s", "DoGetCachedArrayIndex");
return NULL;
}
LInstruction* LChunkBuilder::DoHasCachedArrayIndex( LInstruction* LChunkBuilder::DoHasCachedArrayIndex(
HHasCachedArrayIndex* instr) { HHasCachedArrayIndex* instr) {
Abort("Unimplemented: %s", "DoHasCachedArrayIndex"); Abort("Unimplemented: %s", "DoHasCachedArrayIndex");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment