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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 virtual Representation RequiredInputRepresentation(int index) { | 980 virtual Representation RequiredInputRepresentation(int index) { |
981 return Representation::None(); | 981 return Representation::None(); |
982 } | 982 } |
983 | 983 |
984 DECLARE_CONCRETE_INSTRUCTION(SoftDeoptimize) | 984 DECLARE_CONCRETE_INSTRUCTION(SoftDeoptimize) |
985 }; | 985 }; |
986 | 986 |
987 | 987 |
988 class HDeoptimize: public HControlInstruction { | 988 class HDeoptimize: public HControlInstruction { |
989 public: | 989 public: |
990 explicit HDeoptimize(int environment_length) : values_(environment_length) { } | 990 HDeoptimize(int environment_length, Zone* zone) |
| 991 : values_(environment_length, zone) { } |
991 | 992 |
992 virtual Representation RequiredInputRepresentation(int index) { | 993 virtual Representation RequiredInputRepresentation(int index) { |
993 return Representation::None(); | 994 return Representation::None(); |
994 } | 995 } |
995 | 996 |
996 virtual int OperandCount() { return values_.length(); } | 997 virtual int OperandCount() { return values_.length(); } |
997 virtual HValue* OperandAt(int index) { return values_[index]; } | 998 virtual HValue* OperandAt(int index) { return values_[index]; } |
998 virtual void PrintDataTo(StringStream* stream); | 999 virtual void PrintDataTo(StringStream* stream); |
999 | 1000 |
1000 virtual int SuccessorCount() { return 0; } | 1001 virtual int SuccessorCount() { return 0; } |
1001 virtual HBasicBlock* SuccessorAt(int i) { | 1002 virtual HBasicBlock* SuccessorAt(int i) { |
1002 UNREACHABLE(); | 1003 UNREACHABLE(); |
1003 return NULL; | 1004 return NULL; |
1004 } | 1005 } |
1005 virtual void SetSuccessorAt(int i, HBasicBlock* block) { | 1006 virtual void SetSuccessorAt(int i, HBasicBlock* block) { |
1006 UNREACHABLE(); | 1007 UNREACHABLE(); |
1007 } | 1008 } |
1008 | 1009 |
1009 void AddEnvironmentValue(HValue* value) { | 1010 void AddEnvironmentValue(HValue* value, Zone* zone) { |
1010 values_.Add(NULL); | 1011 values_.Add(NULL, zone); |
1011 SetOperandAt(values_.length() - 1, value); | 1012 SetOperandAt(values_.length() - 1, value); |
1012 } | 1013 } |
1013 | 1014 |
1014 DECLARE_CONCRETE_INSTRUCTION(Deoptimize) | 1015 DECLARE_CONCRETE_INSTRUCTION(Deoptimize) |
1015 | 1016 |
1016 enum UseEnvironment { | 1017 enum UseEnvironment { |
1017 kNoUses, | 1018 kNoUses, |
1018 kUseAll | 1019 kUseAll |
1019 }; | 1020 }; |
1020 | 1021 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 | 1269 |
1269 DECLARE_CONCRETE_INSTRUCTION(ClampToUint8) | 1270 DECLARE_CONCRETE_INSTRUCTION(ClampToUint8) |
1270 | 1271 |
1271 protected: | 1272 protected: |
1272 virtual bool DataEquals(HValue* other) { return true; } | 1273 virtual bool DataEquals(HValue* other) { return true; } |
1273 }; | 1274 }; |
1274 | 1275 |
1275 | 1276 |
1276 class HSimulate: public HInstruction { | 1277 class HSimulate: public HInstruction { |
1277 public: | 1278 public: |
1278 HSimulate(int ast_id, int pop_count) | 1279 HSimulate(int ast_id, int pop_count, Zone* zone) |
1279 : ast_id_(ast_id), | 1280 : ast_id_(ast_id), |
1280 pop_count_(pop_count), | 1281 pop_count_(pop_count), |
1281 values_(2), | 1282 values_(2, zone), |
1282 assigned_indexes_(2) {} | 1283 assigned_indexes_(2, zone), |
| 1284 zone_(zone) {} |
1283 virtual ~HSimulate() {} | 1285 virtual ~HSimulate() {} |
1284 | 1286 |
1285 virtual void PrintDataTo(StringStream* stream); | 1287 virtual void PrintDataTo(StringStream* stream); |
1286 | 1288 |
1287 bool HasAstId() const { return ast_id_ != AstNode::kNoNumber; } | 1289 bool HasAstId() const { return ast_id_ != AstNode::kNoNumber; } |
1288 int ast_id() const { return ast_id_; } | 1290 int ast_id() const { return ast_id_; } |
1289 void set_ast_id(int id) { | 1291 void set_ast_id(int id) { |
1290 ASSERT(!HasAstId()); | 1292 ASSERT(!HasAstId()); |
1291 ast_id_ = id; | 1293 ast_id_ = id; |
1292 } | 1294 } |
(...skipping 27 matching lines...) Expand all Loading... |
1320 #endif | 1322 #endif |
1321 | 1323 |
1322 protected: | 1324 protected: |
1323 virtual void InternalSetOperandAt(int index, HValue* value) { | 1325 virtual void InternalSetOperandAt(int index, HValue* value) { |
1324 values_[index] = value; | 1326 values_[index] = value; |
1325 } | 1327 } |
1326 | 1328 |
1327 private: | 1329 private: |
1328 static const int kNoIndex = -1; | 1330 static const int kNoIndex = -1; |
1329 void AddValue(int index, HValue* value) { | 1331 void AddValue(int index, HValue* value) { |
1330 assigned_indexes_.Add(index); | 1332 assigned_indexes_.Add(index, zone_); |
1331 // Resize the list of pushed values. | 1333 // Resize the list of pushed values. |
1332 values_.Add(NULL); | 1334 values_.Add(NULL, zone_); |
1333 // Set the operand through the base method in HValue to make sure that the | 1335 // Set the operand through the base method in HValue to make sure that the |
1334 // use lists are correctly updated. | 1336 // use lists are correctly updated. |
1335 SetOperandAt(values_.length() - 1, value); | 1337 SetOperandAt(values_.length() - 1, value); |
1336 } | 1338 } |
1337 int ast_id_; | 1339 int ast_id_; |
1338 int pop_count_; | 1340 int pop_count_; |
1339 ZoneList<HValue*> values_; | 1341 ZoneList<HValue*> values_; |
1340 ZoneList<int> assigned_indexes_; | 1342 ZoneList<int> assigned_indexes_; |
| 1343 Zone* zone_; |
1341 }; | 1344 }; |
1342 | 1345 |
1343 | 1346 |
1344 class HStackCheck: public HTemplateInstruction<1> { | 1347 class HStackCheck: public HTemplateInstruction<1> { |
1345 public: | 1348 public: |
1346 enum Type { | 1349 enum Type { |
1347 kFunctionEntry, | 1350 kFunctionEntry, |
1348 kBackwardsBranch | 1351 kBackwardsBranch |
1349 }; | 1352 }; |
1350 | 1353 |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 | 2051 |
2049 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer) | 2052 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer) |
2050 | 2053 |
2051 protected: | 2054 protected: |
2052 virtual bool DataEquals(HValue* other) { return true; } | 2055 virtual bool DataEquals(HValue* other) { return true; } |
2053 }; | 2056 }; |
2054 | 2057 |
2055 | 2058 |
2056 class HCheckMaps: public HTemplateInstruction<2> { | 2059 class HCheckMaps: public HTemplateInstruction<2> { |
2057 public: | 2060 public: |
2058 HCheckMaps(HValue* value, Handle<Map> map, HValue* typecheck = NULL) { | 2061 HCheckMaps(HValue* value, Handle<Map> map, Zone* zone, |
| 2062 HValue* typecheck = NULL) { |
2059 SetOperandAt(0, value); | 2063 SetOperandAt(0, value); |
2060 // If callers don't depend on a typecheck, they can pass in NULL. In that | 2064 // If callers don't depend on a typecheck, they can pass in NULL. In that |
2061 // case we use a copy of the |value| argument as a dummy value. | 2065 // case we use a copy of the |value| argument as a dummy value. |
2062 SetOperandAt(1, typecheck != NULL ? typecheck : value); | 2066 SetOperandAt(1, typecheck != NULL ? typecheck : value); |
2063 set_representation(Representation::Tagged()); | 2067 set_representation(Representation::Tagged()); |
2064 SetFlag(kUseGVN); | 2068 SetFlag(kUseGVN); |
2065 SetGVNFlag(kDependsOnMaps); | 2069 SetGVNFlag(kDependsOnMaps); |
2066 SetGVNFlag(kDependsOnElementsKind); | 2070 SetGVNFlag(kDependsOnElementsKind); |
2067 map_set()->Add(map); | 2071 map_set()->Add(map, zone); |
2068 } | 2072 } |
2069 HCheckMaps(HValue* value, SmallMapList* maps) { | 2073 HCheckMaps(HValue* value, SmallMapList* maps, Zone* zone) { |
2070 SetOperandAt(0, value); | 2074 SetOperandAt(0, value); |
2071 SetOperandAt(1, value); | 2075 SetOperandAt(1, value); |
2072 set_representation(Representation::Tagged()); | 2076 set_representation(Representation::Tagged()); |
2073 SetFlag(kUseGVN); | 2077 SetFlag(kUseGVN); |
2074 SetGVNFlag(kDependsOnMaps); | 2078 SetGVNFlag(kDependsOnMaps); |
2075 SetGVNFlag(kDependsOnElementsKind); | 2079 SetGVNFlag(kDependsOnElementsKind); |
2076 for (int i = 0; i < maps->length(); i++) { | 2080 for (int i = 0; i < maps->length(); i++) { |
2077 map_set()->Add(maps->at(i)); | 2081 map_set()->Add(maps->at(i), zone); |
2078 } | 2082 } |
2079 map_set()->Sort(); | 2083 map_set()->Sort(); |
2080 } | 2084 } |
2081 | 2085 |
2082 static HCheckMaps* NewWithTransitions(HValue* object, Handle<Map> map) { | 2086 static HCheckMaps* NewWithTransitions(HValue* object, Handle<Map> map, |
2083 HCheckMaps* check_map = new HCheckMaps(object, map); | 2087 Zone* zone) { |
| 2088 HCheckMaps* check_map = new(zone) HCheckMaps(object, map, zone); |
2084 SmallMapList* map_set = check_map->map_set(); | 2089 SmallMapList* map_set = check_map->map_set(); |
2085 | 2090 |
2086 // Since transitioned elements maps of the initial map don't fail the map | 2091 // Since transitioned elements maps of the initial map don't fail the map |
2087 // check, the CheckMaps instruction doesn't need to depend on ElementsKinds. | 2092 // check, the CheckMaps instruction doesn't need to depend on ElementsKinds. |
2088 check_map->ClearGVNFlag(kDependsOnElementsKind); | 2093 check_map->ClearGVNFlag(kDependsOnElementsKind); |
2089 | 2094 |
2090 ElementsKind kind = map->elements_kind(); | 2095 ElementsKind kind = map->elements_kind(); |
2091 bool packed = IsFastPackedElementsKind(kind); | 2096 bool packed = IsFastPackedElementsKind(kind); |
2092 while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) { | 2097 while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) { |
2093 kind = GetNextMoreGeneralFastElementsKind(kind, packed); | 2098 kind = GetNextMoreGeneralFastElementsKind(kind, packed); |
2094 Map* transitioned_map = | 2099 Map* transitioned_map = |
2095 map->LookupElementsTransitionMap(kind, NULL); | 2100 map->LookupElementsTransitionMap(kind, NULL); |
2096 if (transitioned_map) { | 2101 if (transitioned_map) { |
2097 map_set->Add(Handle<Map>(transitioned_map)); | 2102 map_set->Add(Handle<Map>(transitioned_map), zone); |
2098 } | 2103 } |
2099 }; | 2104 }; |
2100 map_set->Sort(); | 2105 map_set->Sort(); |
2101 return check_map; | 2106 return check_map; |
2102 } | 2107 } |
2103 | 2108 |
2104 virtual Representation RequiredInputRepresentation(int index) { | 2109 virtual Representation RequiredInputRepresentation(int index) { |
2105 return Representation::Tagged(); | 2110 return Representation::Tagged(); |
2106 } | 2111 } |
2107 virtual void PrintDataTo(StringStream* stream); | 2112 virtual void PrintDataTo(StringStream* stream); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 return target_.is_identical_to(b->target()); | 2161 return target_.is_identical_to(b->target()); |
2157 } | 2162 } |
2158 | 2163 |
2159 private: | 2164 private: |
2160 Handle<JSFunction> target_; | 2165 Handle<JSFunction> target_; |
2161 }; | 2166 }; |
2162 | 2167 |
2163 | 2168 |
2164 class HCheckInstanceType: public HUnaryOperation { | 2169 class HCheckInstanceType: public HUnaryOperation { |
2165 public: | 2170 public: |
2166 static HCheckInstanceType* NewIsSpecObject(HValue* value) { | 2171 static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) { |
2167 return new HCheckInstanceType(value, IS_SPEC_OBJECT); | 2172 return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT); |
2168 } | 2173 } |
2169 static HCheckInstanceType* NewIsJSArray(HValue* value) { | 2174 static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) { |
2170 return new HCheckInstanceType(value, IS_JS_ARRAY); | 2175 return new(zone) HCheckInstanceType(value, IS_JS_ARRAY); |
2171 } | 2176 } |
2172 static HCheckInstanceType* NewIsString(HValue* value) { | 2177 static HCheckInstanceType* NewIsString(HValue* value, Zone* zone) { |
2173 return new HCheckInstanceType(value, IS_STRING); | 2178 return new(zone) HCheckInstanceType(value, IS_STRING); |
2174 } | 2179 } |
2175 static HCheckInstanceType* NewIsSymbol(HValue* value) { | 2180 static HCheckInstanceType* NewIsSymbol(HValue* value, Zone* zone) { |
2176 return new HCheckInstanceType(value, IS_SYMBOL); | 2181 return new(zone) HCheckInstanceType(value, IS_SYMBOL); |
2177 } | 2182 } |
2178 | 2183 |
2179 virtual void PrintDataTo(StringStream* stream); | 2184 virtual void PrintDataTo(StringStream* stream); |
2180 | 2185 |
2181 virtual Representation RequiredInputRepresentation(int index) { | 2186 virtual Representation RequiredInputRepresentation(int index) { |
2182 return Representation::Tagged(); | 2187 return Representation::Tagged(); |
2183 } | 2188 } |
2184 | 2189 |
2185 virtual HValue* Canonicalize(); | 2190 virtual HValue* Canonicalize(); |
2186 | 2191 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 | 2320 |
2316 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) | 2321 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) |
2317 | 2322 |
2318 protected: | 2323 protected: |
2319 virtual bool DataEquals(HValue* other) { return true; } | 2324 virtual bool DataEquals(HValue* other) { return true; } |
2320 }; | 2325 }; |
2321 | 2326 |
2322 | 2327 |
2323 class HPhi: public HValue { | 2328 class HPhi: public HValue { |
2324 public: | 2329 public: |
2325 explicit HPhi(int merged_index) | 2330 HPhi(int merged_index, Zone* zone) |
2326 : inputs_(2), | 2331 : inputs_(2, zone), |
2327 merged_index_(merged_index), | 2332 merged_index_(merged_index), |
2328 phi_id_(-1), | 2333 phi_id_(-1), |
2329 is_live_(false), | 2334 is_live_(false), |
2330 is_convertible_to_integer_(true) { | 2335 is_convertible_to_integer_(true) { |
2331 for (int i = 0; i < Representation::kNumRepresentations; i++) { | 2336 for (int i = 0; i < Representation::kNumRepresentations; i++) { |
2332 non_phi_uses_[i] = 0; | 2337 non_phi_uses_[i] = 0; |
2333 indirect_uses_[i] = 0; | 2338 indirect_uses_[i] = 0; |
2334 } | 2339 } |
2335 ASSERT(merged_index >= 0); | 2340 ASSERT(merged_index >= 0); |
2336 set_representation(Representation::Tagged()); | 2341 set_representation(Representation::Tagged()); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2471 (HeapNumber::cast(*handle_)->value() == | 2476 (HeapNumber::cast(*handle_)->value() == |
2472 static_cast<double>(NumberToInt32(*handle_)))) return true; | 2477 static_cast<double>(NumberToInt32(*handle_)))) return true; |
2473 return false; | 2478 return false; |
2474 } | 2479 } |
2475 | 2480 |
2476 virtual bool EmitAtUses() { return !representation().IsDouble(); } | 2481 virtual bool EmitAtUses() { return !representation().IsDouble(); } |
2477 virtual HValue* Canonicalize(); | 2482 virtual HValue* Canonicalize(); |
2478 virtual void PrintDataTo(StringStream* stream); | 2483 virtual void PrintDataTo(StringStream* stream); |
2479 virtual HType CalculateInferredType(); | 2484 virtual HType CalculateInferredType(); |
2480 bool IsInteger() const { return handle_->IsSmi(); } | 2485 bool IsInteger() const { return handle_->IsSmi(); } |
2481 HConstant* CopyToRepresentation(Representation r) const; | 2486 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; |
2482 HConstant* CopyToTruncatedInt32() const; | 2487 HConstant* CopyToTruncatedInt32(Zone* zone) const; |
2483 bool HasInteger32Value() const { return has_int32_value_; } | 2488 bool HasInteger32Value() const { return has_int32_value_; } |
2484 int32_t Integer32Value() const { | 2489 int32_t Integer32Value() const { |
2485 ASSERT(HasInteger32Value()); | 2490 ASSERT(HasInteger32Value()); |
2486 return int32_value_; | 2491 return int32_value_; |
2487 } | 2492 } |
2488 bool HasDoubleValue() const { return has_double_value_; } | 2493 bool HasDoubleValue() const { return has_double_value_; } |
2489 double DoubleValue() const { | 2494 double DoubleValue() const { |
2490 ASSERT(HasDoubleValue()); | 2495 ASSERT(HasDoubleValue()); |
2491 return double_value_; | 2496 return double_value_; |
2492 } | 2497 } |
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3855 bool is_in_object_; | 3860 bool is_in_object_; |
3856 int offset_; | 3861 int offset_; |
3857 }; | 3862 }; |
3858 | 3863 |
3859 | 3864 |
3860 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { | 3865 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { |
3861 public: | 3866 public: |
3862 HLoadNamedFieldPolymorphic(HValue* context, | 3867 HLoadNamedFieldPolymorphic(HValue* context, |
3863 HValue* object, | 3868 HValue* object, |
3864 SmallMapList* types, | 3869 SmallMapList* types, |
3865 Handle<String> name); | 3870 Handle<String> name, |
| 3871 Zone* zone); |
3866 | 3872 |
3867 HValue* context() { return OperandAt(0); } | 3873 HValue* context() { return OperandAt(0); } |
3868 HValue* object() { return OperandAt(1); } | 3874 HValue* object() { return OperandAt(1); } |
3869 SmallMapList* types() { return &types_; } | 3875 SmallMapList* types() { return &types_; } |
3870 Handle<String> name() { return name_; } | 3876 Handle<String> name() { return name_; } |
3871 bool need_generic() { return need_generic_; } | 3877 bool need_generic() { return need_generic_; } |
3872 | 3878 |
3873 virtual Representation RequiredInputRepresentation(int index) { | 3879 virtual Representation RequiredInputRepresentation(int index) { |
3874 return Representation::Tagged(); | 3880 return Representation::Tagged(); |
3875 } | 3881 } |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5057 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); | 5063 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); |
5058 }; | 5064 }; |
5059 | 5065 |
5060 | 5066 |
5061 #undef DECLARE_INSTRUCTION | 5067 #undef DECLARE_INSTRUCTION |
5062 #undef DECLARE_CONCRETE_INSTRUCTION | 5068 #undef DECLARE_CONCRETE_INSTRUCTION |
5063 | 5069 |
5064 } } // namespace v8::internal | 5070 } } // namespace v8::internal |
5065 | 5071 |
5066 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 5072 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |