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 27 matching lines...) Expand all Loading... | |
38 #include "v8conversions.h" | 38 #include "v8conversions.h" |
39 #include "v8utils.h" | 39 #include "v8utils.h" |
40 #include "zone.h" | 40 #include "zone.h" |
41 | 41 |
42 namespace v8 { | 42 namespace v8 { |
43 namespace internal { | 43 namespace internal { |
44 | 44 |
45 // Forward declarations. | 45 // Forward declarations. |
46 class HBasicBlock; | 46 class HBasicBlock; |
47 class HEnvironment; | 47 class HEnvironment; |
48 class HInferRepresentation; | |
48 class HInstruction; | 49 class HInstruction; |
49 class HLoopInformation; | 50 class HLoopInformation; |
50 class HValue; | 51 class HValue; |
51 class LInstruction; | 52 class LInstruction; |
52 class LChunkBuilder; | 53 class LChunkBuilder; |
53 | 54 |
54 | 55 |
55 #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ | 56 #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ |
56 V(BinaryOperation) \ | 57 V(BinaryOperation) \ |
57 V(BitwiseBinaryOperation) \ | 58 V(BitwiseBinaryOperation) \ |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 int32_t upper_; | 301 int32_t upper_; |
301 Range* next_; | 302 Range* next_; |
302 bool can_be_minus_zero_; | 303 bool can_be_minus_zero_; |
303 }; | 304 }; |
304 | 305 |
305 | 306 |
306 class Representation { | 307 class Representation { |
307 public: | 308 public: |
308 enum Kind { | 309 enum Kind { |
309 kNone, | 310 kNone, |
311 kInteger32, | |
312 kDouble, | |
310 kTagged, | 313 kTagged, |
311 kDouble, | |
312 kInteger32, | |
313 kExternal, | 314 kExternal, |
314 kNumRepresentations | 315 kNumRepresentations |
315 }; | 316 }; |
316 | 317 |
317 Representation() : kind_(kNone) { } | 318 Representation() : kind_(kNone) { } |
318 | 319 |
319 static Representation None() { return Representation(kNone); } | 320 static Representation None() { return Representation(kNone); } |
320 static Representation Tagged() { return Representation(kTagged); } | 321 static Representation Tagged() { return Representation(kTagged); } |
321 static Representation Integer32() { return Representation(kInteger32); } | 322 static Representation Integer32() { return Representation(kInteger32); } |
322 static Representation Double() { return Representation(kDouble); } | 323 static Representation Double() { return Representation(kDouble); } |
323 static Representation External() { return Representation(kExternal); } | 324 static Representation External() { return Representation(kExternal); } |
324 | 325 |
325 bool Equals(const Representation& other) { | 326 bool Equals(const Representation& other) { |
326 return kind_ == other.kind_; | 327 return kind_ == other.kind_; |
327 } | 328 } |
328 | 329 |
330 bool is_more_general_than(const Representation& other) { | |
331 ASSERT(kind_ != kExternal); | |
332 ASSERT(other.kind_ != kExternal); | |
333 return kind_ > other.kind_; | |
334 } | |
335 | |
329 Kind kind() const { return static_cast<Kind>(kind_); } | 336 Kind kind() const { return static_cast<Kind>(kind_); } |
330 bool IsNone() const { return kind_ == kNone; } | 337 bool IsNone() const { return kind_ == kNone; } |
331 bool IsTagged() const { return kind_ == kTagged; } | 338 bool IsTagged() const { return kind_ == kTagged; } |
332 bool IsInteger32() const { return kind_ == kInteger32; } | 339 bool IsInteger32() const { return kind_ == kInteger32; } |
333 bool IsDouble() const { return kind_ == kDouble; } | 340 bool IsDouble() const { return kind_ == kDouble; } |
334 bool IsExternal() const { return kind_ == kExternal; } | 341 bool IsExternal() const { return kind_ == kExternal; } |
335 bool IsSpecialization() const { | 342 bool IsSpecialization() const { |
336 return kind_ == kInteger32 || kind_ == kDouble; | 343 return kind_ == kInteger32 || kind_ == kDouble; |
337 } | 344 } |
338 const char* Mnemonic() const; | 345 const char* Mnemonic() const; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
621 int LoopWeight() const; | 628 int LoopWeight() const; |
622 | 629 |
623 int id() const { return id_; } | 630 int id() const { return id_; } |
624 void set_id(int id) { id_ = id; } | 631 void set_id(int id) { id_ = id; } |
625 | 632 |
626 HUseIterator uses() const { return HUseIterator(use_list_); } | 633 HUseIterator uses() const { return HUseIterator(use_list_); } |
627 | 634 |
628 virtual bool EmitAtUses() { return false; } | 635 virtual bool EmitAtUses() { return false; } |
629 Representation representation() const { return representation_; } | 636 Representation representation() const { return representation_; } |
630 void ChangeRepresentation(Representation r) { | 637 void ChangeRepresentation(Representation r) { |
631 // Representation was already set and is allowed to be changed. | |
632 ASSERT(!r.IsNone()); | |
633 ASSERT(CheckFlag(kFlexibleRepresentation)); | 638 ASSERT(CheckFlag(kFlexibleRepresentation)); |
634 RepresentationChanged(r); | 639 RepresentationChanged(r); |
635 representation_ = r; | 640 representation_ = r; |
641 if (r.IsTagged()) { | |
642 // Tagged is the bottom of the lattice, don't go any further. | |
643 ClearFlag(kFlexibleRepresentation); | |
644 } | |
636 } | 645 } |
637 void AssumeRepresentation(Representation r); | 646 virtual void AssumeRepresentation(Representation r); |
638 | 647 |
639 virtual bool IsConvertibleToInteger() const { return true; } | 648 virtual bool IsConvertibleToInteger() const { return true; } |
640 | 649 |
641 HType type() const { return type_; } | 650 HType type() const { return type_; } |
642 void set_type(HType new_type) { | 651 void set_type(HType new_type) { |
643 ASSERT(new_type.IsSubtypeOf(type_)); | 652 ASSERT(new_type.IsSubtypeOf(type_)); |
644 type_ = new_type; | 653 type_ = new_type; |
645 } | 654 } |
646 | 655 |
647 // An operation needs to override this function iff: | 656 // An operation needs to override this function iff: |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
725 return result; | 734 return result; |
726 } | 735 } |
727 | 736 |
728 Range* range() const { return range_; } | 737 Range* range() const { return range_; } |
729 bool HasRange() const { return range_ != NULL; } | 738 bool HasRange() const { return range_ != NULL; } |
730 void AddNewRange(Range* r, Zone* zone); | 739 void AddNewRange(Range* r, Zone* zone); |
731 void RemoveLastAddedRange(); | 740 void RemoveLastAddedRange(); |
732 void ComputeInitialRange(Zone* zone); | 741 void ComputeInitialRange(Zone* zone); |
733 | 742 |
734 // Representation helpers. | 743 // Representation helpers. |
744 virtual Representation observed_input_representation(int index) { | |
745 return Representation::None(); | |
746 } | |
735 virtual Representation RequiredInputRepresentation(int index) = 0; | 747 virtual Representation RequiredInputRepresentation(int index) = 0; |
736 | 748 virtual void InferRepresentation(HInferRepresentation* hinfer); |
737 virtual Representation InferredRepresentation() { | |
738 return representation(); | |
739 } | |
740 | |
741 // Type feedback access. | |
742 virtual Representation ObservedInputRepresentation(int index) { | |
743 return RequiredInputRepresentation(index); | |
744 } | |
745 | 749 |
746 // This gives the instruction an opportunity to replace itself with an | 750 // This gives the instruction an opportunity to replace itself with an |
747 // instruction that does the same in some better way. To replace an | 751 // instruction that does the same in some better way. To replace an |
748 // instruction with a new one, first add the new instruction to the graph, | 752 // instruction with a new one, first add the new instruction to the graph, |
749 // then return it. Return NULL to have the instruction deleted. | 753 // then return it. Return NULL to have the instruction deleted. |
750 virtual HValue* Canonicalize() { return this; } | 754 virtual HValue* Canonicalize() { return this; } |
751 | 755 |
752 bool Equals(HValue* other); | 756 bool Equals(HValue* other); |
753 virtual intptr_t Hashcode(); | 757 virtual intptr_t Hashcode(); |
754 | 758 |
(...skipping 27 matching lines...) Expand all Loading... | |
782 virtual void Verify() = 0; | 786 virtual void Verify() = 0; |
783 #endif | 787 #endif |
784 | 788 |
785 protected: | 789 protected: |
786 // This function must be overridden for instructions with flag kUseGVN, to | 790 // This function must be overridden for instructions with flag kUseGVN, to |
787 // compare the non-Operand parts of the instruction. | 791 // compare the non-Operand parts of the instruction. |
788 virtual bool DataEquals(HValue* other) { | 792 virtual bool DataEquals(HValue* other) { |
789 UNREACHABLE(); | 793 UNREACHABLE(); |
790 return false; | 794 return false; |
791 } | 795 } |
796 | |
797 virtual Representation RepresentationFromInputs() { | |
798 return representation(); | |
799 } | |
800 Representation RepresentationFromUses(); | |
801 virtual void UpdateRepresentation(Representation new_rep, | |
802 HInferRepresentation* hinfer, | |
803 const char* reason); | |
804 void AddDependantsToWorklist(HInferRepresentation* hinfer); | |
danno
2012/11/06 11:42:59
h_infer
Jakob Kummerow
2012/11/06 12:44:05
Done.
| |
805 | |
792 virtual void RepresentationChanged(Representation to) { } | 806 virtual void RepresentationChanged(Representation to) { } |
807 | |
793 virtual Range* InferRange(Zone* zone); | 808 virtual Range* InferRange(Zone* zone); |
794 virtual void DeleteFromGraph() = 0; | 809 virtual void DeleteFromGraph() = 0; |
795 virtual void InternalSetOperandAt(int index, HValue* value) = 0; | 810 virtual void InternalSetOperandAt(int index, HValue* value) = 0; |
796 void clear_block() { | 811 void clear_block() { |
797 ASSERT(block_ != NULL); | 812 ASSERT(block_ != NULL); |
798 block_ = NULL; | 813 block_ = NULL; |
799 } | 814 } |
800 | 815 |
801 void set_representation(Representation r) { | 816 void set_representation(Representation r) { |
802 // Representation is set-once. | |
803 ASSERT(representation_.IsNone() && !r.IsNone()); | 817 ASSERT(representation_.IsNone() && !r.IsNone()); |
804 representation_ = r; | 818 representation_ = r; |
805 } | 819 } |
806 | 820 |
807 static GVNFlagSet AllDependsOnFlagSet() { | 821 static GVNFlagSet AllDependsOnFlagSet() { |
808 GVNFlagSet result; | 822 GVNFlagSet result; |
809 // Create changes mask. | 823 // Create changes mask. |
810 #define ADD_FLAG(type) result.Add(kDependsOn##type); | 824 #define ADD_FLAG(type) result.Add(kDependsOn##type); |
811 GVN_TRACKED_FLAG_LIST(ADD_FLAG) | 825 GVN_TRACKED_FLAG_LIST(ADD_FLAG) |
812 GVN_UNTRACKED_FLAG_LIST(ADD_FLAG) | 826 GVN_UNTRACKED_FLAG_LIST(ADD_FLAG) |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1105 expected_input_types_(expected_input_types) { | 1119 expected_input_types_(expected_input_types) { |
1106 ASSERT(true_target != NULL && false_target != NULL); | 1120 ASSERT(true_target != NULL && false_target != NULL); |
1107 } | 1121 } |
1108 explicit HBranch(HValue* value) | 1122 explicit HBranch(HValue* value) |
1109 : HUnaryControlInstruction(value, NULL, NULL) { } | 1123 : HUnaryControlInstruction(value, NULL, NULL) { } |
1110 | 1124 |
1111 | 1125 |
1112 virtual Representation RequiredInputRepresentation(int index) { | 1126 virtual Representation RequiredInputRepresentation(int index) { |
1113 return Representation::None(); | 1127 return Representation::None(); |
1114 } | 1128 } |
1129 virtual Representation observed_input_representation(int index) { | |
danno
2012/11/06 11:42:59
put in .cc file
Jakob Kummerow
2012/11/06 12:44:05
Done.
| |
1130 static const ToBooleanStub::Types tagged_types( | |
1131 ToBooleanStub::UNDEFINED | | |
1132 ToBooleanStub::NULL_TYPE | | |
1133 ToBooleanStub::SPEC_OBJECT | | |
1134 ToBooleanStub::STRING); | |
1135 if (expected_input_types_.ContainsAnyOf(tagged_types)) { | |
1136 return Representation::Tagged(); | |
1137 } else if (expected_input_types_.Contains(ToBooleanStub::HEAP_NUMBER)) { | |
1138 return Representation::Double(); | |
1139 } else if (expected_input_types_.Contains(ToBooleanStub::SMI)) { | |
1140 return Representation::Integer32(); | |
1141 } else { | |
1142 return Representation::None(); | |
1143 } | |
1144 } | |
1115 | 1145 |
1116 ToBooleanStub::Types expected_input_types() const { | 1146 ToBooleanStub::Types expected_input_types() const { |
1117 return expected_input_types_; | 1147 return expected_input_types_; |
1118 } | 1148 } |
1119 | 1149 |
1120 DECLARE_CONCRETE_INSTRUCTION(Branch) | 1150 DECLARE_CONCRETE_INSTRUCTION(Branch) |
1121 | 1151 |
1122 private: | 1152 private: |
1123 ToBooleanStub::Types expected_input_types_; | 1153 ToBooleanStub::Types expected_input_types_; |
1124 }; | 1154 }; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1311 protected: | 1341 protected: |
1312 virtual bool DataEquals(HValue* other) { return true; } | 1342 virtual bool DataEquals(HValue* other) { return true; } |
1313 | 1343 |
1314 private: | 1344 private: |
1315 virtual bool IsDeletable() const { return true; } | 1345 virtual bool IsDeletable() const { return true; } |
1316 }; | 1346 }; |
1317 | 1347 |
1318 | 1348 |
1319 class HSimulate: public HInstruction { | 1349 class HSimulate: public HInstruction { |
1320 public: | 1350 public: |
1321 HSimulate(BailoutId ast_id, int pop_count, Zone* zone) | 1351 HSimulate(BailoutId ast_id, int pop_count, Zone* zone, bool optional) |
danno
2012/11/06 11:42:59
removable
Jakob Kummerow
2012/11/06 12:44:05
Done.
| |
1322 : ast_id_(ast_id), | 1352 : ast_id_(ast_id), |
1323 pop_count_(pop_count), | 1353 pop_count_(pop_count), |
1324 values_(2, zone), | 1354 values_(2, zone), |
1325 assigned_indexes_(2, zone), | 1355 assigned_indexes_(2, zone), |
1326 zone_(zone) {} | 1356 zone_(zone), |
1357 candidate_for_removal_(optional) {} | |
1327 virtual ~HSimulate() {} | 1358 virtual ~HSimulate() {} |
1328 | 1359 |
1329 virtual void PrintDataTo(StringStream* stream); | 1360 virtual void PrintDataTo(StringStream* stream); |
1330 | 1361 |
1331 bool HasAstId() const { return !ast_id_.IsNone(); } | 1362 bool HasAstId() const { return !ast_id_.IsNone(); } |
1332 BailoutId ast_id() const { return ast_id_; } | 1363 BailoutId ast_id() const { return ast_id_; } |
1333 void set_ast_id(BailoutId id) { | 1364 void set_ast_id(BailoutId id) { |
1334 ASSERT(!HasAstId()); | 1365 ASSERT(!HasAstId()); |
1335 ast_id_ = id; | 1366 ast_id_ = id; |
1336 } | 1367 } |
(...skipping 13 matching lines...) Expand all Loading... | |
1350 void AddPushedValue(HValue* value) { | 1381 void AddPushedValue(HValue* value) { |
1351 AddValue(kNoIndex, value); | 1382 AddValue(kNoIndex, value); |
1352 } | 1383 } |
1353 virtual int OperandCount() { return values_.length(); } | 1384 virtual int OperandCount() { return values_.length(); } |
1354 virtual HValue* OperandAt(int index) const { return values_[index]; } | 1385 virtual HValue* OperandAt(int index) const { return values_[index]; } |
1355 | 1386 |
1356 virtual Representation RequiredInputRepresentation(int index) { | 1387 virtual Representation RequiredInputRepresentation(int index) { |
1357 return Representation::None(); | 1388 return Representation::None(); |
1358 } | 1389 } |
1359 | 1390 |
1391 void MergeInto(HSimulate* other); | |
1392 bool is_candidate_for_removal() { return candidate_for_removal_; } | |
1393 | |
1360 DECLARE_CONCRETE_INSTRUCTION(Simulate) | 1394 DECLARE_CONCRETE_INSTRUCTION(Simulate) |
1361 | 1395 |
1362 #ifdef DEBUG | 1396 #ifdef DEBUG |
1363 virtual void Verify(); | 1397 virtual void Verify(); |
1364 #endif | 1398 #endif |
1365 | 1399 |
1366 protected: | 1400 protected: |
1367 virtual void InternalSetOperandAt(int index, HValue* value) { | 1401 virtual void InternalSetOperandAt(int index, HValue* value) { |
1368 values_[index] = value; | 1402 values_[index] = value; |
1369 } | 1403 } |
1370 | 1404 |
1371 private: | 1405 private: |
1372 static const int kNoIndex = -1; | 1406 static const int kNoIndex = -1; |
1373 void AddValue(int index, HValue* value) { | 1407 void AddValue(int index, HValue* value) { |
1374 assigned_indexes_.Add(index, zone_); | 1408 assigned_indexes_.Add(index, zone_); |
1375 // Resize the list of pushed values. | 1409 // Resize the list of pushed values. |
1376 values_.Add(NULL, zone_); | 1410 values_.Add(NULL, zone_); |
1377 // Set the operand through the base method in HValue to make sure that the | 1411 // Set the operand through the base method in HValue to make sure that the |
1378 // use lists are correctly updated. | 1412 // use lists are correctly updated. |
1379 SetOperandAt(values_.length() - 1, value); | 1413 SetOperandAt(values_.length() - 1, value); |
1380 } | 1414 } |
1381 BailoutId ast_id_; | 1415 BailoutId ast_id_; |
1382 int pop_count_; | 1416 int pop_count_; |
1383 ZoneList<HValue*> values_; | 1417 ZoneList<HValue*> values_; |
1384 ZoneList<int> assigned_indexes_; | 1418 ZoneList<int> assigned_indexes_; |
1385 Zone* zone_; | 1419 Zone* zone_; |
1420 bool candidate_for_removal_; | |
1386 }; | 1421 }; |
1387 | 1422 |
1388 | 1423 |
1389 class HStackCheck: public HTemplateInstruction<1> { | 1424 class HStackCheck: public HTemplateInstruction<1> { |
1390 public: | 1425 public: |
1391 enum Type { | 1426 enum Type { |
1392 kFunctionEntry, | 1427 kFunctionEntry, |
1393 kBackwardsBranch | 1428 kBackwardsBranch |
1394 }; | 1429 }; |
1395 | 1430 |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2002 public: | 2037 public: |
2003 explicit HBitNot(HValue* value) : HUnaryOperation(value) { | 2038 explicit HBitNot(HValue* value) : HUnaryOperation(value) { |
2004 set_representation(Representation::Integer32()); | 2039 set_representation(Representation::Integer32()); |
2005 SetFlag(kUseGVN); | 2040 SetFlag(kUseGVN); |
2006 SetFlag(kTruncatingToInt32); | 2041 SetFlag(kTruncatingToInt32); |
2007 } | 2042 } |
2008 | 2043 |
2009 virtual Representation RequiredInputRepresentation(int index) { | 2044 virtual Representation RequiredInputRepresentation(int index) { |
2010 return Representation::Integer32(); | 2045 return Representation::Integer32(); |
2011 } | 2046 } |
2047 virtual Representation observed_input_representation(int index) { | |
2048 return Representation::Integer32(); | |
2049 } | |
2012 virtual HType CalculateInferredType(); | 2050 virtual HType CalculateInferredType(); |
2013 | 2051 |
2014 virtual HValue* Canonicalize(); | 2052 virtual HValue* Canonicalize(); |
2015 | 2053 |
2016 DECLARE_CONCRETE_INSTRUCTION(BitNot) | 2054 DECLARE_CONCRETE_INSTRUCTION(BitNot) |
2017 | 2055 |
2018 protected: | 2056 protected: |
2019 virtual bool DataEquals(HValue* other) { return true; } | 2057 virtual bool DataEquals(HValue* other) { return true; } |
2020 | 2058 |
2021 private: | 2059 private: |
2022 virtual bool IsDeletable() const { return true; } | 2060 virtual bool IsDeletable() const { return true; } |
2023 }; | 2061 }; |
2024 | 2062 |
2025 | 2063 |
2026 class HUnaryMathOperation: public HTemplateInstruction<2> { | 2064 class HUnaryMathOperation: public HTemplateInstruction<2> { |
2027 public: | 2065 public: |
2028 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) | 2066 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
2029 : op_(op) { | 2067 : op_(op) { |
2030 SetOperandAt(0, context); | 2068 SetOperandAt(0, context); |
2031 SetOperandAt(1, value); | 2069 SetOperandAt(1, value); |
2032 switch (op) { | 2070 switch (op) { |
2033 case kMathFloor: | 2071 case kMathFloor: |
2034 case kMathRound: | 2072 case kMathRound: |
2035 case kMathCeil: | 2073 case kMathCeil: |
2036 set_representation(Representation::Integer32()); | 2074 set_representation(Representation::Integer32()); |
2037 break; | 2075 break; |
2038 case kMathAbs: | 2076 case kMathAbs: |
2039 set_representation(Representation::Tagged()); | 2077 // Not setting representation here: it is None intentionally. |
2040 SetFlag(kFlexibleRepresentation); | 2078 SetFlag(kFlexibleRepresentation); |
2041 SetGVNFlag(kChangesNewSpacePromotion); | 2079 SetGVNFlag(kChangesNewSpacePromotion); |
2042 break; | 2080 break; |
2043 case kMathSqrt: | 2081 case kMathSqrt: |
2044 case kMathPowHalf: | 2082 case kMathPowHalf: |
2045 case kMathLog: | 2083 case kMathLog: |
2046 case kMathSin: | 2084 case kMathSin: |
2047 case kMathCos: | 2085 case kMathCos: |
2048 case kMathTan: | 2086 case kMathTan: |
2049 set_representation(Representation::Double()); | 2087 set_representation(Representation::Double()); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2209 map_set->Add(Handle<Map>(transitioned_map), zone); | 2247 map_set->Add(Handle<Map>(transitioned_map), zone); |
2210 } | 2248 } |
2211 }; | 2249 }; |
2212 map_set->Sort(); | 2250 map_set->Sort(); |
2213 return check_map; | 2251 return check_map; |
2214 } | 2252 } |
2215 | 2253 |
2216 virtual Representation RequiredInputRepresentation(int index) { | 2254 virtual Representation RequiredInputRepresentation(int index) { |
2217 return Representation::Tagged(); | 2255 return Representation::Tagged(); |
2218 } | 2256 } |
2257 | |
2219 virtual void PrintDataTo(StringStream* stream); | 2258 virtual void PrintDataTo(StringStream* stream); |
2220 virtual HType CalculateInferredType(); | 2259 virtual HType CalculateInferredType(); |
2221 | 2260 |
2222 HValue* value() { return OperandAt(0); } | 2261 HValue* value() { return OperandAt(0); } |
2223 SmallMapList* map_set() { return &map_set_; } | 2262 SmallMapList* map_set() { return &map_set_; } |
2224 | 2263 |
2225 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) | 2264 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) |
2226 | 2265 |
2227 protected: | 2266 protected: |
2228 virtual bool DataEquals(HValue* other) { | 2267 virtual bool DataEquals(HValue* other) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2436 : inputs_(2, zone), | 2475 : inputs_(2, zone), |
2437 merged_index_(merged_index), | 2476 merged_index_(merged_index), |
2438 phi_id_(-1), | 2477 phi_id_(-1), |
2439 is_live_(false), | 2478 is_live_(false), |
2440 is_convertible_to_integer_(true) { | 2479 is_convertible_to_integer_(true) { |
2441 for (int i = 0; i < Representation::kNumRepresentations; i++) { | 2480 for (int i = 0; i < Representation::kNumRepresentations; i++) { |
2442 non_phi_uses_[i] = 0; | 2481 non_phi_uses_[i] = 0; |
2443 indirect_uses_[i] = 0; | 2482 indirect_uses_[i] = 0; |
2444 } | 2483 } |
2445 ASSERT(merged_index >= 0); | 2484 ASSERT(merged_index >= 0); |
2446 set_representation(Representation::Tagged()); | |
2447 SetFlag(kFlexibleRepresentation); | 2485 SetFlag(kFlexibleRepresentation); |
2448 } | 2486 } |
2449 | 2487 |
2450 virtual Representation InferredRepresentation(); | 2488 virtual Representation RepresentationFromInputs(); |
2451 | 2489 |
2452 virtual Range* InferRange(Zone* zone); | 2490 virtual Range* InferRange(Zone* zone); |
2491 virtual void InferRepresentation(HInferRepresentation* hinfer); | |
2492 Representation RepresentationFromUseRequirements(); | |
2453 virtual Representation RequiredInputRepresentation(int index) { | 2493 virtual Representation RequiredInputRepresentation(int index) { |
2454 return representation(); | 2494 return representation(); |
2455 } | 2495 } |
2456 virtual HType CalculateInferredType(); | 2496 virtual HType CalculateInferredType(); |
2457 virtual int OperandCount() { return inputs_.length(); } | 2497 virtual int OperandCount() { return inputs_.length(); } |
2458 virtual HValue* OperandAt(int index) const { return inputs_[index]; } | 2498 virtual HValue* OperandAt(int index) const { return inputs_[index]; } |
2459 HValue* GetRedundantReplacement(); | 2499 HValue* GetRedundantReplacement(); |
2460 void AddInput(HValue* value); | 2500 void AddInput(HValue* value); |
2461 bool HasRealUses(); | 2501 bool HasRealUses(); |
2462 | 2502 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2506 return is_convertible_to_integer_; | 2546 return is_convertible_to_integer_; |
2507 } | 2547 } |
2508 | 2548 |
2509 void set_is_convertible_to_integer(bool b) { | 2549 void set_is_convertible_to_integer(bool b) { |
2510 is_convertible_to_integer_ = b; | 2550 is_convertible_to_integer_ = b; |
2511 } | 2551 } |
2512 | 2552 |
2513 bool AllOperandsConvertibleToInteger() { | 2553 bool AllOperandsConvertibleToInteger() { |
2514 for (int i = 0; i < OperandCount(); ++i) { | 2554 for (int i = 0; i < OperandCount(); ++i) { |
2515 if (!OperandAt(i)->IsConvertibleToInteger()) { | 2555 if (!OperandAt(i)->IsConvertibleToInteger()) { |
2556 if (FLAG_trace_representation) { | |
2557 HValue* input = OperandAt(i); | |
2558 PrintF("#%d %s: Input #%d %s at %d is NCTI\n", | |
2559 id(), Mnemonic(), input->id(), input->Mnemonic(), i); | |
2560 } | |
2516 return false; | 2561 return false; |
2517 } | 2562 } |
2518 } | 2563 } |
2519 return true; | 2564 return true; |
2520 } | 2565 } |
2521 | 2566 |
2522 void ResetInteger32Uses(); | |
2523 | |
2524 protected: | 2567 protected: |
2525 virtual void DeleteFromGraph(); | 2568 virtual void DeleteFromGraph(); |
2526 virtual void InternalSetOperandAt(int index, HValue* value) { | 2569 virtual void InternalSetOperandAt(int index, HValue* value) { |
2527 inputs_[index] = value; | 2570 inputs_[index] = value; |
2528 } | 2571 } |
2529 | 2572 |
2530 private: | 2573 private: |
2531 ZoneList<HValue*> inputs_; | 2574 ZoneList<HValue*> inputs_; |
2532 int merged_index_; | 2575 int merged_index_; |
2533 | 2576 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2697 // not the converse. | 2740 // not the converse. |
2698 bool has_int32_value_ : 1; | 2741 bool has_int32_value_ : 1; |
2699 bool has_double_value_ : 1; | 2742 bool has_double_value_ : 1; |
2700 int32_t int32_value_; | 2743 int32_t int32_value_; |
2701 double double_value_; | 2744 double double_value_; |
2702 }; | 2745 }; |
2703 | 2746 |
2704 | 2747 |
2705 class HBinaryOperation: public HTemplateInstruction<3> { | 2748 class HBinaryOperation: public HTemplateInstruction<3> { |
2706 public: | 2749 public: |
2707 HBinaryOperation(HValue* context, HValue* left, HValue* right) { | 2750 HBinaryOperation(HValue* context, HValue* left, HValue* right) |
2751 : observed_output_representation_(Representation::None()) { | |
2708 ASSERT(left != NULL && right != NULL); | 2752 ASSERT(left != NULL && right != NULL); |
2709 SetOperandAt(0, context); | 2753 SetOperandAt(0, context); |
2710 SetOperandAt(1, left); | 2754 SetOperandAt(1, left); |
2711 SetOperandAt(2, right); | 2755 SetOperandAt(2, right); |
2756 observed_input_representation_[0] = Representation::None(); | |
2757 observed_input_representation_[1] = Representation::None(); | |
2712 } | 2758 } |
2713 | 2759 |
2714 HValue* context() { return OperandAt(0); } | 2760 HValue* context() { return OperandAt(0); } |
2715 HValue* left() { return OperandAt(1); } | 2761 HValue* left() { return OperandAt(1); } |
2716 HValue* right() { return OperandAt(2); } | 2762 HValue* right() { return OperandAt(2); } |
2717 | 2763 |
2718 // TODO(kasperl): Move these helpers to the IA-32 Lithium | 2764 // TODO(kasperl): Move these helpers to the IA-32 Lithium |
2719 // instruction sequence builder. | 2765 // instruction sequence builder. |
2720 HValue* LeastConstantOperand() { | 2766 HValue* LeastConstantOperand() { |
2721 if (IsCommutative() && left()->IsConstant()) return right(); | 2767 if (IsCommutative() && left()->IsConstant()) return right(); |
2722 return left(); | 2768 return left(); |
2723 } | 2769 } |
2724 | 2770 |
2725 HValue* MostConstantOperand() { | 2771 HValue* MostConstantOperand() { |
2726 if (IsCommutative() && left()->IsConstant()) return left(); | 2772 if (IsCommutative() && left()->IsConstant()) return left(); |
2727 return right(); | 2773 return right(); |
2728 } | 2774 } |
2729 | 2775 |
2776 void set_observed_input_representation(Representation left, | |
2777 Representation right) { | |
2778 observed_input_representation_[0] = left; | |
2779 observed_input_representation_[1] = right; | |
2780 } | |
2781 | |
2782 virtual void initialize_output_representation(Representation observed) { | |
2783 observed_output_representation_ = observed; | |
2784 } | |
2785 | |
2786 virtual Representation observed_input_representation(int index) { | |
2787 if (index == 0) return Representation::Tagged(); | |
2788 return observed_input_representation_[index - 1]; | |
2789 } | |
2790 | |
2791 virtual Representation RepresentationFromInputs(); | |
2792 virtual void AssumeRepresentation(Representation r); | |
2793 | |
2730 virtual bool IsCommutative() const { return false; } | 2794 virtual bool IsCommutative() const { return false; } |
2731 | 2795 |
2732 virtual void PrintDataTo(StringStream* stream); | 2796 virtual void PrintDataTo(StringStream* stream); |
2733 | 2797 |
2734 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) | 2798 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) |
2799 | |
2800 private: | |
2801 Representation observed_input_representation_[2]; | |
2802 Representation observed_output_representation_; | |
2735 }; | 2803 }; |
2736 | 2804 |
2737 | 2805 |
2738 class HWrapReceiver: public HTemplateInstruction<2> { | 2806 class HWrapReceiver: public HTemplateInstruction<2> { |
2739 public: | 2807 public: |
2740 HWrapReceiver(HValue* receiver, HValue* function) { | 2808 HWrapReceiver(HValue* receiver, HValue* function) { |
2741 set_representation(Representation::Tagged()); | 2809 set_representation(Representation::Tagged()); |
2742 SetOperandAt(0, receiver); | 2810 SetOperandAt(0, receiver); |
2743 SetOperandAt(1, function); | 2811 SetOperandAt(1, function); |
2744 } | 2812 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2894 } | 2962 } |
2895 // Also allow the length to be tagged if the index is constant, because | 2963 // Also allow the length to be tagged if the index is constant, because |
2896 // it can be tagged to allow direct comparison. | 2964 // it can be tagged to allow direct comparison. |
2897 if (index()->IsConstant() && | 2965 if (index()->IsConstant() && |
2898 index()->representation().IsInteger32() && | 2966 index()->representation().IsInteger32() && |
2899 arg_index == 1) { | 2967 arg_index == 1) { |
2900 return Representation::Tagged(); | 2968 return Representation::Tagged(); |
2901 } | 2969 } |
2902 return Representation::Integer32(); | 2970 return Representation::Integer32(); |
2903 } | 2971 } |
2972 virtual Representation observed_input_representation(int index) { | |
2973 return Representation::Integer32(); | |
2974 } | |
2904 | 2975 |
2905 virtual void PrintDataTo(StringStream* stream); | 2976 virtual void PrintDataTo(StringStream* stream); |
2906 | 2977 |
2907 HValue* index() { return OperandAt(0); } | 2978 HValue* index() { return OperandAt(0); } |
2908 HValue* length() { return OperandAt(1); } | 2979 HValue* length() { return OperandAt(1); } |
2909 | 2980 |
2910 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) | 2981 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) |
2911 | 2982 |
2912 protected: | 2983 protected: |
2913 virtual bool DataEquals(HValue* other) { return true; } | 2984 virtual bool DataEquals(HValue* other) { return true; } |
2914 BoundsCheckKeyMode key_mode_; | 2985 BoundsCheckKeyMode key_mode_; |
2915 }; | 2986 }; |
2916 | 2987 |
2917 | 2988 |
2918 class HBitwiseBinaryOperation: public HBinaryOperation { | 2989 class HBitwiseBinaryOperation: public HBinaryOperation { |
2919 public: | 2990 public: |
2920 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) | 2991 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) |
2921 : HBinaryOperation(context, left, right) { | 2992 : HBinaryOperation(context, left, right) { |
2922 set_representation(Representation::Tagged()); | |
2923 SetFlag(kFlexibleRepresentation); | 2993 SetFlag(kFlexibleRepresentation); |
2994 SetFlag(kTruncatingToInt32); | |
2924 SetAllSideEffects(); | 2995 SetAllSideEffects(); |
danno
2012/11/06 11:42:59
Probably not necessary
Jakob Kummerow
2012/11/06 12:44:05
No, it is in fact necessary, because HBinaryOperat
| |
2925 observed_input_representation_[0] = Representation::Tagged(); | |
2926 observed_input_representation_[1] = Representation::None(); | |
2927 observed_input_representation_[2] = Representation::None(); | |
2928 } | 2996 } |
2929 | 2997 |
2930 virtual Representation RequiredInputRepresentation(int index) { | 2998 virtual Representation RequiredInputRepresentation(int index) { |
2931 return index == 0 | 2999 return index == 0 |
2932 ? Representation::Tagged() | 3000 ? Representation::Tagged() |
2933 : representation(); | 3001 : representation(); |
2934 } | 3002 } |
2935 | 3003 |
2936 virtual void RepresentationChanged(Representation to) { | 3004 virtual void RepresentationChanged(Representation to) { |
2937 if (!to.IsTagged()) { | 3005 if (!to.IsTagged()) { |
2938 ASSERT(to.IsInteger32()); | 3006 ASSERT(to.IsInteger32()); |
2939 ClearAllSideEffects(); | 3007 ClearAllSideEffects(); |
2940 SetFlag(kTruncatingToInt32); | |
2941 SetFlag(kUseGVN); | 3008 SetFlag(kUseGVN); |
3009 } else { | |
3010 SetAllSideEffects(); | |
3011 ClearFlag(kUseGVN); | |
2942 } | 3012 } |
2943 } | 3013 } |
2944 | 3014 |
2945 virtual HType CalculateInferredType(); | 3015 virtual void UpdateRepresentation(Representation new_rep, |
2946 | 3016 HInferRepresentation* hinfer, |
2947 virtual Representation ObservedInputRepresentation(int index) { | 3017 const char* reason) { |
2948 return observed_input_representation_[index]; | 3018 // We only generate either int32 or generic tagged bitwise operations. |
3019 if (new_rep.IsDouble()) new_rep = Representation::Integer32(); | |
3020 HValue::UpdateRepresentation(new_rep, hinfer, reason); | |
2949 } | 3021 } |
2950 | 3022 |
2951 void InitializeObservedInputRepresentation(Representation r) { | 3023 virtual void initialize_output_representation(Representation observed) { |
2952 observed_input_representation_[1] = r; | 3024 if (observed.IsDouble()) observed = Representation::Integer32(); |
2953 observed_input_representation_[2] = r; | 3025 HBinaryOperation::initialize_output_representation(observed); |
2954 } | 3026 } |
2955 | 3027 |
3028 virtual HType CalculateInferredType(); | |
3029 | |
2956 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) | 3030 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) |
2957 | 3031 |
2958 private: | 3032 private: |
2959 virtual bool IsDeletable() const { return true; } | 3033 virtual bool IsDeletable() const { return true; } |
2960 | |
2961 Representation observed_input_representation_[3]; | |
2962 }; | 3034 }; |
2963 | 3035 |
2964 | 3036 |
2965 class HMathFloorOfDiv: public HBinaryOperation { | 3037 class HMathFloorOfDiv: public HBinaryOperation { |
2966 public: | 3038 public: |
2967 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) | 3039 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) |
2968 : HBinaryOperation(context, left, right) { | 3040 : HBinaryOperation(context, left, right) { |
2969 set_representation(Representation::Integer32()); | 3041 set_representation(Representation::Integer32()); |
2970 SetFlag(kUseGVN); | 3042 SetFlag(kUseGVN); |
2971 SetFlag(kCanOverflow); | 3043 SetFlag(kCanOverflow); |
(...skipping 12 matching lines...) Expand all Loading... | |
2984 | 3056 |
2985 private: | 3057 private: |
2986 virtual bool IsDeletable() const { return true; } | 3058 virtual bool IsDeletable() const { return true; } |
2987 }; | 3059 }; |
2988 | 3060 |
2989 | 3061 |
2990 class HArithmeticBinaryOperation: public HBinaryOperation { | 3062 class HArithmeticBinaryOperation: public HBinaryOperation { |
2991 public: | 3063 public: |
2992 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) | 3064 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) |
2993 : HBinaryOperation(context, left, right) { | 3065 : HBinaryOperation(context, left, right) { |
2994 set_representation(Representation::Tagged()); | 3066 SetAllSideEffects(); |
2995 SetFlag(kFlexibleRepresentation); | 3067 SetFlag(kFlexibleRepresentation); |
2996 SetAllSideEffects(); | |
2997 } | 3068 } |
2998 | 3069 |
2999 virtual void RepresentationChanged(Representation to) { | 3070 virtual void RepresentationChanged(Representation to) { |
3000 if (!to.IsTagged()) { | 3071 if (to.IsTagged()) { |
3072 SetAllSideEffects(); | |
3073 ClearFlag(kUseGVN); | |
3074 } else { | |
3001 ClearAllSideEffects(); | 3075 ClearAllSideEffects(); |
3002 SetFlag(kUseGVN); | 3076 SetFlag(kUseGVN); |
3003 } | 3077 } |
3004 } | 3078 } |
3005 | 3079 |
3006 virtual HType CalculateInferredType(); | 3080 virtual HType CalculateInferredType(); |
3007 virtual Representation RequiredInputRepresentation(int index) { | 3081 virtual Representation RequiredInputRepresentation(int index) { |
3008 return index == 0 | 3082 return index == 0 |
3009 ? Representation::Tagged() | 3083 ? Representation::Tagged() |
3010 : representation(); | 3084 : representation(); |
3011 } | 3085 } |
3012 | 3086 |
3013 virtual Representation InferredRepresentation() { | |
3014 if (left()->representation().Equals(right()->representation())) { | |
3015 return left()->representation(); | |
3016 } | |
3017 return HValue::InferredRepresentation(); | |
3018 } | |
3019 | |
3020 private: | 3087 private: |
3021 virtual bool IsDeletable() const { return true; } | 3088 virtual bool IsDeletable() const { return true; } |
3022 }; | 3089 }; |
3023 | 3090 |
3024 | 3091 |
3025 class HCompareGeneric: public HBinaryOperation { | 3092 class HCompareGeneric: public HBinaryOperation { |
3026 public: | 3093 public: |
3027 HCompareGeneric(HValue* context, | 3094 HCompareGeneric(HValue* context, |
3028 HValue* left, | 3095 HValue* left, |
3029 HValue* right, | 3096 HValue* right, |
3030 Token::Value token) | 3097 Token::Value token) |
3031 : HBinaryOperation(context, left, right), token_(token) { | 3098 : HBinaryOperation(context, left, right), token_(token) { |
3032 ASSERT(Token::IsCompareOp(token)); | 3099 ASSERT(Token::IsCompareOp(token)); |
3033 set_representation(Representation::Tagged()); | 3100 set_representation(Representation::Tagged()); |
3034 SetAllSideEffects(); | 3101 SetAllSideEffects(); |
3035 } | 3102 } |
3036 | 3103 |
3037 virtual Representation RequiredInputRepresentation(int index) { | 3104 virtual Representation RequiredInputRepresentation(int index) { |
3038 return Representation::Tagged(); | 3105 return index == 0 |
3039 } | 3106 ? Representation::Tagged() |
3040 | 3107 : representation(); |
3041 Representation GetInputRepresentation() const { | |
3042 return Representation::Tagged(); | |
3043 } | 3108 } |
3044 | 3109 |
3045 Token::Value token() const { return token_; } | 3110 Token::Value token() const { return token_; } |
3046 virtual void PrintDataTo(StringStream* stream); | 3111 virtual void PrintDataTo(StringStream* stream); |
3047 | 3112 |
3048 virtual HType CalculateInferredType(); | 3113 virtual HType CalculateInferredType(); |
3049 | 3114 |
3050 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) | 3115 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) |
3051 | 3116 |
3052 private: | 3117 private: |
3053 Token::Value token_; | 3118 Token::Value token_; |
3054 }; | 3119 }; |
3055 | 3120 |
3056 | 3121 |
3057 class HCompareIDAndBranch: public HTemplateControlInstruction<2, 2> { | 3122 class HCompareIDAndBranch: public HTemplateControlInstruction<2, 2> { |
3058 public: | 3123 public: |
3059 HCompareIDAndBranch(HValue* left, HValue* right, Token::Value token) | 3124 HCompareIDAndBranch(HValue* left, HValue* right, Token::Value token) |
3060 : token_(token) { | 3125 : token_(token) { |
3126 SetFlag(kFlexibleRepresentation); | |
3061 ASSERT(Token::IsCompareOp(token)); | 3127 ASSERT(Token::IsCompareOp(token)); |
3062 SetOperandAt(0, left); | 3128 SetOperandAt(0, left); |
3063 SetOperandAt(1, right); | 3129 SetOperandAt(1, right); |
3064 } | 3130 } |
3065 | 3131 |
3066 HValue* left() { return OperandAt(0); } | 3132 HValue* left() { return OperandAt(0); } |
3067 HValue* right() { return OperandAt(1); } | 3133 HValue* right() { return OperandAt(1); } |
3068 Token::Value token() const { return token_; } | 3134 Token::Value token() const { return token_; } |
3069 | 3135 |
3070 void SetInputRepresentation(Representation r); | 3136 void set_observed_input_representation(Representation left, |
3071 Representation GetInputRepresentation() const { | 3137 Representation right) { |
3072 return input_representation_; | 3138 observed_input_representation_[0] = left; |
3139 observed_input_representation_[1] = right; | |
3073 } | 3140 } |
3074 | 3141 |
3142 virtual void InferRepresentation(HInferRepresentation* hinfer); | |
3143 | |
3075 virtual Representation RequiredInputRepresentation(int index) { | 3144 virtual Representation RequiredInputRepresentation(int index) { |
3076 return input_representation_; | 3145 return representation(); |
3146 } | |
3147 virtual Representation observed_input_representation(int index) { | |
3148 return observed_input_representation_[index]; | |
3077 } | 3149 } |
3078 virtual void PrintDataTo(StringStream* stream); | 3150 virtual void PrintDataTo(StringStream* stream); |
3079 | 3151 |
3080 DECLARE_CONCRETE_INSTRUCTION(CompareIDAndBranch) | 3152 DECLARE_CONCRETE_INSTRUCTION(CompareIDAndBranch) |
3081 | 3153 |
3082 private: | 3154 private: |
3083 Representation input_representation_; | 3155 Representation observed_input_representation_[2]; |
3084 Token::Value token_; | 3156 Token::Value token_; |
3085 }; | 3157 }; |
3086 | 3158 |
3087 | 3159 |
3088 class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> { | 3160 class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> { |
3089 public: | 3161 public: |
3090 HCompareObjectEqAndBranch(HValue* left, HValue* right) { | 3162 HCompareObjectEqAndBranch(HValue* left, HValue* right) { |
3091 SetOperandAt(0, left); | 3163 SetOperandAt(0, left); |
3092 SetOperandAt(1, right); | 3164 SetOperandAt(1, right); |
3093 } | 3165 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3134 : HUnaryControlInstruction(value, NULL, NULL), kind_(kind), nil_(nil) { } | 3206 : HUnaryControlInstruction(value, NULL, NULL), kind_(kind), nil_(nil) { } |
3135 | 3207 |
3136 EqualityKind kind() const { return kind_; } | 3208 EqualityKind kind() const { return kind_; } |
3137 NilValue nil() const { return nil_; } | 3209 NilValue nil() const { return nil_; } |
3138 | 3210 |
3139 virtual void PrintDataTo(StringStream* stream); | 3211 virtual void PrintDataTo(StringStream* stream); |
3140 | 3212 |
3141 virtual Representation RequiredInputRepresentation(int index) { | 3213 virtual Representation RequiredInputRepresentation(int index) { |
3142 return Representation::Tagged(); | 3214 return Representation::Tagged(); |
3143 } | 3215 } |
3216 virtual Representation observed_input_representation(int index) { | |
3217 return Representation::Tagged(); | |
3218 } | |
3144 | 3219 |
3145 DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch) | 3220 DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch) |
3146 | 3221 |
3147 private: | 3222 private: |
3148 EqualityKind kind_; | 3223 EqualityKind kind_; |
3149 NilValue nil_; | 3224 NilValue nil_; |
3150 }; | 3225 }; |
3151 | 3226 |
3152 | 3227 |
3153 class HIsObjectAndBranch: public HUnaryControlInstruction { | 3228 class HIsObjectAndBranch: public HUnaryControlInstruction { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3411 } | 3486 } |
3412 | 3487 |
3413 HValue* left() { return OperandAt(0); } | 3488 HValue* left() { return OperandAt(0); } |
3414 HValue* right() const { return OperandAt(1); } | 3489 HValue* right() const { return OperandAt(1); } |
3415 | 3490 |
3416 virtual Representation RequiredInputRepresentation(int index) { | 3491 virtual Representation RequiredInputRepresentation(int index) { |
3417 return index == 0 | 3492 return index == 0 |
3418 ? Representation::Double() | 3493 ? Representation::Double() |
3419 : Representation::None(); | 3494 : Representation::None(); |
3420 } | 3495 } |
3496 virtual Representation observed_input_representation(int index) { | |
3497 return RequiredInputRepresentation(index); | |
3498 } | |
3421 | 3499 |
3422 DECLARE_CONCRETE_INSTRUCTION(Power) | 3500 DECLARE_CONCRETE_INSTRUCTION(Power) |
3423 | 3501 |
3424 protected: | 3502 protected: |
3425 virtual bool DataEquals(HValue* other) { return true; } | 3503 virtual bool DataEquals(HValue* other) { return true; } |
3426 | 3504 |
3427 private: | 3505 private: |
3428 virtual bool IsDeletable() const { | 3506 virtual bool IsDeletable() const { |
3429 return !right()->representation().IsTagged(); | 3507 return !right()->representation().IsTagged(); |
3430 } | 3508 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3596 | 3674 |
3597 class HMathMinMax: public HArithmeticBinaryOperation { | 3675 class HMathMinMax: public HArithmeticBinaryOperation { |
3598 public: | 3676 public: |
3599 enum Operation { kMathMin, kMathMax }; | 3677 enum Operation { kMathMin, kMathMax }; |
3600 | 3678 |
3601 HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) | 3679 HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) |
3602 : HArithmeticBinaryOperation(context, left, right), | 3680 : HArithmeticBinaryOperation(context, left, right), |
3603 operation_(op) { } | 3681 operation_(op) { } |
3604 | 3682 |
3605 virtual Representation RequiredInputRepresentation(int index) { | 3683 virtual Representation RequiredInputRepresentation(int index) { |
3606 return index == 0 | 3684 return index == 0 ? Representation::Tagged() |
3607 ? Representation::Tagged() | 3685 : representation(); |
3608 : representation(); | 3686 } |
3609 } | |
3610 | 3687 |
3611 virtual Representation InferredRepresentation() { | 3688 virtual Representation observed_input_representation(int index) { |
3612 if (left()->representation().IsInteger32() && | 3689 return RequiredInputRepresentation(index); |
3613 right()->representation().IsInteger32()) { | 3690 } |
3691 | |
3692 virtual Representation RepresentationFromInputs() { | |
3693 Representation left_rep = left()->representation(); | |
3694 Representation right_rep = right()->representation(); | |
3695 if ((left_rep.IsNone() || left_rep.IsInteger32()) && | |
3696 (right_rep.IsNone() || right_rep.IsInteger32())) { | |
3614 return Representation::Integer32(); | 3697 return Representation::Integer32(); |
3615 } | 3698 } |
3616 return Representation::Double(); | 3699 return Representation::Double(); |
3617 } | 3700 } |
3618 | 3701 |
3619 virtual bool IsCommutative() const { return true; } | 3702 virtual bool IsCommutative() const { return true; } |
3620 | 3703 |
3621 Operation operation() { return operation_; } | 3704 Operation operation() { return operation_; } |
3622 | 3705 |
3623 DECLARE_CONCRETE_INSTRUCTION(MathMinMax) | 3706 DECLARE_CONCRETE_INSTRUCTION(MathMinMax) |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4526 return Representation::Double(); | 4609 return Representation::Double(); |
4527 } | 4610 } |
4528 | 4611 |
4529 return is_external() ? Representation::Integer32() | 4612 return is_external() ? Representation::Integer32() |
4530 : Representation::Tagged(); | 4613 : Representation::Tagged(); |
4531 } | 4614 } |
4532 | 4615 |
4533 bool is_external() const { | 4616 bool is_external() const { |
4534 return IsExternalArrayElementsKind(elements_kind()); | 4617 return IsExternalArrayElementsKind(elements_kind()); |
4535 } | 4618 } |
4619 | |
4620 virtual Representation observed_input_representation(int index) { | |
4621 return RequiredInputRepresentation(index); | |
4622 } | |
4623 | |
4536 HValue* elements() { return OperandAt(0); } | 4624 HValue* elements() { return OperandAt(0); } |
4537 HValue* key() { return OperandAt(1); } | 4625 HValue* key() { return OperandAt(1); } |
4538 HValue* value() { return OperandAt(2); } | 4626 HValue* value() { return OperandAt(2); } |
4539 bool value_is_smi() const { | 4627 bool value_is_smi() const { |
4540 return IsFastSmiElementsKind(elements_kind_); | 4628 return IsFastSmiElementsKind(elements_kind_); |
4541 } | 4629 } |
4542 ElementsKind elements_kind() const { return elements_kind_; } | 4630 ElementsKind elements_kind() const { return elements_kind_; } |
4543 uint32_t index_offset() { return index_offset_; } | 4631 uint32_t index_offset() { return index_offset_; } |
4544 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } | 4632 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
4545 HValue* GetKey() { return key(); } | 4633 HValue* GetKey() { return key(); } |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5264 virtual bool IsDeletable() const { return true; } | 5352 virtual bool IsDeletable() const { return true; } |
5265 }; | 5353 }; |
5266 | 5354 |
5267 | 5355 |
5268 #undef DECLARE_INSTRUCTION | 5356 #undef DECLARE_INSTRUCTION |
5269 #undef DECLARE_CONCRETE_INSTRUCTION | 5357 #undef DECLARE_CONCRETE_INSTRUCTION |
5270 | 5358 |
5271 } } // namespace v8::internal | 5359 } } // namespace v8::internal |
5272 | 5360 |
5273 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 5361 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |