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

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

Issue 23654051: Fix IfBuilder to use instruction factories. Add missing instruction factories. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 years, 3 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.cc ('k') | src/hydrogen-osr.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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 } 1344 }
1345 1345
1346 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 1346 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1347 1347
1348 HValue* value() { return OperandAt(0); } 1348 HValue* value() { return OperandAt(0); }
1349 }; 1349 };
1350 1350
1351 1351
1352 class HBranch V8_FINAL : public HUnaryControlInstruction { 1352 class HBranch V8_FINAL : public HUnaryControlInstruction {
1353 public: 1353 public:
1354 HBranch(HValue* value, 1354 DECLARE_INSTRUCTION_FACTORY_P1(HBranch, HValue*);
1355 ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(), 1355 DECLARE_INSTRUCTION_FACTORY_P2(HBranch, HValue*,
1356 HBasicBlock* true_target = NULL, 1356 ToBooleanStub::Types);
1357 HBasicBlock* false_target = NULL) 1357 DECLARE_INSTRUCTION_FACTORY_P4(HBranch, HValue*,
1358 : HUnaryControlInstruction(value, true_target, false_target), 1358 ToBooleanStub::Types,
1359 expected_input_types_(expected_input_types) { 1359 HBasicBlock*, HBasicBlock*);
1360 SetFlag(kAllowUndefinedAsNaN);
1361 }
1362 1360
1363 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 1361 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1364 return Representation::None(); 1362 return Representation::None();
1365 } 1363 }
1366 virtual Representation observed_input_representation(int index) V8_OVERRIDE; 1364 virtual Representation observed_input_representation(int index) V8_OVERRIDE;
1367 1365
1368 ToBooleanStub::Types expected_input_types() const { 1366 ToBooleanStub::Types expected_input_types() const {
1369 return expected_input_types_; 1367 return expected_input_types_;
1370 } 1368 }
1371 1369
1372 DECLARE_CONCRETE_INSTRUCTION(Branch) 1370 DECLARE_CONCRETE_INSTRUCTION(Branch)
1373 1371
1374 private: 1372 private:
1373 HBranch(HValue* value,
1374 ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(),
1375 HBasicBlock* true_target = NULL,
1376 HBasicBlock* false_target = NULL)
1377 : HUnaryControlInstruction(value, true_target, false_target),
1378 expected_input_types_(expected_input_types) {
1379 SetFlag(kAllowUndefinedAsNaN);
1380 }
1381
1375 ToBooleanStub::Types expected_input_types_; 1382 ToBooleanStub::Types expected_input_types_;
1376 }; 1383 };
1377 1384
1378 1385
1379 class HCompareMap V8_FINAL : public HUnaryControlInstruction { 1386 class HCompareMap V8_FINAL : public HUnaryControlInstruction {
1380 public: 1387 public:
1381 HCompareMap(HValue* value, 1388 DECLARE_INSTRUCTION_FACTORY_P2(HCompareMap, HValue*, Handle<Map>);
1382 Handle<Map> map, 1389 DECLARE_INSTRUCTION_FACTORY_P4(HCompareMap, HValue*, Handle<Map>,
1383 HBasicBlock* true_target = NULL, 1390 HBasicBlock*, HBasicBlock*);
1384 HBasicBlock* false_target = NULL)
1385 : HUnaryControlInstruction(value, true_target, false_target),
1386 map_(map) {
1387 ASSERT(!map.is_null());
1388 }
1389 1391
1390 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 1392 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1391 1393
1392 Handle<Map> map() const { return map_; } 1394 Handle<Map> map() const { return map_; }
1393 1395
1394 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 1396 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1395 return Representation::Tagged(); 1397 return Representation::Tagged();
1396 } 1398 }
1397 1399
1398 DECLARE_CONCRETE_INSTRUCTION(CompareMap) 1400 DECLARE_CONCRETE_INSTRUCTION(CompareMap)
1399 1401
1400 protected: 1402 protected:
1401 virtual int RedefinedOperandIndex() { return 0; } 1403 virtual int RedefinedOperandIndex() { return 0; }
1402 1404
1403 private: 1405 private:
1406 HCompareMap(HValue* value,
1407 Handle<Map> map,
1408 HBasicBlock* true_target = NULL,
1409 HBasicBlock* false_target = NULL)
1410 : HUnaryControlInstruction(value, true_target, false_target), map_(map) {
1411 ASSERT(!map.is_null());
1412 }
1413
1404 Handle<Map> map_; 1414 Handle<Map> map_;
1405 }; 1415 };
1406 1416
1407 1417
1408 class HContext V8_FINAL : public HTemplateInstruction<0> { 1418 class HContext V8_FINAL : public HTemplateInstruction<0> {
1409 public: 1419 public:
1410 static HContext* New(Zone* zone) { 1420 static HContext* New(Zone* zone) {
1411 return new(zone) HContext(); 1421 return new(zone) HContext();
1412 } 1422 }
1413 1423
(...skipping 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after
4026 4036
4027 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) 4037 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric)
4028 4038
4029 private: 4039 private:
4030 Token::Value token_; 4040 Token::Value token_;
4031 }; 4041 };
4032 4042
4033 4043
4034 class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> { 4044 class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
4035 public: 4045 public:
4036 HCompareNumericAndBranch(HValue* left, HValue* right, Token::Value token) 4046 DECLARE_INSTRUCTION_FACTORY_P3(HCompareNumericAndBranch,
4037 : token_(token) { 4047 HValue*, HValue*, Token::Value);
4038 SetFlag(kFlexibleRepresentation); 4048 DECLARE_INSTRUCTION_FACTORY_P5(HCompareNumericAndBranch,
4039 ASSERT(Token::IsCompareOp(token)); 4049 HValue*, HValue*, Token::Value,
4040 SetOperandAt(0, left); 4050 HBasicBlock*, HBasicBlock*);
4041 SetOperandAt(1, right);
4042 }
4043 4051
4044 HValue* left() { return OperandAt(0); } 4052 HValue* left() { return OperandAt(0); }
4045 HValue* right() { return OperandAt(1); } 4053 HValue* right() { return OperandAt(1); }
4046 Token::Value token() const { return token_; } 4054 Token::Value token() const { return token_; }
4047 4055
4048 void set_observed_input_representation(Representation left, 4056 void set_observed_input_representation(Representation left,
4049 Representation right) { 4057 Representation right) {
4050 observed_input_representation_[0] = left; 4058 observed_input_representation_[0] = left;
4051 observed_input_representation_[1] = right; 4059 observed_input_representation_[1] = right;
4052 } 4060 }
4053 4061
4054 virtual void InferRepresentation( 4062 virtual void InferRepresentation(
4055 HInferRepresentationPhase* h_infer) V8_OVERRIDE; 4063 HInferRepresentationPhase* h_infer) V8_OVERRIDE;
4056 4064
4057 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4065 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4058 return representation(); 4066 return representation();
4059 } 4067 }
4060 virtual Representation observed_input_representation(int index) V8_OVERRIDE { 4068 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
4061 return observed_input_representation_[index]; 4069 return observed_input_representation_[index];
4062 } 4070 }
4063 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 4071 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4064 4072
4065 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) 4073 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch)
4066 4074
4067 private: 4075 private:
4076 HCompareNumericAndBranch(HValue* left,
4077 HValue* right,
4078 Token::Value token,
4079 HBasicBlock* true_target = NULL,
4080 HBasicBlock* false_target = NULL)
4081 : token_(token) {
4082 SetFlag(kFlexibleRepresentation);
4083 ASSERT(Token::IsCompareOp(token));
4084 SetOperandAt(0, left);
4085 SetOperandAt(1, right);
4086 SetSuccessorAt(0, true_target);
4087 SetSuccessorAt(1, false_target);
4088 }
4089
4068 Representation observed_input_representation_[2]; 4090 Representation observed_input_representation_[2];
4069 Token::Value token_; 4091 Token::Value token_;
4070 }; 4092 };
4071 4093
4072 4094
4073 class HCompareHoleAndBranch V8_FINAL : public HUnaryControlInstruction { 4095 class HCompareHoleAndBranch V8_FINAL : public HUnaryControlInstruction {
4074 public: 4096 public:
4075 // TODO(danno): make this private when the IfBuilder properly constructs
4076 // control flow instructions.
4077 HCompareHoleAndBranch(HValue* value,
4078 HBasicBlock* true_target = NULL,
4079 HBasicBlock* false_target = NULL)
4080 : HUnaryControlInstruction(value, true_target, false_target) {
4081 SetFlag(kFlexibleRepresentation);
4082 SetFlag(kAllowUndefinedAsNaN);
4083 }
4084
4085 DECLARE_INSTRUCTION_FACTORY_P1(HCompareHoleAndBranch, HValue*); 4097 DECLARE_INSTRUCTION_FACTORY_P1(HCompareHoleAndBranch, HValue*);
4086 DECLARE_INSTRUCTION_FACTORY_P3(HCompareHoleAndBranch, HValue*, 4098 DECLARE_INSTRUCTION_FACTORY_P3(HCompareHoleAndBranch, HValue*,
4087 HBasicBlock*, HBasicBlock*); 4099 HBasicBlock*, HBasicBlock*);
4088 4100
4089 virtual void InferRepresentation( 4101 virtual void InferRepresentation(
4090 HInferRepresentationPhase* h_infer) V8_OVERRIDE; 4102 HInferRepresentationPhase* h_infer) V8_OVERRIDE;
4091 4103
4092 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4104 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4093 return representation(); 4105 return representation();
4094 } 4106 }
4095 4107
4096 DECLARE_CONCRETE_INSTRUCTION(CompareHoleAndBranch) 4108 DECLARE_CONCRETE_INSTRUCTION(CompareHoleAndBranch)
4109
4110 private:
4111 HCompareHoleAndBranch(HValue* value,
4112 HBasicBlock* true_target = NULL,
4113 HBasicBlock* false_target = NULL)
4114 : HUnaryControlInstruction(value, true_target, false_target) {
4115 SetFlag(kFlexibleRepresentation);
4116 SetFlag(kAllowUndefinedAsNaN);
4117 }
4097 }; 4118 };
4098 4119
4099 4120
4100 class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> { 4121 class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
4101 public: 4122 public:
4102 // TODO(danno): make this private when the IfBuilder properly constructs
4103 // control flow instructions.
4104 HCompareObjectEqAndBranch(HValue* left,
4105 HValue* right) {
4106 SetOperandAt(0, left);
4107 SetOperandAt(1, right);
4108 }
4109
4110 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*); 4123 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*);
4124 DECLARE_INSTRUCTION_FACTORY_P4(HCompareObjectEqAndBranch, HValue*, HValue*,
4125 HBasicBlock*, HBasicBlock*);
4111 4126
4112 HValue* left() { return OperandAt(0); } 4127 HValue* left() { return OperandAt(0); }
4113 HValue* right() { return OperandAt(1); } 4128 HValue* right() { return OperandAt(1); }
4114 4129
4115 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 4130 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4116 4131
4117 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4132 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4118 return Representation::Tagged(); 4133 return Representation::Tagged();
4119 } 4134 }
4120 4135
4121 virtual Representation observed_input_representation(int index) V8_OVERRIDE { 4136 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
4122 return Representation::Tagged(); 4137 return Representation::Tagged();
4123 } 4138 }
4124 4139
4125 DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch) 4140 DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch)
4141
4142 private:
4143 HCompareObjectEqAndBranch(HValue* left,
4144 HValue* right,
4145 HBasicBlock* true_target = NULL,
4146 HBasicBlock* false_target = NULL) {
4147 SetOperandAt(0, left);
4148 SetOperandAt(1, right);
4149 SetSuccessorAt(0, true_target);
4150 SetSuccessorAt(1, false_target);
4151 }
4126 }; 4152 };
4127 4153
4128 4154
4129 class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction { 4155 class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction {
4130 public: 4156 public:
4131 explicit HIsObjectAndBranch(HValue* value) 4157 DECLARE_INSTRUCTION_FACTORY_P1(HIsObjectAndBranch, HValue*);
4132 : HUnaryControlInstruction(value, NULL, NULL) { } 4158 DECLARE_INSTRUCTION_FACTORY_P3(HIsObjectAndBranch, HValue*,
4159 HBasicBlock*, HBasicBlock*);
4133 4160
4134 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4161 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4135 return Representation::Tagged(); 4162 return Representation::Tagged();
4136 } 4163 }
4137 4164
4138 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch) 4165 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch)
4166
4167 private:
4168 HIsObjectAndBranch(HValue* value,
4169 HBasicBlock* true_target = NULL,
4170 HBasicBlock* false_target = NULL)
4171 : HUnaryControlInstruction(value, true_target, false_target) {}
4139 }; 4172 };
4140 4173
4174
4141 class HIsStringAndBranch V8_FINAL : public HUnaryControlInstruction { 4175 class HIsStringAndBranch V8_FINAL : public HUnaryControlInstruction {
4142 public: 4176 public:
4143 explicit HIsStringAndBranch(HValue* value) 4177 DECLARE_INSTRUCTION_FACTORY_P1(HIsStringAndBranch, HValue*);
4144 : HUnaryControlInstruction(value, NULL, NULL) { } 4178 DECLARE_INSTRUCTION_FACTORY_P3(HIsStringAndBranch, HValue*,
4179 HBasicBlock*, HBasicBlock*);
4145 4180
4146 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4181 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4147 return Representation::Tagged(); 4182 return Representation::Tagged();
4148 } 4183 }
4149 4184
4150 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch) 4185 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch)
4186
4187 private:
4188 HIsStringAndBranch(HValue* value,
4189 HBasicBlock* true_target = NULL,
4190 HBasicBlock* false_target = NULL)
4191 : HUnaryControlInstruction(value, true_target, false_target) {}
4151 }; 4192 };
4152 4193
4153 4194
4154 class HIsSmiAndBranch V8_FINAL : public HUnaryControlInstruction { 4195 class HIsSmiAndBranch V8_FINAL : public HUnaryControlInstruction {
4155 public: 4196 public:
4156 explicit HIsSmiAndBranch(HValue* value) 4197 DECLARE_INSTRUCTION_FACTORY_P1(HIsSmiAndBranch, HValue*);
4157 : HUnaryControlInstruction(value, NULL, NULL) { } 4198 DECLARE_INSTRUCTION_FACTORY_P3(HIsSmiAndBranch, HValue*,
4199 HBasicBlock*, HBasicBlock*);
4158 4200
4159 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch) 4201 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch)
4160 4202
4161 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4203 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4162 return Representation::Tagged(); 4204 return Representation::Tagged();
4163 } 4205 }
4164 4206
4165 protected: 4207 protected:
4166 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } 4208 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4209
4210 private:
4211 HIsSmiAndBranch(HValue* value,
4212 HBasicBlock* true_target = NULL,
4213 HBasicBlock* false_target = NULL)
4214 : HUnaryControlInstruction(value, true_target, false_target) {}
4167 }; 4215 };
4168 4216
4169 4217
4170 class HIsUndetectableAndBranch V8_FINAL : public HUnaryControlInstruction { 4218 class HIsUndetectableAndBranch V8_FINAL : public HUnaryControlInstruction {
4171 public: 4219 public:
4172 explicit HIsUndetectableAndBranch(HValue* value) 4220 DECLARE_INSTRUCTION_FACTORY_P1(HIsUndetectableAndBranch, HValue*);
4173 : HUnaryControlInstruction(value, NULL, NULL) { } 4221 DECLARE_INSTRUCTION_FACTORY_P3(HIsUndetectableAndBranch, HValue*,
4222 HBasicBlock*, HBasicBlock*);
4174 4223
4175 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 4224 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4176 return Representation::Tagged(); 4225 return Representation::Tagged();
4177 } 4226 }
4178 4227
4179 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch) 4228 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch)
4229
4230 private:
4231 HIsUndetectableAndBranch(HValue* value,
4232 HBasicBlock* true_target = NULL,
4233 HBasicBlock* false_target = NULL)
4234 : HUnaryControlInstruction(value, true_target, false_target) {}
4180 }; 4235 };
4181 4236
4182 4237
4183 class HStringCompareAndBranch : public HTemplateControlInstruction<2, 3> { 4238 class HStringCompareAndBranch : public HTemplateControlInstruction<2, 3> {
4184 public: 4239 public:
4185 HStringCompareAndBranch(HValue* context, 4240 HStringCompareAndBranch(HValue* context,
4186 HValue* left, 4241 HValue* left,
4187 HValue* right, 4242 HValue* right,
4188 Token::Value token) 4243 Token::Value token)
4189 : token_(token) { 4244 : token_(token) {
(...skipping 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after
6992 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 7047 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6993 }; 7048 };
6994 7049
6995 7050
6996 #undef DECLARE_INSTRUCTION 7051 #undef DECLARE_INSTRUCTION
6997 #undef DECLARE_CONCRETE_INSTRUCTION 7052 #undef DECLARE_CONCRETE_INSTRUCTION
6998 7053
6999 } } // namespace v8::internal 7054 } } // namespace v8::internal
7000 7055
7001 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7056 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-osr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698