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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1079 virtual Representation RequiredInputRepresentation(int index) = 0; | 1079 virtual Representation RequiredInputRepresentation(int index) = 0; |
1080 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); | 1080 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); |
1081 | 1081 |
1082 // This gives the instruction an opportunity to replace itself with an | 1082 // This gives the instruction an opportunity to replace itself with an |
1083 // instruction that does the same in some better way. To replace an | 1083 // instruction that does the same in some better way. To replace an |
1084 // instruction with a new one, first add the new instruction to the graph, | 1084 // instruction with a new one, first add the new instruction to the graph, |
1085 // then return it. Return NULL to have the instruction deleted. | 1085 // then return it. Return NULL to have the instruction deleted. |
1086 virtual HValue* Canonicalize() { return this; } | 1086 virtual HValue* Canonicalize() { return this; } |
1087 | 1087 |
1088 bool Equals(HValue* other); | 1088 bool Equals(HValue* other); |
1089 virtual int CompareOperandCount() { return OperandCount(); } | |
danno
2013/08/05 10:07:36
See comment below about storing the context explic
Toon Verwaest
2013/08/05 11:32:13
Done.
| |
1089 virtual intptr_t Hashcode(); | 1090 virtual intptr_t Hashcode(); |
1090 | 1091 |
1091 // Compute unique ids upfront that is safe wrt GC and parallel recompilation. | 1092 // Compute unique ids upfront that is safe wrt GC and parallel recompilation. |
1092 virtual void FinalizeUniqueValueId() { } | 1093 virtual void FinalizeUniqueValueId() { } |
1093 | 1094 |
1094 // Printing support. | 1095 // Printing support. |
1095 virtual void PrintTo(StringStream* stream) = 0; | 1096 virtual void PrintTo(StringStream* stream) = 0; |
1096 void PrintNameTo(StringStream* stream); | 1097 void PrintNameTo(StringStream* stream); |
1097 void PrintTypeTo(StringStream* stream); | 1098 void PrintTypeTo(StringStream* stream); |
1098 void PrintRangeTo(StringStream* stream); | 1099 void PrintRangeTo(StringStream* stream); |
(...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2859 // change. The external array of a specialized array elements object cannot | 2860 // change. The external array of a specialized array elements object cannot |
2860 // change once set, so it's no necessary to introduce any additional | 2861 // change once set, so it's no necessary to introduce any additional |
2861 // dependencies on top of the inputs. | 2862 // dependencies on top of the inputs. |
2862 SetFlag(kUseGVN); | 2863 SetFlag(kUseGVN); |
2863 } | 2864 } |
2864 | 2865 |
2865 virtual bool IsDeletable() const { return true; } | 2866 virtual bool IsDeletable() const { return true; } |
2866 }; | 2867 }; |
2867 | 2868 |
2868 | 2869 |
2869 class HCheckMaps: public HTemplateInstruction<2> { | 2870 class HCheckMaps: public HTemplateInstruction<3> { |
danno
2013/08/05 10:07:36
It seems to me this class would be much cleaner if
Toon Verwaest
2013/08/05 11:32:13
Done.
| |
2870 public: | 2871 public: |
2871 static HCheckMaps* New(Zone* zone, HValue* context, HValue* value, | 2872 static HCheckMaps* New(Zone* zone, HValue* context, HValue* value, |
2872 Handle<Map> map, CompilationInfo* info, | 2873 Handle<Map> map, CompilationInfo* info, |
2873 HValue *typecheck = NULL); | 2874 HValue *typecheck = NULL); |
2874 static HCheckMaps* New(Zone* zone, HValue* context, | 2875 static HCheckMaps* New(Zone* zone, HValue* context, |
2875 HValue* value, SmallMapList* maps, | 2876 HValue* value, SmallMapList* maps, |
2876 HValue *typecheck = NULL) { | 2877 HValue *typecheck = NULL) { |
2877 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); | 2878 HCheckMaps* check_map = new(zone) HCheckMaps( |
2879 context, value, zone, typecheck); | |
2878 for (int i = 0; i < maps->length(); i++) { | 2880 for (int i = 0; i < maps->length(); i++) { |
2879 check_map->map_set_.Add(maps->at(i), zone); | 2881 check_map->map_set_.Add(maps->at(i), zone); |
2882 check_map->has_migration_target_ |= maps->at(i)->is_migration_target(); | |
2880 } | 2883 } |
2881 check_map->map_set_.Sort(); | 2884 check_map->map_set_.Sort(); |
2882 return check_map; | 2885 return check_map; |
2883 } | 2886 } |
2884 | 2887 |
2885 bool CanOmitMapChecks() { return omit_; } | 2888 bool CanOmitMapChecks() { return omit_; } |
2886 | 2889 |
2887 virtual bool HasEscapingOperandAt(int index) { return false; } | 2890 virtual bool HasEscapingOperandAt(int index) { return false; } |
2888 virtual Representation RequiredInputRepresentation(int index) { | 2891 virtual Representation RequiredInputRepresentation(int index) { |
2889 return Representation::Tagged(); | 2892 return Representation::Tagged(); |
2890 } | 2893 } |
2891 virtual void HandleSideEffectDominator(GVNFlag side_effect, | 2894 virtual void HandleSideEffectDominator(GVNFlag side_effect, |
2892 HValue* dominator); | 2895 HValue* dominator); |
2893 virtual void PrintDataTo(StringStream* stream); | 2896 virtual void PrintDataTo(StringStream* stream); |
2894 | 2897 |
2895 HValue* value() { return OperandAt(0); } | 2898 HValue* value() { return OperandAt(0); } |
2899 HValue* context() { return OperandAt(2); } | |
2896 SmallMapList* map_set() { return &map_set_; } | 2900 SmallMapList* map_set() { return &map_set_; } |
2897 | 2901 |
2902 bool has_migration_target() { | |
2903 return has_migration_target_; | |
2904 } | |
2905 | |
2898 virtual void FinalizeUniqueValueId(); | 2906 virtual void FinalizeUniqueValueId(); |
2899 | 2907 |
2900 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) | 2908 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) |
2901 | 2909 |
2902 protected: | 2910 protected: |
2911 virtual int CompareOperandCount() { return OperandCount() - 1; } | |
2903 virtual bool DataEquals(HValue* other) { | 2912 virtual bool DataEquals(HValue* other) { |
2904 ASSERT_EQ(map_set_.length(), map_unique_ids_.length()); | 2913 ASSERT_EQ(map_set_.length(), map_unique_ids_.length()); |
2905 HCheckMaps* b = HCheckMaps::cast(other); | 2914 HCheckMaps* b = HCheckMaps::cast(other); |
2906 // Relies on the fact that map_set has been sorted before. | 2915 // Relies on the fact that map_set has been sorted before. |
2907 if (map_unique_ids_.length() != b->map_unique_ids_.length()) { | 2916 if (map_unique_ids_.length() != b->map_unique_ids_.length()) { |
2908 return false; | 2917 return false; |
2909 } | 2918 } |
2910 for (int i = 0; i < map_unique_ids_.length(); i++) { | 2919 for (int i = 0; i < map_unique_ids_.length(); i++) { |
2911 if (map_unique_ids_.at(i) != b->map_unique_ids_.at(i)) { | 2920 if (map_unique_ids_.at(i) != b->map_unique_ids_.at(i)) { |
2912 return false; | 2921 return false; |
2913 } | 2922 } |
2914 } | 2923 } |
2915 return true; | 2924 return true; |
2916 } | 2925 } |
2917 | 2926 |
2918 private: | 2927 private: |
2919 // Clients should use one of the static New* methods above. | 2928 // Clients should use one of the static New* methods above. |
2920 HCheckMaps(HValue* value, Zone *zone, HValue* typecheck) | 2929 HCheckMaps(HValue* context, HValue* value, Zone *zone, HValue* typecheck) |
2921 : HTemplateInstruction<2>(value->type()), | 2930 : HTemplateInstruction<3>(value->type()), |
2922 omit_(false), map_unique_ids_(0, zone) { | 2931 omit_(false), has_migration_target_(false), map_unique_ids_(0, zone) { |
2923 SetOperandAt(0, value); | 2932 SetOperandAt(0, value); |
2924 // Use the object value for the dependency if NULL is passed. | 2933 // Use the object value for the dependency if NULL is passed. |
2925 // TODO(titzer): do GVN flags already express this dependency? | 2934 // TODO(titzer): do GVN flags already express this dependency? |
2926 SetOperandAt(1, typecheck != NULL ? typecheck : value); | 2935 SetOperandAt(1, typecheck != NULL ? typecheck : value); |
2936 SetOperandAt(2, context); | |
2927 set_representation(Representation::Tagged()); | 2937 set_representation(Representation::Tagged()); |
2928 SetFlag(kUseGVN); | 2938 SetFlag(kUseGVN); |
2929 SetFlag(kTrackSideEffectDominators); | 2939 SetFlag(kTrackSideEffectDominators); |
2930 SetGVNFlag(kDependsOnMaps); | 2940 SetGVNFlag(kDependsOnMaps); |
2931 SetGVNFlag(kDependsOnElementsKind); | 2941 SetGVNFlag(kDependsOnElementsKind); |
2932 } | 2942 } |
2933 | 2943 |
2934 void omit(CompilationInfo* info) { | 2944 void omit(CompilationInfo* info) { |
2935 omit_ = true; | 2945 omit_ = true; |
2936 for (int i = 0; i < map_set_.length(); i++) { | 2946 for (int i = 0; i < map_set_.length(); i++) { |
2937 Handle<Map> map = map_set_.at(i); | 2947 Handle<Map> map = map_set_.at(i); |
2938 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup, | 2948 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup, |
2939 info); | 2949 info); |
2940 } | 2950 } |
2941 } | 2951 } |
2942 | 2952 |
2943 bool omit_; | 2953 bool omit_; |
2954 bool has_migration_target_; | |
2944 SmallMapList map_set_; | 2955 SmallMapList map_set_; |
2945 ZoneList<UniqueValueId> map_unique_ids_; | 2956 ZoneList<UniqueValueId> map_unique_ids_; |
2946 }; | 2957 }; |
2947 | 2958 |
2948 | 2959 |
2949 class HCheckFunction: public HUnaryOperation { | 2960 class HCheckFunction: public HUnaryOperation { |
2950 public: | 2961 public: |
2951 DECLARE_INSTRUCTION_FACTORY_P2(HCheckFunction, HValue*, Handle<JSFunction>); | 2962 DECLARE_INSTRUCTION_FACTORY_P2(HCheckFunction, HValue*, Handle<JSFunction>); |
2952 | 2963 |
2953 virtual Representation RequiredInputRepresentation(int index) { | 2964 virtual Representation RequiredInputRepresentation(int index) { |
(...skipping 4213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7167 virtual bool IsDeletable() const { return true; } | 7178 virtual bool IsDeletable() const { return true; } |
7168 }; | 7179 }; |
7169 | 7180 |
7170 | 7181 |
7171 #undef DECLARE_INSTRUCTION | 7182 #undef DECLARE_INSTRUCTION |
7172 #undef DECLARE_CONCRETE_INSTRUCTION | 7183 #undef DECLARE_CONCRETE_INSTRUCTION |
7173 | 7184 |
7174 } } // namespace v8::internal | 7185 } } // namespace v8::internal |
7175 | 7186 |
7176 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7187 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |