| 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 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 Node* argc_; | 1524 Node* argc_; |
| 1523 Node* arguments_; | 1525 Node* arguments_; |
| 1524 Node* fp_; | 1526 Node* fp_; |
| 1525 }; | 1527 }; |
| 1526 | 1528 |
| 1527 class ToDirectStringAssembler : public CodeStubAssembler { | 1529 class ToDirectStringAssembler : public CodeStubAssembler { |
| 1528 private: | 1530 private: |
| 1529 enum StringPointerKind { PTR_TO_DATA, PTR_TO_STRING }; | 1531 enum StringPointerKind { PTR_TO_DATA, PTR_TO_STRING }; |
| 1530 | 1532 |
| 1531 public: | 1533 public: |
| 1532 explicit ToDirectStringAssembler(compiler::CodeAssemblerState* state, | 1534 enum Flag { |
| 1533 Node* string); | 1535 kDontUnpackSlicedStrings = 1 << 0, |
| 1536 }; |
| 1537 typedef base::Flags<Flag> Flags; |
| 1538 |
| 1539 ToDirectStringAssembler(compiler::CodeAssemblerState* state, Node* string, |
| 1540 Flags flags = Flags()); |
| 1534 | 1541 |
| 1535 // Converts flat cons, thin, and sliced strings and returns the direct | 1542 // Converts flat cons, thin, and sliced strings and returns the direct |
| 1536 // string. The result can be either a sequential or external string. | 1543 // string. The result can be either a sequential or external string. |
| 1544 // Jumps to if_bailout if the string if the string is indirect and cannot |
| 1545 // be unpacked. |
| 1537 Node* TryToDirect(Label* if_bailout); | 1546 Node* TryToDirect(Label* if_bailout); |
| 1538 | 1547 |
| 1539 // Returns a pointer to the beginning of the string data. | 1548 // Returns a pointer to the beginning of the string data. |
| 1549 // Jumps to if_bailout if the external string cannot be unpacked. |
| 1540 Node* PointerToData(Label* if_bailout) { | 1550 Node* PointerToData(Label* if_bailout) { |
| 1541 return TryToSequential(PTR_TO_DATA, if_bailout); | 1551 return TryToSequential(PTR_TO_DATA, if_bailout); |
| 1542 } | 1552 } |
| 1543 | 1553 |
| 1544 // Returns a pointer that, offset-wise, looks like a String. | 1554 // Returns a pointer that, offset-wise, looks like a String. |
| 1555 // Jumps to if_bailout if the external string cannot be unpacked. |
| 1545 Node* PointerToString(Label* if_bailout) { | 1556 Node* PointerToString(Label* if_bailout) { |
| 1546 return TryToSequential(PTR_TO_STRING, if_bailout); | 1557 return TryToSequential(PTR_TO_STRING, if_bailout); |
| 1547 } | 1558 } |
| 1548 | 1559 |
| 1549 Node* string() { return var_string_.value(); } | 1560 Node* string() { return var_string_.value(); } |
| 1550 Node* instance_type() { return var_instance_type_.value(); } | 1561 Node* instance_type() { return var_instance_type_.value(); } |
| 1551 Node* offset() { return var_offset_.value(); } | 1562 Node* offset() { return var_offset_.value(); } |
| 1552 Node* is_external() { return var_is_external_.value(); } | 1563 Node* is_external() { return var_is_external_.value(); } |
| 1553 | 1564 |
| 1554 private: | 1565 private: |
| 1555 Node* TryToSequential(StringPointerKind ptr_kind, Label* if_bailout); | 1566 Node* TryToSequential(StringPointerKind ptr_kind, Label* if_bailout); |
| 1556 | 1567 |
| 1557 Variable var_string_; | 1568 Variable var_string_; |
| 1558 Variable var_instance_type_; | 1569 Variable var_instance_type_; |
| 1559 Variable var_offset_; | 1570 Variable var_offset_; |
| 1560 Variable var_is_external_; | 1571 Variable var_is_external_; |
| 1572 |
| 1573 const Flags flags_; |
| 1561 }; | 1574 }; |
| 1562 | 1575 |
| 1563 #ifdef DEBUG | 1576 #ifdef DEBUG |
| 1564 #define CSA_ASSERT(csa, x) \ | 1577 #define CSA_ASSERT(csa, x) \ |
| 1565 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__) | 1578 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__) |
| 1566 #define CSA_ASSERT_JS_ARGC_OP(csa, Op, op, expected) \ | 1579 #define CSA_ASSERT_JS_ARGC_OP(csa, Op, op, expected) \ |
| 1567 (csa)->Assert( \ | 1580 (csa)->Assert( \ |
| 1568 [&] { \ | 1581 [&] { \ |
| 1569 compiler::Node* const argc = \ | 1582 compiler::Node* const argc = \ |
| 1570 (csa)->Parameter(Descriptor::kActualArgumentsCount); \ | 1583 (csa)->Parameter(Descriptor::kActualArgumentsCount); \ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1593 } | 1606 } |
| 1594 #else | 1607 #else |
| 1595 #define CSA_SLOW_ASSERT(csa, x) ((void)0) | 1608 #define CSA_SLOW_ASSERT(csa, x) ((void)0) |
| 1596 #endif | 1609 #endif |
| 1597 | 1610 |
| 1598 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 1611 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
| 1599 | 1612 |
| 1600 } // namespace internal | 1613 } // namespace internal |
| 1601 } // namespace v8 | 1614 } // namespace v8 |
| 1602 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 1615 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
| OLD | NEW |