| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // R10 : number of arguments to the call. | 39 // R10 : number of arguments to the call. |
| 40 // Must preserve callee saved registers R12 and R13. | 40 // Must preserve callee saved registers R12 and R13. |
| 41 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 41 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
| 42 const intptr_t thread_offset = NativeArguments::thread_offset(); | 42 const intptr_t thread_offset = NativeArguments::thread_offset(); |
| 43 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); | 43 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); |
| 44 const intptr_t argv_offset = NativeArguments::argv_offset(); | 44 const intptr_t argv_offset = NativeArguments::argv_offset(); |
| 45 const intptr_t retval_offset = NativeArguments::retval_offset(); | 45 const intptr_t retval_offset = NativeArguments::retval_offset(); |
| 46 | 46 |
| 47 __ EnterStubFrame(); | 47 __ EnterStubFrame(); |
| 48 | 48 |
| 49 COMPILE_ASSERT( | |
| 50 (CallingConventions::kCalleeSaveCpuRegisters & (1 << R12)) != 0); | |
| 51 __ LoadIsolate(R12); | |
| 52 | |
| 53 // Save exit frame information to enable stack walking as we are about | 49 // Save exit frame information to enable stack walking as we are about |
| 54 // to transition to Dart VM C++ code. | 50 // to transition to Dart VM C++ code. |
| 55 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), RBP); | 51 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), RBP); |
| 56 | 52 |
| 57 #if defined(DEBUG) | 53 #if defined(DEBUG) |
| 58 { Label ok; | 54 { Label ok; |
| 59 // Check that we are always entering from Dart code. | 55 // Check that we are always entering from Dart code. |
| 60 __ movq(RAX, Immediate(VMTag::kDartTagId)); | 56 __ movq(RAX, Immediate(VMTag::kDartTagId)); |
| 61 __ cmpq(RAX, Address(R12, Isolate::vm_tag_offset())); | 57 __ cmpq(RAX, Assembler::VMTagAddress()); |
| 62 __ j(EQUAL, &ok, Assembler::kNearJump); | 58 __ j(EQUAL, &ok, Assembler::kNearJump); |
| 63 __ Stop("Not coming from Dart code."); | 59 __ Stop("Not coming from Dart code."); |
| 64 __ Bind(&ok); | 60 __ Bind(&ok); |
| 65 } | 61 } |
| 66 #endif | 62 #endif |
| 67 | 63 |
| 68 // Mark that the isolate is executing VM code. | 64 // Mark that the thread is executing VM code. |
| 69 __ movq(Address(R12, Isolate::vm_tag_offset()), RBX); | 65 __ movq(Assembler::VMTagAddress(), RBX); |
| 70 | 66 |
| 71 // Reserve space for arguments and align frame before entering C++ world. | 67 // Reserve space for arguments and align frame before entering C++ world. |
| 72 __ subq(RSP, Immediate(sizeof(NativeArguments))); | 68 __ subq(RSP, Immediate(sizeof(NativeArguments))); |
| 73 if (OS::ActivationFrameAlignment() > 1) { | 69 if (OS::ActivationFrameAlignment() > 1) { |
| 74 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 70 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
| 75 } | 71 } |
| 76 | 72 |
| 77 // Pass NativeArguments structure by value and call runtime. | 73 // Pass NativeArguments structure by value and call runtime. |
| 78 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. | 74 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. |
| 79 // There are no runtime calls to closures, so we do not need to set the tag | 75 // There are no runtime calls to closures, so we do not need to set the tag |
| 80 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. | 76 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. |
| 81 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. | 77 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. |
| 82 // Compute argv. | 78 // Compute argv. |
| 83 __ leaq(RAX, Address(RBP, R10, TIMES_8, kParamEndSlotFromFp * kWordSize)); | 79 __ leaq(RAX, Address(RBP, R10, TIMES_8, kParamEndSlotFromFp * kWordSize)); |
| 84 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. | 80 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. |
| 85 __ addq(RAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. | 81 __ addq(RAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. |
| 86 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. | 82 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. |
| 87 #if defined(_WIN64) | 83 #if defined(_WIN64) |
| 88 ASSERT(sizeof(NativeArguments) > CallingConventions::kRegisterTransferLimit); | 84 ASSERT(sizeof(NativeArguments) > CallingConventions::kRegisterTransferLimit); |
| 89 __ movq(CallingConventions::kArg1Reg, RSP); | 85 __ movq(CallingConventions::kArg1Reg, RSP); |
| 90 #endif | 86 #endif |
| 91 __ CallCFunction(RBX); | 87 __ CallCFunction(RBX); |
| 92 | 88 |
| 93 // Mark that the isolate is executing Dart code. | 89 // Mark that the thread is executing Dart code. |
| 94 __ movq(Address(R12, Isolate::vm_tag_offset()), | 90 __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); |
| 95 Immediate(VMTag::kDartTagId)); | |
| 96 | 91 |
| 97 // Reset exit frame information in Isolate structure. | 92 // Reset exit frame information in Isolate structure. |
| 98 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); | 93 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); |
| 99 | 94 |
| 100 __ LeaveStubFrame(); | 95 __ LeaveStubFrame(); |
| 101 __ ret(); | 96 __ ret(); |
| 102 } | 97 } |
| 103 | 98 |
| 104 | 99 |
| 105 // Print the stop message. | 100 // Print the stop message. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 NativeArguments::thread_offset() + native_args_struct_offset; | 132 NativeArguments::thread_offset() + native_args_struct_offset; |
| 138 const intptr_t argc_tag_offset = | 133 const intptr_t argc_tag_offset = |
| 139 NativeArguments::argc_tag_offset() + native_args_struct_offset; | 134 NativeArguments::argc_tag_offset() + native_args_struct_offset; |
| 140 const intptr_t argv_offset = | 135 const intptr_t argv_offset = |
| 141 NativeArguments::argv_offset() + native_args_struct_offset; | 136 NativeArguments::argv_offset() + native_args_struct_offset; |
| 142 const intptr_t retval_offset = | 137 const intptr_t retval_offset = |
| 143 NativeArguments::retval_offset() + native_args_struct_offset; | 138 NativeArguments::retval_offset() + native_args_struct_offset; |
| 144 | 139 |
| 145 __ EnterStubFrame(); | 140 __ EnterStubFrame(); |
| 146 | 141 |
| 147 COMPILE_ASSERT( | |
| 148 (CallingConventions::kCalleeSaveCpuRegisters & (1 << R12)) != 0); | |
| 149 __ LoadIsolate(R12); | |
| 150 | |
| 151 // Save exit frame information to enable stack walking as we are about | 142 // Save exit frame information to enable stack walking as we are about |
| 152 // to transition to native code. | 143 // to transition to native code. |
| 153 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), RBP); | 144 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), RBP); |
| 154 | 145 |
| 155 #if defined(DEBUG) | 146 #if defined(DEBUG) |
| 156 { Label ok; | 147 { Label ok; |
| 157 // Check that we are always entering from Dart code. | 148 // Check that we are always entering from Dart code. |
| 158 __ movq(R8, Immediate(VMTag::kDartTagId)); | 149 __ movq(R8, Immediate(VMTag::kDartTagId)); |
| 159 __ cmpq(R8, Address(R12, Isolate::vm_tag_offset())); | 150 __ cmpq(R8, Assembler::VMTagAddress()); |
| 160 __ j(EQUAL, &ok, Assembler::kNearJump); | 151 __ j(EQUAL, &ok, Assembler::kNearJump); |
| 161 __ Stop("Not coming from Dart code."); | 152 __ Stop("Not coming from Dart code."); |
| 162 __ Bind(&ok); | 153 __ Bind(&ok); |
| 163 } | 154 } |
| 164 #endif | 155 #endif |
| 165 | 156 |
| 166 // Mark that the isolate is executing Native code. | 157 // Mark that the thread is executing native code. |
| 167 __ movq(Address(R12, Isolate::vm_tag_offset()), RBX); | 158 __ movq(Assembler::VMTagAddress(), RBX); |
| 168 | 159 |
| 169 // Reserve space for the native arguments structure passed on the stack (the | 160 // Reserve space for the native arguments structure passed on the stack (the |
| 170 // outgoing pointer parameter to the native arguments structure is passed in | 161 // outgoing pointer parameter to the native arguments structure is passed in |
| 171 // RDI) and align frame before entering the C++ world. | 162 // RDI) and align frame before entering the C++ world. |
| 172 __ subq(RSP, Immediate(sizeof(NativeArguments))); | 163 __ subq(RSP, Immediate(sizeof(NativeArguments))); |
| 173 if (OS::ActivationFrameAlignment() > 1) { | 164 if (OS::ActivationFrameAlignment() > 1) { |
| 174 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 165 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
| 175 } | 166 } |
| 176 | 167 |
| 177 // Pass NativeArguments structure by value and call native function. | 168 // Pass NativeArguments structure by value and call native function. |
| 178 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. | 169 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. |
| 179 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. | 170 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. |
| 180 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. | 171 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. |
| 181 __ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr. | 172 __ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr. |
| 182 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. | 173 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. |
| 183 | 174 |
| 184 // Pass the pointer to the NativeArguments. | 175 // Pass the pointer to the NativeArguments. |
| 185 __ movq(CallingConventions::kArg1Reg, RSP); | 176 __ movq(CallingConventions::kArg1Reg, RSP); |
| 186 // Pass pointer to function entrypoint. | 177 // Pass pointer to function entrypoint. |
| 187 __ movq(CallingConventions::kArg2Reg, RBX); | 178 __ movq(CallingConventions::kArg2Reg, RBX); |
| 188 | 179 |
| 189 __ movq(RAX, Address(THR, Thread::native_call_wrapper_entry_point_offset())); | 180 __ movq(RAX, Address(THR, Thread::native_call_wrapper_entry_point_offset())); |
| 190 __ CallCFunction(RAX); | 181 __ CallCFunction(RAX); |
| 191 | 182 |
| 192 // Mark that the isolate is executing Dart code. | 183 // Mark that the thread is executing Dart code. |
| 193 __ movq(Address(R12, Isolate::vm_tag_offset()), | 184 __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); |
| 194 Immediate(VMTag::kDartTagId)); | |
| 195 | 185 |
| 196 // Reset exit frame information in Isolate structure. | 186 // Reset exit frame information in Isolate structure. |
| 197 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); | 187 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); |
| 198 | 188 |
| 199 __ LeaveStubFrame(); | 189 __ LeaveStubFrame(); |
| 200 __ ret(); | 190 __ ret(); |
| 201 } | 191 } |
| 202 | 192 |
| 203 | 193 |
| 204 // Input parameters: | 194 // Input parameters: |
| 205 // RSP : points to return address. | 195 // RSP : points to return address. |
| 206 // RSP + 8 : address of return value. | 196 // RSP + 8 : address of return value. |
| 207 // RAX : address of first argument in argument array. | 197 // RAX : address of first argument in argument array. |
| 208 // RBX : address of the native function to call. | 198 // RBX : address of the native function to call. |
| 209 // R10 : argc_tag including number of arguments and function kind. | 199 // R10 : argc_tag including number of arguments and function kind. |
| 210 void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) { | 200 void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) { |
| 211 const intptr_t native_args_struct_offset = 0; | 201 const intptr_t native_args_struct_offset = 0; |
| 212 const intptr_t thread_offset = | 202 const intptr_t thread_offset = |
| 213 NativeArguments::thread_offset() + native_args_struct_offset; | 203 NativeArguments::thread_offset() + native_args_struct_offset; |
| 214 const intptr_t argc_tag_offset = | 204 const intptr_t argc_tag_offset = |
| 215 NativeArguments::argc_tag_offset() + native_args_struct_offset; | 205 NativeArguments::argc_tag_offset() + native_args_struct_offset; |
| 216 const intptr_t argv_offset = | 206 const intptr_t argv_offset = |
| 217 NativeArguments::argv_offset() + native_args_struct_offset; | 207 NativeArguments::argv_offset() + native_args_struct_offset; |
| 218 const intptr_t retval_offset = | 208 const intptr_t retval_offset = |
| 219 NativeArguments::retval_offset() + native_args_struct_offset; | 209 NativeArguments::retval_offset() + native_args_struct_offset; |
| 220 | 210 |
| 221 __ EnterStubFrame(); | 211 __ EnterStubFrame(); |
| 222 | 212 |
| 223 COMPILE_ASSERT( | |
| 224 (CallingConventions::kCalleeSaveCpuRegisters & (1 << R12)) != 0); | |
| 225 __ LoadIsolate(R12); | |
| 226 | |
| 227 // Save exit frame information to enable stack walking as we are about | 213 // Save exit frame information to enable stack walking as we are about |
| 228 // to transition to native code. | 214 // to transition to native code. |
| 229 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), RBP); | 215 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), RBP); |
| 230 | 216 |
| 231 #if defined(DEBUG) | 217 #if defined(DEBUG) |
| 232 { Label ok; | 218 { Label ok; |
| 233 // Check that we are always entering from Dart code. | 219 // Check that we are always entering from Dart code. |
| 234 __ movq(R8, Immediate(VMTag::kDartTagId)); | 220 __ movq(R8, Immediate(VMTag::kDartTagId)); |
| 235 __ cmpq(R8, Address(R12, Isolate::vm_tag_offset())); | 221 __ cmpq(R8, Assembler::VMTagAddress()); |
| 236 __ j(EQUAL, &ok, Assembler::kNearJump); | 222 __ j(EQUAL, &ok, Assembler::kNearJump); |
| 237 __ Stop("Not coming from Dart code."); | 223 __ Stop("Not coming from Dart code."); |
| 238 __ Bind(&ok); | 224 __ Bind(&ok); |
| 239 } | 225 } |
| 240 #endif | 226 #endif |
| 241 | 227 |
| 242 // Mark that the isolate is executing Native code. | 228 // Mark that the thread is executing native code. |
| 243 __ movq(Address(R12, Isolate::vm_tag_offset()), RBX); | 229 __ movq(Assembler::VMTagAddress(), RBX); |
| 244 | 230 |
| 245 // Reserve space for the native arguments structure passed on the stack (the | 231 // Reserve space for the native arguments structure passed on the stack (the |
| 246 // outgoing pointer parameter to the native arguments structure is passed in | 232 // outgoing pointer parameter to the native arguments structure is passed in |
| 247 // RDI) and align frame before entering the C++ world. | 233 // RDI) and align frame before entering the C++ world. |
| 248 __ subq(RSP, Immediate(sizeof(NativeArguments))); | 234 __ subq(RSP, Immediate(sizeof(NativeArguments))); |
| 249 if (OS::ActivationFrameAlignment() > 1) { | 235 if (OS::ActivationFrameAlignment() > 1) { |
| 250 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 236 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
| 251 } | 237 } |
| 252 | 238 |
| 253 // Pass NativeArguments structure by value and call native function. | 239 // Pass NativeArguments structure by value and call native function. |
| 254 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. | 240 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. |
| 255 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. | 241 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. |
| 256 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. | 242 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. |
| 257 __ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr. | 243 __ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr. |
| 258 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. | 244 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. |
| 259 | 245 |
| 260 // Pass the pointer to the NativeArguments. | 246 // Pass the pointer to the NativeArguments. |
| 261 __ movq(CallingConventions::kArg1Reg, RSP); | 247 __ movq(CallingConventions::kArg1Reg, RSP); |
| 262 __ CallCFunction(RBX); | 248 __ CallCFunction(RBX); |
| 263 | 249 |
| 264 // Mark that the isolate is executing Dart code. | 250 // Mark that the thread is executing Dart code. |
| 265 __ movq(Address(R12, Isolate::vm_tag_offset()), | 251 __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); |
| 266 Immediate(VMTag::kDartTagId)); | |
| 267 | 252 |
| 268 // Reset exit frame information in Isolate structure. | 253 // Reset exit frame information in Isolate structure. |
| 269 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); | 254 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); |
| 270 | 255 |
| 271 __ LeaveStubFrame(); | 256 __ LeaveStubFrame(); |
| 272 __ ret(); | 257 __ ret(); |
| 273 } | 258 } |
| 274 | 259 |
| 275 | 260 |
| 276 // Input parameters: | 261 // Input parameters: |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 __ PushRegisters(CallingConventions::kCalleeSaveCpuRegisters, | 731 __ PushRegisters(CallingConventions::kCalleeSaveCpuRegisters, |
| 747 CallingConventions::kCalleeSaveXmmRegisters); | 732 CallingConventions::kCalleeSaveXmmRegisters); |
| 748 | 733 |
| 749 // If any additional (or fewer) values are pushed, the offsets in | 734 // If any additional (or fewer) values are pushed, the offsets in |
| 750 // kExitLinkSlotFromEntryFp will need to be changed. | 735 // kExitLinkSlotFromEntryFp will need to be changed. |
| 751 | 736 |
| 752 // Set up THR, which caches the current thread in Dart code. | 737 // Set up THR, which caches the current thread in Dart code. |
| 753 if (THR != kThreadReg) { | 738 if (THR != kThreadReg) { |
| 754 __ movq(THR, kThreadReg); | 739 __ movq(THR, kThreadReg); |
| 755 } | 740 } |
| 756 // Load Isolate pointer into kIsolateReg. | |
| 757 const Register kIsolateReg = RBX; | |
| 758 __ LoadIsolate(kIsolateReg); | |
| 759 | 741 |
| 760 // Save the current VMTag on the stack. | 742 // Save the current VMTag on the stack. |
| 761 __ movq(RAX, Address(kIsolateReg, Isolate::vm_tag_offset())); | 743 __ movq(RAX, Assembler::VMTagAddress()); |
| 762 __ pushq(RAX); | 744 __ pushq(RAX); |
| 763 | 745 |
| 764 // Mark that the isolate is executing Dart code. | 746 // Mark that the thread is executing Dart code. |
| 765 __ movq(Address(kIsolateReg, Isolate::vm_tag_offset()), | 747 __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); |
| 766 Immediate(VMTag::kDartTagId)); | |
| 767 | 748 |
| 768 // Save top resource and top exit frame info. Use RAX as a temporary register. | 749 // Save top resource and top exit frame info. Use RAX as a temporary register. |
| 769 // StackFrameIterator reads the top exit frame info saved in this frame. | 750 // StackFrameIterator reads the top exit frame info saved in this frame. |
| 770 __ movq(RAX, Address(THR, Thread::top_resource_offset())); | 751 __ movq(RAX, Address(THR, Thread::top_resource_offset())); |
| 771 __ pushq(RAX); | 752 __ pushq(RAX); |
| 772 __ movq(Address(THR, Thread::top_resource_offset()), | 753 __ movq(Address(THR, Thread::top_resource_offset()), |
| 773 Immediate(0)); | 754 Immediate(0)); |
| 774 __ movq(RAX, Address(THR, Thread::top_exit_frame_info_offset())); | 755 __ movq(RAX, Address(THR, Thread::top_exit_frame_info_offset())); |
| 775 // The constant kExitLinkSlotFromEntryFp must be kept in sync with the | 756 // The constant kExitLinkSlotFromEntryFp must be kept in sync with the |
| 776 // code below. | 757 // code below. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 // Read the saved arguments descriptor array to obtain the number of passed | 807 // Read the saved arguments descriptor array to obtain the number of passed |
| 827 // arguments. | 808 // arguments. |
| 828 __ movq(kArgDescReg, Address(RBP, kArgumentsDescOffset)); | 809 __ movq(kArgDescReg, Address(RBP, kArgumentsDescOffset)); |
| 829 __ movq(R10, Address(kArgDescReg, VMHandles::kOffsetOfRawPtrInHandle)); | 810 __ movq(R10, Address(kArgDescReg, VMHandles::kOffsetOfRawPtrInHandle)); |
| 830 __ movq(RDX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 811 __ movq(RDX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
| 831 // Get rid of arguments pushed on the stack. | 812 // Get rid of arguments pushed on the stack. |
| 832 __ leaq(RSP, Address(RSP, RDX, TIMES_4, 0)); // RDX is a Smi. | 813 __ leaq(RSP, Address(RSP, RDX, TIMES_4, 0)); // RDX is a Smi. |
| 833 | 814 |
| 834 // Restore the saved top exit frame info and top resource back into the | 815 // Restore the saved top exit frame info and top resource back into the |
| 835 // Isolate structure. | 816 // Isolate structure. |
| 836 __ LoadIsolate(kIsolateReg); | |
| 837 __ popq(Address(THR, Thread::top_exit_frame_info_offset())); | 817 __ popq(Address(THR, Thread::top_exit_frame_info_offset())); |
| 838 __ popq(Address(THR, Thread::top_resource_offset())); | 818 __ popq(Address(THR, Thread::top_resource_offset())); |
| 839 | 819 |
| 840 // Restore the current VMTag from the stack. | 820 // Restore the current VMTag from the stack. |
| 841 __ popq(Address(kIsolateReg, Isolate::vm_tag_offset())); | 821 __ popq(Assembler::VMTagAddress()); |
| 842 | 822 |
| 843 // Restore C++ ABI callee-saved registers. | 823 // Restore C++ ABI callee-saved registers. |
| 844 __ PopRegisters(CallingConventions::kCalleeSaveCpuRegisters, | 824 __ PopRegisters(CallingConventions::kCalleeSaveCpuRegisters, |
| 845 CallingConventions::kCalleeSaveXmmRegisters); | 825 CallingConventions::kCalleeSaveXmmRegisters); |
| 846 __ set_constant_pool_allowed(false); | 826 __ set_constant_pool_allowed(false); |
| 847 | 827 |
| 848 // Restore the frame pointer. | 828 // Restore the frame pointer. |
| 849 __ LeaveFrame(); | 829 __ LeaveFrame(); |
| 850 | 830 |
| 851 __ ret(); | 831 __ ret(); |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) { | 1934 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) { |
| 1955 ASSERT(kExceptionObjectReg == RAX); | 1935 ASSERT(kExceptionObjectReg == RAX); |
| 1956 ASSERT(kStackTraceObjectReg == RDX); | 1936 ASSERT(kStackTraceObjectReg == RDX); |
| 1957 ASSERT(CallingConventions::kArg4Reg != kStackTraceObjectReg); | 1937 ASSERT(CallingConventions::kArg4Reg != kStackTraceObjectReg); |
| 1958 ASSERT(CallingConventions::kArg1Reg != kStackTraceObjectReg); | 1938 ASSERT(CallingConventions::kArg1Reg != kStackTraceObjectReg); |
| 1959 | 1939 |
| 1960 #if defined(_WIN64) | 1940 #if defined(_WIN64) |
| 1961 Register stacktrace_reg = RBX; | 1941 Register stacktrace_reg = RBX; |
| 1962 __ movq(stacktrace_reg, Address(RSP, 5 * kWordSize)); | 1942 __ movq(stacktrace_reg, Address(RSP, 5 * kWordSize)); |
| 1963 __ movq(THR, Address(RSP, 6 * kWordSize)); | 1943 __ movq(THR, Address(RSP, 6 * kWordSize)); |
| 1964 Register isolate_reg = RDI; | |
| 1965 #else | 1944 #else |
| 1966 Register stacktrace_reg = CallingConventions::kArg5Reg; | 1945 Register stacktrace_reg = CallingConventions::kArg5Reg; |
| 1967 __ movq(THR, CallingConventions::kArg6Reg); | 1946 __ movq(THR, CallingConventions::kArg6Reg); |
| 1968 Register isolate_reg = CallingConventions::kArg6Reg; | |
| 1969 #endif | 1947 #endif |
| 1970 __ LoadIsolate(isolate_reg); | |
| 1971 __ movq(RBP, CallingConventions::kArg3Reg); | 1948 __ movq(RBP, CallingConventions::kArg3Reg); |
| 1972 __ movq(RSP, CallingConventions::kArg2Reg); | 1949 __ movq(RSP, CallingConventions::kArg2Reg); |
| 1973 __ movq(kStackTraceObjectReg, stacktrace_reg); | 1950 __ movq(kStackTraceObjectReg, stacktrace_reg); |
| 1974 __ movq(kExceptionObjectReg, CallingConventions::kArg4Reg); | 1951 __ movq(kExceptionObjectReg, CallingConventions::kArg4Reg); |
| 1975 // Set the tag. | 1952 // Set the tag. |
| 1976 __ movq(Address(isolate_reg, Isolate::vm_tag_offset()), | 1953 __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); |
| 1977 Immediate(VMTag::kDartTagId)); | |
| 1978 // Clear top exit frame. | 1954 // Clear top exit frame. |
| 1979 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), | 1955 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), |
| 1980 Immediate(0)); | 1956 Immediate(0)); |
| 1981 __ jmp(CallingConventions::kArg1Reg); // Jump to the exception handler code. | 1957 __ jmp(CallingConventions::kArg1Reg); // Jump to the exception handler code. |
| 1982 } | 1958 } |
| 1983 | 1959 |
| 1984 | 1960 |
| 1985 // Calls to the runtime to optimize the given function. | 1961 // Calls to the runtime to optimize the given function. |
| 1986 // RDI: function to be reoptimized. | 1962 // RDI: function to be reoptimized. |
| 1987 // R10: argument descriptor (preserved). | 1963 // R10: argument descriptor (preserved). |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2157 // Result: | 2133 // Result: |
| 2158 // RCX: entry point. | 2134 // RCX: entry point. |
| 2159 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2135 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2160 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); | 2136 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); |
| 2161 __ ret(); | 2137 __ ret(); |
| 2162 } | 2138 } |
| 2163 | 2139 |
| 2164 } // namespace dart | 2140 } // namespace dart |
| 2165 | 2141 |
| 2166 #endif // defined TARGET_ARCH_X64 | 2142 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |