| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
| 6 // are met: | 6 // are met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // The original source code covered by the above license above has been | 33 // The original source code covered by the above license above has been |
| 34 // modified significantly by Google Inc. | 34 // modified significantly by Google Inc. |
| 35 // Copyright 2012 the V8 project authors. All rights reserved. | 35 // Copyright 2012 the V8 project authors. All rights reserved. |
| 36 | 36 |
| 37 // A light-weight ARM Assembler | 37 // A light-weight ARM Assembler |
| 38 // Generates user mode instructions for the ARM architecture up to version 5 | 38 // Generates user mode instructions for the ARM architecture up to version 5 |
| 39 | 39 |
| 40 #ifndef V8_ARM_ASSEMBLER_ARM_H_ | 40 #ifndef V8_ARM_ASSEMBLER_ARM_H_ |
| 41 #define V8_ARM_ASSEMBLER_ARM_H_ | 41 #define V8_ARM_ASSEMBLER_ARM_H_ |
| 42 | |
| 43 #include <stdio.h> | 42 #include <stdio.h> |
| 44 #include <vector> | |
| 45 | |
| 46 #include "assembler.h" | 43 #include "assembler.h" |
| 47 #include "constants-arm.h" | 44 #include "constants-arm.h" |
| 48 #include "serialize.h" | 45 #include "serialize.h" |
| 49 | 46 |
| 50 namespace v8 { | 47 namespace v8 { |
| 51 namespace internal { | 48 namespace internal { |
| 52 | 49 |
| 53 // CpuFeatures keeps track of which features are supported by the target CPU. | 50 // CpuFeatures keeps track of which features are supported by the target CPU. |
| 54 // Supported features must be enabled by a CpuFeatureScope before use. | 51 // Supported features must be enabled by a CpuFeatureScope before use. |
| 55 class CpuFeatures : public AllStatic { | 52 class CpuFeatures : public AllStatic { |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 class NeonListOperand BASE_EMBEDDED { | 695 class NeonListOperand BASE_EMBEDDED { |
| 699 public: | 696 public: |
| 700 explicit NeonListOperand(DoubleRegister base, int registers_count = 1); | 697 explicit NeonListOperand(DoubleRegister base, int registers_count = 1); |
| 701 DoubleRegister base() const { return base_; } | 698 DoubleRegister base() const { return base_; } |
| 702 NeonListType type() const { return type_; } | 699 NeonListType type() const { return type_; } |
| 703 private: | 700 private: |
| 704 DoubleRegister base_; | 701 DoubleRegister base_; |
| 705 NeonListType type_; | 702 NeonListType type_; |
| 706 }; | 703 }; |
| 707 | 704 |
| 708 | |
| 709 // Class used to build a constant pool. | |
| 710 class ConstantPoolBuilder BASE_EMBEDDED { | |
| 711 public: | |
| 712 explicit ConstantPoolBuilder(); | |
| 713 void AddEntry(Assembler* assm, const RelocInfo& rinfo); | |
| 714 void Relocate(int pc_delta); | |
| 715 bool IsEmpty(); | |
| 716 MaybeObject* Allocate(Heap* heap); | |
| 717 void Populate(Assembler* assm, ConstantPoolArray* constant_pool); | |
| 718 | |
| 719 inline int count_of_64bit() const { return count_of_64bit_; } | |
| 720 inline int count_of_code_ptr() const { return count_of_code_ptr_; } | |
| 721 inline int count_of_heap_ptr() const { return count_of_heap_ptr_; } | |
| 722 inline int count_of_32bit() const { return count_of_32bit_; } | |
| 723 | |
| 724 private: | |
| 725 bool Is64BitEntry(RelocInfo::Mode rmode); | |
| 726 bool Is32BitEntry(RelocInfo::Mode rmode); | |
| 727 bool IsCodePtrEntry(RelocInfo::Mode rmode); | |
| 728 bool IsHeapPtrEntry(RelocInfo::Mode rmode); | |
| 729 | |
| 730 std::vector<RelocInfo> entries_; | |
| 731 std::vector<int> merged_indexes_; | |
| 732 int count_of_64bit_; | |
| 733 int count_of_code_ptr_; | |
| 734 int count_of_heap_ptr_; | |
| 735 int count_of_32bit_; | |
| 736 }; | |
| 737 | |
| 738 | |
| 739 extern const Instr kMovLrPc; | 705 extern const Instr kMovLrPc; |
| 740 extern const Instr kLdrPCMask; | 706 extern const Instr kLdrPCMask; |
| 741 extern const Instr kLdrPCPattern; | 707 extern const Instr kLdrPCPattern; |
| 742 extern const Instr kLdrPpMask; | |
| 743 extern const Instr kLdrPpPattern; | |
| 744 extern const Instr kBlxRegMask; | 708 extern const Instr kBlxRegMask; |
| 745 extern const Instr kBlxRegPattern; | 709 extern const Instr kBlxRegPattern; |
| 746 extern const Instr kBlxIp; | 710 extern const Instr kBlxIp; |
| 747 | 711 |
| 748 extern const Instr kMovMvnMask; | 712 extern const Instr kMovMvnMask; |
| 749 extern const Instr kMovMvnPattern; | 713 extern const Instr kMovMvnPattern; |
| 750 extern const Instr kMovMvnFlip; | 714 extern const Instr kMovMvnFlip; |
| 751 | 715 |
| 752 extern const Instr kMovLeaveCCMask; | 716 extern const Instr kMovLeaveCCMask; |
| 753 extern const Instr kMovLeaveCCPattern; | 717 extern const Instr kMovLeaveCCPattern; |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 } | 1406 } |
| 1443 static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } | 1407 static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } |
| 1444 static void instr_at_put(byte* pc, Instr instr) { | 1408 static void instr_at_put(byte* pc, Instr instr) { |
| 1445 *reinterpret_cast<Instr*>(pc) = instr; | 1409 *reinterpret_cast<Instr*>(pc) = instr; |
| 1446 } | 1410 } |
| 1447 static Condition GetCondition(Instr instr); | 1411 static Condition GetCondition(Instr instr); |
| 1448 static bool IsBranch(Instr instr); | 1412 static bool IsBranch(Instr instr); |
| 1449 static int GetBranchOffset(Instr instr); | 1413 static int GetBranchOffset(Instr instr); |
| 1450 static bool IsLdrRegisterImmediate(Instr instr); | 1414 static bool IsLdrRegisterImmediate(Instr instr); |
| 1451 static bool IsVldrDRegisterImmediate(Instr instr); | 1415 static bool IsVldrDRegisterImmediate(Instr instr); |
| 1452 static bool IsLdrPpImmediateOffset(Instr instr); | |
| 1453 static bool IsVldrDPpImmediateOffset(Instr instr); | |
| 1454 static int GetLdrRegisterImmediateOffset(Instr instr); | 1416 static int GetLdrRegisterImmediateOffset(Instr instr); |
| 1455 static int GetVldrDRegisterImmediateOffset(Instr instr); | 1417 static int GetVldrDRegisterImmediateOffset(Instr instr); |
| 1456 static Instr SetLdrRegisterImmediateOffset(Instr instr, int offset); | 1418 static Instr SetLdrRegisterImmediateOffset(Instr instr, int offset); |
| 1457 static Instr SetVldrDRegisterImmediateOffset(Instr instr, int offset); | 1419 static Instr SetVldrDRegisterImmediateOffset(Instr instr, int offset); |
| 1458 static bool IsStrRegisterImmediate(Instr instr); | 1420 static bool IsStrRegisterImmediate(Instr instr); |
| 1459 static Instr SetStrRegisterImmediateOffset(Instr instr, int offset); | 1421 static Instr SetStrRegisterImmediateOffset(Instr instr, int offset); |
| 1460 static bool IsAddRegisterImmediate(Instr instr); | 1422 static bool IsAddRegisterImmediate(Instr instr); |
| 1461 static Instr SetAddRegisterImmediateOffset(Instr instr, int offset); | 1423 static Instr SetAddRegisterImmediateOffset(Instr instr, int offset); |
| 1462 static Register GetRd(Instr instr); | 1424 static Register GetRd(Instr instr); |
| 1463 static Register GetRn(Instr instr); | 1425 static Register GetRn(Instr instr); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1489 static const int kMaxNumPending32RelocInfo = kMaxDistToIntPool/kInstrSize; | 1451 static const int kMaxNumPending32RelocInfo = kMaxDistToIntPool/kInstrSize; |
| 1490 static const int kMaxNumPending64RelocInfo = kMaxDistToFPPool/kInstrSize; | 1452 static const int kMaxNumPending64RelocInfo = kMaxDistToFPPool/kInstrSize; |
| 1491 | 1453 |
| 1492 // Postpone the generation of the constant pool for the specified number of | 1454 // Postpone the generation of the constant pool for the specified number of |
| 1493 // instructions. | 1455 // instructions. |
| 1494 void BlockConstPoolFor(int instructions); | 1456 void BlockConstPoolFor(int instructions); |
| 1495 | 1457 |
| 1496 // Check if is time to emit a constant pool. | 1458 // Check if is time to emit a constant pool. |
| 1497 void CheckConstPool(bool force_emit, bool require_jump); | 1459 void CheckConstPool(bool force_emit, bool require_jump); |
| 1498 | 1460 |
| 1499 // Allocate a constant pool of the correct size for the generated code. | |
| 1500 MaybeObject* AllocateConstantPool(Heap* heap); | |
| 1501 | |
| 1502 // Generate the constant pool for the generated code. | |
| 1503 void PopulateConstantPool(ConstantPoolArray* constant_pool); | |
| 1504 | |
| 1505 bool can_use_constant_pool() const { | 1461 bool can_use_constant_pool() const { |
| 1506 return is_constant_pool_available() && !constant_pool_full_; | 1462 return is_constant_pool_available() && !constant_pool_full_; |
| 1507 } | 1463 } |
| 1508 | 1464 |
| 1509 void set_constant_pool_full() { | 1465 void set_constant_pool_full() { |
| 1510 constant_pool_full_ = true; | 1466 constant_pool_full_ = true; |
| 1511 } | 1467 } |
| 1512 | 1468 |
| 1513 protected: | 1469 protected: |
| 1514 // Relocation for a type-recording IC has the AST id added to it. This | 1470 // Relocation for a type-recording IC has the AST id added to it. This |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1621 // pending relocation entry per instruction. | 1577 // pending relocation entry per instruction. |
| 1622 | 1578 |
| 1623 // The buffers of pending relocation info. | 1579 // The buffers of pending relocation info. |
| 1624 RelocInfo pending_32_bit_reloc_info_[kMaxNumPending32RelocInfo]; | 1580 RelocInfo pending_32_bit_reloc_info_[kMaxNumPending32RelocInfo]; |
| 1625 RelocInfo pending_64_bit_reloc_info_[kMaxNumPending64RelocInfo]; | 1581 RelocInfo pending_64_bit_reloc_info_[kMaxNumPending64RelocInfo]; |
| 1626 // Number of pending reloc info entries in the 32 bits buffer. | 1582 // Number of pending reloc info entries in the 32 bits buffer. |
| 1627 int num_pending_32_bit_reloc_info_; | 1583 int num_pending_32_bit_reloc_info_; |
| 1628 // Number of pending reloc info entries in the 64 bits buffer. | 1584 // Number of pending reloc info entries in the 64 bits buffer. |
| 1629 int num_pending_64_bit_reloc_info_; | 1585 int num_pending_64_bit_reloc_info_; |
| 1630 | 1586 |
| 1631 ConstantPoolBuilder constant_pool_builder_; | |
| 1632 | |
| 1633 // The bound position, before this we cannot do instruction elimination. | 1587 // The bound position, before this we cannot do instruction elimination. |
| 1634 int last_bound_pos_; | 1588 int last_bound_pos_; |
| 1635 | 1589 |
| 1636 // Indicates whether the constant pool can be accessed, which is only possible | 1590 // Indicates whether the constant pool can be accessed, which is only possible |
| 1637 // if the pp register points to the current code object's constant pool. | 1591 // if the pp register points to the current code object's constant pool. |
| 1638 bool constant_pool_available_; | 1592 bool constant_pool_available_; |
| 1639 // Indicates whether the constant pool is too full to accept new entries due | 1593 // Indicates whether the constant pool is too full to accept new entries due |
| 1640 // to the ldr instruction's limitted immediate offset range. | 1594 // to the ldr instruction's limitted immediate offset range. |
| 1641 bool constant_pool_full_; | 1595 bool constant_pool_full_; |
| 1642 | 1596 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1661 void print(Label* L); | 1615 void print(Label* L); |
| 1662 void bind_to(Label* L, int pos); | 1616 void bind_to(Label* L, int pos); |
| 1663 void next(Label* L); | 1617 void next(Label* L); |
| 1664 | 1618 |
| 1665 enum UseConstantPoolMode { | 1619 enum UseConstantPoolMode { |
| 1666 USE_CONSTANT_POOL, | 1620 USE_CONSTANT_POOL, |
| 1667 DONT_USE_CONSTANT_POOL | 1621 DONT_USE_CONSTANT_POOL |
| 1668 }; | 1622 }; |
| 1669 | 1623 |
| 1670 // Record reloc info for current pc_ | 1624 // Record reloc info for current pc_ |
| 1671 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); | 1625 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0, |
| 1672 void RecordRelocInfo(const RelocInfo& rinfo); | 1626 UseConstantPoolMode mode = USE_CONSTANT_POOL); |
| 1673 void ConstantPoolAddEntry(const RelocInfo& rinfo); | 1627 void RecordRelocInfo(double data); |
| 1628 void RecordRelocInfoConstantPoolEntryHelper(const RelocInfo& rinfo); |
| 1674 | 1629 |
| 1675 friend class RelocInfo; | 1630 friend class RelocInfo; |
| 1676 friend class CodePatcher; | 1631 friend class CodePatcher; |
| 1677 friend class BlockConstPoolScope; | 1632 friend class BlockConstPoolScope; |
| 1678 friend class FrameAndConstantPoolScope; | 1633 friend class FrameAndConstantPoolScope; |
| 1679 friend class ConstantPoolUnavailableScope; | 1634 friend class ConstantPoolUnavailableScope; |
| 1680 | 1635 |
| 1681 PositionsRecorder positions_recorder_; | 1636 PositionsRecorder positions_recorder_; |
| 1682 friend class PositionsRecorder; | 1637 friend class PositionsRecorder; |
| 1683 friend class EnsureSpace; | 1638 friend class EnsureSpace; |
| 1684 }; | 1639 }; |
| 1685 | 1640 |
| 1686 | 1641 |
| 1687 class EnsureSpace BASE_EMBEDDED { | 1642 class EnsureSpace BASE_EMBEDDED { |
| 1688 public: | 1643 public: |
| 1689 explicit EnsureSpace(Assembler* assembler) { | 1644 explicit EnsureSpace(Assembler* assembler) { |
| 1690 assembler->CheckBuffer(); | 1645 assembler->CheckBuffer(); |
| 1691 } | 1646 } |
| 1692 }; | 1647 }; |
| 1693 | 1648 |
| 1694 | 1649 |
| 1695 } } // namespace v8::internal | 1650 } } // namespace v8::internal |
| 1696 | 1651 |
| 1697 #endif // V8_ARM_ASSEMBLER_ARM_H_ | 1652 #endif // V8_ARM_ASSEMBLER_ARM_H_ |
| OLD | NEW |