| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/assembler_macros.h" | 9 #include "vm/assembler_macros.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 __ popl(EAX); | 554 __ popl(EAX); |
| 555 __ popl(EAX); | 555 __ popl(EAX); |
| 556 __ popl(EAX); // Get result into EAX. | 556 __ popl(EAX); // Get result into EAX. |
| 557 | 557 |
| 558 // Remove the stub frame as we are about to return. | 558 // Remove the stub frame as we are about to return. |
| 559 __ LeaveFrame(); | 559 __ LeaveFrame(); |
| 560 __ ret(); | 560 __ ret(); |
| 561 } | 561 } |
| 562 | 562 |
| 563 | 563 |
| 564 DECLARE_LEAF_RUNTIME_ENTRY(intptr_t, DeoptimizeCopyFrame, |
| 565 intptr_t deopt_reason, |
| 566 intptr_t* saved_registers_address); |
| 567 |
| 568 DECLARE_LEAF_RUNTIME_ENTRY(void, DeoptimizeFillFrame, uword last_fp); |
| 569 |
| 570 // This stub translates optimized frame into unoptimized frame. The optimized |
| 571 // frame can contain values in registers and on stack, the unoptimized |
| 572 // frame contains all values on stack. |
| 573 // Deoptimization occurs in following steps: |
| 574 // - Push all registers that can contain values. |
| 575 // - Call C routine to copy the stack and saved registers into temporary buffer. |
| 576 // - Adjust caller's frame to correct unoptimized frame size. |
| 577 // - Fill the unoptimized frame. |
| 578 // Stack: |
| 579 // +------------------+ |
| 580 // | 0 as PC marker | <- TOS |
| 581 // +------------------+ |
| 582 // | Saved FP | |
| 583 // +------------------+ |
| 584 // | return-address | (deoptimization point) |
| 585 // +------------------+ |
| 586 // | optimized frame | |
| 587 // | ... | |
| 588 // |
| 589 // EAX: Deoptimization reason id. |
| 564 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { | 590 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { |
| 565 // Create a stub frame as we are pushing some objects on the stack before | 591 __ EnterFrame(0); |
| 566 // calling into the runtime. | 592 // Push registers in their enumeration order. |
| 567 AssemblerMacros::EnterStubFrame(assembler); | 593 // for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { |
| 568 // EAX: deoptimization reason id. | 594 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) { |
| 569 // Stack at this point: | 595 __ pushl(static_cast<Register>(i)); |
| 570 // TOS + 0: PC marker => RawInstruction object. | 596 } |
| 571 // TOS + 1: Saved EBP of function frame that will be deoptimized. <== EBP | 597 __ movl(ECX, ESP); // Saved saved registers block. |
| 572 // TOS + 2: Deoptimization point (return address), will be patched. | 598 __ ReserveAlignedFrameSpace(2 * kWordSize); |
| 573 // TOS + 3: top-of-stack at deoptimization point (all arguments on stack). | 599 __ SmiUntag(EAX); |
| 574 __ pushl(EAX); | 600 __ movl(Address(ESP, 0), EAX); // Deopt reason (untagged). |
| 575 __ CallRuntime(kDeoptimizeRuntimeEntry); | 601 __ movl(Address(ESP, kWordSize), ECX); // Start of register block. |
| 576 __ popl(EAX); | 602 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry); |
| 603 // Result (EAX) is stack-size (FP - SP) in bytes, incl. the return address. |
| 604 __ LeaveFrame(); |
| 605 __ popl(EDX); // Discard return address. |
| 606 __ movl(ESP, EBP); |
| 607 __ subl(ESP, EAX); |
| 608 |
| 609 __ EnterFrame(0); |
| 610 __ movl(ECX, ESP); // Get last FP address. |
| 611 __ ReserveAlignedFrameSpace(1 * kWordSize); |
| 612 __ movl(Address(ESP, 0), ECX); |
| 613 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry); |
| 577 __ LeaveFrame(); | 614 __ LeaveFrame(); |
| 578 __ ret(); | 615 __ ret(); |
| 579 } | 616 } |
| 580 | 617 |
| 581 | 618 |
| 582 // Called for inline allocation of arrays. | 619 // Called for inline allocation of arrays. |
| 583 // Input parameters: | 620 // Input parameters: |
| 584 // EDX : Array length as Smi. | 621 // EDX : Array length as Smi. |
| 585 // ECX : array element type (either NULL or an instantiated type). | 622 // ECX : array element type (either NULL or an instantiated type). |
| 586 // Uses EAX, EBX, ECX, EDI as temporary registers. | 623 // Uses EAX, EBX, ECX, EDI as temporary registers. |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1937 __ movl(EAX, Address(ESP, 4 * kWordSize)); // Load error object. | 1974 __ movl(EAX, Address(ESP, 4 * kWordSize)); // Load error object. |
| 1938 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. | 1975 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. |
| 1939 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. | 1976 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. |
| 1940 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. | 1977 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. |
| 1941 __ jmp(EBX); // Jump to the exception handler code. | 1978 __ jmp(EBX); // Jump to the exception handler code. |
| 1942 } | 1979 } |
| 1943 | 1980 |
| 1944 } // namespace dart | 1981 } // namespace dart |
| 1945 | 1982 |
| 1946 #endif // defined TARGET_ARCH_IA32 | 1983 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |