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

Side by Side Diff: src/virtual-frame-ia32.cc

Issue 16567: Enable register allocation for return statements. Make sure to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 11 years, 11 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
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 Comment cmnt(masm_, "[ Enter JS frame"); 587 Comment cmnt(masm_, "[ Enter JS frame");
588 EmitPush(ebp); 588 EmitPush(ebp);
589 589
590 frame_pointer_ = stack_pointer_; 590 frame_pointer_ = stack_pointer_;
591 __ mov(ebp, Operand(esp)); 591 __ mov(ebp, Operand(esp));
592 592
593 // Store the context in the frame. The context is kept in esi and a 593 // Store the context in the frame. The context is kept in esi and a
594 // copy is stored in the frame. The external reference to esi 594 // copy is stored in the frame. The external reference to esi
595 // remains in addition to the cached copy in the frame. 595 // remains in addition to the cached copy in the frame.
596 Push(esi); 596 Push(esi);
597 SyncElementAt(elements_.length() - 1);
597 598
598 // Store the function in the frame. The frame owns the register reference 599 // Store the function in the frame. The frame owns the register
599 // now (ie, it can keep it in edi or spill it later). 600 // reference now (ie, it can keep it in edi or spill it later).
600 Push(edi); 601 Push(edi);
601 cgen_->allocator()->Unuse(edi); 602 cgen_->allocator()->Unuse(edi);
603 SpillElementAt(elements_.length() - 1);
602 } 604 }
603 605
604 606
605 void VirtualFrame::Exit() { 607 void VirtualFrame::Exit() {
606 Comment cmnt(masm_, "[ Exit JS frame"); 608 Comment cmnt(masm_, "[ Exit JS frame");
607 // Record the location of the JS exit code for patching when setting 609 // Record the location of the JS exit code for patching when setting
608 // break point. 610 // break point.
609 __ RecordJSReturn(); 611 __ RecordJSReturn();
610 612
611 // Avoid using the leave instruction here, because it is too 613 // Avoid using the leave instruction here, because it is too
612 // short. We need the return sequence to be a least the size of a 614 // short. We need the return sequence to be a least the size of a
613 // call instruction to support patching the exit code in the 615 // call instruction to support patching the exit code in the
614 // debugger. See VisitReturnStatement for the full return sequence. 616 // debugger. See VisitReturnStatement for the full return sequence.
615 __ mov(esp, Operand(ebp)); 617 __ mov(esp, Operand(ebp));
616 stack_pointer_ = frame_pointer_; 618 stack_pointer_ = frame_pointer_;
617 for (int i = elements_.length() - 1; i > stack_pointer_; i--) { 619 for (int i = elements_.length() - 1; i > stack_pointer_; i--) {
618 FrameElement last = elements_.RemoveLast(); 620 FrameElement last = elements_.RemoveLast();
619 if (last.is_register()) { 621 if (last.is_register()) {
620 Unuse(last.reg()); 622 Unuse(last.reg());
621 } 623 }
622 } 624 }
623 625
624 frame_pointer_ = kIllegalIndex; 626 frame_pointer_ = kIllegalIndex;
625 EmitPop(ebp); 627 EmitPop(ebp);
626 } 628 }
627 629
628 630
631 void VirtualFrame::PrepareForReturn() {
632 // Spill all locals. This is necessary to make sure all locals have
633 // the right value when breaking at the return site in the debugger.
634 for (int i = 0; i < expression_base_index(); i++) SpillElementAt(i);
635
636 // Forget all about non-local stack elements.
637 Forget(height());
Kevin Millikin (Chromium) 2009/01/07 10:25:12 As discussed offline, Forget as it currently stand
638
639 // Validate state: The expression stack should be empty and the
640 // stack pointer should have been updated to reflect this.
641 ASSERT(height() == 0);
642 ASSERT(stack_pointer_ == expression_base_index() - 1);
643 }
644
645
629 void VirtualFrame::AllocateStackSlots(int count) { 646 void VirtualFrame::AllocateStackSlots(int count) {
630 ASSERT(height() == 0); 647 ASSERT(height() == 0);
631 local_count_ = count; 648 local_count_ = count;
632 649
633 if (count > 0) { 650 if (count > 0) {
634 Comment cmnt(masm_, "[ Allocate space for locals"); 651 Comment cmnt(masm_, "[ Allocate space for locals");
635 // The locals are initialized to a constant (the undefined value), but 652 // The locals are initialized to a constant (the undefined value), but
636 // we sync them with the actual frame to allocate space for spilling 653 // we sync them with the actual frame to allocate space for spilling
637 // them later. First sync everything above the stack pointer so we can 654 // them later. First sync everything above the stack pointer so we can
638 // use pushes to allocate and initialize the locals. 655 // use pushes to allocate and initialize the locals.
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 return false; 1014 return false;
998 } 1015 }
999 } 1016 }
1000 return true; 1017 return true;
1001 } 1018 }
1002 #endif 1019 #endif
1003 1020
1004 #undef __ 1021 #undef __
1005 1022
1006 } } // namespace v8::internal 1023 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698