Simple elimination of redundant array-hole checks.

If the result of an fast elements load is converted to an untagged
representation we can omit the hole check if the value is not used
anywhere else except for HChange instructions converting it to
an untagged representation since those will deoptimize for the hole
value anyway.
Review URL: http://codereview.chromium.org/6964012

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7827 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2fb4556b
...@@ -2473,9 +2473,11 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { ...@@ -2473,9 +2473,11 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
__ ldr(result, FieldMemOperand(scratch, FixedArray::kHeaderSize)); __ ldr(result, FieldMemOperand(scratch, FixedArray::kHeaderSize));
// Check for the hole value. // Check for the hole value.
if (instr->hydrogen()->RequiresHoleCheck()) {
__ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex);
__ cmp(result, scratch); __ cmp(result, scratch);
DeoptimizeIf(eq, instr->environment()); DeoptimizeIf(eq, instr->environment());
}
} }
......
...@@ -1263,6 +1263,15 @@ void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) { ...@@ -1263,6 +1263,15 @@ void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) {
} }
bool HLoadKeyedFastElement::RequiresHoleCheck() const {
for (HUseIterator it(uses()); !it.Done(); it.Advance()) {
HValue* use = it.value();
if (!use->IsChange()) return true;
}
return false;
}
void HLoadKeyedGeneric::PrintDataTo(StringStream* stream) { void HLoadKeyedGeneric::PrintDataTo(StringStream* stream) {
object()->PrintNameTo(stream); object()->PrintNameTo(stream);
stream->Add("["); stream->Add("[");
......
...@@ -3255,6 +3255,8 @@ class HLoadKeyedFastElement: public HBinaryOperation { ...@@ -3255,6 +3255,8 @@ class HLoadKeyedFastElement: public HBinaryOperation {
virtual void PrintDataTo(StringStream* stream); virtual void PrintDataTo(StringStream* stream);
bool RequiresHoleCheck() const;
DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement) DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement)
protected: protected:
......
...@@ -2384,8 +2384,10 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { ...@@ -2384,8 +2384,10 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
FixedArray::kHeaderSize)); FixedArray::kHeaderSize));
// Check for the hole value. // Check for the hole value.
if (instr->hydrogen()->RequiresHoleCheck()) {
__ cmp(result, factory()->the_hole_value()); __ cmp(result, factory()->the_hole_value());
DeoptimizeIf(equal, instr->environment()); DeoptimizeIf(equal, instr->environment());
}
} }
......
...@@ -2394,8 +2394,10 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { ...@@ -2394,8 +2394,10 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
FixedArray::kHeaderSize)); FixedArray::kHeaderSize));
// Check for the hole value. // Check for the hole value.
if (instr->hydrogen()->RequiresHoleCheck()) {
__ CompareRoot(result, Heap::kTheHoleValueRootIndex); __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
DeoptimizeIf(equal, instr->environment()); DeoptimizeIf(equal, instr->environment());
}
} }
......
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