| OLD | NEW |
| 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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 } | 554 } |
| 555 | 555 |
| 556 | 556 |
| 557 MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { | 557 MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { |
| 558 ASSERT(op->IsDoubleStackSlot()); | 558 ASSERT(op->IsDoubleStackSlot()); |
| 559 return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); | 559 return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); |
| 560 } | 560 } |
| 561 | 561 |
| 562 | 562 |
| 563 void LCodeGen::WriteTranslation(LEnvironment* environment, | 563 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 564 Translation* translation, | 564 Translation* translation) { |
| 565 int* pushed_arguments_index, | |
| 566 int* pushed_arguments_count) { | |
| 567 if (environment == NULL) return; | 565 if (environment == NULL) return; |
| 568 | 566 |
| 569 // The translation includes one command per value in the environment. | 567 // The translation includes one command per value in the environment. |
| 570 int translation_size = environment->values()->length(); | 568 int translation_size = environment->translation_size(); |
| 571 // The output frame height does not include the parameters. | 569 // The output frame height does not include the parameters. |
| 572 int height = translation_size - environment->parameter_count(); | 570 int height = translation_size - environment->parameter_count(); |
| 573 | 571 |
| 574 // Function parameters are arguments to the outermost environment. The | 572 WriteTranslation(environment->outer(), translation); |
| 575 // arguments index points to the first element of a sequence of tagged | |
| 576 // values on the stack that represent the arguments. This needs to be | |
| 577 // kept in sync with the LArgumentsElements implementation. | |
| 578 *pushed_arguments_index = -environment->parameter_count(); | |
| 579 *pushed_arguments_count = environment->parameter_count(); | |
| 580 | |
| 581 WriteTranslation(environment->outer(), | |
| 582 translation, | |
| 583 pushed_arguments_index, | |
| 584 pushed_arguments_count); | |
| 585 bool has_closure_id = !info()->closure().is_null() && | 573 bool has_closure_id = !info()->closure().is_null() && |
| 586 !info()->closure().is_identical_to(environment->closure()); | 574 !info()->closure().is_identical_to(environment->closure()); |
| 587 int closure_id = has_closure_id | 575 int closure_id = has_closure_id |
| 588 ? DefineDeoptimizationLiteral(environment->closure()) | 576 ? DefineDeoptimizationLiteral(environment->closure()) |
| 589 : Translation::kSelfLiteralId; | 577 : Translation::kSelfLiteralId; |
| 590 | 578 |
| 591 switch (environment->frame_type()) { | 579 switch (environment->frame_type()) { |
| 592 case JS_FUNCTION: | 580 case JS_FUNCTION: |
| 593 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 581 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
| 594 break; | 582 break; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 606 translation->BeginSetterStubFrame(closure_id); | 594 translation->BeginSetterStubFrame(closure_id); |
| 607 break; | 595 break; |
| 608 case STUB: | 596 case STUB: |
| 609 translation->BeginCompiledStubFrame(); | 597 translation->BeginCompiledStubFrame(); |
| 610 break; | 598 break; |
| 611 case ARGUMENTS_ADAPTOR: | 599 case ARGUMENTS_ADAPTOR: |
| 612 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 600 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
| 613 break; | 601 break; |
| 614 } | 602 } |
| 615 | 603 |
| 616 // Inlined frames which push their arguments cause the index to be | |
| 617 // bumped and another stack area to be used for materialization, | |
| 618 // otherwise actual argument values are unknown for inlined frames. | |
| 619 bool arguments_known = true; | |
| 620 int arguments_index = *pushed_arguments_index; | |
| 621 int arguments_count = *pushed_arguments_count; | |
| 622 if (environment->entry() != NULL) { | |
| 623 arguments_known = environment->entry()->arguments_pushed(); | |
| 624 arguments_index = arguments_index < 0 | |
| 625 ? GetStackSlotCount() : arguments_index + arguments_count; | |
| 626 arguments_count = environment->entry()->arguments_count() + 1; | |
| 627 if (environment->entry()->arguments_pushed()) { | |
| 628 *pushed_arguments_index = arguments_index; | |
| 629 *pushed_arguments_count = arguments_count; | |
| 630 } | |
| 631 } | |
| 632 | |
| 633 for (int i = 0; i < translation_size; ++i) { | 604 for (int i = 0; i < translation_size; ++i) { |
| 634 LOperand* value = environment->values()->at(i); | 605 LOperand* value = environment->values()->at(i); |
| 635 // spilled_registers_ and spilled_double_registers_ are either | 606 // spilled_registers_ and spilled_double_registers_ are either |
| 636 // both NULL or both set. | 607 // both NULL or both set. |
| 637 if (environment->spilled_registers() != NULL && value != NULL) { | 608 if (environment->spilled_registers() != NULL && value != NULL) { |
| 638 if (value->IsRegister() && | 609 if (value->IsRegister() && |
| 639 environment->spilled_registers()[value->index()] != NULL) { | 610 environment->spilled_registers()[value->index()] != NULL) { |
| 640 translation->MarkDuplicate(); | 611 translation->MarkDuplicate(); |
| 641 AddToTranslation(translation, | 612 AddToTranslation(translation, |
| 642 environment->spilled_registers()[value->index()], | 613 environment->spilled_registers()[value->index()], |
| 643 environment->HasTaggedValueAt(i), | 614 environment->HasTaggedValueAt(i), |
| 644 environment->HasUint32ValueAt(i), | 615 environment->HasUint32ValueAt(i)); |
| 645 arguments_known, | |
| 646 arguments_index, | |
| 647 arguments_count); | |
| 648 } else if ( | 616 } else if ( |
| 649 value->IsDoubleRegister() && | 617 value->IsDoubleRegister() && |
| 650 environment->spilled_double_registers()[value->index()] != NULL) { | 618 environment->spilled_double_registers()[value->index()] != NULL) { |
| 651 translation->MarkDuplicate(); | 619 translation->MarkDuplicate(); |
| 652 AddToTranslation( | 620 AddToTranslation( |
| 653 translation, | 621 translation, |
| 654 environment->spilled_double_registers()[value->index()], | 622 environment->spilled_double_registers()[value->index()], |
| 655 false, | 623 false, |
| 656 false, | 624 false); |
| 657 arguments_known, | |
| 658 arguments_index, | |
| 659 arguments_count); | |
| 660 } | 625 } |
| 661 } | 626 } |
| 662 | 627 |
| 628 // TODO(mstarzinger): Introduce marker operands to indicate that this value |
| 629 // is not present and must be reconstructed from the deoptimizer. Currently |
| 630 // this is only used for the arguments object. |
| 631 if (value == NULL) { |
| 632 int arguments_count = environment->values()->length() - translation_size; |
| 633 translation->BeginArgumentsObject(arguments_count); |
| 634 for (int i = 0; i < arguments_count; ++i) { |
| 635 LOperand* value = environment->values()->at(translation_size + i); |
| 636 ASSERT(environment->spilled_registers() == NULL || |
| 637 !value->IsRegister() || |
| 638 environment->spilled_registers()[value->index()] == NULL); |
| 639 ASSERT(environment->spilled_registers() == NULL || |
| 640 !value->IsDoubleRegister() || |
| 641 environment->spilled_double_registers()[value->index()] == NULL); |
| 642 AddToTranslation(translation, |
| 643 value, |
| 644 environment->HasTaggedValueAt(translation_size + i), |
| 645 environment->HasUint32ValueAt(translation_size + i)); |
| 646 } |
| 647 continue; |
| 648 } |
| 649 |
| 663 AddToTranslation(translation, | 650 AddToTranslation(translation, |
| 664 value, | 651 value, |
| 665 environment->HasTaggedValueAt(i), | 652 environment->HasTaggedValueAt(i), |
| 666 environment->HasUint32ValueAt(i), | 653 environment->HasUint32ValueAt(i)); |
| 667 arguments_known, | |
| 668 arguments_index, | |
| 669 arguments_count); | |
| 670 } | 654 } |
| 671 } | 655 } |
| 672 | 656 |
| 673 | 657 |
| 674 void LCodeGen::AddToTranslation(Translation* translation, | 658 void LCodeGen::AddToTranslation(Translation* translation, |
| 675 LOperand* op, | 659 LOperand* op, |
| 676 bool is_tagged, | 660 bool is_tagged, |
| 677 bool is_uint32, | 661 bool is_uint32) { |
| 678 bool arguments_known, | 662 if (op->IsStackSlot()) { |
| 679 int arguments_index, | |
| 680 int arguments_count) { | |
| 681 if (op == NULL) { | |
| 682 // TODO(twuerthinger): Introduce marker operands to indicate that this value | |
| 683 // is not present and must be reconstructed from the deoptimizer. Currently | |
| 684 // this is only used for the arguments object. | |
| 685 translation->StoreArgumentsObject( | |
| 686 arguments_known, arguments_index, arguments_count); | |
| 687 } else if (op->IsStackSlot()) { | |
| 688 if (is_tagged) { | 663 if (is_tagged) { |
| 689 translation->StoreStackSlot(op->index()); | 664 translation->StoreStackSlot(op->index()); |
| 690 } else if (is_uint32) { | 665 } else if (is_uint32) { |
| 691 translation->StoreUint32StackSlot(op->index()); | 666 translation->StoreUint32StackSlot(op->index()); |
| 692 } else { | 667 } else { |
| 693 translation->StoreInt32StackSlot(op->index()); | 668 translation->StoreInt32StackSlot(op->index()); |
| 694 } | 669 } |
| 695 } else if (op->IsDoubleStackSlot()) { | 670 } else if (op->IsDoubleStackSlot()) { |
| 696 translation->StoreDoubleStackSlot(op->index()); | 671 translation->StoreDoubleStackSlot(op->index()); |
| 697 } else if (op->IsArgument()) { | 672 } else if (op->IsArgument()) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 // 0 ..................................................... size-1 | 747 // 0 ..................................................... size-1 |
| 773 // [parameters] [locals] [expression stack including arguments] | 748 // [parameters] [locals] [expression stack including arguments] |
| 774 | 749 |
| 775 // Layout of the translation: | 750 // Layout of the translation: |
| 776 // 0 ........................................................ size - 1 + 4 | 751 // 0 ........................................................ size - 1 + 4 |
| 777 // [expression stack including arguments] [locals] [4 words] [parameters] | 752 // [expression stack including arguments] [locals] [4 words] [parameters] |
| 778 // |>------------ translation_size ------------<| | 753 // |>------------ translation_size ------------<| |
| 779 | 754 |
| 780 int frame_count = 0; | 755 int frame_count = 0; |
| 781 int jsframe_count = 0; | 756 int jsframe_count = 0; |
| 782 int args_index = 0; | |
| 783 int args_count = 0; | |
| 784 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 757 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
| 785 ++frame_count; | 758 ++frame_count; |
| 786 if (e->frame_type() == JS_FUNCTION) { | 759 if (e->frame_type() == JS_FUNCTION) { |
| 787 ++jsframe_count; | 760 ++jsframe_count; |
| 788 } | 761 } |
| 789 } | 762 } |
| 790 Translation translation(&translations_, frame_count, jsframe_count, zone()); | 763 Translation translation(&translations_, frame_count, jsframe_count, zone()); |
| 791 WriteTranslation(environment, &translation, &args_index, &args_count); | 764 WriteTranslation(environment, &translation); |
| 792 int deoptimization_index = deoptimizations_.length(); | 765 int deoptimization_index = deoptimizations_.length(); |
| 793 int pc_offset = masm()->pc_offset(); | 766 int pc_offset = masm()->pc_offset(); |
| 794 environment->Register(deoptimization_index, | 767 environment->Register(deoptimization_index, |
| 795 translation.index(), | 768 translation.index(), |
| 796 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 769 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
| 797 deoptimizations_.Add(environment, zone()); | 770 deoptimizations_.Add(environment, zone()); |
| 798 } | 771 } |
| 799 } | 772 } |
| 800 | 773 |
| 801 | 774 |
| (...skipping 4891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5693 __ Subu(scratch, result, scratch); | 5666 __ Subu(scratch, result, scratch); |
| 5694 __ lw(result, FieldMemOperand(scratch, | 5667 __ lw(result, FieldMemOperand(scratch, |
| 5695 FixedArray::kHeaderSize - kPointerSize)); | 5668 FixedArray::kHeaderSize - kPointerSize)); |
| 5696 __ bind(&done); | 5669 __ bind(&done); |
| 5697 } | 5670 } |
| 5698 | 5671 |
| 5699 | 5672 |
| 5700 #undef __ | 5673 #undef __ |
| 5701 | 5674 |
| 5702 } } // namespace v8::internal | 5675 } } // namespace v8::internal |
| OLD | NEW |