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

Side by Side Diff: src/ia32/deoptimizer-ia32.cc

Issue 12379042: Unify deoptimizer for construct stub frames. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | « src/deoptimizer.cc ('k') | src/ia32/frames-ia32.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 output_frame->SetPc(reinterpret_cast<intptr_t>( 636 output_frame->SetPc(reinterpret_cast<intptr_t>(
637 trampoline->instruction_start())); 637 trampoline->instruction_start()));
638 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); 638 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
639 Code* notify_failure = 639 Code* notify_failure =
640 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); 640 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
641 output_frame->SetContinuation( 641 output_frame->SetContinuation(
642 reinterpret_cast<intptr_t>(notify_failure->entry())); 642 reinterpret_cast<intptr_t>(notify_failure->entry()));
643 } 643 }
644 644
645 645
646 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
647 int frame_index) {
648 Builtins* builtins = isolate_->builtins();
649 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric);
650 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
651 unsigned height = iterator->Next();
652 unsigned height_in_bytes = height * kPointerSize;
653 if (trace_) {
654 PrintF(" translating construct stub => height=%d\n", height_in_bytes);
655 }
656
657 unsigned fixed_frame_size = 7 * kPointerSize;
658 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
659
660 // Allocate and store the output frame description.
661 FrameDescription* output_frame =
662 new(output_frame_size) FrameDescription(output_frame_size, function);
663 output_frame->SetFrameType(StackFrame::CONSTRUCT);
664
665 // Construct stub can not be topmost or bottommost.
666 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
667 ASSERT(output_[frame_index] == NULL);
668 output_[frame_index] = output_frame;
669
670 // The top address of the frame is computed from the previous
671 // frame's top and this frame's size.
672 uint32_t top_address;
673 top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
674 output_frame->SetTop(top_address);
675
676 // Compute the incoming parameter translation.
677 int parameter_count = height;
678 unsigned output_offset = output_frame_size;
679 for (int i = 0; i < parameter_count; ++i) {
680 output_offset -= kPointerSize;
681 DoTranslateCommand(iterator, frame_index, output_offset);
682 }
683
684 // Read caller's PC from the previous frame.
685 output_offset -= kPointerSize;
686 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
687 output_frame->SetFrameSlot(output_offset, callers_pc);
688 if (trace_) {
689 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
690 top_address + output_offset, output_offset, callers_pc);
691 }
692
693 // Read caller's FP from the previous frame, and set this frame's FP.
694 output_offset -= kPointerSize;
695 intptr_t value = output_[frame_index - 1]->GetFp();
696 output_frame->SetFrameSlot(output_offset, value);
697 intptr_t fp_value = top_address + output_offset;
698 output_frame->SetFp(fp_value);
699 if (trace_) {
700 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
701 fp_value, output_offset, value);
702 }
703
704 // The context can be gotten from the previous frame.
705 output_offset -= kPointerSize;
706 value = output_[frame_index - 1]->GetContext();
707 output_frame->SetFrameSlot(output_offset, value);
708 if (trace_) {
709 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n",
710 top_address + output_offset, output_offset, value);
711 }
712
713 // A marker value is used in place of the function.
714 output_offset -= kPointerSize;
715 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::CONSTRUCT));
716 output_frame->SetFrameSlot(output_offset, value);
717 if (trace_) {
718 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function (construct sentinel)\n",
719 top_address + output_offset, output_offset, value);
720 }
721
722 // The output frame reflects a JSConstructStubGeneric frame.
723 output_offset -= kPointerSize;
724 value = reinterpret_cast<intptr_t>(construct_stub);
725 output_frame->SetFrameSlot(output_offset, value);
726 if (trace_) {
727 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; code object\n",
728 top_address + output_offset, output_offset, value);
729 }
730
731 // Number of incoming arguments.
732 output_offset -= kPointerSize;
733 value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1));
734 output_frame->SetFrameSlot(output_offset, value);
735 if (trace_) {
736 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n",
737 top_address + output_offset, output_offset, value, height - 1);
738 }
739
740 // The newly allocated object was passed as receiver in the artificial
741 // constructor stub environment created by HEnvironment::CopyForInlining().
742 output_offset -= kPointerSize;
743 value = output_frame->GetFrameSlot(output_frame_size - kPointerSize);
744 output_frame->SetFrameSlot(output_offset, value);
745 if (trace_) {
746 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; allocated receiver\n",
747 top_address + output_offset, output_offset, value);
748 }
749
750 ASSERT(0 == output_offset);
751
752 uint32_t pc = reinterpret_cast<uint32_t>(
753 construct_stub->instruction_start() +
754 isolate_->heap()->construct_stub_deopt_pc_offset()->value());
755 output_frame->SetPc(pc);
756 }
757
758
759 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, 646 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
760 int frame_index) { 647 int frame_index) {
761 BailoutId node_id = BailoutId(iterator->Next()); 648 BailoutId node_id = BailoutId(iterator->Next());
762 JSFunction* function; 649 JSFunction* function;
763 if (frame_index != 0) { 650 if (frame_index != 0) {
764 function = JSFunction::cast(ComputeLiteral(iterator->Next())); 651 function = JSFunction::cast(ComputeLiteral(iterator->Next()));
765 } else { 652 } else {
766 int closure_id = iterator->Next(); 653 int closure_id = iterator->Next();
767 USE(closure_id); 654 USE(closure_id);
768 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); 655 ASSERT_EQ(Translation::kSelfLiteralId, closure_id);
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 } 1062 }
1176 __ bind(&done); 1063 __ bind(&done);
1177 } 1064 }
1178 1065
1179 #undef __ 1066 #undef __
1180 1067
1181 1068
1182 } } // namespace v8::internal 1069 } } // namespace v8::internal
1183 1070
1184 #endif // V8_TARGET_ARCH_IA32 1071 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | src/ia32/frames-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698