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

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

Issue 6062002: Merge 6006:6095 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 10 years 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-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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // HCallFunction 87 // HCallFunction
88 // HCallGlobal 88 // HCallGlobal
89 // HCallKeyed 89 // HCallKeyed
90 // HCallKnownGlobal 90 // HCallKnownGlobal
91 // HCallNamed 91 // HCallNamed
92 // HCallNew 92 // HCallNew
93 // HCallRuntime 93 // HCallRuntime
94 // HCallStub 94 // HCallStub
95 // HConstant 95 // HConstant
96 // HControlInstruction 96 // HControlInstruction
97 // HDeoptimize
97 // HGoto 98 // HGoto
98 // HUnaryControlInstruction 99 // HUnaryControlInstruction
99 // HBranch 100 // HBranch
100 // HCompareMapAndBranch 101 // HCompareMapAndBranch
101 // HReturn 102 // HReturn
102 // HThrow 103 // HThrow
103 // HDeoptimize
104 // HEnterInlined 104 // HEnterInlined
105 // HFunctionLiteral 105 // HFunctionLiteral
106 // HGlobalObject 106 // HGlobalObject
107 // HGlobalReceiver 107 // HGlobalReceiver
108 // HLeaveInlined 108 // HLeaveInlined
109 // HLoadGlobal 109 // HLoadGlobal
110 // HMaterializedLiteral 110 // HMaterializedLiteral
111 // HArrayLiteral 111 // HArrayLiteral
112 // HObjectLiteral 112 // HObjectLiteral
113 // HRegExpLiteral 113 // HRegExpLiteral
(...skipping 19 matching lines...) Expand all
133 // HTypeofIs 133 // HTypeofIs
134 // HLoadNamedField 134 // HLoadNamedField
135 // HPushArgument 135 // HPushArgument
136 // HTypeof 136 // HTypeof
137 // HUnaryMathOperation 137 // HUnaryMathOperation
138 // HUnaryPredicate 138 // HUnaryPredicate
139 // HClassOfTest 139 // HClassOfTest
140 // HHasCachedArrayIndex 140 // HHasCachedArrayIndex
141 // HHasInstanceType 141 // HHasInstanceType
142 // HIsNull 142 // HIsNull
143 // HIsObject
143 // HIsSmi 144 // HIsSmi
144 // HValueOf 145 // HValueOf
145 // HUnknownOSRValue 146 // HUnknownOSRValue
146 // HPhi 147 // HPhi
147 148
148 #define HYDROGEN_ALL_INSTRUCTION_LIST(V) \ 149 #define HYDROGEN_ALL_INSTRUCTION_LIST(V) \
149 V(ArithmeticBinaryOperation) \ 150 V(ArithmeticBinaryOperation) \
150 V(BinaryOperation) \ 151 V(BinaryOperation) \
151 V(BitwiseBinaryOperation) \ 152 V(BitwiseBinaryOperation) \
152 V(Call) \ 153 V(Call) \
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 V(DeleteProperty) \ 202 V(DeleteProperty) \
202 V(Deoptimize) \ 203 V(Deoptimize) \
203 V(Div) \ 204 V(Div) \
204 V(EnterInlined) \ 205 V(EnterInlined) \
205 V(FunctionLiteral) \ 206 V(FunctionLiteral) \
206 V(GlobalObject) \ 207 V(GlobalObject) \
207 V(GlobalReceiver) \ 208 V(GlobalReceiver) \
208 V(Goto) \ 209 V(Goto) \
209 V(InstanceOf) \ 210 V(InstanceOf) \
210 V(IsNull) \ 211 V(IsNull) \
212 V(IsObject) \
211 V(IsSmi) \ 213 V(IsSmi) \
212 V(HasInstanceType) \ 214 V(HasInstanceType) \
213 V(HasCachedArrayIndex) \ 215 V(HasCachedArrayIndex) \
214 V(ClassOfTest) \ 216 V(ClassOfTest) \
215 V(LeaveInlined) \ 217 V(LeaveInlined) \
216 V(LoadElements) \ 218 V(LoadElements) \
217 V(LoadGlobal) \ 219 V(LoadGlobal) \
218 V(LoadKeyedFastElement) \ 220 V(LoadKeyedFastElement) \
219 V(LoadKeyedGeneric) \ 221 V(LoadKeyedGeneric) \
220 V(LoadNamedField) \ 222 V(LoadNamedField) \
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 int old_upper = upper_; 327 int old_upper = upper_;
326 lower_ = lower_ << bits; 328 lower_ = lower_ << bits;
327 upper_ = upper_ << bits; 329 upper_ = upper_ << bits;
328 if (old_lower != lower_ >> bits || old_upper != upper_ >> bits) { 330 if (old_lower != lower_ >> bits || old_upper != upper_ >> bits) {
329 upper_ = kMaxInt; 331 upper_ = kMaxInt;
330 lower_ = kMinInt; 332 lower_ = kMinInt;
331 } 333 }
332 set_can_be_minus_zero(false); 334 set_can_be_minus_zero(false);
333 } 335 }
334 336
337 // Adds a constant to the lower and upper bound of the range.
338 void AddConstant(int32_t value);
339
335 void StackUpon(Range* other) { 340 void StackUpon(Range* other) {
336 Intersect(other); 341 Intersect(other);
337 next_ = other; 342 next_ = other;
338 } 343 }
339 344
340 void Intersect(Range* other) { 345 void Intersect(Range* other) {
341 upper_ = Min(upper_, other->upper_); 346 upper_ = Min(upper_, other->upper_);
342 lower_ = Max(lower_, other->lower_); 347 lower_ = Max(lower_, other->lower_);
343 bool b = CanBeMinusZero() && other->CanBeMinusZero(); 348 bool b = CanBeMinusZero() && other->CanBeMinusZero();
344 set_can_be_minus_zero(b); 349 set_can_be_minus_zero(b);
345 } 350 }
346 351
347 void Union(Range* other) { 352 void Union(Range* other) {
348 upper_ = Max(upper_, other->upper_); 353 upper_ = Max(upper_, other->upper_);
349 lower_ = Min(lower_, other->lower_); 354 lower_ = Min(lower_, other->lower_);
350 bool b = CanBeMinusZero() || other->CanBeMinusZero(); 355 bool b = CanBeMinusZero() || other->CanBeMinusZero();
351 set_can_be_minus_zero(b); 356 set_can_be_minus_zero(b);
352 } 357 }
353 358
354 void Add(int32_t value); 359 // Compute a new result range and return true, if the operation
360 // can overflow.
355 bool AddAndCheckOverflow(Range* other); 361 bool AddAndCheckOverflow(Range* other);
356 bool SubAndCheckOverflow(Range* other); 362 bool SubAndCheckOverflow(Range* other);
357 bool MulAndCheckOverflow(Range* other); 363 bool MulAndCheckOverflow(Range* other);
358 364
359 private: 365 private:
360 int32_t lower_; 366 int32_t lower_;
361 int32_t upper_; 367 int32_t upper_;
362 Range* next_; 368 Range* next_;
363 bool can_be_minus_zero_; 369 bool can_be_minus_zero_;
364 }; 370 };
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 true_destination_(true_destination), 898 true_destination_(true_destination),
893 false_destination_(false_destination) { 899 false_destination_(false_destination) {
894 ASSERT(true_destination != NULL); 900 ASSERT(true_destination != NULL);
895 ASSERT(false_destination != NULL); 901 ASSERT(false_destination != NULL);
896 ASSERT(!map.is_null()); 902 ASSERT(!map.is_null());
897 } 903 }
898 904
899 virtual HBasicBlock* FirstSuccessor() const { return true_destination_; } 905 virtual HBasicBlock* FirstSuccessor() const { return true_destination_; }
900 virtual HBasicBlock* SecondSuccessor() const { return false_destination_; } 906 virtual HBasicBlock* SecondSuccessor() const { return false_destination_; }
901 907
908 virtual void PrintDataTo(StringStream* stream) const;
909
902 Handle<Map> map() const { return map_; } 910 Handle<Map> map() const { return map_; }
903 911
904 DECLARE_CONCRETE_INSTRUCTION(CompareMapAndBranch, "compare_map_and_branch") 912 DECLARE_CONCRETE_INSTRUCTION(CompareMapAndBranch, "compare_map_and_branch")
905 913
906 private: 914 private:
907 Handle<Map> map_; 915 Handle<Map> map_;
908 HBasicBlock* true_destination_; 916 HBasicBlock* true_destination_;
909 HBasicBlock* false_destination_; 917 HBasicBlock* false_destination_;
910 }; 918 };
911 919
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 return Representation::Integer32(); 1367 return Representation::Integer32();
1360 } 1368 }
1361 virtual HType CalculateInferredType() const; 1369 virtual HType CalculateInferredType() const;
1362 1370
1363 DECLARE_CONCRETE_INSTRUCTION(BitNot, "bit_not") 1371 DECLARE_CONCRETE_INSTRUCTION(BitNot, "bit_not")
1364 }; 1372 };
1365 1373
1366 1374
1367 class HUnaryMathOperation: public HUnaryOperation { 1375 class HUnaryMathOperation: public HUnaryOperation {
1368 public: 1376 public:
1369 HUnaryMathOperation(HValue* value, MathFunctionId op) 1377 HUnaryMathOperation(HValue* value, BuiltinFunctionId op)
1370 : HUnaryOperation(value), op_(op) { 1378 : HUnaryOperation(value), op_(op) {
1371 switch (op) { 1379 switch (op) {
1372 case kMathFloor: 1380 case kMathFloor:
1373 case kMathRound: 1381 case kMathRound:
1374 case kMathCeil: 1382 case kMathCeil:
1375 set_representation(Representation::Integer32()); 1383 set_representation(Representation::Integer32());
1376 break; 1384 break;
1377 case kMathAbs: 1385 case kMathAbs:
1378 set_representation(Representation::Tagged()); 1386 set_representation(Representation::Tagged());
1379 SetFlag(kFlexibleRepresentation); 1387 SetFlag(kFlexibleRepresentation);
1380 break; 1388 break;
1381 case kMathSqrt: 1389 case kMathSqrt:
1382 case kMathPowHalf: 1390 case kMathPowHalf:
1391 case kMathLog:
1392 case kMathSin:
1393 case kMathCos:
1394 set_representation(Representation::Double());
1395 break;
1383 default: 1396 default:
1384 set_representation(Representation::Double()); 1397 UNREACHABLE();
1385 } 1398 }
1386 SetFlag(kUseGVN); 1399 SetFlag(kUseGVN);
1387 } 1400 }
1388 1401
1389 virtual void PrintDataTo(StringStream* stream) const; 1402 virtual void PrintDataTo(StringStream* stream) const;
1390 1403
1391 virtual HType CalculateInferredType() const; 1404 virtual HType CalculateInferredType() const;
1392 1405
1393 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 1406 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
1394 1407
1395 virtual Representation RequiredInputRepresentation(int index) const { 1408 virtual Representation RequiredInputRepresentation(int index) const {
1396 switch (op_) { 1409 switch (op_) {
1397 case kMathFloor: 1410 case kMathFloor:
1398 case kMathRound: 1411 case kMathRound:
1399 case kMathCeil: 1412 case kMathCeil:
1400 case kMathSqrt: 1413 case kMathSqrt:
1401 case kMathPowHalf: 1414 case kMathPowHalf:
1415 case kMathLog:
1416 case kMathSin:
1417 case kMathCos:
1402 return Representation::Double(); 1418 return Representation::Double();
1403 break; 1419 break;
1404 case kMathAbs: 1420 case kMathAbs:
1405 return representation(); 1421 return representation();
1406 break; 1422 break;
1407 default: 1423 default:
1408 return Representation::None(); 1424 return Representation::None();
1409 } 1425 }
1410 } 1426 }
1411 1427
1412 virtual HValue* Canonicalize() { 1428 virtual HValue* Canonicalize() {
1413 // If the input is integer32 then we replace the floor instruction 1429 // If the input is integer32 then we replace the floor instruction
1414 // with its inputs. This happens before the representation changes are 1430 // with its inputs. This happens before the representation changes are
1415 // introduced. 1431 // introduced.
1416 if (op() == kMathFloor) { 1432 if (op() == kMathFloor) {
1417 if (value()->representation().IsInteger32()) return value(); 1433 if (value()->representation().IsInteger32()) return value();
1418 } 1434 }
1419 return this; 1435 return this;
1420 } 1436 }
1421 1437
1422 MathFunctionId op() const { return op_; } 1438 BuiltinFunctionId op() const { return op_; }
1423 const char* OpName() const; 1439 const char* OpName() const;
1424 1440
1425 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary_math_operation") 1441 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary_math_operation")
1426 1442
1443 protected:
1444 virtual bool DataEquals(HValue* other) const {
1445 HUnaryMathOperation* b = HUnaryMathOperation::cast(other);
1446 return op_ == b->op();
1447 }
1448
1427 private: 1449 private:
1428 MathFunctionId op_; 1450 BuiltinFunctionId op_;
1429 }; 1451 };
1430 1452
1431 1453
1432 class HLoadElements: public HUnaryOperation { 1454 class HLoadElements: public HUnaryOperation {
1433 public: 1455 public:
1434 explicit HLoadElements(HValue* value) : HUnaryOperation(value) { 1456 explicit HLoadElements(HValue* value) : HUnaryOperation(value) {
1435 set_representation(Representation::Tagged()); 1457 set_representation(Representation::Tagged());
1436 SetFlag(kUseGVN); 1458 SetFlag(kUseGVN);
1437 SetFlag(kDependsOnMaps); 1459 SetFlag(kDependsOnMaps);
1438 } 1460 }
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 2106
2085 class HIsNull: public HUnaryPredicate { 2107 class HIsNull: public HUnaryPredicate {
2086 public: 2108 public:
2087 HIsNull(HValue* value, bool is_strict) 2109 HIsNull(HValue* value, bool is_strict)
2088 : HUnaryPredicate(value), is_strict_(is_strict) { } 2110 : HUnaryPredicate(value), is_strict_(is_strict) { }
2089 2111
2090 bool is_strict() const { return is_strict_; } 2112 bool is_strict() const { return is_strict_; }
2091 2113
2092 DECLARE_CONCRETE_INSTRUCTION(IsNull, "is_null") 2114 DECLARE_CONCRETE_INSTRUCTION(IsNull, "is_null")
2093 2115
2116 protected:
2117 virtual bool DataEquals(HValue* other) const {
2118 HIsNull* b = HIsNull::cast(other);
2119 return is_strict_ == b->is_strict();
2120 }
2121
2094 private: 2122 private:
2095 bool is_strict_; 2123 bool is_strict_;
2096 }; 2124 };
2097 2125
2098 2126
2127 class HIsObject: public HUnaryPredicate {
2128 public:
2129 explicit HIsObject(HValue* value) : HUnaryPredicate(value) { }
2130
2131 DECLARE_CONCRETE_INSTRUCTION(IsObject, "is_object")
2132 };
2133
2134
2099 class HIsSmi: public HUnaryPredicate { 2135 class HIsSmi: public HUnaryPredicate {
2100 public: 2136 public:
2101 explicit HIsSmi(HValue* value) : HUnaryPredicate(value) { } 2137 explicit HIsSmi(HValue* value) : HUnaryPredicate(value) { }
2102 2138
2103 DECLARE_CONCRETE_INSTRUCTION(IsSmi, "is_smi") 2139 DECLARE_CONCRETE_INSTRUCTION(IsSmi, "is_smi")
2104 }; 2140 };
2105 2141
2106 2142
2107 class HHasInstanceType: public HUnaryPredicate { 2143 class HHasInstanceType: public HUnaryPredicate {
2108 public: 2144 public:
2109 HHasInstanceType(HValue* value, InstanceType type) 2145 HHasInstanceType(HValue* value, InstanceType type)
2110 : HUnaryPredicate(value), from_(type), to_(type) { } 2146 : HUnaryPredicate(value), from_(type), to_(type) { }
2111 HHasInstanceType(HValue* value, InstanceType from, InstanceType to) 2147 HHasInstanceType(HValue* value, InstanceType from, InstanceType to)
2112 : HUnaryPredicate(value), from_(from), to_(to) { 2148 : HUnaryPredicate(value), from_(from), to_(to) {
2113 ASSERT(to == LAST_TYPE); // Others not implemented yet in backend. 2149 ASSERT(to == LAST_TYPE); // Others not implemented yet in backend.
2114 } 2150 }
2115 2151
2116 InstanceType from() { return from_; } 2152 InstanceType from() { return from_; }
2117 InstanceType to() { return to_; } 2153 InstanceType to() { return to_; }
2118 2154
2119 virtual void PrintDataTo(StringStream* stream) const; 2155 virtual void PrintDataTo(StringStream* stream) const;
2120 2156
2121 DECLARE_CONCRETE_INSTRUCTION(HasInstanceType, "has_instance_type") 2157 DECLARE_CONCRETE_INSTRUCTION(HasInstanceType, "has_instance_type")
2122 2158
2159 protected:
2160 virtual bool DataEquals(HValue* other) const {
2161 HHasInstanceType* b = HHasInstanceType::cast(other);
2162 return (from_ == b->from()) && (to_ == b->to());
2163 }
2164
2123 private: 2165 private:
2124 InstanceType from_; 2166 InstanceType from_;
2125 InstanceType to_; // Inclusive range, not all combinations work. 2167 InstanceType to_; // Inclusive range, not all combinations work.
2126 }; 2168 };
2127 2169
2128 2170
2129 class HHasCachedArrayIndex: public HUnaryPredicate { 2171 class HHasCachedArrayIndex: public HUnaryPredicate {
2130 public: 2172 public:
2131 explicit HHasCachedArrayIndex(HValue* value) : HUnaryPredicate(value) { } 2173 explicit HHasCachedArrayIndex(HValue* value) : HUnaryPredicate(value) { }
2132 2174
2133 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has_cached_array_index") 2175 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has_cached_array_index")
2134 }; 2176 };
2135 2177
2136 2178
2137 class HClassOfTest: public HUnaryPredicate { 2179 class HClassOfTest: public HUnaryPredicate {
2138 public: 2180 public:
2139 HClassOfTest(HValue* value, Handle<String> class_name) 2181 HClassOfTest(HValue* value, Handle<String> class_name)
2140 : HUnaryPredicate(value), class_name_(class_name) { } 2182 : HUnaryPredicate(value), class_name_(class_name) { }
2141 2183
2142 DECLARE_CONCRETE_INSTRUCTION(ClassOfTest, "class_of_test") 2184 DECLARE_CONCRETE_INSTRUCTION(ClassOfTest, "class_of_test")
2143 2185
2144 virtual void PrintDataTo(StringStream* stream) const; 2186 virtual void PrintDataTo(StringStream* stream) const;
2145 2187
2146 Handle<String> class_name() const { return class_name_; } 2188 Handle<String> class_name() const { return class_name_; }
2147 2189
2190 protected:
2191 virtual bool DataEquals(HValue* other) const {
2192 HClassOfTest* b = HClassOfTest::cast(other);
2193 return class_name_.is_identical_to(b->class_name_);
2194 }
2195
2148 private: 2196 private:
2149 Handle<String> class_name_; 2197 Handle<String> class_name_;
2150 }; 2198 };
2151 2199
2152 2200
2153 class HTypeofIs: public HUnaryPredicate { 2201 class HTypeofIs: public HUnaryPredicate {
2154 public: 2202 public:
2155 HTypeofIs(HValue* value, Handle<String> type_literal) 2203 HTypeofIs(HValue* value, Handle<String> type_literal)
2156 : HUnaryPredicate(value), type_literal_(type_literal) { } 2204 : HUnaryPredicate(value), type_literal_(type_literal) { }
2157 2205
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
2896 HValue* object() const { return left(); } 2944 HValue* object() const { return left(); }
2897 HValue* key() const { return right(); } 2945 HValue* key() const { return right(); }
2898 }; 2946 };
2899 2947
2900 #undef DECLARE_INSTRUCTION 2948 #undef DECLARE_INSTRUCTION
2901 #undef DECLARE_CONCRETE_INSTRUCTION 2949 #undef DECLARE_CONCRETE_INSTRUCTION
2902 2950
2903 } } // namespace v8::internal 2951 } } // namespace v8::internal
2904 2952
2905 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 2953 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698