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

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

Issue 12220074: Compile FastCloneShallowObjectStub using Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 7 years, 10 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/ia32/code-stubs-ia32.cc ('k') | src/ia32/full-codegen-ia32.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 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 Builtins* builtins = isolate_->builtins(); 552 Builtins* builtins = isolate_->builtins();
553 Code* adaptor_trampoline = 553 Code* adaptor_trampoline =
554 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); 554 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
555 uint32_t pc = reinterpret_cast<uint32_t>( 555 uint32_t pc = reinterpret_cast<uint32_t>(
556 adaptor_trampoline->instruction_start() + 556 adaptor_trampoline->instruction_start() +
557 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); 557 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
558 output_frame->SetPc(pc); 558 output_frame->SetPc(pc);
559 } 559 }
560 560
561 561
562 void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, 562 void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
563 int frame_index) { 563 int frame_index) {
564 // 564 //
565 // FROM TO 565 // FROM TO
566 // | .... | | .... | 566 // | .... | | .... |
567 // +-------------------------+ +-------------------------+ 567 // +-------------------------+ +-------------------------+
568 // | JSFunction continuation | | JSFunction continuation | 568 // | JSFunction continuation | | JSFunction continuation |
569 // +-------------------------+ +-------------------------+ 569 // +-------------------------+ +-------------------------+
570 // | | saved frame (ebp) | | saved frame (ebp) | 570 // | | saved frame (ebp) | | saved frame (ebp) |
571 // | +=========================+<-ebp +=========================+<-ebp 571 // | +=========================+<-ebp +=========================+<-ebp
572 // | | JSFunction context | | JSFunction context | 572 // | | JSFunction context | | JSFunction context |
573 // v +-------------------------+ +-------------------------| 573 // v +-------------------------+ +-------------------------|
574 // | COMPILED_STUB marker | | STUB_FAILURE marker | 574 // | COMPILED_STUB marker | | STUB_FAILURE marker |
575 // +-------------------------+ +-------------------------+ 575 // +-------------------------+ +-------------------------+
576 // | | | caller args.length_ | 576 // | | | caller args.arguments_ |
577 // | ... | +-------------------------+ 577 // | ... | +-------------------------+
578 // | | | caller args.arguments_ | 578 // | | | caller args.length_ |
579 // |-------------------------|<-esp +-------------------------+ 579 // |-------------------------|<-esp +-------------------------+
580 // | caller args pointer | 580 // | caller args pointer |
581 // +-------------------------+ 581 // +-------------------------+
582 // | caller stack param 1 | 582 // | caller stack param 1 |
583 // parameters in registers +-------------------------+ 583 // parameters in registers +-------------------------+
584 // and spilled to stack | .... | 584 // and spilled to stack | .... |
585 // +-------------------------+ 585 // +-------------------------+
586 // | caller stack param n | 586 // | caller stack param n |
587 // +-------------------------+<-esp 587 // +-------------------------+<-esp
588 // eax = number of parameters 588 // eax = number of parameters
589 // ebx = failure handler address 589 // ebx = failure handler address
590 // ebp = saved frame 590 // ebp = saved frame
591 // esi = JSFunction context 591 // esi = JSFunction context
592 // 592 //
593 593
594 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); 594 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
595 int major_key = compiled_code_->major_key(); 595 int major_key = compiled_code_->major_key();
596 CodeStubInterfaceDescriptor* descriptor = 596 CodeStubInterfaceDescriptor* descriptor =
597 isolate_->code_stub_interface_descriptor(major_key); 597 isolate_->code_stub_interface_descriptor(major_key);
598 598
599 // The output frame must have room for all pushed register parameters 599 // The output frame must have room for all pushed register parameters
600 // and the standard stack frame slots. 600 // and the standard stack frame slots. Include space for an argument
601 int output_frame_size = StandardFrameConstants::kFixedFrameSize + 601 // object to the callee and optionally the space to pass the argument
602 kPointerSize * descriptor->register_param_count_; 602 // object to the stub failure handler.
603 int height_in_bytes = kPointerSize * descriptor->register_param_count_ +
604 sizeof(Arguments) + kPointerSize;
605 int fixed_frame_size = StandardFrameConstants::kFixedFrameSize;
606 int input_frame_size = input_->GetFrameSize();
607 int output_frame_size = height_in_bytes + fixed_frame_size;
608 if (trace_) {
609 PrintF(" translating %s => StubFailureTrampolineStub, height=%d\n",
610 CodeStub::MajorName(static_cast<CodeStub::Major>(major_key), false),
611 height_in_bytes);
612 }
603 613
604 // Include space for an argument object to the callee and optionally 614 // The stub failure trampoline is a single frame.
605 // the space to pass the argument object to the stub failure handler.
606 output_frame_size += sizeof(Arguments) + kPointerSize;
607
608 FrameDescription* output_frame = 615 FrameDescription* output_frame =
609 new(output_frame_size) FrameDescription(output_frame_size, 0); 616 new(output_frame_size) FrameDescription(output_frame_size, NULL);
617 output_frame->SetFrameType(StackFrame::STUB_FAILURE_TRAMPOLINE);
610 ASSERT(frame_index == 0); 618 ASSERT(frame_index == 0);
611 output_[frame_index] = output_frame; 619 output_[frame_index] = output_frame;
612 Code* notify_failure =
613 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
614 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
615 output_frame->SetContinuation(
616 reinterpret_cast<intptr_t>(notify_failure->entry()));
617 620
618 Code* trampoline = NULL; 621 // The top address for the output frame can be computed from the input
619 int extra = descriptor->extra_expression_stack_count_; 622 // frame pointer and the output frame's height. Subtract space for the
620 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_); 623 // context and function slots.
621 ASSERT(trampoline != NULL); 624 intptr_t top_address = input_->GetRegister(ebp.code()) - (2 * kPointerSize) -
622 output_frame->SetPc(reinterpret_cast<intptr_t>( 625 height_in_bytes;
623 trampoline->instruction_start())); 626 output_frame->SetTop(top_address);
624 unsigned input_frame_size = input_->GetFrameSize();
625 627
626 intptr_t frame_ptr = input_->GetRegister(ebp.code()); 628 // Read caller's PC (JSFunction continuation) from the input frame.
627
628 // JSFunction continuation
629 intptr_t input_frame_offset = input_frame_size - kPointerSize; 629 intptr_t input_frame_offset = input_frame_size - kPointerSize;
630 intptr_t output_frame_offset = output_frame_size - kPointerSize; 630 intptr_t output_frame_offset = output_frame_size - kPointerSize;
631 intptr_t value = input_->GetFrameSlot(input_frame_offset); 631 intptr_t value = input_->GetFrameSlot(input_frame_offset);
632 output_frame->SetFrameSlot(output_frame_offset, value); 632 output_frame->SetFrameSlot(output_frame_offset, value);
633 if (trace_) {
634 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
635 top_address + output_frame_offset, output_frame_offset, value);
636 }
633 637
634 // saved frame ptr 638 // Read caller's FP from the input frame, and set this frame's FP.
635 input_frame_offset -= kPointerSize; 639 input_frame_offset -= kPointerSize;
636 value = input_->GetFrameSlot(input_frame_offset); 640 value = input_->GetFrameSlot(input_frame_offset);
637 output_frame_offset -= kPointerSize; 641 output_frame_offset -= kPointerSize;
638 output_frame->SetFrameSlot(output_frame_offset, value); 642 output_frame->SetFrameSlot(output_frame_offset, value);
643 intptr_t frame_ptr = input_->GetRegister(ebp.code());
644 output_frame->SetRegister(ebp.code(), frame_ptr);
645 output_frame->SetFp(frame_ptr);
646 if (trace_) {
647 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
648 top_address + output_frame_offset, output_frame_offset, value);
649 }
639 650
640 // Restore context 651 // The context can be gotten from the input frame.
641 input_frame_offset -= kPointerSize; 652 input_frame_offset -= kPointerSize;
642 value = input_->GetFrameSlot(input_frame_offset); 653 value = input_->GetFrameSlot(input_frame_offset);
643 output_frame->SetRegister(esi.code(), value); 654 output_frame->SetRegister(esi.code(), value);
644 output_frame_offset -= kPointerSize; 655 output_frame_offset -= kPointerSize;
645 output_frame->SetFrameSlot(output_frame_offset, value); 656 output_frame->SetFrameSlot(output_frame_offset, value);
657 if (trace_) {
658 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n",
659 top_address + output_frame_offset, output_frame_offset, value);
660 }
646 661
647 // Internal frame markers 662 // A marker value is used in place of the function.
648 output_frame_offset -= kPointerSize; 663 output_frame_offset -= kPointerSize;
649 value = reinterpret_cast<intptr_t>( 664 value = reinterpret_cast<intptr_t>(
650 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); 665 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE));
651 output_frame->SetFrameSlot(output_frame_offset, value); 666 output_frame->SetFrameSlot(output_frame_offset, value);
667 if (trace_) {
668 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function (stub fail sentinel)\n",
669 top_address + output_frame_offset, output_frame_offset, value);
670 }
652 671
653 int caller_arg_count = 0; 672 int caller_arg_count = 0;
654 if (descriptor->stack_parameter_count_ != NULL) { 673 if (descriptor->stack_parameter_count_ != NULL) {
655 caller_arg_count = 674 caller_arg_count =
656 input_->GetRegister(descriptor->stack_parameter_count_->code()); 675 input_->GetRegister(descriptor->stack_parameter_count_->code());
657 } 676 }
658 677
659 // Build the Arguments object for the caller's parameters and a pointer to it. 678 // Build the Arguments object for the caller's parameters and a pointer to it.
660 output_frame_offset -= kPointerSize; 679 output_frame_offset -= kPointerSize;
661 value = frame_ptr + StandardFrameConstants::kCallerSPOffset + 680 value = frame_ptr + StandardFrameConstants::kCallerSPOffset +
662 (caller_arg_count - 1) * kPointerSize; 681 (caller_arg_count - 1) * kPointerSize;
663 output_frame->SetFrameSlot(output_frame_offset, value); 682 output_frame->SetFrameSlot(output_frame_offset, value);
683 if (trace_) {
684 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; args.arguments\n",
685 top_address + output_frame_offset, output_frame_offset, value);
686 }
664 687
688 output_frame_offset -= kPointerSize;
689 value = caller_arg_count;
665 output_frame->SetFrameSlot(output_frame_offset, value); 690 output_frame->SetFrameSlot(output_frame_offset, value);
691 if (trace_) {
692 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; args.length\n",
693 top_address + output_frame_offset, output_frame_offset, value);
694 }
695
666 output_frame_offset -= kPointerSize; 696 output_frame_offset -= kPointerSize;
667 output_frame->SetFrameSlot(output_frame_offset, caller_arg_count);
668
669 value = frame_ptr - (output_frame_size - output_frame_offset) - 697 value = frame_ptr - (output_frame_size - output_frame_offset) -
670 StandardFrameConstants::kMarkerOffset; 698 StandardFrameConstants::kMarkerOffset + kPointerSize;
671 output_frame_offset -= kPointerSize;
672 output_frame->SetFrameSlot(output_frame_offset, value); 699 output_frame->SetFrameSlot(output_frame_offset, value);
700 if (trace_) {
701 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; args*\n",
702 top_address + output_frame_offset, output_frame_offset, value);
703 }
673 704
674 // Copy the register parameters to the failure frame. 705 // Copy the register parameters to the failure frame.
675 for (int i = 0; i < descriptor->register_param_count_; ++i) { 706 for (int i = 0; i < descriptor->register_param_count_; ++i) {
676 output_frame_offset -= kPointerSize; 707 output_frame_offset -= kPointerSize;
677 DoTranslateCommand(iterator, 0, output_frame_offset); 708 DoTranslateCommand(iterator, 0, output_frame_offset);
678 } 709 }
679 710
680 output_frame->SetRegister(ebp.code(), frame_ptr); 711 ASSERT(0 == output_frame_offset);
681 output_frame->SetFp(frame_ptr);
682 712
683 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 713 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) {
684 double double_value = input_->GetDoubleRegister(i); 714 double double_value = input_->GetDoubleRegister(i);
685 output_frame->SetDoubleRegister(i, double_value); 715 output_frame->SetDoubleRegister(i, double_value);
686 } 716 }
687 717
688 intptr_t handler = 718 intptr_t handler =
689 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); 719 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_);
690 int params = descriptor->register_param_count_; 720 int params = descriptor->register_param_count_;
691 if (descriptor->stack_parameter_count_ != NULL) { 721 if (descriptor->stack_parameter_count_ != NULL) {
692 params++; 722 params++;
693 } 723 }
694 output_frame->SetRegister(eax.code(), params); 724 output_frame->SetRegister(eax.code(), params);
695 output_frame->SetRegister(ebx.code(), handler); 725 output_frame->SetRegister(ebx.code(), handler);
726
727 // Compute this frame's PC, state, and continuation.
728 Code* trampoline = NULL;
729 int extra = descriptor->extra_expression_stack_count_;
730 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_);
731 ASSERT(trampoline != NULL);
732 output_frame->SetPc(reinterpret_cast<intptr_t>(
733 trampoline->instruction_start()));
734 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
735 Code* notify_failure =
736 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
737 output_frame->SetContinuation(
738 reinterpret_cast<intptr_t>(notify_failure->entry()));
696 } 739 }
697 740
698 741
699 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, 742 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
700 int frame_index) { 743 int frame_index) {
701 Builtins* builtins = isolate_->builtins(); 744 Builtins* builtins = isolate_->builtins();
702 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); 745 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric);
703 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); 746 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
704 unsigned height = iterator->Next(); 747 unsigned height = iterator->Next();
705 unsigned height_in_bytes = height * kPointerSize; 748 unsigned height_in_bytes = height * kPointerSize;
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 } 1390 }
1348 __ bind(&done); 1391 __ bind(&done);
1349 } 1392 }
1350 1393
1351 #undef __ 1394 #undef __
1352 1395
1353 1396
1354 } } // namespace v8::internal 1397 } } // namespace v8::internal
1355 1398
1356 #endif // V8_TARGET_ARCH_IA32 1399 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698