Index: src/hydrogen-instructions.h |
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h |
index 23390dc1115a48df3305bad9bc237afb6c3e45ad..6f77add81f164944e685a1d9ee3a42081b3d9f36 100644 |
--- a/src/hydrogen-instructions.h |
+++ b/src/hydrogen-instructions.h |
@@ -348,6 +348,10 @@ class Representation { |
} |
const char* Mnemonic() const; |
+ Representation KeyedAccessIndexRequirement() { |
Jakob Kummerow
2013/01/10 16:06:47
nit: I'm a bit unhappy about adding instruction-sp
|
+ return IsInteger32() ? Integer32() : Tagged(); |
+ } |
+ |
private: |
explicit Representation(Kind k) : kind_(k) { } |
@@ -672,6 +676,14 @@ class HValue: public ZoneObject { |
return NULL; |
} |
+ // There are HInstructions that do not really change a value, they |
+ // only add pieces of information to it (like bounds checks, map checks |
+ // or SSI definitions after conditional branches). |
+ // This method must always return the original HValue SSA definition (the |
+ // register allocator relies on this to avoid allocating multiple registers |
+ // for the same value). |
+ virtual HValue* ActualValue() { return this; } |
+ |
bool IsDefinedAfter(HBasicBlock* other) const; |
// Operands. |
@@ -2955,44 +2967,40 @@ enum BoundsCheckKeyMode { |
class HBoundsCheck: public HTemplateInstruction<2> { |
public: |
HBoundsCheck(HValue* index, HValue* length, |
- BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY) |
+ BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, |
+ Representation r = Representation::None()) |
: key_mode_(key_mode) { |
SetOperandAt(0, index); |
SetOperandAt(1, length); |
- set_representation(Representation::Integer32()); |
+ if (r.IsNone()) { |
+ // In the normal compilation pipeline the representation is flexible |
+ // (see comment to RequiredInputRepresentation). |
+ SetFlag(kFlexibleRepresentation); |
+ } else { |
+ // When compiling stubs we want to set the representation explicitly |
+ // so the compilation pipeline can skip the HInferRepresentation phase. |
+ set_representation(r); |
+ } |
SetFlag(kUseGVN); |
} |
virtual Representation RequiredInputRepresentation(int arg_index) { |
- if (key_mode_ == DONT_ALLOW_SMI_KEY || |
- !length()->representation().IsTagged()) { |
- return Representation::Integer32(); |
- } |
- // If the index is tagged and isn't constant, then allow the length |
- // to be tagged, since it is usually already tagged from loading it out of |
- // the length field of a JSArray. This allows for direct comparison without |
- // untagging. |
- if (index()->representation().IsTagged() && !index()->IsConstant()) { |
- return Representation::Tagged(); |
- } |
- // Also allow the length to be tagged if the index is constant, because |
- // it can be tagged to allow direct comparison. |
- if (index()->IsConstant() && |
- index()->representation().IsInteger32() && |
- arg_index == 1) { |
- return Representation::Tagged(); |
- } |
- return Representation::Integer32(); |
+ return representation(); |
} |
virtual Representation observed_input_representation(int index) { |
return Representation::Integer32(); |
} |
virtual void PrintDataTo(StringStream* stream); |
+ virtual void InferRepresentation(HInferRepresentation* h_infer); |
HValue* index() { return OperandAt(0); } |
HValue* length() { return OperandAt(1); } |
+ virtual HValue* ActualValue() { |
+ return index(); |
+ } |
+ |
DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) |
protected: |
@@ -4446,7 +4454,9 @@ class HLoadKeyed |
return is_external() ? Representation::External() |
: Representation::Tagged(); |
} |
- if (index == 1) return Representation::Integer32(); |
+ if (index == 1) { |
+ return OperandAt(1)->representation().KeyedAccessIndexRequirement(); |
+ } |
return Representation::None(); |
} |
@@ -4661,7 +4671,7 @@ class HStoreKeyed |
return is_external() ? Representation::External() |
: Representation::Tagged(); |
} else if (index == 1) { |
- return Representation::Integer32(); |
+ return OperandAt(1)->representation().KeyedAccessIndexRequirement(); |
} |
ASSERT_EQ(index, 2); |