Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: runtime/vm/stub_code_ia32.cc

Issue 10919008: Unbox phis that were proven to be of type Double. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address Srdjan's comments Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/locations.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 __ popl(EAX); // Get result into EAX. 470 __ popl(EAX); // Get result into EAX.
471 471
472 // Remove the stub frame as we are about to return. 472 // Remove the stub frame as we are about to return.
473 __ LeaveFrame(); 473 __ LeaveFrame();
474 __ ret(); 474 __ ret();
475 } 475 }
476 476
477 477
478 DECLARE_LEAF_RUNTIME_ENTRY(intptr_t, DeoptimizeCopyFrame, 478 DECLARE_LEAF_RUNTIME_ENTRY(intptr_t, DeoptimizeCopyFrame,
479 intptr_t deopt_reason, 479 intptr_t deopt_reason,
480 intptr_t* saved_registers_address); 480 uword saved_registers_address);
481 481
482 DECLARE_LEAF_RUNTIME_ENTRY(void, DeoptimizeFillFrame, uword last_fp); 482 DECLARE_LEAF_RUNTIME_ENTRY(void, DeoptimizeFillFrame, uword last_fp);
483 483
484 // This stub translates optimized frame into unoptimized frame. The optimized 484 // This stub translates optimized frame into unoptimized frame. The optimized
485 // frame can contain values in registers and on stack, the unoptimized 485 // frame can contain values in registers and on stack, the unoptimized
486 // frame contains all values on stack. 486 // frame contains all values on stack.
487 // Deoptimization occurs in following steps: 487 // Deoptimization occurs in following steps:
488 // - Push all registers that can contain values. 488 // - Push all registers that can contain values.
489 // - Call C routine to copy the stack and saved registers into temporary buffer. 489 // - Call C routine to copy the stack and saved registers into temporary buffer.
490 // - Adjust caller's frame to correct unoptimized frame size. 490 // - Adjust caller's frame to correct unoptimized frame size.
491 // - Fill the unoptimized frame. 491 // - Fill the unoptimized frame.
492 // - Materialize objects that require allocation (e.g. Double instances).
493 // GC can occur only after frame is fully rewritten.
492 // Stack: 494 // Stack:
493 // +------------------+ 495 // +------------------+
494 // | 0 as PC marker | <- TOS 496 // | 0 as PC marker | <- TOS
495 // +------------------+ 497 // +------------------+
496 // | Saved FP | 498 // | Saved FP |
497 // +------------------+ 499 // +------------------+
498 // | return-address | (deoptimization point) 500 // | return-address | (deoptimization point)
499 // +------------------+ 501 // +------------------+
500 // | optimized frame | 502 // | optimized frame |
501 // | ... | 503 // | ... |
502 // 504 //
503 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { 505 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) {
504 __ EnterFrame(0); 506 __ EnterFrame(0);
505 // Push registers in their enumeration order: lowest register number at 507 // Push registers in their enumeration order: lowest register number at
506 // lowest address. 508 // lowest address.
507 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { 509 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) {
508 __ pushl(static_cast<Register>(i)); 510 __ pushl(static_cast<Register>(i));
509 } 511 }
512 __ subl(ESP, Immediate(kNumberOfXmmRegisters * kDoubleSize));
513 intptr_t offset = 0;
514 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) {
515 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx);
516 __ movsd(Address(ESP, offset), xmm_reg);
517 offset += kDoubleSize;
518 }
519
510 __ movl(ECX, ESP); // Saved saved registers block. 520 __ movl(ECX, ESP); // Saved saved registers block.
511 __ ReserveAlignedFrameSpace(1 * kWordSize); 521 __ ReserveAlignedFrameSpace(1 * kWordSize);
512 __ SmiUntag(EAX); 522 __ SmiUntag(EAX);
513 __ movl(Address(ESP, 0), ECX); // Start of register block. 523 __ movl(Address(ESP, 0), ECX); // Start of register block.
514 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry); 524 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry);
515 // Result (EAX) is stack-size (FP - SP) in bytes, incl. the return address. 525 // Result (EAX) is stack-size (FP - SP) in bytes, incl. the return address.
516 __ LeaveFrame(); 526 __ LeaveFrame();
517 __ popl(EDX); // Preserve return address. 527 __ popl(EDX); // Preserve return address.
518 __ movl(ESP, EBP); 528 __ movl(ESP, EBP);
519 __ subl(ESP, EAX); 529 __ subl(ESP, EAX);
520 __ movl(Address(ESP, 0), EDX); 530 __ movl(Address(ESP, 0), EDX);
521 531
522 __ EnterFrame(0); 532 __ EnterFrame(0);
523 __ movl(ECX, ESP); // Get last FP address. 533 __ movl(ECX, ESP); // Get last FP address.
524 __ ReserveAlignedFrameSpace(1 * kWordSize); 534 __ ReserveAlignedFrameSpace(1 * kWordSize);
525 __ movl(Address(ESP, 0), ECX); 535 __ movl(Address(ESP, 0), ECX);
526 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry); 536 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry);
527 __ LeaveFrame(); 537 __ LeaveFrame();
538
539 // Frame is fully rewritten at this point and it is safe to perform a GC.
540 // Materialize any objects that were deferred by FillFrame because they
541 // require allocation.
542 __ EnterFrame(0);
543 __ CallRuntime(kDeoptimizeMaterializeDoublesRuntimeEntry);
544 __ LeaveFrame();
528 __ ret(); 545 __ ret();
529 } 546 }
530 547
531 548
532 // Called for inline allocation of arrays. 549 // Called for inline allocation of arrays.
533 // Input parameters: 550 // Input parameters:
534 // EDX : Array length as Smi. 551 // EDX : Array length as Smi.
535 // ECX : array element type (either NULL or an instantiated type). 552 // ECX : array element type (either NULL or an instantiated type).
536 // Uses EAX, EBX, ECX, EDI as temporary registers. 553 // Uses EAX, EBX, ECX, EDI as temporary registers.
537 // NOTE: EDX cannot be clobbered here as the caller relies on it being saved. 554 // NOTE: EDX cannot be clobbered here as the caller relies on it being saved.
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 __ movl(EAX, Address(ESP, 4 * kWordSize)); // Load error object. 1904 __ movl(EAX, Address(ESP, 4 * kWordSize)); // Load error object.
1888 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. 1905 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer.
1889 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. 1906 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX.
1890 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. 1907 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer.
1891 __ jmp(EBX); // Jump to the exception handler code. 1908 __ jmp(EBX); // Jump to the exception handler code.
1892 } 1909 }
1893 1910
1894 } // namespace dart 1911 } // namespace dart
1895 1912
1896 #endif // defined TARGET_ARCH_IA32 1913 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/locations.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698