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 10 matching lines...) Expand all Loading... |
21 #define __ assembler-> | 21 #define __ assembler-> |
22 | 22 |
23 namespace dart { | 23 namespace dart { |
24 | 24 |
25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); | 25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); |
26 DEFINE_FLAG(bool, use_slow_path, false, | 26 DEFINE_FLAG(bool, use_slow_path, false, |
27 "Set to true for debugging & verifying the slow paths."); | 27 "Set to true for debugging & verifying the slow paths."); |
28 DECLARE_FLAG(int, optimization_counter_threshold); | 28 DECLARE_FLAG(int, optimization_counter_threshold); |
29 DECLARE_FLAG(bool, trace_optimized_ic_calls); | 29 DECLARE_FLAG(bool, trace_optimized_ic_calls); |
30 | 30 |
| 31 |
31 // Input parameters: | 32 // Input parameters: |
32 // RSP : points to return address. | 33 // RSP : points to return address. |
33 // RSP + 8 : address of last argument in argument array. | 34 // RSP + 8 : address of last argument in argument array. |
34 // RSP + 8*R10 : address of first argument in argument array. | 35 // RSP + 8*R10 : address of first argument in argument array. |
35 // RSP + 8*R10 + 8 : address of return value. | 36 // RSP + 8*R10 + 8 : address of return value. |
36 // RBX : address of the runtime function to call. | 37 // RBX : address of the runtime function to call. |
37 // R10 : number of arguments to the call. | 38 // R10 : number of arguments to the call. |
38 // Must preserve callee saved registers R12 and R13. | 39 // Must preserve callee saved registers R12 and R13. |
39 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 40 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
40 ASSERT((R12 != CTX) && (R13 != CTX)); | 41 ASSERT((R12 != CTX) && (R13 != CTX)); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 155 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
155 } | 156 } |
156 | 157 |
157 // Pass NativeArguments structure by value and call native function. | 158 // Pass NativeArguments structure by value and call native function. |
158 __ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs. | 159 __ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs. |
159 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. | 160 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. |
160 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. | 161 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. |
161 __ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr. | 162 __ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr. |
162 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. | 163 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. |
163 __ movq(RDI, RSP); // Pass the pointer to the NativeArguments. | 164 __ movq(RDI, RSP); // Pass the pointer to the NativeArguments. |
| 165 __ movq(RSI, RBX); // Pass pointer to function entrypoint. |
| 166 __ call(&NativeEntry::NativeCallWrapperLabel()); |
| 167 |
| 168 // Reset exit frame information in Isolate structure. |
| 169 __ movq(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); |
| 170 |
| 171 // Load Context pointer from Isolate structure into R8. |
| 172 __ movq(R8, Address(CTX, Isolate::top_context_offset())); |
| 173 |
| 174 // Reset Context pointer in Isolate structure. |
| 175 const Immediate& raw_null = |
| 176 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 177 __ movq(Address(CTX, Isolate::top_context_offset()), raw_null); |
| 178 |
| 179 // Cache Context pointer into CTX while executing Dart code. |
| 180 __ movq(CTX, R8); |
| 181 |
| 182 __ LeaveFrame(); |
| 183 __ ret(); |
| 184 } |
| 185 |
| 186 |
| 187 // Input parameters: |
| 188 // RSP : points to return address. |
| 189 // RSP + 8 : address of return value. |
| 190 // RAX : address of first argument in argument array. |
| 191 // RBX : address of the native function to call. |
| 192 // R10 : argc_tag including number of arguments and function kind. |
| 193 void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) { |
| 194 const intptr_t native_args_struct_offset = 0; |
| 195 const intptr_t isolate_offset = |
| 196 NativeArguments::isolate_offset() + native_args_struct_offset; |
| 197 const intptr_t argc_tag_offset = |
| 198 NativeArguments::argc_tag_offset() + native_args_struct_offset; |
| 199 const intptr_t argv_offset = |
| 200 NativeArguments::argv_offset() + native_args_struct_offset; |
| 201 const intptr_t retval_offset = |
| 202 NativeArguments::retval_offset() + native_args_struct_offset; |
| 203 |
| 204 __ EnterFrame(0); |
| 205 |
| 206 // Load current Isolate pointer from Context structure into R8. |
| 207 __ movq(R8, FieldAddress(CTX, Context::isolate_offset())); |
| 208 |
| 209 // Save exit frame information to enable stack walking as we are about |
| 210 // to transition to native code. |
| 211 __ movq(Address(R8, Isolate::top_exit_frame_info_offset()), RSP); |
| 212 |
| 213 // Save current Context pointer into Isolate structure. |
| 214 __ movq(Address(R8, Isolate::top_context_offset()), CTX); |
| 215 |
| 216 // Cache Isolate pointer into CTX while executing native code. |
| 217 __ movq(CTX, R8); |
| 218 |
| 219 // Reserve space for the native arguments structure passed on the stack (the |
| 220 // outgoing pointer parameter to the native arguments structure is passed in |
| 221 // RDI) and align frame before entering the C++ world. |
| 222 __ AddImmediate(RSP, Immediate(-sizeof(NativeArguments))); |
| 223 if (OS::ActivationFrameAlignment() > 0) { |
| 224 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
| 225 } |
| 226 |
| 227 // Pass NativeArguments structure by value and call native function. |
| 228 __ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs. |
| 229 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. |
| 230 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. |
| 231 __ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr. |
| 232 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. |
| 233 __ movq(RDI, RSP); // Pass the pointer to the NativeArguments. |
164 __ call(RBX); | 234 __ call(RBX); |
165 | 235 |
166 // Reset exit frame information in Isolate structure. | 236 // Reset exit frame information in Isolate structure. |
167 __ movq(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); | 237 __ movq(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); |
168 | 238 |
169 // Load Context pointer from Isolate structure into R8. | 239 // Load Context pointer from Isolate structure into R8. |
170 __ movq(R8, Address(CTX, Isolate::top_context_offset())); | 240 __ movq(R8, Address(CTX, Isolate::top_context_offset())); |
171 | 241 |
172 // Reset Context pointer in Isolate structure. | 242 // Reset Context pointer in Isolate structure. |
173 const Immediate& raw_null = | 243 const Immediate& raw_null = |
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2158 __ movq(right, Address(RSP, 3 * kWordSize)); | 2228 __ movq(right, Address(RSP, 3 * kWordSize)); |
2159 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 2229 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
2160 __ popq(right); | 2230 __ popq(right); |
2161 __ popq(left); | 2231 __ popq(left); |
2162 __ ret(); | 2232 __ ret(); |
2163 } | 2233 } |
2164 | 2234 |
2165 } // namespace dart | 2235 } // namespace dart |
2166 | 2236 |
2167 #endif // defined TARGET_ARCH_X64 | 2237 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |