OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // +------------------+ | 441 // +------------------+ |
442 // | return-address | (deoptimization point) | 442 // | return-address | (deoptimization point) |
443 // +------------------+ | 443 // +------------------+ |
444 // | ... | <- SP of optimized frame | 444 // | ... | <- SP of optimized frame |
445 // | 445 // |
446 // Parts of the code cannot GC, part of the code can GC. | 446 // Parts of the code cannot GC, part of the code can GC. |
447 static void GenerateDeoptimizationSequence(Assembler* assembler, | 447 static void GenerateDeoptimizationSequence(Assembler* assembler, |
448 bool preserve_result) { | 448 bool preserve_result) { |
449 // DeoptimizeCopyFrame expects a Dart frame, i.e. EnterDartFrame(0), but there | 449 // DeoptimizeCopyFrame expects a Dart frame, i.e. EnterDartFrame(0), but there |
450 // is no need to set the correct PC marker or load PP, since they get patched. | 450 // is no need to set the correct PC marker or load PP, since they get patched. |
451 __ EnterFrame(0); | 451 __ EnterStubFrame(); |
452 __ TagAndPushPPAndPcMarker(ZR); | |
453 | 452 |
454 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry | 453 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry |
455 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls. | 454 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls. |
456 const intptr_t saved_result_slot_from_fp = | 455 const intptr_t saved_result_slot_from_fp = |
457 kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - R0); | 456 kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - R0); |
458 // Result in R0 is preserved as part of pushing all registers below. | 457 // Result in R0 is preserved as part of pushing all registers below. |
459 | 458 |
460 // Push registers in their enumeration order: lowest register number at | 459 // Push registers in their enumeration order: lowest register number at |
461 // lowest address. | 460 // lowest address. |
462 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { | 461 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { |
(...skipping 10 matching lines...) Expand all Loading... |
473 __ ReserveAlignedFrameSpace(0); | 472 __ ReserveAlignedFrameSpace(0); |
474 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry, 1); | 473 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry, 1); |
475 // Result (R0) is stack-size (FP - SP) in bytes. | 474 // Result (R0) is stack-size (FP - SP) in bytes. |
476 | 475 |
477 if (preserve_result) { | 476 if (preserve_result) { |
478 // Restore result into R1 temporarily. | 477 // Restore result into R1 temporarily. |
479 __ LoadFromOffset(R1, FP, saved_result_slot_from_fp * kWordSize); | 478 __ LoadFromOffset(R1, FP, saved_result_slot_from_fp * kWordSize); |
480 } | 479 } |
481 | 480 |
482 // There is a Dart Frame on the stack. We must restore PP and leave frame. | 481 // There is a Dart Frame on the stack. We must restore PP and leave frame. |
483 __ LeaveDartFrame(); | 482 __ LeaveStubFrame(); |
484 __ sub(SP, FP, Operand(R0)); | 483 __ sub(SP, FP, Operand(R0)); |
485 | 484 |
486 // DeoptimizeFillFrame expects a Dart frame, i.e. EnterDartFrame(0), but there | 485 // DeoptimizeFillFrame expects a Dart frame, i.e. EnterDartFrame(0), but there |
487 // is no need to set the correct PC marker or load PP, since they get patched. | 486 // is no need to set the correct PC marker or load PP, since they get patched. |
488 __ EnterFrame(0); | 487 __ EnterStubFrame(); |
489 __ TagAndPushPPAndPcMarker(ZR); | |
490 | 488 |
491 if (preserve_result) { | 489 if (preserve_result) { |
492 __ Push(R1); // Preserve result as first local. | 490 __ Push(R1); // Preserve result as first local. |
493 } | 491 } |
494 __ ReserveAlignedFrameSpace(0); | 492 __ ReserveAlignedFrameSpace(0); |
495 __ mov(R0, FP); // Pass last FP as parameter in R0. | 493 __ mov(R0, FP); // Pass last FP as parameter in R0. |
496 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry, 1); | 494 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry, 1); |
497 if (preserve_result) { | 495 if (preserve_result) { |
498 // Restore result into R1. | 496 // Restore result into R1. |
499 __ LoadFromOffset(R1, FP, kFirstLocalSlotFromFp * kWordSize); | 497 __ LoadFromOffset(R1, FP, kFirstLocalSlotFromFp * kWordSize); |
500 } | 498 } |
501 // Code above cannot cause GC. | 499 // Code above cannot cause GC. |
502 // There is a Dart Frame on the stack. We must restore PP and leave frame. | 500 // There is a Dart Frame on the stack. We must restore PP and leave frame. |
503 __ LeaveDartFrame(); | 501 __ LeaveStubFrame(); |
504 | 502 |
505 // Frame is fully rewritten at this point and it is safe to perform a GC. | 503 // Frame is fully rewritten at this point and it is safe to perform a GC. |
506 // Materialize any objects that were deferred by FillFrame because they | 504 // Materialize any objects that were deferred by FillFrame because they |
507 // require allocation. | 505 // require allocation. |
508 // Enter stub frame with loading PP. The caller's PP is not materialized yet. | 506 // Enter stub frame with loading PP. The caller's PP is not materialized yet. |
509 __ EnterStubFrame(); | 507 __ EnterStubFrame(); |
510 if (preserve_result) { | 508 if (preserve_result) { |
511 __ Push(R1); // Preserve result, it will be GC-d here. | 509 __ Push(R1); // Preserve result, it will be GC-d here. |
512 } | 510 } |
513 __ Push(ZR); // Space for the result. | 511 __ Push(ZR); // Space for the result. |
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 // Result: | 2120 // Result: |
2123 // R1: entry point. | 2121 // R1: entry point. |
2124 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2122 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
2125 EmitMegamorphicLookup(assembler, R0, R1, R1); | 2123 EmitMegamorphicLookup(assembler, R0, R1, R1); |
2126 __ ret(); | 2124 __ ret(); |
2127 } | 2125 } |
2128 | 2126 |
2129 } // namespace dart | 2127 } // namespace dart |
2130 | 2128 |
2131 #endif // defined TARGET_ARCH_ARM64 | 2129 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |