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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. | 177 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. |
178 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. | 178 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. |
179 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. | 179 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. |
180 __ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr. | 180 __ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr. |
181 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. | 181 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. |
182 | 182 |
183 // Pass the pointer to the NativeArguments. | 183 // Pass the pointer to the NativeArguments. |
184 __ movq(CallingConventions::kArg1Reg, RSP); | 184 __ movq(CallingConventions::kArg1Reg, RSP); |
185 // Pass pointer to function entrypoint. | 185 // Pass pointer to function entrypoint. |
186 __ movq(CallingConventions::kArg2Reg, RBX); | 186 __ movq(CallingConventions::kArg2Reg, RBX); |
187 __ CallCFunction(&NativeEntry::NativeCallWrapperLabel()); | 187 __ LoadExternalLabel( |
| 188 RAX, &NativeEntry::NativeCallWrapperLabel(), kNotPatchable); |
| 189 __ CallCFunction(RAX); |
188 | 190 |
189 // Mark that the isolate is executing Dart code. | 191 // Mark that the isolate is executing Dart code. |
190 __ movq(Address(R12, Isolate::vm_tag_offset()), | 192 __ movq(Address(R12, Isolate::vm_tag_offset()), |
191 Immediate(VMTag::kDartTagId)); | 193 Immediate(VMTag::kDartTagId)); |
192 | 194 |
193 // Reset exit frame information in Isolate structure. | 195 // Reset exit frame information in Isolate structure. |
194 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); | 196 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); |
195 | 197 |
196 __ LeaveStubFrame(); | 198 __ LeaveStubFrame(); |
197 __ ret(); | 199 __ ret(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 // +------------------+ | 379 // +------------------+ |
378 // | return-address | (deoptimization point) | 380 // | return-address | (deoptimization point) |
379 // +------------------+ | 381 // +------------------+ |
380 // | ... | <- SP of optimized frame | 382 // | ... | <- SP of optimized frame |
381 // | 383 // |
382 // Parts of the code cannot GC, part of the code can GC. | 384 // Parts of the code cannot GC, part of the code can GC. |
383 static void GenerateDeoptimizationSequence(Assembler* assembler, | 385 static void GenerateDeoptimizationSequence(Assembler* assembler, |
384 bool preserve_result) { | 386 bool preserve_result) { |
385 // DeoptimizeCopyFrame expects a Dart frame, i.e. EnterDartFrame(0), but there | 387 // DeoptimizeCopyFrame expects a Dart frame, i.e. EnterDartFrame(0), but there |
386 // is no need to set the correct PC marker or load PP, since they get patched. | 388 // is no need to set the correct PC marker or load PP, since they get patched. |
387 __ EnterFrame(0); | 389 __ EnterStubFrame(); |
388 __ pushq(Immediate(0)); | |
389 __ pushq(PP); | |
390 | 390 |
391 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry | 391 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry |
392 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls. | 392 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls. |
393 const intptr_t saved_result_slot_from_fp = | 393 const intptr_t saved_result_slot_from_fp = |
394 kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - RAX); | 394 kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - RAX); |
395 // Result in RAX is preserved as part of pushing all registers below. | 395 // Result in RAX is preserved as part of pushing all registers below. |
396 | 396 |
397 // Push registers in their enumeration order: lowest register number at | 397 // Push registers in their enumeration order: lowest register number at |
398 // lowest address. | 398 // lowest address. |
399 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { | 399 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { |
(...skipping 12 matching lines...) Expand all Loading... |
412 __ ReserveAlignedFrameSpace(0); // Ensure stack is aligned before the call. | 412 __ ReserveAlignedFrameSpace(0); // Ensure stack is aligned before the call. |
413 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry, 1); | 413 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry, 1); |
414 // Result (RAX) is stack-size (FP - SP) in bytes. | 414 // Result (RAX) is stack-size (FP - SP) in bytes. |
415 | 415 |
416 if (preserve_result) { | 416 if (preserve_result) { |
417 // Restore result into RBX temporarily. | 417 // Restore result into RBX temporarily. |
418 __ movq(RBX, Address(RBP, saved_result_slot_from_fp * kWordSize)); | 418 __ movq(RBX, Address(RBP, saved_result_slot_from_fp * kWordSize)); |
419 } | 419 } |
420 | 420 |
421 // There is a Dart Frame on the stack. We must restore PP and leave frame. | 421 // There is a Dart Frame on the stack. We must restore PP and leave frame. |
422 __ LeaveDartFrame(); | 422 __ LeaveStubFrame(); |
423 | 423 |
424 __ popq(RCX); // Preserve return address. | 424 __ popq(RCX); // Preserve return address. |
425 __ movq(RSP, RBP); // Discard optimized frame. | 425 __ movq(RSP, RBP); // Discard optimized frame. |
426 __ subq(RSP, RAX); // Reserve space for deoptimized frame. | 426 __ subq(RSP, RAX); // Reserve space for deoptimized frame. |
427 __ pushq(RCX); // Restore return address. | 427 __ pushq(RCX); // Restore return address. |
428 | 428 |
429 // DeoptimizeFillFrame expects a Dart frame, i.e. EnterDartFrame(0), but there | 429 // DeoptimizeFillFrame expects a Dart frame, i.e. EnterDartFrame(0), but there |
430 // is no need to set the correct PC marker or load PP, since they get patched. | 430 // is no need to set the correct PC marker or load PP, since they get patched. |
431 __ EnterFrame(0); | 431 __ EnterStubFrame(); |
432 __ pushq(Immediate(0)); | |
433 __ pushq(PP); | |
434 | 432 |
435 if (preserve_result) { | 433 if (preserve_result) { |
436 __ pushq(RBX); // Preserve result as first local. | 434 __ pushq(RBX); // Preserve result as first local. |
437 } | 435 } |
438 __ ReserveAlignedFrameSpace(0); | 436 __ ReserveAlignedFrameSpace(0); |
439 // Pass last FP as a parameter. | 437 // Pass last FP as a parameter. |
440 __ movq(CallingConventions::kArg1Reg, RBP); | 438 __ movq(CallingConventions::kArg1Reg, RBP); |
441 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry, 1); | 439 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry, 1); |
442 if (preserve_result) { | 440 if (preserve_result) { |
443 // Restore result into RBX. | 441 // Restore result into RBX. |
444 __ movq(RBX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); | 442 __ movq(RBX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); |
445 } | 443 } |
446 // Code above cannot cause GC. | 444 // Code above cannot cause GC. |
447 // There is a Dart Frame on the stack. We must restore PP and leave frame. | 445 // There is a Dart Frame on the stack. We must restore PP and leave frame. |
448 __ LeaveDartFrame(); | 446 __ LeaveStubFrame(); |
449 | 447 |
450 // Frame is fully rewritten at this point and it is safe to perform a GC. | 448 // Frame is fully rewritten at this point and it is safe to perform a GC. |
451 // Materialize any objects that were deferred by FillFrame because they | 449 // Materialize any objects that were deferred by FillFrame because they |
452 // require allocation. | 450 // require allocation. |
453 // Enter stub frame with loading PP. The caller's PP is not materialized yet. | 451 // Enter stub frame with loading PP. The caller's PP is not materialized yet. |
454 __ EnterStubFrame(); | 452 __ EnterStubFrame(); |
455 if (preserve_result) { | 453 if (preserve_result) { |
456 __ pushq(RBX); // Preserve result, it will be GC-d here. | 454 __ pushq(RBX); // Preserve result, it will be GC-d here. |
457 } | 455 } |
458 __ pushq(Immediate(Smi::RawValue(0))); // Space for the result. | 456 __ pushq(Immediate(Smi::RawValue(0))); // Space for the result. |
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 // Result: | 2123 // Result: |
2126 // RCX: entry point. | 2124 // RCX: entry point. |
2127 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2125 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
2128 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); | 2126 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); |
2129 __ ret(); | 2127 __ ret(); |
2130 } | 2128 } |
2131 | 2129 |
2132 } // namespace dart | 2130 } // namespace dart |
2133 | 2131 |
2134 #endif // defined TARGET_ARCH_X64 | 2132 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |