Chromium Code Reviews| Index: src/hydrogen-instructions.h |
| diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h |
| index d11835452c72d7024f2a38bb49a854eba7ce45f1..a211029559ae2de54887513e42630bb6923353f5 100644 |
| --- a/src/hydrogen-instructions.h |
| +++ b/src/hydrogen-instructions.h |
| @@ -2221,6 +2221,7 @@ class HCheckMaps: public HTemplateInstruction<2> { |
| virtual HType CalculateInferredType(); |
| HValue* value() { return OperandAt(0); } |
| + bool has_typecheck() const { return OperandAt(0) != OperandAt(1); } |
|
danno
2012/11/14 15:28:18
HasTypeCheck()
mvstanton
2012/11/16 15:15:06
Done.
|
| SmallMapList* map_set() { return &map_set_; } |
| DECLARE_CONCRETE_INSTRUCTION(CheckMaps) |
| @@ -4262,48 +4263,42 @@ class HLoadKeyed |
| HLoadKeyed(HValue* obj, |
| HValue* key, |
| HValue* dependency, |
| - ElementsKind elements_kind) |
| + ElementsKind elements_kind, |
| + bool defer_initialization=false) |
|
danno
2012/11/14 15:28:18
nit: separate all operators from variable names an
mvstanton
2012/11/16 15:15:06
Done.
|
| : bit_field_(0) { |
| bit_field_ = ElementsKindField::encode(elements_kind); |
| - |
| + |
| +#ifdef DEBUG |
| + initialized_ = !defer_initialization; |
| +#endif |
| + |
| SetOperandAt(0, obj); |
| SetOperandAt(1, key); |
| SetOperandAt(2, dependency); |
| - if (!is_external()) { |
| - // I can detect the case between storing double (holey and fast) and |
| - // smi/object by looking at elements_kind_. |
| - ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || |
| - IsFastDoubleElementsKind(elements_kind)); |
| - |
| - if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
| - if (IsFastSmiElementsKind(elements_kind) && |
| - IsFastPackedElementsKind(elements_kind)) { |
| - set_type(HType::Smi()); |
| - } |
| - |
| - set_representation(Representation::Tagged()); |
| - SetGVNFlag(kDependsOnArrayElements); |
| - } else { |
| - set_representation(Representation::Double()); |
| - SetGVNFlag(kDependsOnDoubleArrayElements); |
| - } |
| - } else { |
| - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || |
| - elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
| - set_representation(Representation::Double()); |
| - } else { |
| - set_representation(Representation::Integer32()); |
| - } |
| - |
| - SetGVNFlag(kDependsOnSpecializedArrayElements); |
| - // Native code could change the specialized array. |
| - SetGVNFlag(kDependsOnCalls); |
| + if (!defer_initialization) { |
| + InitializeFields(); |
| } |
| - |
| + |
| SetFlag(kUseGVN); |
| } |
| +#ifdef DEBUG |
| + bool Initialized() const { return initialized_; } |
| +#endif |
| + |
| + void PerformDeferredInitialization(ElementsKind new_elements_kind) { |
| +#ifdef DEBUG |
| + ASSERT(!initialized_); |
| + initialized_ = true; |
| +#endif |
| + if (new_elements_kind != elements_kind()) { |
| + bit_field_ = ElementsKindField::encode(new_elements_kind); |
| + } |
| + |
| + InitializeFields(); |
| + } |
| + |
| bool is_external() const { |
| return IsExternalArrayElementsKind(elements_kind()); |
| } |
| @@ -4325,6 +4320,9 @@ class HLoadKeyed |
| } |
| virtual Representation RequiredInputRepresentation(int index) { |
| +#ifdef DEBUG |
| + ASSERT(initialized_); |
| +#endif |
| // kind_fast: tagged[int32] (none) |
| // kind_double: tagged[int32] (none) |
| // kind_external: external[int32] (none) |
| @@ -4355,6 +4353,39 @@ class HLoadKeyed |
| } |
| private: |
| + void InitializeFields() { |
|
danno
2012/11/14 15:28:18
Move implementation this to the .cc file.
And oh
mvstanton
2012/11/16 15:15:06
Done.
|
| + if (!is_external()) { |
| + // I can detect the case between storing double (holey and fast) and |
| + // smi/object by looking at elements_kind_. |
| + ASSERT(IsFastSmiOrObjectElementsKind(elements_kind()) || |
| + IsFastDoubleElementsKind(elements_kind())); |
| + |
| + if (IsFastSmiOrObjectElementsKind(elements_kind())) { |
| + if (IsFastSmiElementsKind(elements_kind()) && |
| + IsFastPackedElementsKind(elements_kind())) { |
| + set_type(HType::Smi()); |
| + } |
| + |
| + set_representation(Representation::Tagged()); |
| + SetGVNFlag(kDependsOnArrayElements); |
| + } else { |
| + set_representation(Representation::Double()); |
| + SetGVNFlag(kDependsOnDoubleArrayElements); |
| + } |
| + } else { |
| + if (elements_kind() == EXTERNAL_FLOAT_ELEMENTS || |
| + elements_kind() == EXTERNAL_DOUBLE_ELEMENTS) { |
| + set_representation(Representation::Double()); |
| + } else { |
| + set_representation(Representation::Integer32()); |
| + } |
| + |
| + SetGVNFlag(kDependsOnSpecializedArrayElements); |
| + // Native code could change the specialized array. |
| + SetGVNFlag(kDependsOnCalls); |
| + } |
| + } |
| + |
| virtual bool IsDeletable() const { |
| return !RequiresHoleCheck(); |
| } |
| @@ -4383,6 +4414,9 @@ class HLoadKeyed |
| public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> |
| {}; // NOLINT |
| uint32_t bit_field_; |
| +#ifdef DEBUG |
| + bool initialized_; |
| +#endif |
| }; |
| @@ -4513,23 +4547,40 @@ class HStoreKeyed |
| : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
| public: |
| HStoreKeyed(HValue* obj, HValue* key, HValue* val, |
| - ElementsKind elements_kind) |
| + ElementsKind elements_kind, |
| + bool defer_initialization=false) |
|
danno
2012/11/14 15:28:18
spaces b/a =
mvstanton
2012/11/16 15:15:06
Done.
|
| : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) { |
| SetOperandAt(0, obj); |
| SetOperandAt(1, key); |
| SetOperandAt(2, val); |
| + |
| +#ifdef DEBUG |
| + initialized_ = !defer_initialization; |
| +#endif |
| + |
| + InitializeFlags(); |
| + } |
| - if (is_external()) { |
| - SetGVNFlag(kChangesSpecializedArrayElements); |
| - } else if (IsFastDoubleElementsKind(elements_kind)) { |
| - SetGVNFlag(kChangesDoubleArrayElements); |
| - SetFlag(kDeoptimizeOnUndefined); |
| - } else { |
| - SetGVNFlag(kChangesArrayElements); |
| +#ifdef DEBUG |
| + bool Initialized() const { return initialized_; } |
| +#endif |
| + |
| + void PerformDeferredInitialization(ElementsKind new_elements_kind) { |
| +#ifdef DEBUG |
| + ASSERT(!initialized_); |
| + initialized_ = true; |
| +#endif |
| + if (new_elements_kind != elements_kind_) { |
| + elements_kind_ = new_elements_kind; |
| } |
| + |
| + InitializeFlags(); |
| } |
| - |
| + |
| virtual Representation RequiredInputRepresentation(int index) { |
| +#ifdef DEBUG |
| + ASSERT(initialized_); |
| +#endif |
| // kind_fast: tagged[int32] = tagged |
| // kind_double: tagged[int32] = double |
| // kind_external: external[int32] = (double | int32) |
| @@ -4581,9 +4632,22 @@ class HStoreKeyed |
| DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) |
| private: |
| + void InitializeFlags() { |
|
danno
2012/11/14 15:28:18
Again, how about just "Initialize"?
mvstanton
2012/11/16 15:15:06
Done.
|
| + if (is_external()) { |
| + SetGVNFlag(kChangesSpecializedArrayElements); |
| + } else if (IsFastDoubleElementsKind(elements_kind())) { |
| + SetGVNFlag(kChangesDoubleArrayElements); |
| + SetFlag(kDeoptimizeOnUndefined); |
| + } else { |
| + SetGVNFlag(kChangesArrayElements); |
| + } |
| + } |
| ElementsKind elements_kind_; |
| uint32_t index_offset_; |
| bool is_dehoisted_; |
| +#ifdef DEBUG |
| + bool initialized_; |
| +#endif |
| }; |