OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 6974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6985 ElementsKind to_kind_; | 6985 ElementsKind to_kind_; |
6986 }; | 6986 }; |
6987 | 6987 |
6988 | 6988 |
6989 class HStringAdd V8_FINAL : public HBinaryOperation { | 6989 class HStringAdd V8_FINAL : public HBinaryOperation { |
6990 public: | 6990 public: |
6991 static HInstruction* New(Zone* zone, | 6991 static HInstruction* New(Zone* zone, |
6992 HValue* context, | 6992 HValue* context, |
6993 HValue* left, | 6993 HValue* left, |
6994 HValue* right, | 6994 HValue* right, |
6995 PretenureFlag pretenure_flag = NOT_TENURED, | 6995 StringAddFlags flags = STRING_ADD_CHECK_NONE); |
6996 StringAddFlags flags = STRING_ADD_CHECK_BOTH, | |
6997 Handle<AllocationSite> allocation_site = | |
6998 Handle<AllocationSite>::null()); | |
6999 | 6996 |
7000 StringAddFlags flags() const { return flags_; } | 6997 StringAddFlags flags() const { return flags_; } |
7001 PretenureFlag pretenure_flag() const { return pretenure_flag_; } | |
7002 | 6998 |
7003 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 6999 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
7004 return Representation::Tagged(); | 7000 return Representation::Tagged(); |
7005 } | 7001 } |
7006 | 7002 |
7007 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | |
7008 | |
7009 DECLARE_CONCRETE_INSTRUCTION(StringAdd) | 7003 DECLARE_CONCRETE_INSTRUCTION(StringAdd) |
7010 | 7004 |
7011 protected: | 7005 protected: |
7012 virtual bool DataEquals(HValue* other) V8_OVERRIDE { | 7006 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } |
7013 return flags_ == HStringAdd::cast(other)->flags_ && | |
7014 pretenure_flag_ == HStringAdd::cast(other)->pretenure_flag_; | |
7015 } | |
7016 | 7007 |
7017 private: | 7008 private: |
7018 HStringAdd(HValue* context, | 7009 HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags) |
7019 HValue* left, | 7010 : HBinaryOperation(context, left, right, HType::String()), flags_(flags) { |
7020 HValue* right, | |
7021 PretenureFlag pretenure_flag, | |
7022 StringAddFlags flags, | |
7023 Handle<AllocationSite> allocation_site) | |
7024 : HBinaryOperation(context, left, right, HType::String()), | |
7025 flags_(flags), pretenure_flag_(pretenure_flag) { | |
7026 set_representation(Representation::Tagged()); | 7011 set_representation(Representation::Tagged()); |
7027 SetFlag(kUseGVN); | 7012 if (MightHaveSideEffects()) { |
7028 SetGVNFlag(kDependsOnMaps); | 7013 SetAllSideEffects(); |
7029 SetGVNFlag(kChangesNewSpacePromotion); | 7014 } else { |
7030 if (FLAG_trace_pretenuring) { | 7015 SetFlag(kUseGVN); |
7031 PrintF("HStringAdd with AllocationSite %p %s\n", | 7016 SetGVNFlag(kDependsOnMaps); |
7032 allocation_site.is_null() | 7017 SetGVNFlag(kChangesNewSpacePromotion); |
7033 ? static_cast<void*>(NULL) | |
7034 : static_cast<void*>(*allocation_site), | |
7035 pretenure_flag == TENURED ? "tenured" : "not tenured"); | |
7036 } | 7018 } |
7037 } | 7019 } |
7038 | 7020 |
| 7021 bool MightHaveSideEffects() const { |
| 7022 return flags_ != STRING_ADD_CHECK_NONE && |
| 7023 (left()->ToStringCanBeObserved() || right()->ToStringCanBeObserved()); |
| 7024 } |
| 7025 |
7039 // No side-effects except possible allocation: | 7026 // No side-effects except possible allocation: |
7040 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7027 // NOTE: this instruction does not call ToString() on its inputs, when flags_ |
| 7028 // is set to STRING_ADD_CHECK_NONE. |
| 7029 virtual bool IsDeletable() const V8_OVERRIDE { |
| 7030 return !MightHaveSideEffects(); |
| 7031 } |
7041 | 7032 |
7042 const StringAddFlags flags_; | 7033 const StringAddFlags flags_; |
7043 const PretenureFlag pretenure_flag_; | |
7044 }; | 7034 }; |
7045 | 7035 |
7046 | 7036 |
7047 class HStringCharCodeAt V8_FINAL : public HTemplateInstruction<3> { | 7037 class HStringCharCodeAt V8_FINAL : public HTemplateInstruction<3> { |
7048 public: | 7038 public: |
7049 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HStringCharCodeAt, | 7039 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HStringCharCodeAt, |
7050 HValue*, | 7040 HValue*, |
7051 HValue*); | 7041 HValue*); |
7052 | 7042 |
7053 virtual Representation RequiredInputRepresentation(int index) { | 7043 virtual Representation RequiredInputRepresentation(int index) { |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7576 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7566 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
7577 }; | 7567 }; |
7578 | 7568 |
7579 | 7569 |
7580 #undef DECLARE_INSTRUCTION | 7570 #undef DECLARE_INSTRUCTION |
7581 #undef DECLARE_CONCRETE_INSTRUCTION | 7571 #undef DECLARE_CONCRETE_INSTRUCTION |
7582 | 7572 |
7583 } } // namespace v8::internal | 7573 } } // namespace v8::internal |
7584 | 7574 |
7585 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7575 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |