| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 scale(scale) {} | 69 scale(scale) {} |
| 70 Register reg; | 70 Register reg; |
| 71 ScaleFactor scale; | 71 ScaleFactor scale; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // MacroAssembler implements a collection of frequently used macros. | 74 // MacroAssembler implements a collection of frequently used macros. |
| 75 class MacroAssembler: public Assembler { | 75 class MacroAssembler: public Assembler { |
| 76 public: | 76 public: |
| 77 MacroAssembler(void* buffer, int size); | 77 MacroAssembler(void* buffer, int size); |
| 78 | 78 |
| 79 // Prevent the use of the RootArray during the lifetime of this |
| 80 // scope object. |
| 81 class NoRootArrayScope BASE_EMBEDDED { |
| 82 public: |
| 83 explicit NoRootArrayScope(MacroAssembler* assembler) |
| 84 : variable_(&assembler->root_array_available_), |
| 85 old_value_(assembler->root_array_available_) { |
| 86 assembler->root_array_available_ = false; |
| 87 } |
| 88 ~NoRootArrayScope() { |
| 89 *variable_ = old_value_; |
| 90 } |
| 91 private: |
| 92 bool* variable_; |
| 93 bool old_value_; |
| 94 }; |
| 95 |
| 96 // Operand pointing to an external reference. |
| 97 // May emit code to set up the scratch register. The operand is |
| 98 // only guaranteed to be correct as long as the scratch register |
| 99 // isn't changed. |
| 100 // If the operand is used more than once, use a scratch register |
| 101 // that is guaranteed not to be clobbered. |
| 102 Operand ExternalOperand(ExternalReference reference, |
| 103 Register scratch = kScratchRegister); |
| 104 // Loads and stores the value of an external reference. |
| 105 // Special case code for load and store to take advantage of |
| 106 // load_rax/store_rax if possible/necessary. |
| 107 // For other operations, just use: |
| 108 // Operand operand = ExternalOperand(extref); |
| 109 // operation(operand, ..); |
| 110 void Load(Register destination, ExternalReference source); |
| 111 void Store(ExternalReference destination, Register source); |
| 112 // Loads the address of the external reference into the destination |
| 113 // register. |
| 114 void LoadAddress(Register destination, ExternalReference source); |
| 115 // Returns the size of the code generated by LoadAddress. |
| 116 // Used by CallSize(ExternalReference) to find the size of a call. |
| 117 int LoadAddressSize(ExternalReference source); |
| 118 |
| 119 // Operations on roots in the root-array. |
| 79 void LoadRoot(Register destination, Heap::RootListIndex index); | 120 void LoadRoot(Register destination, Heap::RootListIndex index); |
| 121 void StoreRoot(Register source, Heap::RootListIndex index); |
| 80 // Load a root value where the index (or part of it) is variable. | 122 // Load a root value where the index (or part of it) is variable. |
| 81 // The variable_offset register is added to the fixed_offset value | 123 // The variable_offset register is added to the fixed_offset value |
| 82 // to get the index into the root-array. | 124 // to get the index into the root-array. |
| 83 void LoadRootIndexed(Register destination, | 125 void LoadRootIndexed(Register destination, |
| 84 Register variable_offset, | 126 Register variable_offset, |
| 85 int fixed_offset); | 127 int fixed_offset); |
| 86 void CompareRoot(Register with, Heap::RootListIndex index); | 128 void CompareRoot(Register with, Heap::RootListIndex index); |
| 87 void CompareRoot(const Operand& with, Heap::RootListIndex index); | 129 void CompareRoot(const Operand& with, Heap::RootListIndex index); |
| 88 void PushRoot(Heap::RootListIndex index); | 130 void PushRoot(Heap::RootListIndex index); |
| 89 void StoreRoot(Register source, Heap::RootListIndex index); | |
| 90 | 131 |
| 91 // --------------------------------------------------------------------------- | 132 // --------------------------------------------------------------------------- |
| 92 // GC Support | 133 // GC Support |
| 93 | 134 |
| 94 // For page containing |object| mark region covering |addr| dirty. | 135 // For page containing |object| mark region covering |addr| dirty. |
| 95 // RecordWriteHelper only works if the object is not in new | 136 // RecordWriteHelper only works if the object is not in new |
| 96 // space. | 137 // space. |
| 97 void RecordWriteHelper(Register object, | 138 void RecordWriteHelper(Register object, |
| 98 Register addr, | 139 Register addr, |
| 99 Register scratch); | 140 Register scratch); |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 void Jump(Handle<Code> code_object, RelocInfo::Mode rmode); | 667 void Jump(Handle<Code> code_object, RelocInfo::Mode rmode); |
| 627 | 668 |
| 628 void Call(Address destination, RelocInfo::Mode rmode); | 669 void Call(Address destination, RelocInfo::Mode rmode); |
| 629 void Call(ExternalReference ext); | 670 void Call(ExternalReference ext); |
| 630 void Call(Handle<Code> code_object, RelocInfo::Mode rmode); | 671 void Call(Handle<Code> code_object, RelocInfo::Mode rmode); |
| 631 | 672 |
| 632 // The size of the code generated for different call instructions. | 673 // The size of the code generated for different call instructions. |
| 633 int CallSize(Address destination, RelocInfo::Mode rmode) { | 674 int CallSize(Address destination, RelocInfo::Mode rmode) { |
| 634 return kCallInstructionLength; | 675 return kCallInstructionLength; |
| 635 } | 676 } |
| 636 int CallSize(ExternalReference ext) { | 677 int CallSize(ExternalReference ext); |
| 637 return kCallInstructionLength; | |
| 638 } | |
| 639 int CallSize(Handle<Code> code_object) { | 678 int CallSize(Handle<Code> code_object) { |
| 640 // Code calls use 32-bit relative addressing. | 679 // Code calls use 32-bit relative addressing. |
| 641 return kShortCallInstructionLength; | 680 return kShortCallInstructionLength; |
| 642 } | 681 } |
| 643 int CallSize(Register target) { | 682 int CallSize(Register target) { |
| 644 // Opcode: REX_opt FF /2 m64 | 683 // Opcode: REX_opt FF /2 m64 |
| 645 return (target.high_bit() != 0) ? 3 : 2; | 684 return (target.high_bit() != 0) ? 3 : 2; |
| 646 } | 685 } |
| 647 int CallSize(const Operand& target) { | 686 int CallSize(const Operand& target) { |
| 648 // Opcode: REX_opt FF /2 m64 | 687 // Opcode: REX_opt FF /2 m64 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 bool allow_stub_calls() { return allow_stub_calls_; } | 1055 bool allow_stub_calls() { return allow_stub_calls_; } |
| 1017 | 1056 |
| 1018 private: | 1057 private: |
| 1019 // Order general registers are pushed by Pushad. | 1058 // Order general registers are pushed by Pushad. |
| 1020 // rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r14, r15. | 1059 // rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r14, r15. |
| 1021 static int kSafepointPushRegisterIndices[Register::kNumRegisters]; | 1060 static int kSafepointPushRegisterIndices[Register::kNumRegisters]; |
| 1022 static const int kNumSafepointSavedRegisters = 11; | 1061 static const int kNumSafepointSavedRegisters = 11; |
| 1023 | 1062 |
| 1024 bool generating_stub_; | 1063 bool generating_stub_; |
| 1025 bool allow_stub_calls_; | 1064 bool allow_stub_calls_; |
| 1065 bool root_array_available_; |
| 1026 | 1066 |
| 1027 // Returns a register holding the smi value. The register MUST NOT be | 1067 // Returns a register holding the smi value. The register MUST NOT be |
| 1028 // modified. It may be the "smi 1 constant" register. | 1068 // modified. It may be the "smi 1 constant" register. |
| 1029 Register GetSmiConstant(Smi* value); | 1069 Register GetSmiConstant(Smi* value); |
| 1030 | 1070 |
| 1031 // Moves the smi value to the destination register. | 1071 // Moves the smi value to the destination register. |
| 1032 void LoadSmiConstant(Register dst, Smi* value); | 1072 void LoadSmiConstant(Register dst, Smi* value); |
| 1033 | 1073 |
| 1034 // This handle will be patched with the code object on installation. | 1074 // This handle will be patched with the code object on installation. |
| 1035 Handle<Object> code_object_; | 1075 Handle<Object> code_object_; |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 Jump(adaptor, RelocInfo::CODE_TARGET); | 1928 Jump(adaptor, RelocInfo::CODE_TARGET); |
| 1889 } | 1929 } |
| 1890 bind(&invoke); | 1930 bind(&invoke); |
| 1891 } | 1931 } |
| 1892 } | 1932 } |
| 1893 | 1933 |
| 1894 | 1934 |
| 1895 } } // namespace v8::internal | 1935 } } // namespace v8::internal |
| 1896 | 1936 |
| 1897 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ | 1937 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ |
| OLD | NEW |