| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_CODE_STUB_ASSEMBLER_H_ | 5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ |
| 6 #define V8_CODE_STUB_ASSEMBLER_H_ | 6 #define V8_CODE_STUB_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "src/compiler/code-assembler.h" | 10 #include "src/compiler/code-assembler.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 413 |
| 414 // Load the hash field of a name as an uint32 value. | 414 // Load the hash field of a name as an uint32 value. |
| 415 Node* LoadNameHashField(Node* name); | 415 Node* LoadNameHashField(Node* name); |
| 416 // Load the hash value of a name as an uint32 value. | 416 // Load the hash value of a name as an uint32 value. |
| 417 // If {if_hash_not_computed} label is specified then it also checks if | 417 // If {if_hash_not_computed} label is specified then it also checks if |
| 418 // hash is actually computed. | 418 // hash is actually computed. |
| 419 Node* LoadNameHash(Node* name, Label* if_hash_not_computed = nullptr); | 419 Node* LoadNameHash(Node* name, Label* if_hash_not_computed = nullptr); |
| 420 | 420 |
| 421 // Load length field of a String object. | 421 // Load length field of a String object. |
| 422 Node* LoadStringLength(Node* object); | 422 Node* LoadStringLength(Node* object); |
| 423 // Loads a pointer to the sequential String char array. |
| 424 Node* PointerToSeqStringData(Node* seq_string); |
| 423 // Load value field of a JSValue object. | 425 // Load value field of a JSValue object. |
| 424 Node* LoadJSValueValue(Node* object); | 426 Node* LoadJSValueValue(Node* object); |
| 425 // Load value field of a WeakCell object. | 427 // Load value field of a WeakCell object. |
| 426 Node* LoadWeakCellValueUnchecked(Node* weak_cell); | 428 Node* LoadWeakCellValueUnchecked(Node* weak_cell); |
| 427 Node* LoadWeakCellValue(Node* weak_cell, Label* if_cleared = nullptr); | 429 Node* LoadWeakCellValue(Node* weak_cell, Label* if_cleared = nullptr); |
| 428 | 430 |
| 429 // Load an array element from a FixedArray. | 431 // Load an array element from a FixedArray. |
| 430 Node* LoadFixedArrayElement(Node* object, Node* index, | 432 Node* LoadFixedArrayElement(Node* object, Node* index, |
| 431 int additional_offset = 0, | 433 int additional_offset = 0, |
| 432 ParameterMode parameter_mode = INTPTR_PARAMETERS); | 434 ParameterMode parameter_mode = INTPTR_PARAMETERS); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 // JSProxy or an object with interceptors. | 735 // JSProxy or an object with interceptors. |
| 734 Node* InstanceTypeEqual(Node* instance_type, int type); | 736 Node* InstanceTypeEqual(Node* instance_type, int type); |
| 735 Node* IsSpecialReceiverMap(Node* map); | 737 Node* IsSpecialReceiverMap(Node* map); |
| 736 Node* IsSpecialReceiverInstanceType(Node* instance_type); | 738 Node* IsSpecialReceiverInstanceType(Node* instance_type); |
| 737 Node* IsStringInstanceType(Node* instance_type); | 739 Node* IsStringInstanceType(Node* instance_type); |
| 738 Node* IsOneByteStringInstanceType(Node* instance_type); | 740 Node* IsOneByteStringInstanceType(Node* instance_type); |
| 739 Node* IsExternalStringInstanceType(Node* instance_type); | 741 Node* IsExternalStringInstanceType(Node* instance_type); |
| 740 Node* IsShortExternalStringInstanceType(Node* instance_type); | 742 Node* IsShortExternalStringInstanceType(Node* instance_type); |
| 741 Node* IsSequentialStringInstanceType(Node* instance_type); | 743 Node* IsSequentialStringInstanceType(Node* instance_type); |
| 742 Node* IsConsStringInstanceType(Node* instance_type); | 744 Node* IsConsStringInstanceType(Node* instance_type); |
| 745 Node* IsIndirectStringInstanceType(Node* instance_type); |
| 743 Node* IsString(Node* object); | 746 Node* IsString(Node* object); |
| 744 Node* IsJSObject(Node* object); | 747 Node* IsJSObject(Node* object); |
| 745 Node* IsJSGlobalProxy(Node* object); | 748 Node* IsJSGlobalProxy(Node* object); |
| 746 Node* IsJSReceiverInstanceType(Node* instance_type); | 749 Node* IsJSReceiverInstanceType(Node* instance_type); |
| 747 Node* IsJSReceiver(Node* object); | 750 Node* IsJSReceiver(Node* object); |
| 748 Node* IsJSReceiverMap(Node* map); | 751 Node* IsJSReceiverMap(Node* map); |
| 749 Node* IsMap(Node* object); | 752 Node* IsMap(Node* object); |
| 750 Node* IsCallableMap(Node* map); | 753 Node* IsCallableMap(Node* map); |
| 751 Node* IsDeprecatedMap(Node* map); | 754 Node* IsDeprecatedMap(Node* map); |
| 752 Node* IsCallable(Node* object); | 755 Node* IsCallable(Node* object); |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 Node* argc_; | 1525 Node* argc_; |
| 1523 Node* arguments_; | 1526 Node* arguments_; |
| 1524 Node* fp_; | 1527 Node* fp_; |
| 1525 }; | 1528 }; |
| 1526 | 1529 |
| 1527 class ToDirectStringAssembler : public CodeStubAssembler { | 1530 class ToDirectStringAssembler : public CodeStubAssembler { |
| 1528 private: | 1531 private: |
| 1529 enum StringPointerKind { PTR_TO_DATA, PTR_TO_STRING }; | 1532 enum StringPointerKind { PTR_TO_DATA, PTR_TO_STRING }; |
| 1530 | 1533 |
| 1531 public: | 1534 public: |
| 1532 explicit ToDirectStringAssembler(compiler::CodeAssemblerState* state, | 1535 enum Flag { |
| 1533 Node* string); | 1536 kDontUnpackSlicedStrings = 1 << 0, |
| 1537 }; |
| 1538 typedef base::Flags<Flag> Flags; |
| 1539 |
| 1540 ToDirectStringAssembler(compiler::CodeAssemblerState* state, Node* string, |
| 1541 Flags flags = Flags()); |
| 1534 | 1542 |
| 1535 // Converts flat cons, thin, and sliced strings and returns the direct | 1543 // Converts flat cons, thin, and sliced strings and returns the direct |
| 1536 // string. The result can be either a sequential or external string. | 1544 // string. The result can be either a sequential or external string. |
| 1545 // Jumps to if_bailout if the string if the string is indirect and cannot |
| 1546 // be unpacked. |
| 1537 Node* TryToDirect(Label* if_bailout); | 1547 Node* TryToDirect(Label* if_bailout); |
| 1538 | 1548 |
| 1539 // Returns a pointer to the beginning of the string data. | 1549 // Returns a pointer to the beginning of the string data. |
| 1550 // Jumps to if_bailout if the external string cannot be unpacked. |
| 1540 Node* PointerToData(Label* if_bailout) { | 1551 Node* PointerToData(Label* if_bailout) { |
| 1541 return TryToSequential(PTR_TO_DATA, if_bailout); | 1552 return TryToSequential(PTR_TO_DATA, if_bailout); |
| 1542 } | 1553 } |
| 1543 | 1554 |
| 1544 // Returns a pointer that, offset-wise, looks like a String. | 1555 // Returns a pointer that, offset-wise, looks like a String. |
| 1556 // Jumps to if_bailout if the external string cannot be unpacked. |
| 1545 Node* PointerToString(Label* if_bailout) { | 1557 Node* PointerToString(Label* if_bailout) { |
| 1546 return TryToSequential(PTR_TO_STRING, if_bailout); | 1558 return TryToSequential(PTR_TO_STRING, if_bailout); |
| 1547 } | 1559 } |
| 1548 | 1560 |
| 1549 Node* string() { return var_string_.value(); } | 1561 Node* string() { return var_string_.value(); } |
| 1550 Node* instance_type() { return var_instance_type_.value(); } | 1562 Node* instance_type() { return var_instance_type_.value(); } |
| 1551 Node* offset() { return var_offset_.value(); } | 1563 Node* offset() { return var_offset_.value(); } |
| 1552 Node* is_external() { return var_is_external_.value(); } | 1564 Node* is_external() { return var_is_external_.value(); } |
| 1553 | 1565 |
| 1554 private: | 1566 private: |
| 1555 Node* TryToSequential(StringPointerKind ptr_kind, Label* if_bailout); | 1567 Node* TryToSequential(StringPointerKind ptr_kind, Label* if_bailout); |
| 1556 | 1568 |
| 1557 Variable var_string_; | 1569 Variable var_string_; |
| 1558 Variable var_instance_type_; | 1570 Variable var_instance_type_; |
| 1559 Variable var_offset_; | 1571 Variable var_offset_; |
| 1560 Variable var_is_external_; | 1572 Variable var_is_external_; |
| 1573 |
| 1574 Flags flags_; |
| 1561 }; | 1575 }; |
| 1562 | 1576 |
| 1563 #ifdef DEBUG | 1577 #ifdef DEBUG |
| 1564 #define CSA_ASSERT(csa, x) \ | 1578 #define CSA_ASSERT(csa, x) \ |
| 1565 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__) | 1579 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__) |
| 1566 #define CSA_ASSERT_JS_ARGC_OP(csa, Op, op, expected) \ | 1580 #define CSA_ASSERT_JS_ARGC_OP(csa, Op, op, expected) \ |
| 1567 (csa)->Assert( \ | 1581 (csa)->Assert( \ |
| 1568 [&] { \ | 1582 [&] { \ |
| 1569 compiler::Node* const argc = \ | 1583 compiler::Node* const argc = \ |
| 1570 (csa)->Parameter(Descriptor::kActualArgumentsCount); \ | 1584 (csa)->Parameter(Descriptor::kActualArgumentsCount); \ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1593 } | 1607 } |
| 1594 #else | 1608 #else |
| 1595 #define CSA_SLOW_ASSERT(csa, x) ((void)0) | 1609 #define CSA_SLOW_ASSERT(csa, x) ((void)0) |
| 1596 #endif | 1610 #endif |
| 1597 | 1611 |
| 1598 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 1612 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
| 1599 | 1613 |
| 1600 } // namespace internal | 1614 } // namespace internal |
| 1601 } // namespace v8 | 1615 } // namespace v8 |
| 1602 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 1616 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
| OLD | NEW |