Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: src/hydrogen-instructions.h

Issue 22876009: Improve and simplify removal of unreachable code (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review feedback Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-gvn.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 static const int kNoRedefinedOperand = -1; 714 static const int kNoRedefinedOperand = -1;
715 virtual int RedefinedOperandIndex() { return kNoRedefinedOperand; } 715 virtual int RedefinedOperandIndex() { return kNoRedefinedOperand; }
716 bool IsInformativeDefinition() { 716 bool IsInformativeDefinition() {
717 return RedefinedOperandIndex() != kNoRedefinedOperand; 717 return RedefinedOperandIndex() != kNoRedefinedOperand;
718 } 718 }
719 HValue* RedefinedOperand() { 719 HValue* RedefinedOperand() {
720 int index = RedefinedOperandIndex(); 720 int index = RedefinedOperandIndex();
721 return index == kNoRedefinedOperand ? NULL : OperandAt(index); 721 return index == kNoRedefinedOperand ? NULL : OperandAt(index);
722 } 722 }
723 723
724 bool CanReplaceWithDummyUses();
725
724 // A purely informative definition is an idef that will not emit code and 726 // A purely informative definition is an idef that will not emit code and
725 // should therefore be removed from the graph in the RestoreActualValues 727 // should therefore be removed from the graph in the RestoreActualValues
726 // phase (so that live ranges will be shorter). 728 // phase (so that live ranges will be shorter).
727 virtual bool IsPurelyInformativeDefinition() { return false; } 729 virtual bool IsPurelyInformativeDefinition() { return false; }
728 730
729 // This method must always return the original HValue SSA definition, 731 // This method must always return the original HValue SSA definition,
730 // regardless of any chain of iDefs of this value. 732 // regardless of any chain of iDefs of this value.
731 HValue* ActualValue() { 733 HValue* ActualValue() {
732 HValue* value = this; 734 HValue* value = this;
733 int index; 735 int index;
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1178
1177 1179
1178 class HControlInstruction : public HInstruction { 1180 class HControlInstruction : public HInstruction {
1179 public: 1181 public:
1180 virtual HBasicBlock* SuccessorAt(int i) = 0; 1182 virtual HBasicBlock* SuccessorAt(int i) = 0;
1181 virtual int SuccessorCount() = 0; 1183 virtual int SuccessorCount() = 0;
1182 virtual void SetSuccessorAt(int i, HBasicBlock* block) = 0; 1184 virtual void SetSuccessorAt(int i, HBasicBlock* block) = 0;
1183 1185
1184 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 1186 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1185 1187
1188 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE {
1189 *block = NULL;
1190 return false;
1191 }
1192
1186 HBasicBlock* FirstSuccessor() { 1193 HBasicBlock* FirstSuccessor() {
1187 return SuccessorCount() > 0 ? SuccessorAt(0) : NULL; 1194 return SuccessorCount() > 0 ? SuccessorAt(0) : NULL;
1188 } 1195 }
1189 HBasicBlock* SecondSuccessor() { 1196 HBasicBlock* SecondSuccessor() {
1190 return SuccessorCount() > 1 ? SuccessorAt(1) : NULL; 1197 return SuccessorCount() > 1 ? SuccessorAt(1) : NULL;
1191 } 1198 }
1192 1199
1193 void Not() { 1200 void Not() {
1194 HBasicBlock* swap = SuccessorAt(0); 1201 HBasicBlock* swap = SuccessorAt(0);
1195 SetSuccessorAt(0, SuccessorAt(1)); 1202 SetSuccessorAt(0, SuccessorAt(1));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 1272 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1266 return Representation::None(); 1273 return Representation::None();
1267 } 1274 }
1268 1275
1269 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 1276 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1270 1277
1271 DECLARE_CONCRETE_INSTRUCTION(DummyUse); 1278 DECLARE_CONCRETE_INSTRUCTION(DummyUse);
1272 }; 1279 };
1273 1280
1274 1281
1275 class HDeoptimize V8_FINAL : public HTemplateInstruction<0> {
1276 public:
1277 DECLARE_INSTRUCTION_FACTORY_P2(HDeoptimize, const char*,
1278 Deoptimizer::BailoutType);
1279
1280 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1281 return Representation::None();
1282 }
1283
1284 const char* reason() const { return reason_; }
1285 Deoptimizer::BailoutType type() { return type_; }
1286
1287 DECLARE_CONCRETE_INSTRUCTION(Deoptimize)
1288
1289 private:
1290 explicit HDeoptimize(const char* reason, Deoptimizer::BailoutType type)
1291 : reason_(reason), type_(type) {}
1292
1293 const char* reason_;
1294 Deoptimizer::BailoutType type_;
1295 };
1296
1297
1298 // Inserts an int3/stop break instruction for debugging purposes. 1282 // Inserts an int3/stop break instruction for debugging purposes.
1299 class HDebugBreak V8_FINAL : public HTemplateInstruction<0> { 1283 class HDebugBreak V8_FINAL : public HTemplateInstruction<0> {
1300 public: 1284 public:
1301 DECLARE_INSTRUCTION_FACTORY_P0(HDebugBreak); 1285 DECLARE_INSTRUCTION_FACTORY_P0(HDebugBreak);
1302 1286
1303 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 1287 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1304 return Representation::None(); 1288 return Representation::None();
1305 } 1289 }
1306 1290
1307 DECLARE_CONCRETE_INSTRUCTION(DebugBreak) 1291 DECLARE_CONCRETE_INSTRUCTION(DebugBreak)
1308 }; 1292 };
1309 1293
1310 1294
1311 class HGoto V8_FINAL : public HTemplateControlInstruction<1, 0> { 1295 class HGoto V8_FINAL : public HTemplateControlInstruction<1, 0> {
1312 public: 1296 public:
1313 explicit HGoto(HBasicBlock* target) { 1297 explicit HGoto(HBasicBlock* target) {
1314 SetSuccessorAt(0, target); 1298 SetSuccessorAt(0, target);
1315 } 1299 }
1316 1300
1301 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE {
1302 *block = FirstSuccessor();
1303 return true;
1304 }
1305
1317 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 1306 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1318 return Representation::None(); 1307 return Representation::None();
1319 } 1308 }
1320 1309
1321 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 1310 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1322 1311
1323 DECLARE_CONCRETE_INSTRUCTION(Goto) 1312 DECLARE_CONCRETE_INSTRUCTION(Goto)
1324 }; 1313 };
1325 1314
1326 1315
1316 class HDeoptimize V8_FINAL : public HTemplateControlInstruction<1, 0> {
1317 public:
1318 static HInstruction* New(Zone* zone,
1319 HValue* context,
1320 const char* reason,
1321 Deoptimizer::BailoutType type,
1322 HBasicBlock* unreachable_continuation) {
1323 return new(zone) HDeoptimize(reason, type, unreachable_continuation);
1324 }
1325
1326 virtual bool KnownSuccessorBlock(HBasicBlock** block) {
1327 *block = NULL;
1328 return true;
1329 }
1330
1331 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1332 return Representation::None();
1333 }
1334
1335 const char* reason() const { return reason_; }
1336 Deoptimizer::BailoutType type() { return type_; }
1337
1338 DECLARE_CONCRETE_INSTRUCTION(Deoptimize)
1339
1340 private:
1341 explicit HDeoptimize(const char* reason,
1342 Deoptimizer::BailoutType type,
1343 HBasicBlock* unreachable_continuation)
1344 : reason_(reason), type_(type) {
1345 SetSuccessorAt(0, unreachable_continuation);
1346 }
1347
1348 const char* reason_;
1349 Deoptimizer::BailoutType type_;
1350 };
1351
1352
1327 class HUnaryControlInstruction : public HTemplateControlInstruction<2, 1> { 1353 class HUnaryControlInstruction : public HTemplateControlInstruction<2, 1> {
1328 public: 1354 public:
1329 HUnaryControlInstruction(HValue* value, 1355 HUnaryControlInstruction(HValue* value,
1330 HBasicBlock* true_target, 1356 HBasicBlock* true_target,
1331 HBasicBlock* false_target) { 1357 HBasicBlock* false_target) {
1332 SetOperandAt(0, value); 1358 SetOperandAt(0, value);
1333 SetSuccessorAt(0, true_target); 1359 SetSuccessorAt(0, true_target);
1334 SetSuccessorAt(1, false_target); 1360 SetSuccessorAt(1, false_target);
1335 } 1361 }
1336 1362
(...skipping 10 matching lines...) Expand all
1347 ToBooleanStub::Types); 1373 ToBooleanStub::Types);
1348 DECLARE_INSTRUCTION_FACTORY_P4(HBranch, HValue*, 1374 DECLARE_INSTRUCTION_FACTORY_P4(HBranch, HValue*,
1349 ToBooleanStub::Types, 1375 ToBooleanStub::Types,
1350 HBasicBlock*, HBasicBlock*); 1376 HBasicBlock*, HBasicBlock*);
1351 1377
1352 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 1378 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1353 return Representation::None(); 1379 return Representation::None();
1354 } 1380 }
1355 virtual Representation observed_input_representation(int index) V8_OVERRIDE; 1381 virtual Representation observed_input_representation(int index) V8_OVERRIDE;
1356 1382
1383 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE;
1384
1357 ToBooleanStub::Types expected_input_types() const { 1385 ToBooleanStub::Types expected_input_types() const {
1358 return expected_input_types_; 1386 return expected_input_types_;
1359 } 1387 }
1360 1388
1361 DECLARE_CONCRETE_INSTRUCTION(Branch) 1389 DECLARE_CONCRETE_INSTRUCTION(Branch)
1362 1390
1363 private: 1391 private:
1364 HBranch(HValue* value, 1392 HBranch(HValue* value,
1365 ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(), 1393 ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(),
1366 HBasicBlock* true_target = NULL, 1394 HBasicBlock* true_target = NULL,
(...skipping 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3481 int32_value_ == other_constant->int32_value_; 3509 int32_value_ == other_constant->int32_value_;
3482 } else if (has_double_value_) { 3510 } else if (has_double_value_) {
3483 return other_constant->has_double_value_ && 3511 return other_constant->has_double_value_ &&
3484 BitCast<int64_t>(double_value_) == 3512 BitCast<int64_t>(double_value_) ==
3485 BitCast<int64_t>(other_constant->double_value_); 3513 BitCast<int64_t>(other_constant->double_value_);
3486 } else if (has_external_reference_value_) { 3514 } else if (has_external_reference_value_) {
3487 return other_constant->has_external_reference_value_ && 3515 return other_constant->has_external_reference_value_ &&
3488 external_reference_value_ == 3516 external_reference_value_ ==
3489 other_constant->external_reference_value_; 3517 other_constant->external_reference_value_;
3490 } else { 3518 } else {
3519 if (other_constant->has_int32_value_ ||
3520 other_constant->has_double_value_ ||
3521 other_constant->has_external_reference_value_) {
3522 return false;
3523 }
3491 ASSERT(!object_.handle().is_null()); 3524 ASSERT(!object_.handle().is_null());
3492 return other_constant->object_ == object_; 3525 return other_constant->object_ == object_;
3493 } 3526 }
3494 } 3527 }
3495 3528
3496 private: 3529 private:
3497 friend class HGraph; 3530 friend class HGraph;
3498 HConstant(Handle<Object> handle, Representation r = Representation::None()); 3531 HConstant(Handle<Object> handle, Representation r = Representation::None());
3499 HConstant(int32_t value, 3532 HConstant(int32_t value,
3500 Representation r = Representation::None(), 3533 Representation r = Representation::None(),
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
4084 HBasicBlock* false_target = NULL) 4117 HBasicBlock* false_target = NULL)
4085 : HUnaryControlInstruction(value, true_target, false_target) { 4118 : HUnaryControlInstruction(value, true_target, false_target) {
4086 SetFlag(kFlexibleRepresentation); 4119 SetFlag(kFlexibleRepresentation);
4087 SetFlag(kAllowUndefinedAsNaN); 4120 SetFlag(kAllowUndefinedAsNaN);
4088 } 4121 }
4089 }; 4122 };
4090 4123
4091 4124
4092 class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> { 4125 class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
4093 public: 4126 public:
4127 HCompareObjectEqAndBranch(HValue* left,
4128 HValue* right,
4129 HBasicBlock* true_target = NULL,
4130 HBasicBlock* false_target = NULL) {
4131 // TODO(danno): make this private when the IfBuilder properly constructs
4132 // control flow instructions.
4133 ASSERT(!left->IsConstant() ||
4134 (!HConstant::cast(left)->HasInteger32Value() ||
4135 HConstant::cast(left)->HasSmiValue()));
4136 ASSERT(!right->IsConstant() ||
4137 (!HConstant::cast(right)->HasInteger32Value() ||
4138 HConstant::cast(right)->HasSmiValue()));
4139 SetOperandAt(0, left);
4140 SetOperandAt(1, right);
4141 SetSuccessorAt(0, true_target);
4142 SetSuccessorAt(1, false_target);
4143 }
4144
4094 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*); 4145 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*);
4095 DECLARE_INSTRUCTION_FACTORY_P4(HCompareObjectEqAndBranch, HValue*, HValue*, 4146 DECLARE_INSTRUCTION_FACTORY_P4(HCompareObjectEqAndBranch, HValue*, HValue*,
4096 HBasicBlock*, HBasicBlock*); 4147 HBasicBlock*, HBasicBlock*);
4097 4148
4149 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE;
4150
4098 HValue* left() { return OperandAt(0); } 4151 HValue* left() { return OperandAt(0); }
4099 HValue* right() { return OperandAt(1); } 4152 HValue* right() { return OperandAt(1); }
4100 4153
4101 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 4154 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4102 4155
4103 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4156 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4104 return Representation::Tagged(); 4157 return Representation::Tagged();
4105 } 4158 }
4106 4159
4107 virtual Representation observed_input_representation(int index) V8_OVERRIDE { 4160 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
4108 return Representation::Tagged(); 4161 return Representation::Tagged();
4109 } 4162 }
4110 4163
4111 DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch) 4164 DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch)
4112
4113 private:
4114 HCompareObjectEqAndBranch(HValue* left,
4115 HValue* right,
4116 HBasicBlock* true_target = NULL,
4117 HBasicBlock* false_target = NULL) {
4118 SetOperandAt(0, left);
4119 SetOperandAt(1, right);
4120 SetSuccessorAt(0, true_target);
4121 SetSuccessorAt(1, false_target);
4122 }
4123 }; 4165 };
4124 4166
4125 4167
4126 class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction { 4168 class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction {
4127 public: 4169 public:
4128 DECLARE_INSTRUCTION_FACTORY_P1(HIsObjectAndBranch, HValue*); 4170 DECLARE_INSTRUCTION_FACTORY_P1(HIsObjectAndBranch, HValue*);
4129 DECLARE_INSTRUCTION_FACTORY_P3(HIsObjectAndBranch, HValue*, 4171 DECLARE_INSTRUCTION_FACTORY_P3(HIsObjectAndBranch, HValue*,
4130 HBasicBlock*, HBasicBlock*); 4172 HBasicBlock*, HBasicBlock*);
4131 4173
4132 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4174 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
(...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after
7064 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 7106 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
7065 }; 7107 };
7066 7108
7067 7109
7068 #undef DECLARE_INSTRUCTION 7110 #undef DECLARE_INSTRUCTION
7069 #undef DECLARE_CONCRETE_INSTRUCTION 7111 #undef DECLARE_CONCRETE_INSTRUCTION
7070 7112
7071 } } // namespace v8::internal 7113 } } // namespace v8::internal
7072 7114
7073 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7115 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-gvn.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698