OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HYDROGEN_H_ | 5 #ifndef V8_HYDROGEN_H_ |
6 #define V8_HYDROGEN_H_ | 6 #define V8_HYDROGEN_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 // When initializing arrays, we'll unfold the loop if the number of elements | 1302 // When initializing arrays, we'll unfold the loop if the number of elements |
1303 // is known at compile time and is <= kElementLoopUnrollThreshold. | 1303 // is known at compile time and is <= kElementLoopUnrollThreshold. |
1304 static const int kElementLoopUnrollThreshold = 8; | 1304 static const int kElementLoopUnrollThreshold = 8; |
1305 | 1305 |
1306 protected: | 1306 protected: |
1307 virtual bool BuildGraph() = 0; | 1307 virtual bool BuildGraph() = 0; |
1308 | 1308 |
1309 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1309 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
1310 HBasicBlock* CreateLoopHeaderBlock(); | 1310 HBasicBlock* CreateLoopHeaderBlock(); |
1311 | 1311 |
| 1312 template <class BitFieldClass> |
| 1313 HValue* BuildDecodeField(HValue* encoded_field) { |
| 1314 HValue* shifted_field = AddUncasted<HShr>(encoded_field, |
| 1315 Add<HConstant>(static_cast<int>(BitFieldClass::kShift))); |
| 1316 HValue* mask_value = Add<HConstant>(static_cast<int>(BitFieldClass::kMask)); |
| 1317 return AddUncasted<HBitwise>(Token::BIT_AND, shifted_field, mask_value); |
| 1318 } |
| 1319 |
| 1320 HValue* BuildGetElementsKind(HValue* object); |
| 1321 |
1312 HValue* BuildCheckHeapObject(HValue* object); | 1322 HValue* BuildCheckHeapObject(HValue* object); |
1313 HValue* BuildCheckString(HValue* string); | 1323 HValue* BuildCheckString(HValue* string); |
1314 HValue* BuildWrapReceiver(HValue* object, HValue* function); | 1324 HValue* BuildWrapReceiver(HValue* object, HValue* function); |
1315 | 1325 |
1316 // Building common constructs | 1326 // Building common constructs |
1317 HValue* BuildCheckForCapacityGrow(HValue* object, | 1327 HValue* BuildCheckForCapacityGrow(HValue* object, |
1318 HValue* elements, | 1328 HValue* elements, |
1319 ElementsKind kind, | 1329 ElementsKind kind, |
1320 HValue* length, | 1330 HValue* length, |
1321 HValue* key, | 1331 HValue* key, |
1322 bool is_js_array, | 1332 bool is_js_array, |
1323 PropertyAccessType access_type); | 1333 PropertyAccessType access_type); |
1324 | 1334 |
1325 HValue* BuildCopyElementsOnWrite(HValue* object, | 1335 HValue* BuildCopyElementsOnWrite(HValue* object, |
1326 HValue* elements, | 1336 HValue* elements, |
1327 ElementsKind kind, | 1337 ElementsKind kind, |
1328 HValue* length); | 1338 HValue* length); |
1329 | 1339 |
1330 void BuildTransitionElementsKind(HValue* object, | 1340 void BuildTransitionElementsKind(HValue* object, |
1331 HValue* map, | 1341 HValue* map, |
1332 ElementsKind from_kind, | 1342 ElementsKind from_kind, |
1333 ElementsKind to_kind, | 1343 ElementsKind to_kind, |
1334 bool is_jsarray); | 1344 bool is_jsarray); |
1335 | 1345 |
1336 HValue* BuildNumberToString(HValue* object, Type* type); | 1346 HValue* BuildNumberToString(HValue* object, Type* type); |
1337 | 1347 |
| 1348 void BuildReceiverCheck(HValue* receiver, |
| 1349 int bit_field_mask); |
| 1350 |
| 1351 // Checks a key value that's being used for a keyed element access context. If |
| 1352 // the key is a index, i.e. a smi or a number in a unique string with a cached |
| 1353 // numeric value, the "true" of the continuation is joined. Otherwise, |
| 1354 // if the key is a name or a unique string, the "false" of the continuation is |
| 1355 // joined. Otherwise, a deoptimization is triggered. In both paths of the |
| 1356 // continuation, the key is pushed on the top of the environment. |
| 1357 void BuildKeyedIndexCheck(HValue* key, |
| 1358 HIfContinuation* join_continuation); |
| 1359 |
| 1360 // Checks the properties of an object if they are in dictionary case, in which |
| 1361 // case "true" of continuation is taken, otherwise the "false" |
| 1362 void BuildCheckForDictionaryProperties(HValue* object, |
| 1363 HIfContinuation* continuation); |
| 1364 |
| 1365 void BuildGlobalInstanceTypeCheck(HValue* receiver); |
| 1366 |
| 1367 HValue* BuildKeyedLookupCacheHash(HValue* object, |
| 1368 HValue* key); |
| 1369 |
1338 HValue* BuildUncheckedDictionaryElementLoad(HValue* receiver, | 1370 HValue* BuildUncheckedDictionaryElementLoad(HValue* receiver, |
1339 HValue* key); | 1371 HValue* elements, |
| 1372 HValue* key, |
| 1373 HValue* hash); |
1340 | 1374 |
1341 HValue* BuildRegExpConstructResult(HValue* length, | 1375 HValue* BuildRegExpConstructResult(HValue* length, |
1342 HValue* index, | 1376 HValue* index, |
1343 HValue* input); | 1377 HValue* input); |
1344 | 1378 |
1345 // Allocates a new object according with the given allocation properties. | 1379 // Allocates a new object according with the given allocation properties. |
1346 HAllocate* BuildAllocate(HValue* object_size, | 1380 HAllocate* BuildAllocate(HValue* object_size, |
1347 HType type, | 1381 HType type, |
1348 InstanceType instance_type, | 1382 InstanceType instance_type, |
1349 HAllocationMode allocation_mode); | 1383 HAllocationMode allocation_mode); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 HInstruction* increment_; | 1701 HInstruction* increment_; |
1668 HPhi* phi_; | 1702 HPhi* phi_; |
1669 HBasicBlock* header_block_; | 1703 HBasicBlock* header_block_; |
1670 HBasicBlock* body_block_; | 1704 HBasicBlock* body_block_; |
1671 HBasicBlock* exit_block_; | 1705 HBasicBlock* exit_block_; |
1672 HBasicBlock* exit_trampoline_block_; | 1706 HBasicBlock* exit_trampoline_block_; |
1673 Direction direction_; | 1707 Direction direction_; |
1674 bool finished_; | 1708 bool finished_; |
1675 }; | 1709 }; |
1676 | 1710 |
| 1711 template <class A, class P1> |
| 1712 void DeoptimizeIf(P1 p1, char* const reason) { |
| 1713 IfBuilder builder(this); |
| 1714 builder.If<A>(p1); |
| 1715 builder.ThenDeopt(reason); |
| 1716 } |
| 1717 |
| 1718 template <class A, class P1, class P2> |
| 1719 void DeoptimizeIf(P1 p1, P2 p2, const char* reason) { |
| 1720 IfBuilder builder(this); |
| 1721 builder.If<A>(p1, p2); |
| 1722 builder.ThenDeopt(reason); |
| 1723 } |
| 1724 |
| 1725 template <class A, class P1, class P2, class P3> |
| 1726 void DeoptimizeIf(P1 p1, P2 p2, P3 p3, const char* reason) { |
| 1727 IfBuilder builder(this); |
| 1728 builder.If<A>(p1, p2, p3); |
| 1729 builder.ThenDeopt(reason); |
| 1730 } |
| 1731 |
1677 HValue* BuildNewElementsCapacity(HValue* old_capacity); | 1732 HValue* BuildNewElementsCapacity(HValue* old_capacity); |
1678 | 1733 |
1679 class JSArrayBuilder V8_FINAL { | 1734 class JSArrayBuilder V8_FINAL { |
1680 public: | 1735 public: |
1681 JSArrayBuilder(HGraphBuilder* builder, | 1736 JSArrayBuilder(HGraphBuilder* builder, |
1682 ElementsKind kind, | 1737 ElementsKind kind, |
1683 HValue* allocation_site_payload, | 1738 HValue* allocation_site_payload, |
1684 HValue* constructor_function, | 1739 HValue* constructor_function, |
1685 AllocationSiteOverrideMode override_mode); | 1740 AllocationSiteOverrideMode override_mode); |
1686 | 1741 |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2839 } | 2894 } |
2840 | 2895 |
2841 private: | 2896 private: |
2842 HGraphBuilder* builder_; | 2897 HGraphBuilder* builder_; |
2843 }; | 2898 }; |
2844 | 2899 |
2845 | 2900 |
2846 } } // namespace v8::internal | 2901 } } // namespace v8::internal |
2847 | 2902 |
2848 #endif // V8_HYDROGEN_H_ | 2903 #endif // V8_HYDROGEN_H_ |
OLD | NEW |