| 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 |
| 42 #include <stdio.h> | 43 #include <stdio.h> |
| 44 #include <vector> |
| 45 |
| 43 #include "assembler.h" | 46 #include "assembler.h" |
| 44 #include "constants-arm.h" | 47 #include "constants-arm.h" |
| 45 #include "serialize.h" | 48 #include "serialize.h" |
| 46 | 49 |
| 47 namespace v8 { | 50 namespace v8 { |
| 48 namespace internal { | 51 namespace internal { |
| 49 | 52 |
| 50 // CpuFeatures keeps track of which features are supported by the target CPU. | 53 // CpuFeatures keeps track of which features are supported by the target CPU. |
| 51 // Supported features must be enabled by a CpuFeatureScope before use. | 54 // Supported features must be enabled by a CpuFeatureScope before use. |
| 52 class CpuFeatures : public AllStatic { | 55 class CpuFeatures : public AllStatic { |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 class NeonListOperand BASE_EMBEDDED { | 698 class NeonListOperand BASE_EMBEDDED { |
| 696 public: | 699 public: |
| 697 explicit NeonListOperand(DoubleRegister base, int registers_count = 1); | 700 explicit NeonListOperand(DoubleRegister base, int registers_count = 1); |
| 698 DoubleRegister base() const { return base_; } | 701 DoubleRegister base() const { return base_; } |
| 699 NeonListType type() const { return type_; } | 702 NeonListType type() const { return type_; } |
| 700 private: | 703 private: |
| 701 DoubleRegister base_; | 704 DoubleRegister base_; |
| 702 NeonListType type_; | 705 NeonListType type_; |
| 703 }; | 706 }; |
| 704 | 707 |
| 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 |
| 705 extern const Instr kMovLrPc; | 739 extern const Instr kMovLrPc; |
| 706 extern const Instr kLdrPCMask; | 740 extern const Instr kLdrPCMask; |
| 707 extern const Instr kLdrPCPattern; | 741 extern const Instr kLdrPCPattern; |
| 742 extern const Instr kLdrPpMask; |
| 743 extern const Instr kLdrPpPattern; |
| 708 extern const Instr kBlxRegMask; | 744 extern const Instr kBlxRegMask; |
| 709 extern const Instr kBlxRegPattern; | 745 extern const Instr kBlxRegPattern; |
| 710 extern const Instr kBlxIp; | 746 extern const Instr kBlxIp; |
| 711 | 747 |
| 712 extern const Instr kMovMvnMask; | 748 extern const Instr kMovMvnMask; |
| 713 extern const Instr kMovMvnPattern; | 749 extern const Instr kMovMvnPattern; |
| 714 extern const Instr kMovMvnFlip; | 750 extern const Instr kMovMvnFlip; |
| 715 | 751 |
| 716 extern const Instr kMovLeaveCCMask; | 752 extern const Instr kMovLeaveCCMask; |
| 717 extern const Instr kMovLeaveCCPattern; | 753 extern const Instr kMovLeaveCCPattern; |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 } | 1442 } |
| 1407 static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } | 1443 static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } |
| 1408 static void instr_at_put(byte* pc, Instr instr) { | 1444 static void instr_at_put(byte* pc, Instr instr) { |
| 1409 *reinterpret_cast<Instr*>(pc) = instr; | 1445 *reinterpret_cast<Instr*>(pc) = instr; |
| 1410 } | 1446 } |
| 1411 static Condition GetCondition(Instr instr); | 1447 static Condition GetCondition(Instr instr); |
| 1412 static bool IsBranch(Instr instr); | 1448 static bool IsBranch(Instr instr); |
| 1413 static int GetBranchOffset(Instr instr); | 1449 static int GetBranchOffset(Instr instr); |
| 1414 static bool IsLdrRegisterImmediate(Instr instr); | 1450 static bool IsLdrRegisterImmediate(Instr instr); |
| 1415 static bool IsVldrDRegisterImmediate(Instr instr); | 1451 static bool IsVldrDRegisterImmediate(Instr instr); |
| 1452 static bool IsLdrPpImmediateOffset(Instr instr); |
| 1453 static bool IsVldrDPpImmediateOffset(Instr instr); |
| 1416 static int GetLdrRegisterImmediateOffset(Instr instr); | 1454 static int GetLdrRegisterImmediateOffset(Instr instr); |
| 1417 static int GetVldrDRegisterImmediateOffset(Instr instr); | 1455 static int GetVldrDRegisterImmediateOffset(Instr instr); |
| 1418 static Instr SetLdrRegisterImmediateOffset(Instr instr, int offset); | 1456 static Instr SetLdrRegisterImmediateOffset(Instr instr, int offset); |
| 1419 static Instr SetVldrDRegisterImmediateOffset(Instr instr, int offset); | 1457 static Instr SetVldrDRegisterImmediateOffset(Instr instr, int offset); |
| 1420 static bool IsStrRegisterImmediate(Instr instr); | 1458 static bool IsStrRegisterImmediate(Instr instr); |
| 1421 static Instr SetStrRegisterImmediateOffset(Instr instr, int offset); | 1459 static Instr SetStrRegisterImmediateOffset(Instr instr, int offset); |
| 1422 static bool IsAddRegisterImmediate(Instr instr); | 1460 static bool IsAddRegisterImmediate(Instr instr); |
| 1423 static Instr SetAddRegisterImmediateOffset(Instr instr, int offset); | 1461 static Instr SetAddRegisterImmediateOffset(Instr instr, int offset); |
| 1424 static Register GetRd(Instr instr); | 1462 static Register GetRd(Instr instr); |
| 1425 static Register GetRn(Instr instr); | 1463 static Register GetRn(Instr instr); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1451 static const int kMaxNumPending32RelocInfo = kMaxDistToIntPool/kInstrSize; | 1489 static const int kMaxNumPending32RelocInfo = kMaxDistToIntPool/kInstrSize; |
| 1452 static const int kMaxNumPending64RelocInfo = kMaxDistToFPPool/kInstrSize; | 1490 static const int kMaxNumPending64RelocInfo = kMaxDistToFPPool/kInstrSize; |
| 1453 | 1491 |
| 1454 // Postpone the generation of the constant pool for the specified number of | 1492 // Postpone the generation of the constant pool for the specified number of |
| 1455 // instructions. | 1493 // instructions. |
| 1456 void BlockConstPoolFor(int instructions); | 1494 void BlockConstPoolFor(int instructions); |
| 1457 | 1495 |
| 1458 // Check if is time to emit a constant pool. | 1496 // Check if is time to emit a constant pool. |
| 1459 void CheckConstPool(bool force_emit, bool require_jump); | 1497 void CheckConstPool(bool force_emit, bool require_jump); |
| 1460 | 1498 |
| 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 |
| 1461 bool can_use_constant_pool() const { | 1505 bool can_use_constant_pool() const { |
| 1462 return is_constant_pool_available() && !constant_pool_full_; | 1506 return is_constant_pool_available() && !constant_pool_full_; |
| 1463 } | 1507 } |
| 1464 | 1508 |
| 1465 void set_constant_pool_full() { | 1509 void set_constant_pool_full() { |
| 1466 constant_pool_full_ = true; | 1510 constant_pool_full_ = true; |
| 1467 } | 1511 } |
| 1468 | 1512 |
| 1469 protected: | 1513 protected: |
| 1470 // Relocation for a type-recording IC has the AST id added to it. This | 1514 // 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... |
| 1577 // pending relocation entry per instruction. | 1621 // pending relocation entry per instruction. |
| 1578 | 1622 |
| 1579 // The buffers of pending relocation info. | 1623 // The buffers of pending relocation info. |
| 1580 RelocInfo pending_32_bit_reloc_info_[kMaxNumPending32RelocInfo]; | 1624 RelocInfo pending_32_bit_reloc_info_[kMaxNumPending32RelocInfo]; |
| 1581 RelocInfo pending_64_bit_reloc_info_[kMaxNumPending64RelocInfo]; | 1625 RelocInfo pending_64_bit_reloc_info_[kMaxNumPending64RelocInfo]; |
| 1582 // Number of pending reloc info entries in the 32 bits buffer. | 1626 // Number of pending reloc info entries in the 32 bits buffer. |
| 1583 int num_pending_32_bit_reloc_info_; | 1627 int num_pending_32_bit_reloc_info_; |
| 1584 // Number of pending reloc info entries in the 64 bits buffer. | 1628 // Number of pending reloc info entries in the 64 bits buffer. |
| 1585 int num_pending_64_bit_reloc_info_; | 1629 int num_pending_64_bit_reloc_info_; |
| 1586 | 1630 |
| 1631 ConstantPoolBuilder constant_pool_builder_; |
| 1632 |
| 1587 // The bound position, before this we cannot do instruction elimination. | 1633 // The bound position, before this we cannot do instruction elimination. |
| 1588 int last_bound_pos_; | 1634 int last_bound_pos_; |
| 1589 | 1635 |
| 1590 // Indicates whether the constant pool can be accessed, which is only possible | 1636 // Indicates whether the constant pool can be accessed, which is only possible |
| 1591 // if the pp register points to the current code object's constant pool. | 1637 // if the pp register points to the current code object's constant pool. |
| 1592 bool constant_pool_available_; | 1638 bool constant_pool_available_; |
| 1593 // Indicates whether the constant pool is too full to accept new entries due | 1639 // Indicates whether the constant pool is too full to accept new entries due |
| 1594 // to the ldr instruction's limitted immediate offset range. | 1640 // to the ldr instruction's limitted immediate offset range. |
| 1595 bool constant_pool_full_; | 1641 bool constant_pool_full_; |
| 1596 | 1642 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1615 void print(Label* L); | 1661 void print(Label* L); |
| 1616 void bind_to(Label* L, int pos); | 1662 void bind_to(Label* L, int pos); |
| 1617 void next(Label* L); | 1663 void next(Label* L); |
| 1618 | 1664 |
| 1619 enum UseConstantPoolMode { | 1665 enum UseConstantPoolMode { |
| 1620 USE_CONSTANT_POOL, | 1666 USE_CONSTANT_POOL, |
| 1621 DONT_USE_CONSTANT_POOL | 1667 DONT_USE_CONSTANT_POOL |
| 1622 }; | 1668 }; |
| 1623 | 1669 |
| 1624 // Record reloc info for current pc_ | 1670 // Record reloc info for current pc_ |
| 1625 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0, | 1671 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
| 1626 UseConstantPoolMode mode = USE_CONSTANT_POOL); | 1672 void RecordRelocInfo(const RelocInfo& rinfo); |
| 1627 void RecordRelocInfo(double data); | 1673 void ConstantPoolAddEntry(const RelocInfo& rinfo); |
| 1628 void RecordRelocInfoConstantPoolEntryHelper(const RelocInfo& rinfo); | |
| 1629 | 1674 |
| 1630 friend class RelocInfo; | 1675 friend class RelocInfo; |
| 1631 friend class CodePatcher; | 1676 friend class CodePatcher; |
| 1632 friend class BlockConstPoolScope; | 1677 friend class BlockConstPoolScope; |
| 1633 friend class FrameAndConstantPoolScope; | 1678 friend class FrameAndConstantPoolScope; |
| 1634 friend class ConstantPoolUnavailableScope; | 1679 friend class ConstantPoolUnavailableScope; |
| 1635 | 1680 |
| 1636 PositionsRecorder positions_recorder_; | 1681 PositionsRecorder positions_recorder_; |
| 1637 friend class PositionsRecorder; | 1682 friend class PositionsRecorder; |
| 1638 friend class EnsureSpace; | 1683 friend class EnsureSpace; |
| 1639 }; | 1684 }; |
| 1640 | 1685 |
| 1641 | 1686 |
| 1642 class EnsureSpace BASE_EMBEDDED { | 1687 class EnsureSpace BASE_EMBEDDED { |
| 1643 public: | 1688 public: |
| 1644 explicit EnsureSpace(Assembler* assembler) { | 1689 explicit EnsureSpace(Assembler* assembler) { |
| 1645 assembler->CheckBuffer(); | 1690 assembler->CheckBuffer(); |
| 1646 } | 1691 } |
| 1647 }; | 1692 }; |
| 1648 | 1693 |
| 1649 | 1694 |
| 1650 } } // namespace v8::internal | 1695 } } // namespace v8::internal |
| 1651 | 1696 |
| 1652 #endif // V8_ARM_ASSEMBLER_ARM_H_ | 1697 #endif // V8_ARM_ASSEMBLER_ARM_H_ |
| OLD | NEW |