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

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

Issue 12093089: Support pass-through of stub caller arguments (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix bugs 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
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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // | | | stub parameter 1 | 576 // | | | caller args.length_ |
577 // | ... | +-------------------------+ 577 // | ... | +-------------------------+
578 // | | | ... | 578 // | | | caller args.arguments_ |
579 // |-------------------------|<-esp +-------------------------+ 579 // |-------------------------|<-esp +-------------------------+
580 // | stub parameter n | 580 // | caller args pointer |
581 // parameters in registers +-------------------------+<-esp 581 // +-------------------------+
582 // and spilled to stack eax = number of parameters 582 // | caller stack param 1 |
583 // parameters in registers +-------------------------+
584 // and spilled to stack | .... |
585 // +-------------------------+
586 // | caller stack param n |
587 // +-------------------------+<-esp
588 // eax = number of parameters
583 // ebx = failure handler address 589 // ebx = failure handler address
584 // ebp = saved frame 590 // ebp = saved frame
585 // esi = JSFunction context 591 // esi = JSFunction context
586 // 592 //
587 593
588 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); 594 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
589 int major_key = compiled_code_->major_key(); 595 int major_key = compiled_code_->major_key();
590 CodeStubInterfaceDescriptor* descriptor = 596 CodeStubInterfaceDescriptor* descriptor =
591 isolate_->code_stub_interface_descriptor(major_key); 597 isolate_->code_stub_interface_descriptor(major_key);
592 598
599 // The output frame must have room for all pushed register parameters
600 // and the standard stack frame slots.
593 int output_frame_size = StandardFrameConstants::kFixedFrameSize + 601 int output_frame_size = StandardFrameConstants::kFixedFrameSize +
594 kPointerSize * descriptor->register_param_count_; 602 kPointerSize * descriptor->register_param_count_;
595 603
604 // Include space for an argument object to the callee and optionally
605 // the space to pass the argument object to the stub failure handler.
606 output_frame_size += sizeof(Arguments) + kPointerSize;
607
596 FrameDescription* output_frame = 608 FrameDescription* output_frame =
597 new(output_frame_size) FrameDescription(output_frame_size, 0); 609 new(output_frame_size) FrameDescription(output_frame_size, 0);
598 ASSERT(frame_index == 0); 610 ASSERT(frame_index == 0);
599 output_[frame_index] = output_frame; 611 output_[frame_index] = output_frame;
600 Code* notify_failure = 612 Code* notify_failure =
601 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); 613 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
602 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); 614 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
603 output_frame->SetContinuation( 615 output_frame->SetContinuation(
604 reinterpret_cast<intptr_t>(notify_failure->entry())); 616 reinterpret_cast<intptr_t>(notify_failure->entry()));
605 617
606 Code* trampoline = NULL; 618 Code* trampoline = NULL;
607 StubFailureTrampolineStub().FindCodeInCache(&trampoline, isolate_); 619 int extra = descriptor->extra_expression_stack_count_;
620 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_);
608 ASSERT(trampoline != NULL); 621 ASSERT(trampoline != NULL);
609 output_frame->SetPc(reinterpret_cast<intptr_t>( 622 output_frame->SetPc(reinterpret_cast<intptr_t>(
610 trampoline->instruction_start())); 623 trampoline->instruction_start()));
611 unsigned input_frame_size = input_->GetFrameSize(); 624 unsigned input_frame_size = input_->GetFrameSize();
612 625
626 intptr_t frame_ptr = input_->GetRegister(ebp.code());
627
613 // JSFunction continuation 628 // JSFunction continuation
614 intptr_t input_frame_offset = input_frame_size - kPointerSize; 629 intptr_t input_frame_offset = input_frame_size - kPointerSize;
615 intptr_t output_frame_offset = output_frame_size - kPointerSize; 630 intptr_t output_frame_offset = output_frame_size - kPointerSize;
616 intptr_t value = input_->GetFrameSlot(input_frame_offset); 631 intptr_t value = input_->GetFrameSlot(input_frame_offset);
617 output_frame->SetFrameSlot(output_frame_offset, value); 632 output_frame->SetFrameSlot(output_frame_offset, value);
618 633
619 // saved frame ptr 634 // saved frame ptr
620 input_frame_offset -= kPointerSize; 635 input_frame_offset -= kPointerSize;
621 value = input_->GetFrameSlot(input_frame_offset); 636 value = input_->GetFrameSlot(input_frame_offset);
622 output_frame_offset -= kPointerSize; 637 output_frame_offset -= kPointerSize;
623 output_frame->SetFrameSlot(output_frame_offset, value); 638 output_frame->SetFrameSlot(output_frame_offset, value);
624 639
625 // Restore context 640 // Restore context
626 input_frame_offset -= kPointerSize; 641 input_frame_offset -= kPointerSize;
627 value = input_->GetFrameSlot(input_frame_offset); 642 value = input_->GetFrameSlot(input_frame_offset);
628 output_frame->SetRegister(esi.code(), value); 643 output_frame->SetRegister(esi.code(), value);
629 output_frame_offset -= kPointerSize; 644 output_frame_offset -= kPointerSize;
630 output_frame->SetFrameSlot(output_frame_offset, value); 645 output_frame->SetFrameSlot(output_frame_offset, value);
631 646
632 // Internal frame markers 647 // Internal frame markers
633 output_frame_offset -= kPointerSize; 648 output_frame_offset -= kPointerSize;
634 value = reinterpret_cast<intptr_t>( 649 value = reinterpret_cast<intptr_t>(
635 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); 650 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE));
636 output_frame->SetFrameSlot(output_frame_offset, value); 651 output_frame->SetFrameSlot(output_frame_offset, value);
637 652
653 int caller_arg_count = 0;
654 if (descriptor->stack_parameter_count_ != NULL) {
655 caller_arg_count =
656 input_->GetRegister(descriptor->stack_parameter_count_->code());
657 }
658
659 // Build the Arguments object for the caller's parameters and a pointer to it.
660 output_frame_offset -= kPointerSize;
661 value = frame_ptr + StandardFrameConstants::kCallerSPOffset +
662 (caller_arg_count - 1) * kPointerSize;
663 output_frame->SetFrameSlot(output_frame_offset, value);
664
665 output_frame->SetFrameSlot(output_frame_offset, value);
666 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) -
670 StandardFrameConstants::kMarkerOffset;
671 output_frame_offset -= kPointerSize;
672 output_frame->SetFrameSlot(output_frame_offset, value);
673
674 // Copy the register parameters to the failure frame.
638 for (int i = 0; i < descriptor->register_param_count_; ++i) { 675 for (int i = 0; i < descriptor->register_param_count_; ++i) {
639 output_frame_offset -= kPointerSize; 676 output_frame_offset -= kPointerSize;
640 DoTranslateCommand(iterator, 0, output_frame_offset); 677 DoTranslateCommand(iterator, 0, output_frame_offset);
641 } 678 }
642 679
643 value = input_->GetRegister(ebp.code()); 680 output_frame->SetRegister(ebp.code(), frame_ptr);
644 output_frame->SetRegister(ebp.code(), value); 681 output_frame->SetFp(frame_ptr);
645 output_frame->SetFp(value);
646 682
647 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 683 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) {
648 double double_value = input_->GetDoubleRegister(i); 684 double double_value = input_->GetDoubleRegister(i);
649 output_frame->SetDoubleRegister(i, double_value); 685 output_frame->SetDoubleRegister(i, double_value);
650 } 686 }
651 687
652 intptr_t handler = 688 intptr_t handler =
653 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); 689 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_);
654 output_frame->SetRegister(eax.code(), descriptor->register_param_count_); 690 int params = descriptor->register_param_count_;
691 if (descriptor->stack_parameter_count_ != NULL) {
692 params++;
693 }
694 output_frame->SetRegister(eax.code(), params);
655 output_frame->SetRegister(ebx.code(), handler); 695 output_frame->SetRegister(ebx.code(), handler);
656 } 696 }
657 697
658 698
659 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, 699 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
660 int frame_index) { 700 int frame_index) {
661 Builtins* builtins = isolate_->builtins(); 701 Builtins* builtins = isolate_->builtins();
662 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); 702 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric);
663 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); 703 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
664 unsigned height = iterator->Next(); 704 unsigned height = iterator->Next();
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 } 1352 }
1313 __ bind(&done); 1353 __ bind(&done);
1314 } 1354 }
1315 1355
1316 #undef __ 1356 #undef __
1317 1357
1318 1358
1319 } } // namespace v8::internal 1359 } } // namespace v8::internal
1320 1360
1321 #endif // V8_TARGET_ARCH_IA32 1361 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/frames.cc ('K') | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/frames-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698