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 2959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2970 | 2970 |
2971 protected: | 2971 protected: |
2972 virtual bool DataEquals(HValue* other) { return true; } | 2972 virtual bool DataEquals(HValue* other) { return true; } |
2973 }; | 2973 }; |
2974 | 2974 |
2975 | 2975 |
2976 class HCheckPrototypeMaps: public HTemplateInstruction<0> { | 2976 class HCheckPrototypeMaps: public HTemplateInstruction<0> { |
2977 public: | 2977 public: |
2978 HCheckPrototypeMaps(Handle<JSObject> prototype, | 2978 HCheckPrototypeMaps(Handle<JSObject> prototype, |
2979 Handle<JSObject> holder, | 2979 Handle<JSObject> holder, |
2980 Zone* zone) | 2980 Zone* zone, |
| 2981 CompilationInfo* info) |
2981 : prototypes_(2, zone), | 2982 : prototypes_(2, zone), |
2982 maps_(2, zone), | 2983 maps_(2, zone), |
2983 first_prototype_unique_id_(), | 2984 first_prototype_unique_id_(), |
2984 last_prototype_unique_id_() { | 2985 last_prototype_unique_id_(), |
| 2986 can_omit_prototype_maps_(true) { |
2985 SetFlag(kUseGVN); | 2987 SetFlag(kUseGVN); |
2986 SetGVNFlag(kDependsOnMaps); | 2988 SetGVNFlag(kDependsOnMaps); |
2987 // Keep a list of all objects on the prototype chain up to the holder | 2989 // Keep a list of all objects on the prototype chain up to the holder |
2988 // and the expected maps. | 2990 // and the expected maps. |
2989 while (true) { | 2991 while (true) { |
2990 prototypes_.Add(prototype, zone); | 2992 prototypes_.Add(prototype, zone); |
2991 maps_.Add(Handle<Map>(prototype->map()), zone); | 2993 Handle<Map> map(prototype->map()); |
| 2994 maps_.Add(map, zone); |
| 2995 can_omit_prototype_maps_ &= map->CanOmitPrototypeChecks(); |
2992 if (prototype.is_identical_to(holder)) break; | 2996 if (prototype.is_identical_to(holder)) break; |
2993 prototype = Handle<JSObject>(JSObject::cast(prototype->GetPrototype())); | 2997 prototype = Handle<JSObject>(JSObject::cast(prototype->GetPrototype())); |
2994 } | 2998 } |
| 2999 if (can_omit_prototype_maps_) { |
| 3000 // Mark in-flight compilation as dependent on those maps. |
| 3001 for (int i = 0; i < maps()->length(); i++) { |
| 3002 Handle<Map> map = maps()->at(i); |
| 3003 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup, |
| 3004 info); |
| 3005 } |
| 3006 } |
2995 } | 3007 } |
2996 | 3008 |
2997 ZoneList<Handle<JSObject> >* prototypes() { return &prototypes_; } | 3009 ZoneList<Handle<JSObject> >* prototypes() { return &prototypes_; } |
2998 | 3010 |
2999 ZoneList<Handle<Map> >* maps() { return &maps_; } | 3011 ZoneList<Handle<Map> >* maps() { return &maps_; } |
3000 | 3012 |
3001 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps) | 3013 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps) |
3002 | 3014 |
3003 virtual Representation RequiredInputRepresentation(int index) { | 3015 virtual Representation RequiredInputRepresentation(int index) { |
3004 return Representation::None(); | 3016 return Representation::None(); |
3005 } | 3017 } |
3006 | 3018 |
3007 virtual void PrintDataTo(StringStream* stream); | 3019 virtual void PrintDataTo(StringStream* stream); |
3008 | 3020 |
3009 virtual intptr_t Hashcode() { | 3021 virtual intptr_t Hashcode() { |
3010 return first_prototype_unique_id_.Hashcode() * 17 + | 3022 return first_prototype_unique_id_.Hashcode() * 17 + |
3011 last_prototype_unique_id_.Hashcode(); | 3023 last_prototype_unique_id_.Hashcode(); |
3012 } | 3024 } |
3013 | 3025 |
3014 virtual void FinalizeUniqueValueId() { | 3026 virtual void FinalizeUniqueValueId() { |
3015 first_prototype_unique_id_ = UniqueValueId(prototypes_.first()); | 3027 first_prototype_unique_id_ = UniqueValueId(prototypes_.first()); |
3016 last_prototype_unique_id_ = UniqueValueId(prototypes_.last()); | 3028 last_prototype_unique_id_ = UniqueValueId(prototypes_.last()); |
3017 } | 3029 } |
3018 | 3030 |
3019 bool CanOmitPrototypeChecks() { | 3031 bool CanOmitPrototypeChecks() { return can_omit_prototype_maps_; } |
3020 for (int i = 0; i < maps()->length(); i++) { | |
3021 if (!maps()->at(i)->CanOmitPrototypeChecks()) return false; | |
3022 } | |
3023 return true; | |
3024 } | |
3025 | 3032 |
3026 protected: | 3033 protected: |
3027 virtual bool DataEquals(HValue* other) { | 3034 virtual bool DataEquals(HValue* other) { |
3028 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); | 3035 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); |
3029 return first_prototype_unique_id_ == b->first_prototype_unique_id_ && | 3036 return first_prototype_unique_id_ == b->first_prototype_unique_id_ && |
3030 last_prototype_unique_id_ == b->last_prototype_unique_id_; | 3037 last_prototype_unique_id_ == b->last_prototype_unique_id_; |
3031 } | 3038 } |
3032 | 3039 |
3033 private: | 3040 private: |
3034 ZoneList<Handle<JSObject> > prototypes_; | 3041 ZoneList<Handle<JSObject> > prototypes_; |
3035 ZoneList<Handle<Map> > maps_; | 3042 ZoneList<Handle<Map> > maps_; |
3036 UniqueValueId first_prototype_unique_id_; | 3043 UniqueValueId first_prototype_unique_id_; |
3037 UniqueValueId last_prototype_unique_id_; | 3044 UniqueValueId last_prototype_unique_id_; |
| 3045 bool can_omit_prototype_maps_; |
3038 }; | 3046 }; |
3039 | 3047 |
3040 | 3048 |
3041 class HPhi: public HValue { | 3049 class HPhi: public HValue { |
3042 public: | 3050 public: |
3043 HPhi(int merged_index, Zone* zone) | 3051 HPhi(int merged_index, Zone* zone) |
3044 : inputs_(2, zone), | 3052 : inputs_(2, zone), |
3045 merged_index_(merged_index), | 3053 merged_index_(merged_index), |
3046 phi_id_(-1) { | 3054 phi_id_(-1) { |
3047 for (int i = 0; i < Representation::kNumRepresentations; i++) { | 3055 for (int i = 0; i < Representation::kNumRepresentations; i++) { |
(...skipping 2636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5684 | 5692 |
5685 class HStoreNamedField: public HTemplateInstruction<2> { | 5693 class HStoreNamedField: public HTemplateInstruction<2> { |
5686 public: | 5694 public: |
5687 HStoreNamedField(HValue* obj, | 5695 HStoreNamedField(HValue* obj, |
5688 HObjectAccess access, | 5696 HObjectAccess access, |
5689 HValue* val, | 5697 HValue* val, |
5690 Representation field_representation | 5698 Representation field_representation |
5691 = Representation::Tagged()) | 5699 = Representation::Tagged()) |
5692 : access_(access), | 5700 : access_(access), |
5693 field_representation_(field_representation), | 5701 field_representation_(field_representation), |
| 5702 transition_(), |
5694 transition_unique_id_(), | 5703 transition_unique_id_(), |
5695 new_space_dominator_(NULL) { | 5704 new_space_dominator_(NULL) { |
5696 SetOperandAt(0, obj); | 5705 SetOperandAt(0, obj); |
5697 SetOperandAt(1, val); | 5706 SetOperandAt(1, val); |
5698 access.SetGVNFlags(this, true); | 5707 access.SetGVNFlags(this, true); |
5699 } | 5708 } |
5700 | 5709 |
5701 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) | 5710 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) |
5702 | 5711 |
5703 virtual Representation RequiredInputRepresentation(int index) { | 5712 virtual Representation RequiredInputRepresentation(int index) { |
(...skipping 11 matching lines...) Expand all Loading... |
5715 new_space_dominator_ = dominator; | 5724 new_space_dominator_ = dominator; |
5716 } | 5725 } |
5717 virtual void PrintDataTo(StringStream* stream); | 5726 virtual void PrintDataTo(StringStream* stream); |
5718 | 5727 |
5719 HValue* object() { return OperandAt(0); } | 5728 HValue* object() { return OperandAt(0); } |
5720 HValue* value() { return OperandAt(1); } | 5729 HValue* value() { return OperandAt(1); } |
5721 | 5730 |
5722 HObjectAccess access() const { return access_; } | 5731 HObjectAccess access() const { return access_; } |
5723 Handle<Map> transition() const { return transition_; } | 5732 Handle<Map> transition() const { return transition_; } |
5724 UniqueValueId transition_unique_id() const { return transition_unique_id_; } | 5733 UniqueValueId transition_unique_id() const { return transition_unique_id_; } |
5725 void set_transition(Handle<Map> map) { transition_ = map; } | 5734 void SetTransition(Handle<Map> map, CompilationInfo* info) { |
| 5735 ASSERT(transition_.is_null()); // Only set once. |
| 5736 if (map->CanBeDeprecated()) { |
| 5737 map->AddDependentCompilationInfo(DependentCode::kTransitionGroup, info); |
| 5738 } |
| 5739 transition_ = map; |
| 5740 } |
5726 HValue* new_space_dominator() const { return new_space_dominator_; } | 5741 HValue* new_space_dominator() const { return new_space_dominator_; } |
5727 | 5742 |
5728 bool NeedsWriteBarrier() { | 5743 bool NeedsWriteBarrier() { |
5729 ASSERT(!(FLAG_track_double_fields && field_representation_.IsDouble()) || | 5744 ASSERT(!(FLAG_track_double_fields && field_representation_.IsDouble()) || |
5730 transition_.is_null()); | 5745 transition_.is_null()); |
5731 return (!FLAG_track_fields || !field_representation_.IsSmi()) && | 5746 return (!FLAG_track_fields || !field_representation_.IsSmi()) && |
5732 // If there is a transition, a new storage object needs to be allocated. | 5747 // If there is a transition, a new storage object needs to be allocated. |
5733 !(FLAG_track_double_fields && field_representation_.IsDouble()) && | 5748 !(FLAG_track_double_fields && field_representation_.IsDouble()) && |
5734 StoringValueNeedsWriteBarrier(value()) && | 5749 StoringValueNeedsWriteBarrier(value()) && |
5735 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); | 5750 ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6572 virtual bool IsDeletable() const { return true; } | 6587 virtual bool IsDeletable() const { return true; } |
6573 }; | 6588 }; |
6574 | 6589 |
6575 | 6590 |
6576 #undef DECLARE_INSTRUCTION | 6591 #undef DECLARE_INSTRUCTION |
6577 #undef DECLARE_CONCRETE_INSTRUCTION | 6592 #undef DECLARE_CONCRETE_INSTRUCTION |
6578 | 6593 |
6579 } } // namespace v8::internal | 6594 } } // namespace v8::internal |
6580 | 6595 |
6581 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6596 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |