| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 309 |
| 310 Isolate* isolate() const { return isolate_; } | 310 Isolate* isolate() const { return isolate_; } |
| 311 Zone* zone() const { return zone_; } | 311 Zone* zone() const { return zone_; } |
| 312 CompilationInfo* info() const { return info_; } | 312 CompilationInfo* info() const { return info_; } |
| 313 | 313 |
| 314 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } | 314 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } |
| 315 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } | 315 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } |
| 316 HBasicBlock* entry_block() const { return entry_block_; } | 316 HBasicBlock* entry_block() const { return entry_block_; } |
| 317 HEnvironment* start_environment() const { return start_environment_; } | 317 HEnvironment* start_environment() const { return start_environment_; } |
| 318 | 318 |
| 319 void FinalizeUniqueValueIds(); | 319 void FinalizeUniqueness(); |
| 320 bool ProcessArgumentsObject(); | 320 bool ProcessArgumentsObject(); |
| 321 void OrderBlocks(); | 321 void OrderBlocks(); |
| 322 void AssignDominators(); | 322 void AssignDominators(); |
| 323 void RestoreActualValues(); | 323 void RestoreActualValues(); |
| 324 | 324 |
| 325 // Returns false if there are phi-uses of the arguments-object | 325 // Returns false if there are phi-uses of the arguments-object |
| 326 // which are not supported by the optimizing compiler. | 326 // which are not supported by the optimizing compiler. |
| 327 bool CheckArgumentsPhiUses(); | 327 bool CheckArgumentsPhiUses(); |
| 328 | 328 |
| 329 // Returns false if there are phi-uses of an uninitialized const | 329 // Returns false if there are phi-uses of an uninitialized const |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 | 934 |
| 935 HArgumentsObject* arguments_object_; | 935 HArgumentsObject* arguments_object_; |
| 936 HArgumentsElements* arguments_elements_; | 936 HArgumentsElements* arguments_elements_; |
| 937 | 937 |
| 938 FunctionState* outer_; | 938 FunctionState* outer_; |
| 939 }; | 939 }; |
| 940 | 940 |
| 941 | 941 |
| 942 class HIfContinuation V8_FINAL { | 942 class HIfContinuation V8_FINAL { |
| 943 public: | 943 public: |
| 944 HIfContinuation() { continuation_captured_ = false; } | 944 HIfContinuation() : continuation_captured_(false) {} |
| 945 HIfContinuation(HBasicBlock* true_branch, |
| 946 HBasicBlock* false_branch, |
| 947 int position = RelocInfo::kNoPosition) |
| 948 : continuation_captured_(true), true_branch_(true_branch), |
| 949 false_branch_(false_branch), position_(position) {} |
| 945 ~HIfContinuation() { ASSERT(!continuation_captured_); } | 950 ~HIfContinuation() { ASSERT(!continuation_captured_); } |
| 946 | 951 |
| 947 void Capture(HBasicBlock* true_branch, | 952 void Capture(HBasicBlock* true_branch, |
| 948 HBasicBlock* false_branch, | 953 HBasicBlock* false_branch, |
| 949 int position) { | 954 int position) { |
| 950 ASSERT(!continuation_captured_); | 955 ASSERT(!continuation_captured_); |
| 951 true_branch_ = true_branch; | 956 true_branch_ = true_branch; |
| 952 false_branch_ = false_branch; | 957 false_branch_ = false_branch; |
| 953 position_ = position; | 958 position_ = position; |
| 954 continuation_captured_ = true; | 959 continuation_captured_ = true; |
| 955 } | 960 } |
| 956 | 961 |
| 957 void Continue(HBasicBlock** true_branch, | 962 void Continue(HBasicBlock** true_branch, |
| 958 HBasicBlock** false_branch, | 963 HBasicBlock** false_branch, |
| 959 int* position) { | 964 int* position) { |
| 960 ASSERT(continuation_captured_); | 965 ASSERT(continuation_captured_); |
| 961 *true_branch = true_branch_; | 966 *true_branch = true_branch_; |
| 962 *false_branch = false_branch_; | 967 *false_branch = false_branch_; |
| 963 if (position != NULL) *position = position_; | 968 if (position != NULL) *position = position_; |
| 964 continuation_captured_ = false; | 969 continuation_captured_ = false; |
| 965 } | 970 } |
| 966 | 971 |
| 967 bool IsTrueReachable() { return true_branch_ != NULL; } | 972 bool IsTrueReachable() { return true_branch_ != NULL; } |
| 968 bool IsFalseReachable() { return false_branch_ != NULL; } | 973 bool IsFalseReachable() { return false_branch_ != NULL; } |
| 969 bool TrueAndFalseReachable() { | 974 bool TrueAndFalseReachable() { |
| 970 return IsTrueReachable() || IsFalseReachable(); | 975 return IsTrueReachable() || IsFalseReachable(); |
| 971 } | 976 } |
| 972 | 977 |
| 978 HBasicBlock* true_branch() const { return true_branch_; } |
| 979 HBasicBlock* false_branch() const { return false_branch_; } |
| 980 |
| 981 private: |
| 973 bool continuation_captured_; | 982 bool continuation_captured_; |
| 974 HBasicBlock* true_branch_; | 983 HBasicBlock* true_branch_; |
| 975 HBasicBlock* false_branch_; | 984 HBasicBlock* false_branch_; |
| 976 int position_; | 985 int position_; |
| 977 }; | 986 }; |
| 978 | 987 |
| 979 | 988 |
| 980 class HGraphBuilder { | 989 class HGraphBuilder { |
| 981 public: | 990 public: |
| 982 explicit HGraphBuilder(CompilationInfo* info) | 991 explicit HGraphBuilder(CompilationInfo* info) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 HValue* elements, | 1230 HValue* elements, |
| 1222 ElementsKind kind, | 1231 ElementsKind kind, |
| 1223 HValue* length); | 1232 HValue* length); |
| 1224 | 1233 |
| 1225 void BuildTransitionElementsKind(HValue* object, | 1234 void BuildTransitionElementsKind(HValue* object, |
| 1226 HValue* map, | 1235 HValue* map, |
| 1227 ElementsKind from_kind, | 1236 ElementsKind from_kind, |
| 1228 ElementsKind to_kind, | 1237 ElementsKind to_kind, |
| 1229 bool is_jsarray); | 1238 bool is_jsarray); |
| 1230 | 1239 |
| 1240 // Do lookup in the number string cache. If the object is not found |
| 1241 // in the cache, the false branch of the continuation is taken; |
| 1242 // otherwise the true branch is taken and the returned value contains |
| 1243 // the cache value for the object. The returned value must NOT be used |
| 1244 // on the false branch. |
| 1245 HValue* BuildLookupNumberStringCache(HValue* object, |
| 1246 HIfContinuation* continuation); |
| 1247 HValue* BuildNumberToString(HValue* number); |
| 1248 |
| 1231 HInstruction* BuildUncheckedMonomorphicElementAccess( | 1249 HInstruction* BuildUncheckedMonomorphicElementAccess( |
| 1232 HValue* checked_object, | 1250 HValue* checked_object, |
| 1233 HValue* key, | 1251 HValue* key, |
| 1234 HValue* val, | 1252 HValue* val, |
| 1235 bool is_js_array, | 1253 bool is_js_array, |
| 1236 ElementsKind elements_kind, | 1254 ElementsKind elements_kind, |
| 1237 bool is_store, | 1255 bool is_store, |
| 1238 LoadKeyedHoleMode load_mode, | 1256 LoadKeyedHoleMode load_mode, |
| 1239 KeyedAccessStoreMode store_mode); | 1257 KeyedAccessStoreMode store_mode); |
| 1240 | 1258 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1265 HValue* right, | 1283 HValue* right, |
| 1266 HValue** operand, | 1284 HValue** operand, |
| 1267 HValue** shift_amount); | 1285 HValue** shift_amount); |
| 1268 | 1286 |
| 1269 HInstruction* BuildBinaryOperation(Token::Value op, | 1287 HInstruction* BuildBinaryOperation(Token::Value op, |
| 1270 HValue* left, | 1288 HValue* left, |
| 1271 HValue* right, | 1289 HValue* right, |
| 1272 Handle<Type> left_type, | 1290 Handle<Type> left_type, |
| 1273 Handle<Type> right_type, | 1291 Handle<Type> right_type, |
| 1274 Handle<Type> result_type, | 1292 Handle<Type> result_type, |
| 1275 Maybe<int> fixed_right_arg, | 1293 Maybe<int> fixed_right_arg); |
| 1276 HValue* context); | |
| 1277 | 1294 |
| 1278 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); | 1295 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); |
| 1279 | 1296 |
| 1280 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin); | 1297 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin); |
| 1281 | 1298 |
| 1282 HValue* EnforceNumberType(HValue* number, Handle<Type> expected); | 1299 HValue* EnforceNumberType(HValue* number, Handle<Type> expected); |
| 1283 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); | 1300 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); |
| 1284 | 1301 |
| 1285 void PushAndAdd(HInstruction* instr); | 1302 void PushAndAdd(HInstruction* instr); |
| 1286 | 1303 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 | 1391 |
| 1375 template<class Condition, class P2, class P3> | 1392 template<class Condition, class P2, class P3> |
| 1376 Condition* AndIf(HValue* p1, P2 p2, P3 p3) { | 1393 Condition* AndIf(HValue* p1, P2 p2, P3 p3) { |
| 1377 And(); | 1394 And(); |
| 1378 return If<Condition>(p1, p2, p3); | 1395 return If<Condition>(p1, p2, p3); |
| 1379 } | 1396 } |
| 1380 | 1397 |
| 1381 void Or(); | 1398 void Or(); |
| 1382 void And(); | 1399 void And(); |
| 1383 | 1400 |
| 1401 // Captures the current state of this IfBuilder in the specified |
| 1402 // continuation and ends this IfBuilder. |
| 1384 void CaptureContinuation(HIfContinuation* continuation); | 1403 void CaptureContinuation(HIfContinuation* continuation); |
| 1385 | 1404 |
| 1405 // Joins the specified continuation from this IfBuilder and ends this |
| 1406 // IfBuilder. This appends a Goto instruction from the true branch of |
| 1407 // this IfBuilder to the true branch of the continuation unless the |
| 1408 // true branch of this IfBuilder is already finished. And vice versa |
| 1409 // for the false branch. |
| 1410 // |
| 1411 // The basic idea is as follows: You have several nested IfBuilder's |
| 1412 // that you want to join based on two possible outcomes (i.e. success |
| 1413 // and failure, or whatever). You can do this easily using this method |
| 1414 // now, for example: |
| 1415 // |
| 1416 // HIfContinuation cont(graph()->CreateBasicBlock(), |
| 1417 // graph()->CreateBasicBlock()); |
| 1418 // ... |
| 1419 // IfBuilder if_whatever(this); |
| 1420 // if_whatever.If<Condition>(arg); |
| 1421 // if_whatever.Then(); |
| 1422 // ... |
| 1423 // if_whatever.Else(); |
| 1424 // ... |
| 1425 // if_whatever.JoinContinuation(&cont); |
| 1426 // ... |
| 1427 // IfBuilder if_something(this); |
| 1428 // if_something.If<Condition>(arg1, arg2); |
| 1429 // if_something.Then(); |
| 1430 // ... |
| 1431 // if_something.Else(); |
| 1432 // ... |
| 1433 // if_something.JoinContinuation(&cont); |
| 1434 // ... |
| 1435 // IfBuilder if_finally(this, &cont); |
| 1436 // if_finally.Then(); |
| 1437 // // continues after then code of if_whatever or if_something. |
| 1438 // ... |
| 1439 // if_finally.Else(); |
| 1440 // // continues after else code of if_whatever or if_something. |
| 1441 // ... |
| 1442 // if_finally.End(); |
| 1443 void JoinContinuation(HIfContinuation* continuation); |
| 1444 |
| 1386 void Then(); | 1445 void Then(); |
| 1387 void Else(); | 1446 void Else(); |
| 1388 void End(); | 1447 void End(); |
| 1389 | 1448 |
| 1390 void Deopt(const char* reason); | 1449 void Deopt(const char* reason); |
| 1391 void ElseDeopt(const char* reason) { | 1450 void ElseDeopt(const char* reason) { |
| 1392 Else(); | 1451 Else(); |
| 1393 Deopt(reason); | 1452 Deopt(reason); |
| 1394 } | 1453 } |
| 1395 | 1454 |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2380 } | 2439 } |
| 2381 | 2440 |
| 2382 private: | 2441 private: |
| 2383 HGraphBuilder* builder_; | 2442 HGraphBuilder* builder_; |
| 2384 }; | 2443 }; |
| 2385 | 2444 |
| 2386 | 2445 |
| 2387 } } // namespace v8::internal | 2446 } } // namespace v8::internal |
| 2388 | 2447 |
| 2389 #endif // V8_HYDROGEN_H_ | 2448 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |