| 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 11 matching lines...) Expand all  Loading... | 
|    22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |    22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
|    23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |    23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
|    24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |    24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
|    25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |    25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
|    26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |    26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
|    27  |    27  | 
|    28 #ifndef V8_X64_MACRO_ASSEMBLER_X64_H_ |    28 #ifndef V8_X64_MACRO_ASSEMBLER_X64_H_ | 
|    29 #define V8_X64_MACRO_ASSEMBLER_X64_H_ |    29 #define V8_X64_MACRO_ASSEMBLER_X64_H_ | 
|    30  |    30  | 
|    31 #include "assembler.h" |    31 #include "assembler.h" | 
|    32 #include "frames.h" |  | 
|    33 #include "v8globals.h" |    32 #include "v8globals.h" | 
|    34  |    33  | 
|    35 namespace v8 { |    34 namespace v8 { | 
|    36 namespace internal { |    35 namespace internal { | 
|    37  |    36  | 
|    38 // Flags used for the AllocateInNewSpace functions. |    37 // Flags used for the AllocateInNewSpace functions. | 
|    39 enum AllocationFlags { |    38 enum AllocationFlags { | 
|    40   // No special flags. |    39   // No special flags. | 
|    41   NO_ALLOCATION_FLAGS = 0, |    40   NO_ALLOCATION_FLAGS = 0, | 
|    42   // Return the pointer to the allocated already tagged as a heap object. |    41   // Return the pointer to the allocated already tagged as a heap object. | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|    66 class JumpTarget; |    65 class JumpTarget; | 
|    67  |    66  | 
|    68 struct SmiIndex { |    67 struct SmiIndex { | 
|    69   SmiIndex(Register index_register, ScaleFactor scale) |    68   SmiIndex(Register index_register, ScaleFactor scale) | 
|    70       : reg(index_register), |    69       : reg(index_register), | 
|    71         scale(scale) {} |    70         scale(scale) {} | 
|    72   Register reg; |    71   Register reg; | 
|    73   ScaleFactor scale; |    72   ScaleFactor scale; | 
|    74 }; |    73 }; | 
|    75  |    74  | 
|    76  |  | 
|    77 // MacroAssembler implements a collection of frequently used macros. |    75 // MacroAssembler implements a collection of frequently used macros. | 
|    78 class MacroAssembler: public Assembler { |    76 class MacroAssembler: public Assembler { | 
|    79  public: |    77  public: | 
|    80   // The isolate parameter can be NULL if the macro assembler should |    78   // The isolate parameter can be NULL if the macro assembler should | 
|    81   // not use isolate-dependent functionality. In this case, it's the |    79   // not use isolate-dependent functionality. In this case, it's the | 
|    82   // responsibility of the caller to never invoke such function on the |    80   // responsibility of the caller to never invoke such function on the | 
|    83   // macro assembler. |    81   // macro assembler. | 
|    84   MacroAssembler(Isolate* isolate, void* buffer, int size); |    82   MacroAssembler(Isolate* isolate, void* buffer, int size); | 
|    85  |    83  | 
|    86   // Prevent the use of the RootArray during the lifetime of this |    84   // Prevent the use of the RootArray during the lifetime of this | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   187                          Register value, |   185                          Register value, | 
|   188                          Register scratch); |   186                          Register scratch); | 
|   189  |   187  | 
|   190 #ifdef ENABLE_DEBUGGER_SUPPORT |   188 #ifdef ENABLE_DEBUGGER_SUPPORT | 
|   191   // --------------------------------------------------------------------------- |   189   // --------------------------------------------------------------------------- | 
|   192   // Debugger Support |   190   // Debugger Support | 
|   193  |   191  | 
|   194   void DebugBreak(); |   192   void DebugBreak(); | 
|   195 #endif |   193 #endif | 
|   196  |   194  | 
 |   195   // --------------------------------------------------------------------------- | 
 |   196   // Activation frames | 
 |   197  | 
 |   198   void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); } | 
 |   199   void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); } | 
 |   200  | 
 |   201   void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); } | 
 |   202   void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); } | 
 |   203  | 
|   197   // Enter specific kind of exit frame; either in normal or |   204   // Enter specific kind of exit frame; either in normal or | 
|   198   // debug mode. Expects the number of arguments in register rax and |   205   // debug mode. Expects the number of arguments in register rax and | 
|   199   // sets up the number of arguments in register rdi and the pointer |   206   // sets up the number of arguments in register rdi and the pointer | 
|   200   // to the first argument in register rsi. |   207   // to the first argument in register rsi. | 
|   201   // |   208   // | 
|   202   // Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack |   209   // Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack | 
|   203   // accessible via StackSpaceOperand. |   210   // accessible via StackSpaceOperand. | 
|   204   void EnterExitFrame(int arg_stack_space = 0, bool save_doubles = false); |   211   void EnterExitFrame(int arg_stack_space = 0, bool save_doubles = false); | 
|   205  |   212  | 
|   206   // Enter specific kind of exit frame. Allocates arg_stack_space * kPointerSize |   213   // Enter specific kind of exit frame. Allocates arg_stack_space * kPointerSize | 
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1111   void Abort(const char* msg); |  1118   void Abort(const char* msg); | 
|  1112  |  1119  | 
|  1113   // Check that the stack is aligned. |  1120   // Check that the stack is aligned. | 
|  1114   void CheckStackAlignment(); |  1121   void CheckStackAlignment(); | 
|  1115  |  1122  | 
|  1116   // Verify restrictions about code generated in stubs. |  1123   // Verify restrictions about code generated in stubs. | 
|  1117   void set_generating_stub(bool value) { generating_stub_ = value; } |  1124   void set_generating_stub(bool value) { generating_stub_ = value; } | 
|  1118   bool generating_stub() { return generating_stub_; } |  1125   bool generating_stub() { return generating_stub_; } | 
|  1119   void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; } |  1126   void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; } | 
|  1120   bool allow_stub_calls() { return allow_stub_calls_; } |  1127   bool allow_stub_calls() { return allow_stub_calls_; } | 
|  1121   void set_has_frame(bool value) { has_frame_ = value; } |  | 
|  1122   bool has_frame() { return has_frame_; } |  | 
|  1123   inline bool AllowThisStubCall(CodeStub* stub); |  | 
|  1124  |  1128  | 
|  1125   static int SafepointRegisterStackIndex(Register reg) { |  1129   static int SafepointRegisterStackIndex(Register reg) { | 
|  1126     return SafepointRegisterStackIndex(reg.code()); |  1130     return SafepointRegisterStackIndex(reg.code()); | 
|  1127   } |  1131   } | 
|  1128  |  1132  | 
|  1129   // Activation support. |  | 
|  1130   void EnterFrame(StackFrame::Type type); |  | 
|  1131   void LeaveFrame(StackFrame::Type type); |  | 
|  1132  |  | 
|  1133  private: |  1133  private: | 
|  1134   // Order general registers are pushed by Pushad. |  1134   // Order general registers are pushed by Pushad. | 
|  1135   // rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r14, r15. |  1135   // rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r14, r15. | 
|  1136   static int kSafepointPushRegisterIndices[Register::kNumRegisters]; |  1136   static int kSafepointPushRegisterIndices[Register::kNumRegisters]; | 
|  1137   static const int kNumSafepointSavedRegisters = 11; |  1137   static const int kNumSafepointSavedRegisters = 11; | 
|  1138   static const int kSmiShift = kSmiTagSize + kSmiShiftSize; |  1138   static const int kSmiShift = kSmiTagSize + kSmiShiftSize; | 
|  1139  |  1139  | 
|  1140   bool generating_stub_; |  1140   bool generating_stub_; | 
|  1141   bool allow_stub_calls_; |  1141   bool allow_stub_calls_; | 
|  1142   bool has_frame_; |  | 
|  1143   bool root_array_available_; |  1142   bool root_array_available_; | 
|  1144  |  1143  | 
|  1145   // Returns a register holding the smi value. The register MUST NOT be |  1144   // Returns a register holding the smi value. The register MUST NOT be | 
|  1146   // modified. It may be the "smi 1 constant" register. |  1145   // modified. It may be the "smi 1 constant" register. | 
|  1147   Register GetSmiConstant(Smi* value); |  1146   Register GetSmiConstant(Smi* value); | 
|  1148  |  1147  | 
|  1149   // Moves the smi value to the destination register. |  1148   // Moves the smi value to the destination register. | 
|  1150   void LoadSmiConstant(Register dst, Smi* value); |  1149   void LoadSmiConstant(Register dst, Smi* value); | 
|  1151  |  1150  | 
|  1152   // This handle will be patched with the code object on installation. |  1151   // This handle will be patched with the code object on installation. | 
|  1153   Handle<Object> code_object_; |  1152   Handle<Object> code_object_; | 
|  1154  |  1153  | 
|  1155   // Helper functions for generating invokes. |  1154   // Helper functions for generating invokes. | 
|  1156   void InvokePrologue(const ParameterCount& expected, |  1155   void InvokePrologue(const ParameterCount& expected, | 
|  1157                       const ParameterCount& actual, |  1156                       const ParameterCount& actual, | 
|  1158                       Handle<Code> code_constant, |  1157                       Handle<Code> code_constant, | 
|  1159                       Register code_register, |  1158                       Register code_register, | 
|  1160                       Label* done, |  1159                       Label* done, | 
|  1161                       InvokeFlag flag, |  1160                       InvokeFlag flag, | 
|  1162                       Label::Distance near_jump = Label::kFar, |  1161                       Label::Distance near_jump = Label::kFar, | 
|  1163                       const CallWrapper& call_wrapper = NullCallWrapper(), |  1162                       const CallWrapper& call_wrapper = NullCallWrapper(), | 
|  1164                       CallKind call_kind = CALL_AS_METHOD); |  1163                       CallKind call_kind = CALL_AS_METHOD); | 
|  1165  |  1164  | 
 |  1165   // Activation support. | 
 |  1166   void EnterFrame(StackFrame::Type type); | 
 |  1167   void LeaveFrame(StackFrame::Type type); | 
 |  1168  | 
|  1166   void EnterExitFramePrologue(bool save_rax); |  1169   void EnterExitFramePrologue(bool save_rax); | 
|  1167  |  1170  | 
|  1168   // Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack |  1171   // Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack | 
|  1169   // accessible via StackSpaceOperand. |  1172   // accessible via StackSpaceOperand. | 
|  1170   void EnterExitFrameEpilogue(int arg_stack_space, bool save_doubles); |  1173   void EnterExitFrameEpilogue(int arg_stack_space, bool save_doubles); | 
|  1171  |  1174  | 
|  1172   void LeaveExitFrameEpilogue(); |  1175   void LeaveExitFrameEpilogue(); | 
|  1173  |  1176  | 
|  1174   // Allocation support helpers. |  1177   // Allocation support helpers. | 
|  1175   // Loads the top of new-space into the result register. |  1178   // Loads the top of new-space into the result register. | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1279     masm->popfd();                                                        \ |  1282     masm->popfd();                                                        \ | 
|  1280   }                                                                       \ |  1283   }                                                                       \ | 
|  1281   masm-> |  1284   masm-> | 
|  1282 #else |  1285 #else | 
|  1283 #define ACCESS_MASM(masm) masm-> |  1286 #define ACCESS_MASM(masm) masm-> | 
|  1284 #endif |  1287 #endif | 
|  1285  |  1288  | 
|  1286 } }  // namespace v8::internal |  1289 } }  // namespace v8::internal | 
|  1287  |  1290  | 
|  1288 #endif  // V8_X64_MACRO_ASSEMBLER_X64_H_ |  1291 #endif  // V8_X64_MACRO_ASSEMBLER_X64_H_ | 
| OLD | NEW |