| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 V(MapEnumLength) \ | 148 V(MapEnumLength) \ |
| 149 V(MathFloorOfDiv) \ | 149 V(MathFloorOfDiv) \ |
| 150 V(MathMinMax) \ | 150 V(MathMinMax) \ |
| 151 V(Mod) \ | 151 V(Mod) \ |
| 152 V(Mul) \ | 152 V(Mul) \ |
| 153 V(OsrEntry) \ | 153 V(OsrEntry) \ |
| 154 V(OuterContext) \ | 154 V(OuterContext) \ |
| 155 V(Parameter) \ | 155 V(Parameter) \ |
| 156 V(Power) \ | 156 V(Power) \ |
| 157 V(PushArgument) \ | 157 V(PushArgument) \ |
| 158 V(Random) \ | |
| 159 V(RegExpLiteral) \ | 158 V(RegExpLiteral) \ |
| 160 V(Return) \ | 159 V(Return) \ |
| 161 V(Ror) \ | 160 V(Ror) \ |
| 162 V(Sar) \ | 161 V(Sar) \ |
| 163 V(SeqStringGetChar) \ | 162 V(SeqStringGetChar) \ |
| 164 V(SeqStringSetChar) \ | 163 V(SeqStringSetChar) \ |
| 165 V(Shl) \ | 164 V(Shl) \ |
| 166 V(Shr) \ | 165 V(Shr) \ |
| 167 V(Simulate) \ | 166 V(Simulate) \ |
| 168 V(StackCheck) \ | 167 V(StackCheck) \ |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 HValue(HType type = HType::Tagged()) | 634 HValue(HType type = HType::Tagged()) |
| 636 : block_(NULL), | 635 : block_(NULL), |
| 637 id_(kNoNumber), | 636 id_(kNoNumber), |
| 638 type_(type), | 637 type_(type), |
| 639 use_list_(NULL), | 638 use_list_(NULL), |
| 640 range_(NULL), | 639 range_(NULL), |
| 641 flags_(0) {} | 640 flags_(0) {} |
| 642 virtual ~HValue() {} | 641 virtual ~HValue() {} |
| 643 | 642 |
| 644 virtual int position() const { return RelocInfo::kNoPosition; } | 643 virtual int position() const { return RelocInfo::kNoPosition; } |
| 644 virtual int operand_position(int index) const { return position(); } |
| 645 | 645 |
| 646 HBasicBlock* block() const { return block_; } | 646 HBasicBlock* block() const { return block_; } |
| 647 void SetBlock(HBasicBlock* block); | 647 void SetBlock(HBasicBlock* block); |
| 648 int LoopWeight() const; | 648 int LoopWeight() const; |
| 649 | 649 |
| 650 // Note: Never call this method for an unlinked value. | 650 // Note: Never call this method for an unlinked value. |
| 651 Isolate* isolate() const; | 651 Isolate* isolate() const; |
| 652 | 652 |
| 653 int id() const { return id_; } | 653 int id() const { return id_; } |
| 654 void set_id(int id) { id_ = id; } | 654 void set_id(int id) { id_ = id; } |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 HValue* context, \ | 1098 HValue* context, \ |
| 1099 P1 p1, \ | 1099 P1 p1, \ |
| 1100 P2 p2, \ | 1100 P2 p2, \ |
| 1101 P3 p3, \ | 1101 P3 p3, \ |
| 1102 P4 p4, \ | 1102 P4 p4, \ |
| 1103 P5 p5) { \ | 1103 P5 p5) { \ |
| 1104 return new(zone) I(context, p1, p2, p3, p4, p5); \ | 1104 return new(zone) I(context, p1, p2, p3, p4, p5); \ |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 | 1107 |
| 1108 // A helper class to represent per-operand position information attached to |
| 1109 // the HInstruction in the compact form. Uses tagging to distinguish between |
| 1110 // case when only instruction's position is available and case when operands' |
| 1111 // positions are also available. |
| 1112 // In the first case it contains intruction's position as a tagged value. |
| 1113 // In the second case it points to an array which contains instruction's |
| 1114 // position and operands' positions. |
| 1115 // TODO(vegorov): what we really want to track here is a combination of |
| 1116 // source position and a script id because cross script inlining can easily |
| 1117 // result in optimized functions composed of several scripts. |
| 1118 class HPositionInfo { |
| 1119 public: |
| 1120 explicit HPositionInfo(int pos) : data_(TagPosition(pos)) { } |
| 1121 |
| 1122 int position() const { |
| 1123 if (has_operand_positions()) { |
| 1124 return static_cast<int>(operand_positions()[kInstructionPosIndex]); |
| 1125 } |
| 1126 return static_cast<int>(UntagPosition(data_)); |
| 1127 } |
| 1128 |
| 1129 void set_position(int pos) { |
| 1130 if (has_operand_positions()) { |
| 1131 operand_positions()[kInstructionPosIndex] = pos; |
| 1132 } else { |
| 1133 data_ = TagPosition(pos); |
| 1134 } |
| 1135 } |
| 1136 |
| 1137 void ensure_storage_for_operand_positions(Zone* zone, int operand_count) { |
| 1138 if (has_operand_positions()) { |
| 1139 return; |
| 1140 } |
| 1141 |
| 1142 const int length = kFirstOperandPosIndex + operand_count; |
| 1143 intptr_t* positions = |
| 1144 zone->NewArray<intptr_t>(length); |
| 1145 for (int i = 0; i < length; i++) { |
| 1146 positions[i] = RelocInfo::kNoPosition; |
| 1147 } |
| 1148 |
| 1149 const int pos = position(); |
| 1150 data_ = reinterpret_cast<intptr_t>(positions); |
| 1151 set_position(pos); |
| 1152 |
| 1153 ASSERT(has_operand_positions()); |
| 1154 } |
| 1155 |
| 1156 int operand_position(int idx) const { |
| 1157 if (!has_operand_positions()) { |
| 1158 return position(); |
| 1159 } |
| 1160 return static_cast<int>(*operand_position_slot(idx)); |
| 1161 } |
| 1162 |
| 1163 void set_operand_position(int idx, int pos) { |
| 1164 *operand_position_slot(idx) = pos; |
| 1165 } |
| 1166 |
| 1167 private: |
| 1168 static const intptr_t kInstructionPosIndex = 0; |
| 1169 static const intptr_t kFirstOperandPosIndex = 1; |
| 1170 |
| 1171 intptr_t* operand_position_slot(int idx) const { |
| 1172 ASSERT(has_operand_positions()); |
| 1173 return &(operand_positions()[kFirstOperandPosIndex + idx]); |
| 1174 } |
| 1175 |
| 1176 bool has_operand_positions() const { |
| 1177 return !IsTaggedPosition(data_); |
| 1178 } |
| 1179 |
| 1180 intptr_t* operand_positions() const { |
| 1181 ASSERT(has_operand_positions()); |
| 1182 return reinterpret_cast<intptr_t*>(data_); |
| 1183 } |
| 1184 |
| 1185 static const intptr_t kPositionTag = 1; |
| 1186 static const intptr_t kPositionShift = 1; |
| 1187 static bool IsTaggedPosition(intptr_t val) { |
| 1188 return (val & kPositionTag) != 0; |
| 1189 } |
| 1190 static intptr_t UntagPosition(intptr_t val) { |
| 1191 ASSERT(IsTaggedPosition(val)); |
| 1192 return val >> kPositionShift; |
| 1193 } |
| 1194 static intptr_t TagPosition(intptr_t val) { |
| 1195 const intptr_t result = (val << kPositionShift) | kPositionTag; |
| 1196 ASSERT(UntagPosition(result) == val); |
| 1197 return result; |
| 1198 } |
| 1199 |
| 1200 intptr_t data_; |
| 1201 }; |
| 1202 |
| 1203 |
| 1108 class HInstruction : public HValue { | 1204 class HInstruction : public HValue { |
| 1109 public: | 1205 public: |
| 1110 HInstruction* next() const { return next_; } | 1206 HInstruction* next() const { return next_; } |
| 1111 HInstruction* previous() const { return previous_; } | 1207 HInstruction* previous() const { return previous_; } |
| 1112 | 1208 |
| 1113 virtual void PrintTo(StringStream* stream) V8_OVERRIDE; | 1209 virtual void PrintTo(StringStream* stream) V8_OVERRIDE; |
| 1114 virtual void PrintDataTo(StringStream* stream); | 1210 virtual void PrintDataTo(StringStream* stream); |
| 1115 | 1211 |
| 1116 bool IsLinked() const { return block() != NULL; } | 1212 bool IsLinked() const { return block() != NULL; } |
| 1117 void Unlink(); | 1213 void Unlink(); |
| 1118 void InsertBefore(HInstruction* next); | 1214 void InsertBefore(HInstruction* next); |
| 1119 void InsertAfter(HInstruction* previous); | 1215 void InsertAfter(HInstruction* previous); |
| 1120 | 1216 |
| 1121 // The position is a write-once variable. | 1217 // The position is a write-once variable. |
| 1122 virtual int position() const V8_OVERRIDE { return position_; } | 1218 virtual int position() const V8_OVERRIDE { |
| 1123 bool has_position() const { return position_ != RelocInfo::kNoPosition; } | 1219 return position_.position(); |
| 1220 } |
| 1221 bool has_position() const { |
| 1222 return position_.position() != RelocInfo::kNoPosition; |
| 1223 } |
| 1124 void set_position(int position) { | 1224 void set_position(int position) { |
| 1125 ASSERT(!has_position()); | 1225 ASSERT(!has_position()); |
| 1126 ASSERT(position != RelocInfo::kNoPosition); | 1226 ASSERT(position != RelocInfo::kNoPosition); |
| 1127 position_ = position; | 1227 position_.set_position(position); |
| 1228 } |
| 1229 |
| 1230 virtual int operand_position(int index) const V8_OVERRIDE { |
| 1231 const int pos = position_.operand_position(index); |
| 1232 return (pos != RelocInfo::kNoPosition) ? pos : position(); |
| 1233 } |
| 1234 void set_operand_position(Zone* zone, int index, int pos) { |
| 1235 ASSERT(0 <= index && index < OperandCount()); |
| 1236 position_.ensure_storage_for_operand_positions(zone, OperandCount()); |
| 1237 position_.set_operand_position(index, pos); |
| 1128 } | 1238 } |
| 1129 | 1239 |
| 1130 bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); } | 1240 bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); } |
| 1131 | 1241 |
| 1132 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; | 1242 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; |
| 1133 | 1243 |
| 1134 #ifdef DEBUG | 1244 #ifdef DEBUG |
| 1135 virtual void Verify() V8_OVERRIDE; | 1245 virtual void Verify() V8_OVERRIDE; |
| 1136 #endif | 1246 #endif |
| 1137 | 1247 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1153 private: | 1263 private: |
| 1154 void InitializeAsFirst(HBasicBlock* block) { | 1264 void InitializeAsFirst(HBasicBlock* block) { |
| 1155 ASSERT(!IsLinked()); | 1265 ASSERT(!IsLinked()); |
| 1156 SetBlock(block); | 1266 SetBlock(block); |
| 1157 } | 1267 } |
| 1158 | 1268 |
| 1159 void PrintMnemonicTo(StringStream* stream); | 1269 void PrintMnemonicTo(StringStream* stream); |
| 1160 | 1270 |
| 1161 HInstruction* next_; | 1271 HInstruction* next_; |
| 1162 HInstruction* previous_; | 1272 HInstruction* previous_; |
| 1163 int position_; | 1273 HPositionInfo position_; |
| 1164 | 1274 |
| 1165 friend class HBasicBlock; | 1275 friend class HBasicBlock; |
| 1166 }; | 1276 }; |
| 1167 | 1277 |
| 1168 | 1278 |
| 1169 template<int V> | 1279 template<int V> |
| 1170 class HTemplateInstruction : public HInstruction { | 1280 class HTemplateInstruction : public HInstruction { |
| 1171 public: | 1281 public: |
| 1172 virtual int OperandCount() V8_FINAL V8_OVERRIDE { return V; } | 1282 virtual int OperandCount() V8_FINAL V8_OVERRIDE { return V; } |
| 1173 virtual HValue* OperandAt(int i) const V8_FINAL V8_OVERRIDE { | 1283 virtual HValue* OperandAt(int i) const V8_FINAL V8_OVERRIDE { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 | 1667 |
| 1558 DECLARE_CONCRETE_INSTRUCTION(UseConst) | 1668 DECLARE_CONCRETE_INSTRUCTION(UseConst) |
| 1559 | 1669 |
| 1560 private: | 1670 private: |
| 1561 explicit HUseConst(HValue* old_value) : HUnaryOperation(old_value) { } | 1671 explicit HUseConst(HValue* old_value) : HUnaryOperation(old_value) { } |
| 1562 }; | 1672 }; |
| 1563 | 1673 |
| 1564 | 1674 |
| 1565 class HForceRepresentation V8_FINAL : public HTemplateInstruction<1> { | 1675 class HForceRepresentation V8_FINAL : public HTemplateInstruction<1> { |
| 1566 public: | 1676 public: |
| 1567 DECLARE_INSTRUCTION_FACTORY_P2(HForceRepresentation, HValue*, Representation); | 1677 static HInstruction* New(Zone* zone, HValue* context, HValue* value, |
| 1678 Representation required_representation); |
| 1568 | 1679 |
| 1569 HValue* value() { return OperandAt(0); } | 1680 HValue* value() { return OperandAt(0); } |
| 1570 | 1681 |
| 1571 virtual HValue* EnsureAndPropagateNotMinusZero( | 1682 virtual HValue* EnsureAndPropagateNotMinusZero( |
| 1572 BitVector* visited) V8_OVERRIDE; | 1683 BitVector* visited) V8_OVERRIDE; |
| 1573 | 1684 |
| 1574 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 1685 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 1575 return representation(); // Same as the output representation. | 1686 return representation(); // Same as the output representation. |
| 1576 } | 1687 } |
| 1577 | 1688 |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2279 | 2390 |
| 2280 private: | 2391 private: |
| 2281 HCallNamed(HValue* context, Handle<String> name, int argument_count) | 2392 HCallNamed(HValue* context, Handle<String> name, int argument_count) |
| 2282 : HUnaryCall(context, argument_count), name_(name) { | 2393 : HUnaryCall(context, argument_count), name_(name) { |
| 2283 } | 2394 } |
| 2284 | 2395 |
| 2285 Handle<String> name_; | 2396 Handle<String> name_; |
| 2286 }; | 2397 }; |
| 2287 | 2398 |
| 2288 | 2399 |
| 2400 enum CallMode { |
| 2401 NORMAL_CALL, |
| 2402 TAIL_CALL |
| 2403 }; |
| 2404 |
| 2405 |
| 2289 class HCallFunction V8_FINAL : public HBinaryCall { | 2406 class HCallFunction V8_FINAL : public HBinaryCall { |
| 2290 public: | 2407 public: |
| 2291 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HCallFunction, HValue*, int); | 2408 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HCallFunction, HValue*, int); |
| 2409 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3( |
| 2410 HCallFunction, HValue*, int, CallMode); |
| 2411 |
| 2412 bool IsTailCall() const { return call_mode_ == TAIL_CALL; } |
| 2292 | 2413 |
| 2293 HValue* context() { return first(); } | 2414 HValue* context() { return first(); } |
| 2294 HValue* function() { return second(); } | 2415 HValue* function() { return second(); } |
| 2295 | 2416 |
| 2296 DECLARE_CONCRETE_INSTRUCTION(CallFunction) | 2417 DECLARE_CONCRETE_INSTRUCTION(CallFunction) |
| 2297 | 2418 |
| 2419 virtual int argument_delta() const V8_OVERRIDE { |
| 2420 if (IsTailCall()) return 0; |
| 2421 return -argument_count(); |
| 2422 } |
| 2423 |
| 2298 private: | 2424 private: |
| 2299 HCallFunction(HValue* context, HValue* function, int argument_count) | 2425 HCallFunction(HValue* context, |
| 2300 : HBinaryCall(context, function, argument_count) { | 2426 HValue* function, |
| 2427 int argument_count, |
| 2428 CallMode mode = NORMAL_CALL) |
| 2429 : HBinaryCall(context, function, argument_count), call_mode_(mode) { |
| 2301 } | 2430 } |
| 2431 CallMode call_mode_; |
| 2302 }; | 2432 }; |
| 2303 | 2433 |
| 2304 | 2434 |
| 2305 class HCallGlobal V8_FINAL : public HUnaryCall { | 2435 class HCallGlobal V8_FINAL : public HUnaryCall { |
| 2306 public: | 2436 public: |
| 2307 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HCallGlobal, Handle<String>, int); | 2437 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HCallGlobal, Handle<String>, int); |
| 2308 | 2438 |
| 2309 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 2439 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 2310 | 2440 |
| 2311 HValue* context() { return value(); } | 2441 HValue* context() { return value(); } |
| (...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3678 | 3808 |
| 3679 virtual bool IsCommutative() const { return false; } | 3809 virtual bool IsCommutative() const { return false; } |
| 3680 | 3810 |
| 3681 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 3811 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 3682 | 3812 |
| 3683 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 3813 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 3684 if (index == 0) return Representation::Tagged(); | 3814 if (index == 0) return Representation::Tagged(); |
| 3685 return representation(); | 3815 return representation(); |
| 3686 } | 3816 } |
| 3687 | 3817 |
| 3818 void SetOperandPositions(Zone* zone, int left_pos, int right_pos) { |
| 3819 set_operand_position(zone, 1, left_pos); |
| 3820 set_operand_position(zone, 2, right_pos); |
| 3821 } |
| 3822 |
| 3688 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) | 3823 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) |
| 3689 | 3824 |
| 3690 private: | 3825 private: |
| 3691 bool IgnoreObservedOutputRepresentation(Representation current_rep); | 3826 bool IgnoreObservedOutputRepresentation(Representation current_rep); |
| 3692 | 3827 |
| 3693 Representation observed_input_representation_[2]; | 3828 Representation observed_input_representation_[2]; |
| 3694 Representation observed_output_representation_; | 3829 Representation observed_output_representation_; |
| 3695 }; | 3830 }; |
| 3696 | 3831 |
| 3697 | 3832 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4111 HInferRepresentationPhase* h_infer) V8_OVERRIDE; | 4246 HInferRepresentationPhase* h_infer) V8_OVERRIDE; |
| 4112 | 4247 |
| 4113 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 4248 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 4114 return representation(); | 4249 return representation(); |
| 4115 } | 4250 } |
| 4116 virtual Representation observed_input_representation(int index) V8_OVERRIDE { | 4251 virtual Representation observed_input_representation(int index) V8_OVERRIDE { |
| 4117 return observed_input_representation_[index]; | 4252 return observed_input_representation_[index]; |
| 4118 } | 4253 } |
| 4119 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 4254 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 4120 | 4255 |
| 4256 void SetOperandPositions(Zone* zone, int left_pos, int right_pos) { |
| 4257 set_operand_position(zone, 0, left_pos); |
| 4258 set_operand_position(zone, 1, right_pos); |
| 4259 } |
| 4260 |
| 4121 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) | 4261 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) |
| 4122 | 4262 |
| 4123 private: | 4263 private: |
| 4124 HCompareNumericAndBranch(HValue* left, | 4264 HCompareNumericAndBranch(HValue* left, |
| 4125 HValue* right, | 4265 HValue* right, |
| 4126 Token::Value token, | 4266 Token::Value token, |
| 4127 HBasicBlock* true_target = NULL, | 4267 HBasicBlock* true_target = NULL, |
| 4128 HBasicBlock* false_target = NULL) | 4268 HBasicBlock* false_target = NULL) |
| 4129 : token_(token) { | 4269 : token_(token) { |
| 4130 SetFlag(kFlexibleRepresentation); | 4270 SetFlag(kFlexibleRepresentation); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4461 | 4601 |
| 4462 Handle<String> class_name_; | 4602 Handle<String> class_name_; |
| 4463 }; | 4603 }; |
| 4464 | 4604 |
| 4465 | 4605 |
| 4466 class HTypeofIsAndBranch V8_FINAL : public HUnaryControlInstruction { | 4606 class HTypeofIsAndBranch V8_FINAL : public HUnaryControlInstruction { |
| 4467 public: | 4607 public: |
| 4468 DECLARE_INSTRUCTION_FACTORY_P2(HTypeofIsAndBranch, HValue*, Handle<String>); | 4608 DECLARE_INSTRUCTION_FACTORY_P2(HTypeofIsAndBranch, HValue*, Handle<String>); |
| 4469 | 4609 |
| 4470 Handle<String> type_literal() { return type_literal_; } | 4610 Handle<String> type_literal() { return type_literal_; } |
| 4611 bool compares_number_type() { return compares_number_type_; } |
| 4471 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 4612 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 4472 | 4613 |
| 4473 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch) | 4614 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch) |
| 4474 | 4615 |
| 4475 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 4616 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 4476 return Representation::Tagged(); | 4617 return Representation::None(); |
| 4477 } | 4618 } |
| 4478 | 4619 |
| 4620 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE; |
| 4621 |
| 4479 private: | 4622 private: |
| 4480 HTypeofIsAndBranch(HValue* value, Handle<String> type_literal) | 4623 HTypeofIsAndBranch(HValue* value, Handle<String> type_literal) |
| 4481 : HUnaryControlInstruction(value, NULL, NULL), | 4624 : HUnaryControlInstruction(value, NULL, NULL), |
| 4482 type_literal_(type_literal) { } | 4625 type_literal_(type_literal) { |
| 4626 Heap* heap = type_literal->GetHeap(); |
| 4627 compares_number_type_ = type_literal->Equals(heap->number_string()); |
| 4628 } |
| 4483 | 4629 |
| 4484 Handle<String> type_literal_; | 4630 Handle<String> type_literal_; |
| 4631 bool compares_number_type_ : 1; |
| 4485 }; | 4632 }; |
| 4486 | 4633 |
| 4487 | 4634 |
| 4488 class HInstanceOf V8_FINAL : public HBinaryOperation { | 4635 class HInstanceOf V8_FINAL : public HBinaryOperation { |
| 4489 public: | 4636 public: |
| 4490 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HInstanceOf, HValue*, HValue*); | 4637 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HInstanceOf, HValue*, HValue*); |
| 4491 | 4638 |
| 4492 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 4639 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 4493 return Representation::Tagged(); | 4640 return Representation::Tagged(); |
| 4494 } | 4641 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4569 SetFlag(kUseGVN); | 4716 SetFlag(kUseGVN); |
| 4570 SetGVNFlag(kChangesNewSpacePromotion); | 4717 SetGVNFlag(kChangesNewSpacePromotion); |
| 4571 } | 4718 } |
| 4572 | 4719 |
| 4573 virtual bool IsDeletable() const V8_OVERRIDE { | 4720 virtual bool IsDeletable() const V8_OVERRIDE { |
| 4574 return !right()->representation().IsTagged(); | 4721 return !right()->representation().IsTagged(); |
| 4575 } | 4722 } |
| 4576 }; | 4723 }; |
| 4577 | 4724 |
| 4578 | 4725 |
| 4579 class HRandom V8_FINAL : public HTemplateInstruction<1> { | |
| 4580 public: | |
| 4581 DECLARE_INSTRUCTION_FACTORY_P1(HRandom, HValue*); | |
| 4582 | |
| 4583 HValue* global_object() { return OperandAt(0); } | |
| 4584 | |
| 4585 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | |
| 4586 return Representation::Tagged(); | |
| 4587 } | |
| 4588 | |
| 4589 DECLARE_CONCRETE_INSTRUCTION(Random) | |
| 4590 | |
| 4591 private: | |
| 4592 explicit HRandom(HValue* global_object) { | |
| 4593 SetOperandAt(0, global_object); | |
| 4594 set_representation(Representation::Double()); | |
| 4595 } | |
| 4596 | |
| 4597 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | |
| 4598 }; | |
| 4599 | |
| 4600 | |
| 4601 class HAdd V8_FINAL : public HArithmeticBinaryOperation { | 4726 class HAdd V8_FINAL : public HArithmeticBinaryOperation { |
| 4602 public: | 4727 public: |
| 4603 static HInstruction* New(Zone* zone, | 4728 static HInstruction* New(Zone* zone, |
| 4604 HValue* context, | 4729 HValue* context, |
| 4605 HValue* left, | 4730 HValue* left, |
| 4606 HValue* right); | 4731 HValue* right); |
| 4607 | 4732 |
| 4608 // Add is only commutative if two integer values are added and not if two | 4733 // Add is only commutative if two integer values are added and not if two |
| 4609 // tagged values are added (because it might be a String concatenation). | 4734 // tagged values are added (because it might be a String concatenation). |
| 4610 virtual bool IsCommutative() const V8_OVERRIDE { | 4735 virtual bool IsCommutative() const V8_OVERRIDE { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4746 SetFlag(kCanOverflow); | 4871 SetFlag(kCanOverflow); |
| 4747 } | 4872 } |
| 4748 }; | 4873 }; |
| 4749 | 4874 |
| 4750 | 4875 |
| 4751 class HMod V8_FINAL : public HArithmeticBinaryOperation { | 4876 class HMod V8_FINAL : public HArithmeticBinaryOperation { |
| 4752 public: | 4877 public: |
| 4753 static HInstruction* New(Zone* zone, | 4878 static HInstruction* New(Zone* zone, |
| 4754 HValue* context, | 4879 HValue* context, |
| 4755 HValue* left, | 4880 HValue* left, |
| 4756 HValue* right, | 4881 HValue* right); |
| 4757 Maybe<int> fixed_right_arg); | |
| 4758 | |
| 4759 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } | |
| 4760 | 4882 |
| 4761 bool HasPowerOf2Divisor() { | 4883 bool HasPowerOf2Divisor() { |
| 4762 if (right()->IsConstant() && | 4884 if (right()->IsConstant() && |
| 4763 HConstant::cast(right())->HasInteger32Value()) { | 4885 HConstant::cast(right())->HasInteger32Value()) { |
| 4764 int32_t value = HConstant::cast(right())->Integer32Value(); | 4886 int32_t value = HConstant::cast(right())->Integer32Value(); |
| 4765 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); | 4887 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); |
| 4766 } | 4888 } |
| 4767 | 4889 |
| 4768 return false; | 4890 return false; |
| 4769 } | 4891 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4783 DECLARE_CONCRETE_INSTRUCTION(Mod) | 4905 DECLARE_CONCRETE_INSTRUCTION(Mod) |
| 4784 | 4906 |
| 4785 protected: | 4907 protected: |
| 4786 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } | 4908 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } |
| 4787 | 4909 |
| 4788 virtual Range* InferRange(Zone* zone) V8_OVERRIDE; | 4910 virtual Range* InferRange(Zone* zone) V8_OVERRIDE; |
| 4789 | 4911 |
| 4790 private: | 4912 private: |
| 4791 HMod(HValue* context, | 4913 HMod(HValue* context, |
| 4792 HValue* left, | 4914 HValue* left, |
| 4793 HValue* right, | 4915 HValue* right) : HArithmeticBinaryOperation(context, left, right) { |
| 4794 Maybe<int> fixed_right_arg) | |
| 4795 : HArithmeticBinaryOperation(context, left, right), | |
| 4796 fixed_right_arg_(fixed_right_arg) { | |
| 4797 SetFlag(kCanBeDivByZero); | 4916 SetFlag(kCanBeDivByZero); |
| 4798 SetFlag(kCanOverflow); | 4917 SetFlag(kCanOverflow); |
| 4799 } | 4918 } |
| 4800 | |
| 4801 const Maybe<int> fixed_right_arg_; | |
| 4802 }; | 4919 }; |
| 4803 | 4920 |
| 4804 | 4921 |
| 4805 class HDiv V8_FINAL : public HArithmeticBinaryOperation { | 4922 class HDiv V8_FINAL : public HArithmeticBinaryOperation { |
| 4806 public: | 4923 public: |
| 4807 static HInstruction* New(Zone* zone, | 4924 static HInstruction* New(Zone* zone, |
| 4808 HValue* context, | 4925 HValue* context, |
| 4809 HValue* left, | 4926 HValue* left, |
| 4810 HValue* right); | 4927 HValue* right); |
| 4811 | 4928 |
| (...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6115 SetFlag(kUseGVN); | 6232 SetFlag(kUseGVN); |
| 6116 SetGVNFlag(kDependsOnCalls); | 6233 SetGVNFlag(kDependsOnCalls); |
| 6117 } | 6234 } |
| 6118 }; | 6235 }; |
| 6119 | 6236 |
| 6120 class ArrayInstructionInterface { | 6237 class ArrayInstructionInterface { |
| 6121 public: | 6238 public: |
| 6122 virtual HValue* GetKey() = 0; | 6239 virtual HValue* GetKey() = 0; |
| 6123 virtual void SetKey(HValue* key) = 0; | 6240 virtual void SetKey(HValue* key) = 0; |
| 6124 virtual void SetIndexOffset(uint32_t index_offset) = 0; | 6241 virtual void SetIndexOffset(uint32_t index_offset) = 0; |
| 6242 virtual int MaxIndexOffsetBits() = 0; |
| 6125 virtual bool IsDehoisted() = 0; | 6243 virtual bool IsDehoisted() = 0; |
| 6126 virtual void SetDehoisted(bool is_dehoisted) = 0; | 6244 virtual void SetDehoisted(bool is_dehoisted) = 0; |
| 6127 virtual ~ArrayInstructionInterface() { }; | 6245 virtual ~ArrayInstructionInterface() { }; |
| 6128 | 6246 |
| 6129 static Representation KeyedAccessIndexRequirement(Representation r) { | 6247 static Representation KeyedAccessIndexRequirement(Representation r) { |
| 6130 return r.IsInteger32() || SmiValuesAre32Bits() | 6248 return r.IsInteger32() || SmiValuesAre32Bits() |
| 6131 ? Representation::Integer32() : Representation::Smi(); | 6249 ? Representation::Integer32() : Representation::Smi(); |
| 6132 } | 6250 } |
| 6133 }; | 6251 }; |
| 6134 | 6252 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6154 HValue* key() { return OperandAt(1); } | 6272 HValue* key() { return OperandAt(1); } |
| 6155 HValue* dependency() { | 6273 HValue* dependency() { |
| 6156 ASSERT(HasDependency()); | 6274 ASSERT(HasDependency()); |
| 6157 return OperandAt(2); | 6275 return OperandAt(2); |
| 6158 } | 6276 } |
| 6159 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } | 6277 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } |
| 6160 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } | 6278 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } |
| 6161 void SetIndexOffset(uint32_t index_offset) { | 6279 void SetIndexOffset(uint32_t index_offset) { |
| 6162 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); | 6280 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); |
| 6163 } | 6281 } |
| 6282 virtual int MaxIndexOffsetBits() { |
| 6283 return kBitsForIndexOffset; |
| 6284 } |
| 6164 HValue* GetKey() { return key(); } | 6285 HValue* GetKey() { return key(); } |
| 6165 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6286 void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 6166 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } | 6287 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
| 6167 void SetDehoisted(bool is_dehoisted) { | 6288 void SetDehoisted(bool is_dehoisted) { |
| 6168 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); | 6289 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
| 6169 } | 6290 } |
| 6170 ElementsKind elements_kind() const { | 6291 ElementsKind elements_kind() const { |
| 6171 return ElementsKindField::decode(bit_field_); | 6292 return ElementsKindField::decode(bit_field_); |
| 6172 } | 6293 } |
| 6173 LoadKeyedHoleMode hole_mode() const { | 6294 LoadKeyedHoleMode hole_mode() const { |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6540 | 6661 |
| 6541 HValue* elements() { return OperandAt(0); } | 6662 HValue* elements() { return OperandAt(0); } |
| 6542 HValue* key() { return OperandAt(1); } | 6663 HValue* key() { return OperandAt(1); } |
| 6543 HValue* value() { return OperandAt(2); } | 6664 HValue* value() { return OperandAt(2); } |
| 6544 bool value_is_smi() const { | 6665 bool value_is_smi() const { |
| 6545 return IsFastSmiElementsKind(elements_kind_); | 6666 return IsFastSmiElementsKind(elements_kind_); |
| 6546 } | 6667 } |
| 6547 ElementsKind elements_kind() const { return elements_kind_; } | 6668 ElementsKind elements_kind() const { return elements_kind_; } |
| 6548 uint32_t index_offset() { return index_offset_; } | 6669 uint32_t index_offset() { return index_offset_; } |
| 6549 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } | 6670 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
| 6671 virtual int MaxIndexOffsetBits() { |
| 6672 return 31 - ElementsKindToShiftSize(elements_kind_); |
| 6673 } |
| 6550 HValue* GetKey() { return key(); } | 6674 HValue* GetKey() { return key(); } |
| 6551 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6675 void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 6552 bool IsDehoisted() { return is_dehoisted_; } | 6676 bool IsDehoisted() { return is_dehoisted_; } |
| 6553 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | 6677 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
| 6554 bool IsUninitialized() { return is_uninitialized_; } | 6678 bool IsUninitialized() { return is_uninitialized_; } |
| 6555 void SetUninitialized(bool is_uninitialized) { | 6679 void SetUninitialized(bool is_uninitialized) { |
| 6556 is_uninitialized_ = is_uninitialized; | 6680 is_uninitialized_ = is_uninitialized; |
| 6557 } | 6681 } |
| 6558 | 6682 |
| 6559 bool IsConstantHoleStore() { | 6683 bool IsConstantHoleStore() { |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7120 SetFlag(kUseGVN); | 7244 SetFlag(kUseGVN); |
| 7121 SetGVNFlag(kDependsOnStringChars); | 7245 SetGVNFlag(kDependsOnStringChars); |
| 7122 } | 7246 } |
| 7123 | 7247 |
| 7124 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7248 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
| 7125 | 7249 |
| 7126 String::Encoding encoding_; | 7250 String::Encoding encoding_; |
| 7127 }; | 7251 }; |
| 7128 | 7252 |
| 7129 | 7253 |
| 7130 class HSeqStringSetChar V8_FINAL : public HTemplateInstruction<3> { | 7254 class HSeqStringSetChar V8_FINAL : public HTemplateInstruction<4> { |
| 7131 public: | 7255 public: |
| 7132 DECLARE_INSTRUCTION_FACTORY_P4(HSeqStringSetChar, String::Encoding, | 7256 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4( |
| 7133 HValue*, HValue*, HValue*); | 7257 HSeqStringSetChar, String::Encoding, |
| 7258 HValue*, HValue*, HValue*); |
| 7134 | 7259 |
| 7135 String::Encoding encoding() { return encoding_; } | 7260 String::Encoding encoding() { return encoding_; } |
| 7136 HValue* string() { return OperandAt(0); } | 7261 HValue* context() { return OperandAt(0); } |
| 7137 HValue* index() { return OperandAt(1); } | 7262 HValue* string() { return OperandAt(1); } |
| 7138 HValue* value() { return OperandAt(2); } | 7263 HValue* index() { return OperandAt(2); } |
| 7264 HValue* value() { return OperandAt(3); } |
| 7139 | 7265 |
| 7140 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 7266 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 7141 return (index == 0) ? Representation::Tagged() | 7267 return (index <= 1) ? Representation::Tagged() |
| 7142 : Representation::Integer32(); | 7268 : Representation::Integer32(); |
| 7143 } | 7269 } |
| 7144 | 7270 |
| 7145 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar) | 7271 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar) |
| 7146 | 7272 |
| 7147 private: | 7273 private: |
| 7148 HSeqStringSetChar(String::Encoding encoding, | 7274 HSeqStringSetChar(HValue* context, |
| 7275 String::Encoding encoding, |
| 7149 HValue* string, | 7276 HValue* string, |
| 7150 HValue* index, | 7277 HValue* index, |
| 7151 HValue* value) : encoding_(encoding) { | 7278 HValue* value) : encoding_(encoding) { |
| 7152 SetOperandAt(0, string); | 7279 SetOperandAt(0, context); |
| 7153 SetOperandAt(1, index); | 7280 SetOperandAt(1, string); |
| 7154 SetOperandAt(2, value); | 7281 SetOperandAt(2, index); |
| 7282 SetOperandAt(3, value); |
| 7155 set_representation(Representation::Tagged()); | 7283 set_representation(Representation::Tagged()); |
| 7156 SetGVNFlag(kChangesStringChars); | 7284 SetGVNFlag(kChangesStringChars); |
| 7157 } | 7285 } |
| 7158 | 7286 |
| 7159 String::Encoding encoding_; | 7287 String::Encoding encoding_; |
| 7160 }; | 7288 }; |
| 7161 | 7289 |
| 7162 | 7290 |
| 7163 class HCheckMapValue V8_FINAL : public HTemplateInstruction<2> { | 7291 class HCheckMapValue V8_FINAL : public HTemplateInstruction<2> { |
| 7164 public: | 7292 public: |
| 7165 DECLARE_INSTRUCTION_FACTORY_P2(HCheckMapValue, HValue*, HValue*); | 7293 DECLARE_INSTRUCTION_FACTORY_P2(HCheckMapValue, HValue*, HValue*); |
| 7166 | 7294 |
| 7167 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 7295 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 7168 return Representation::Tagged(); | 7296 return Representation::Tagged(); |
| 7169 } | 7297 } |
| 7170 | 7298 |
| 7171 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 7299 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 7172 | 7300 |
| 7173 virtual HType CalculateInferredType() V8_OVERRIDE { | 7301 virtual HType CalculateInferredType() V8_OVERRIDE { |
| 7174 return HType::Tagged(); | 7302 return HType::Tagged(); |
| 7175 } | 7303 } |
| 7176 | 7304 |
| 7177 HValue* value() { return OperandAt(0); } | 7305 HValue* value() { return OperandAt(0); } |
| 7178 HValue* map() { return OperandAt(1); } | 7306 HValue* map() { return OperandAt(1); } |
| 7179 | 7307 |
| 7180 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue) | 7308 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue) |
| 7181 | 7309 |
| 7182 protected: | 7310 protected: |
| 7311 virtual int RedefinedOperandIndex() { return 0; } |
| 7312 |
| 7183 virtual bool DataEquals(HValue* other) V8_OVERRIDE { | 7313 virtual bool DataEquals(HValue* other) V8_OVERRIDE { |
| 7184 return true; | 7314 return true; |
| 7185 } | 7315 } |
| 7186 | 7316 |
| 7187 private: | 7317 private: |
| 7188 HCheckMapValue(HValue* value, | 7318 HCheckMapValue(HValue* value, |
| 7189 HValue* map) { | 7319 HValue* map) { |
| 7190 SetOperandAt(0, value); | 7320 SetOperandAt(0, value); |
| 7191 SetOperandAt(1, map); | 7321 SetOperandAt(1, map); |
| 7192 set_representation(Representation::Tagged()); | 7322 set_representation(Representation::Tagged()); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7297 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7427 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
| 7298 }; | 7428 }; |
| 7299 | 7429 |
| 7300 | 7430 |
| 7301 #undef DECLARE_INSTRUCTION | 7431 #undef DECLARE_INSTRUCTION |
| 7302 #undef DECLARE_CONCRETE_INSTRUCTION | 7432 #undef DECLARE_CONCRETE_INSTRUCTION |
| 7303 | 7433 |
| 7304 } } // namespace v8::internal | 7434 } } // namespace v8::internal |
| 7305 | 7435 |
| 7306 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7436 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |