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

Side by Side Diff: src/arm/deoptimizer-arm.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 | « no previous file | src/arm/frames-arm.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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 output_frame->SetPc(reinterpret_cast<intptr_t>( 530 output_frame->SetPc(reinterpret_cast<intptr_t>(
531 trampoline->instruction_start())); 531 trampoline->instruction_start()));
532 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); 532 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
533 Code* notify_failure = 533 Code* notify_failure =
534 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); 534 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
535 output_frame->SetContinuation( 535 output_frame->SetContinuation(
536 reinterpret_cast<intptr_t>(notify_failure->entry())); 536 reinterpret_cast<intptr_t>(notify_failure->entry()));
537 } 537 }
538 538
539 539
540 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
541 int frame_index) {
542 Builtins* builtins = isolate_->builtins();
543 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric);
544 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
545 unsigned height = iterator->Next();
546 unsigned height_in_bytes = height * kPointerSize;
547 if (FLAG_trace_deopt) {
548 PrintF(" translating construct stub => height=%d\n", height_in_bytes);
549 }
550
551 unsigned fixed_frame_size = 8 * kPointerSize;
552 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
553
554 // Allocate and store the output frame description.
555 FrameDescription* output_frame =
556 new(output_frame_size) FrameDescription(output_frame_size, function);
557 output_frame->SetFrameType(StackFrame::CONSTRUCT);
558
559 // Construct stub can not be topmost or bottommost.
560 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
561 ASSERT(output_[frame_index] == NULL);
562 output_[frame_index] = output_frame;
563
564 // The top address of the frame is computed from the previous
565 // frame's top and this frame's size.
566 uint32_t top_address;
567 top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
568 output_frame->SetTop(top_address);
569
570 // Compute the incoming parameter translation.
571 int parameter_count = height;
572 unsigned output_offset = output_frame_size;
573 for (int i = 0; i < parameter_count; ++i) {
574 output_offset -= kPointerSize;
575 DoTranslateCommand(iterator, frame_index, output_offset);
576 }
577
578 // Read caller's PC from the previous frame.
579 output_offset -= kPointerSize;
580 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
581 output_frame->SetFrameSlot(output_offset, callers_pc);
582 if (FLAG_trace_deopt) {
583 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
584 top_address + output_offset, output_offset, callers_pc);
585 }
586
587 // Read caller's FP from the previous frame, and set this frame's FP.
588 output_offset -= kPointerSize;
589 intptr_t value = output_[frame_index - 1]->GetFp();
590 output_frame->SetFrameSlot(output_offset, value);
591 intptr_t fp_value = top_address + output_offset;
592 output_frame->SetFp(fp_value);
593 if (trace_) {
594 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
595 fp_value, output_offset, value);
596 }
597
598 // The context can be gotten from the previous frame.
599 output_offset -= kPointerSize;
600 value = output_[frame_index - 1]->GetContext();
601 output_frame->SetFrameSlot(output_offset, value);
602 if (trace_) {
603 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n",
604 top_address + output_offset, output_offset, value);
605 }
606
607 // A marker value is used in place of the function.
608 output_offset -= kPointerSize;
609 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::CONSTRUCT));
610 output_frame->SetFrameSlot(output_offset, value);
611 if (trace_) {
612 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function (construct sentinel)\n",
613 top_address + output_offset, output_offset, value);
614 }
615
616 // The output frame reflects a JSConstructStubGeneric frame.
617 output_offset -= kPointerSize;
618 value = reinterpret_cast<intptr_t>(construct_stub);
619 output_frame->SetFrameSlot(output_offset, value);
620 if (trace_) {
621 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; code object\n",
622 top_address + output_offset, output_offset, value);
623 }
624
625 // Number of incoming arguments.
626 output_offset -= kPointerSize;
627 value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1));
628 output_frame->SetFrameSlot(output_offset, value);
629 if (trace_) {
630 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n",
631 top_address + output_offset, output_offset, value, height - 1);
632 }
633
634 // Constructor function being invoked by the stub.
635 output_offset -= kPointerSize;
636 value = reinterpret_cast<intptr_t>(function);
637 output_frame->SetFrameSlot(output_offset, value);
638 if (trace_) {
639 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; constructor function\n",
640 top_address + output_offset, output_offset, value);
641 }
642
643 // The newly allocated object was passed as receiver in the artificial
644 // constructor stub environment created by HEnvironment::CopyForInlining().
645 output_offset -= kPointerSize;
646 value = output_frame->GetFrameSlot(output_frame_size - kPointerSize);
647 output_frame->SetFrameSlot(output_offset, value);
648 if (trace_) {
649 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; allocated receiver\n",
650 top_address + output_offset, output_offset, value);
651 }
652
653 ASSERT(0 == output_offset);
654
655 uint32_t pc = reinterpret_cast<uint32_t>(
656 construct_stub->instruction_start() +
657 isolate_->heap()->construct_stub_deopt_pc_offset()->value());
658 output_frame->SetPc(pc);
659 }
660
661
662 // This code is very similar to ia32 code, but relies on register names (fp, sp) 540 // This code is very similar to ia32 code, but relies on register names (fp, sp)
663 // and how the frame is laid out. 541 // and how the frame is laid out.
664 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, 542 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
665 int frame_index) { 543 int frame_index) {
666 // Read the ast node id, function, and frame height for this output frame. 544 // Read the ast node id, function, and frame height for this output frame.
667 BailoutId node_id = BailoutId(iterator->Next()); 545 BailoutId node_id = BailoutId(iterator->Next());
668 JSFunction* function; 546 JSFunction* function;
669 if (frame_index != 0) { 547 if (frame_index != 0) {
670 function = JSFunction::cast(ComputeLiteral(iterator->Next())); 548 function = JSFunction::cast(ComputeLiteral(iterator->Next()));
671 } else { 549 } else {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 __ push(ip); 975 __ push(ip);
1098 __ b(&done); 976 __ b(&done);
1099 ASSERT(masm()->pc_offset() - start == table_entry_size_); 977 ASSERT(masm()->pc_offset() - start == table_entry_size_);
1100 } 978 }
1101 __ bind(&done); 979 __ bind(&done);
1102 } 980 }
1103 981
1104 #undef __ 982 #undef __
1105 983
1106 } } // namespace v8::internal 984 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/arm/frames-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698