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

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: Add missing file 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
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 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after
3458 Unique<Object> GetUnique() const { 3486 Unique<Object> GetUnique() const {
3459 return object_; 3487 return object_;
3460 } 3488 }
3461 3489
3462 #ifdef DEBUG 3490 #ifdef DEBUG
3463 virtual void Verify() V8_OVERRIDE { } 3491 virtual void Verify() V8_OVERRIDE { }
3464 #endif 3492 #endif
3465 3493
3466 DECLARE_CONCRETE_INSTRUCTION(Constant) 3494 DECLARE_CONCRETE_INSTRUCTION(Constant)
3467 3495
3468 protected:
3469 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
3470
3471 virtual bool DataEquals(HValue* other) V8_OVERRIDE { 3496 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
3472 HConstant* other_constant = HConstant::cast(other); 3497 HConstant* other_constant = HConstant::cast(other);
3473 if (has_int32_value_) { 3498 if (has_int32_value_) {
3474 return other_constant->has_int32_value_ && 3499 return other_constant->has_int32_value_ &&
3475 int32_value_ == other_constant->int32_value_; 3500 int32_value_ == other_constant->int32_value_;
3476 } else if (has_double_value_) { 3501 } else if (has_double_value_) {
3477 return other_constant->has_double_value_ && 3502 return other_constant->has_double_value_ &&
3478 BitCast<int64_t>(double_value_) == 3503 BitCast<int64_t>(double_value_) ==
3479 BitCast<int64_t>(other_constant->double_value_); 3504 BitCast<int64_t>(other_constant->double_value_);
3480 } else if (has_external_reference_value_) { 3505 } else if (has_external_reference_value_) {
3481 return other_constant->has_external_reference_value_ && 3506 return other_constant->has_external_reference_value_ &&
3482 external_reference_value_ == 3507 external_reference_value_ ==
3483 other_constant->external_reference_value_; 3508 other_constant->external_reference_value_;
3484 } else { 3509 } else {
3510 if (other_constant->has_int32_value_ ||
3511 other_constant->has_double_value_ ||
3512 other_constant->has_external_reference_value_) {
3513 return false;
3514 }
3485 ASSERT(!object_.handle().is_null()); 3515 ASSERT(!object_.handle().is_null());
3486 return other_constant->object_ == object_; 3516 return other_constant->object_ == object_;
3487 } 3517 }
3488 } 3518 }
3489 3519
3520 protected:
3521 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
3522
3490 private: 3523 private:
3491 friend class HGraph; 3524 friend class HGraph;
3492 HConstant(Handle<Object> handle, Representation r = Representation::None()); 3525 HConstant(Handle<Object> handle, Representation r = Representation::None());
3493 HConstant(int32_t value, 3526 HConstant(int32_t value,
3494 Representation r = Representation::None(), 3527 Representation r = Representation::None(),
3495 bool is_not_in_new_space = true, 3528 bool is_not_in_new_space = true,
3496 Unique<Object> optional = Unique<Object>(Handle<Object>::null())); 3529 Unique<Object> optional = Unique<Object>(Handle<Object>::null()));
3497 HConstant(double value, 3530 HConstant(double value,
3498 Representation r = Representation::None(), 3531 Representation r = Representation::None(),
3499 bool is_not_in_new_space = true, 3532 bool is_not_in_new_space = true,
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
4078 HBasicBlock* false_target = NULL) 4111 HBasicBlock* false_target = NULL)
4079 : HUnaryControlInstruction(value, true_target, false_target) { 4112 : HUnaryControlInstruction(value, true_target, false_target) {
4080 SetFlag(kFlexibleRepresentation); 4113 SetFlag(kFlexibleRepresentation);
4081 SetFlag(kAllowUndefinedAsNaN); 4114 SetFlag(kAllowUndefinedAsNaN);
4082 } 4115 }
4083 }; 4116 };
4084 4117
4085 4118
4086 class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> { 4119 class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
4087 public: 4120 public:
4121 HCompareObjectEqAndBranch(HValue* left,
4122 HValue* right,
4123 HBasicBlock* true_target = NULL,
4124 HBasicBlock* false_target = NULL) {
4125 // TODO(danno): make this private when the IfBuilder properly constructs
4126 // control flow instructions.
4127 ASSERT(!left->IsConstant() ||
4128 (!HConstant::cast(left)->HasInteger32Value() ||
4129 HConstant::cast(left)->HasSmiValue()));
4130 ASSERT(!right->IsConstant() ||
4131 (!HConstant::cast(right)->HasInteger32Value() ||
4132 HConstant::cast(right)->HasSmiValue()));
4133 SetOperandAt(0, left);
4134 SetOperandAt(1, right);
4135 SetSuccessorAt(0, true_target);
4136 SetSuccessorAt(1, false_target);
4137 }
4138
4088 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*); 4139 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*);
4089 DECLARE_INSTRUCTION_FACTORY_P4(HCompareObjectEqAndBranch, HValue*, HValue*, 4140 DECLARE_INSTRUCTION_FACTORY_P4(HCompareObjectEqAndBranch, HValue*, HValue*,
4090 HBasicBlock*, HBasicBlock*); 4141 HBasicBlock*, HBasicBlock*);
4091 4142
4143 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE;
4144
4092 HValue* left() { return OperandAt(0); } 4145 HValue* left() { return OperandAt(0); }
4093 HValue* right() { return OperandAt(1); } 4146 HValue* right() { return OperandAt(1); }
4094 4147
4095 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 4148 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4096 4149
4097 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4150 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4098 return Representation::Tagged(); 4151 return Representation::Tagged();
4099 } 4152 }
4100 4153
4101 virtual Representation observed_input_representation(int index) V8_OVERRIDE { 4154 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
4102 return Representation::Tagged(); 4155 return Representation::Tagged();
4103 } 4156 }
4104 4157
4105 DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch) 4158 DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch)
4106
4107 private:
4108 HCompareObjectEqAndBranch(HValue* left,
4109 HValue* right,
4110 HBasicBlock* true_target = NULL,
4111 HBasicBlock* false_target = NULL) {
4112 SetOperandAt(0, left);
4113 SetOperandAt(1, right);
4114 SetSuccessorAt(0, true_target);
4115 SetSuccessorAt(1, false_target);
4116 }
4117 }; 4159 };
4118 4160
4119 4161
4120 class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction { 4162 class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction {
4121 public: 4163 public:
4122 DECLARE_INSTRUCTION_FACTORY_P1(HIsObjectAndBranch, HValue*); 4164 DECLARE_INSTRUCTION_FACTORY_P1(HIsObjectAndBranch, HValue*);
4123 DECLARE_INSTRUCTION_FACTORY_P3(HIsObjectAndBranch, HValue*, 4165 DECLARE_INSTRUCTION_FACTORY_P3(HIsObjectAndBranch, HValue*,
4124 HBasicBlock*, HBasicBlock*); 4166 HBasicBlock*, HBasicBlock*);
4125 4167
4126 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4168 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
(...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after
7058 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 7100 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
7059 }; 7101 };
7060 7102
7061 7103
7062 #undef DECLARE_INSTRUCTION 7104 #undef DECLARE_INSTRUCTION
7063 #undef DECLARE_CONCRETE_INSTRUCTION 7105 #undef DECLARE_CONCRETE_INSTRUCTION
7064 7106
7065 } } // namespace v8::internal 7107 } } // namespace v8::internal
7066 7108
7067 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7109 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698