| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 580 |
| 581 | 581 |
| 582 MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { | 582 MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { |
| 583 ASSERT(op->IsDoubleStackSlot()); | 583 ASSERT(op->IsDoubleStackSlot()); |
| 584 return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); | 584 return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); |
| 585 } | 585 } |
| 586 | 586 |
| 587 | 587 |
| 588 void LCodeGen::WriteTranslation(LEnvironment* environment, | 588 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 589 Translation* translation, | 589 Translation* translation, |
| 590 int* arguments_index, | 590 int* pushed_arguments_index, |
| 591 int* arguments_count) { | 591 int* pushed_arguments_count) { |
| 592 if (environment == NULL) return; | 592 if (environment == NULL) return; |
| 593 | 593 |
| 594 // The translation includes one command per value in the environment. | 594 // The translation includes one command per value in the environment. |
| 595 int translation_size = environment->values()->length(); | 595 int translation_size = environment->values()->length(); |
| 596 // The output frame height does not include the parameters. | 596 // The output frame height does not include the parameters. |
| 597 int height = translation_size - environment->parameter_count(); | 597 int height = translation_size - environment->parameter_count(); |
| 598 | 598 |
| 599 // Function parameters are arguments to the outermost environment. The | 599 // Function parameters are arguments to the outermost environment. The |
| 600 // arguments index points to the first element of a sequence of tagged | 600 // arguments index points to the first element of a sequence of tagged |
| 601 // values on the stack that represent the arguments. This needs to be | 601 // values on the stack that represent the arguments. This needs to be |
| 602 // kept in sync with the LArgumentsElements implementation. | 602 // kept in sync with the LArgumentsElements implementation. |
| 603 *arguments_index = -environment->parameter_count(); | 603 *pushed_arguments_index = -environment->parameter_count(); |
| 604 *arguments_count = environment->parameter_count(); | 604 *pushed_arguments_count = environment->parameter_count(); |
| 605 | 605 |
| 606 WriteTranslation(environment->outer(), | 606 WriteTranslation(environment->outer(), |
| 607 translation, | 607 translation, |
| 608 arguments_index, | 608 pushed_arguments_index, |
| 609 arguments_count); | 609 pushed_arguments_count); |
| 610 bool has_closure_id = !info()->closure().is_null() && | 610 bool has_closure_id = !info()->closure().is_null() && |
| 611 *info()->closure() != *environment->closure(); | 611 *info()->closure() != *environment->closure(); |
| 612 int closure_id = has_closure_id | 612 int closure_id = has_closure_id |
| 613 ? DefineDeoptimizationLiteral(environment->closure()) | 613 ? DefineDeoptimizationLiteral(environment->closure()) |
| 614 : Translation::kSelfLiteralId; | 614 : Translation::kSelfLiteralId; |
| 615 | 615 |
| 616 switch (environment->frame_type()) { | 616 switch (environment->frame_type()) { |
| 617 case JS_FUNCTION: | 617 case JS_FUNCTION: |
| 618 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 618 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
| 619 break; | 619 break; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 632 break; | 632 break; |
| 633 case STUB: | 633 case STUB: |
| 634 translation->BeginCompiledStubFrame(); | 634 translation->BeginCompiledStubFrame(); |
| 635 break; | 635 break; |
| 636 case ARGUMENTS_ADAPTOR: | 636 case ARGUMENTS_ADAPTOR: |
| 637 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 637 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
| 638 break; | 638 break; |
| 639 } | 639 } |
| 640 | 640 |
| 641 // Inlined frames which push their arguments cause the index to be | 641 // Inlined frames which push their arguments cause the index to be |
| 642 // bumped and a new stack area to be used for materialization. | 642 // bumped and another stack area to be used for materialization, |
| 643 if (environment->entry() != NULL && | 643 // otherwise actual argument values are unknown for inlined frames. |
| 644 environment->entry()->arguments_pushed()) { | 644 bool arguments_known = true; |
| 645 *arguments_index = *arguments_index < 0 | 645 int arguments_index = *pushed_arguments_index; |
| 646 ? GetStackSlotCount() | 646 int arguments_count = *pushed_arguments_count; |
| 647 : *arguments_index + *arguments_count; | 647 if (environment->entry() != NULL) { |
| 648 *arguments_count = environment->entry()->arguments_count() + 1; | 648 arguments_known = environment->entry()->arguments_pushed(); |
| 649 arguments_index = arguments_index < 0 |
| 650 ? GetStackSlotCount() : arguments_index + arguments_count; |
| 651 arguments_count = environment->entry()->arguments_count() + 1; |
| 652 if (environment->entry()->arguments_pushed()) { |
| 653 *pushed_arguments_index = arguments_index; |
| 654 *pushed_arguments_count = arguments_count; |
| 655 } |
| 649 } | 656 } |
| 650 | 657 |
| 651 for (int i = 0; i < translation_size; ++i) { | 658 for (int i = 0; i < translation_size; ++i) { |
| 652 LOperand* value = environment->values()->at(i); | 659 LOperand* value = environment->values()->at(i); |
| 653 // spilled_registers_ and spilled_double_registers_ are either | 660 // spilled_registers_ and spilled_double_registers_ are either |
| 654 // both NULL or both set. | 661 // both NULL or both set. |
| 655 if (environment->spilled_registers() != NULL && value != NULL) { | 662 if (environment->spilled_registers() != NULL && value != NULL) { |
| 656 if (value->IsRegister() && | 663 if (value->IsRegister() && |
| 657 environment->spilled_registers()[value->index()] != NULL) { | 664 environment->spilled_registers()[value->index()] != NULL) { |
| 658 translation->MarkDuplicate(); | 665 translation->MarkDuplicate(); |
| 659 AddToTranslation(translation, | 666 AddToTranslation(translation, |
| 660 environment->spilled_registers()[value->index()], | 667 environment->spilled_registers()[value->index()], |
| 661 environment->HasTaggedValueAt(i), | 668 environment->HasTaggedValueAt(i), |
| 662 environment->HasUint32ValueAt(i), | 669 environment->HasUint32ValueAt(i), |
| 663 *arguments_index, | 670 arguments_known, |
| 664 *arguments_count); | 671 arguments_index, |
| 672 arguments_count); |
| 665 } else if ( | 673 } else if ( |
| 666 value->IsDoubleRegister() && | 674 value->IsDoubleRegister() && |
| 667 environment->spilled_double_registers()[value->index()] != NULL) { | 675 environment->spilled_double_registers()[value->index()] != NULL) { |
| 668 translation->MarkDuplicate(); | 676 translation->MarkDuplicate(); |
| 669 AddToTranslation( | 677 AddToTranslation( |
| 670 translation, | 678 translation, |
| 671 environment->spilled_double_registers()[value->index()], | 679 environment->spilled_double_registers()[value->index()], |
| 672 false, | 680 false, |
| 673 false, | 681 false, |
| 674 *arguments_index, | 682 arguments_known, |
| 675 *arguments_count); | 683 arguments_index, |
| 684 arguments_count); |
| 676 } | 685 } |
| 677 } | 686 } |
| 678 | 687 |
| 679 AddToTranslation(translation, | 688 AddToTranslation(translation, |
| 680 value, | 689 value, |
| 681 environment->HasTaggedValueAt(i), | 690 environment->HasTaggedValueAt(i), |
| 682 environment->HasUint32ValueAt(i), | 691 environment->HasUint32ValueAt(i), |
| 683 *arguments_index, | 692 arguments_known, |
| 684 *arguments_count); | 693 arguments_index, |
| 694 arguments_count); |
| 685 } | 695 } |
| 686 } | 696 } |
| 687 | 697 |
| 688 | 698 |
| 689 void LCodeGen::AddToTranslation(Translation* translation, | 699 void LCodeGen::AddToTranslation(Translation* translation, |
| 690 LOperand* op, | 700 LOperand* op, |
| 691 bool is_tagged, | 701 bool is_tagged, |
| 692 bool is_uint32, | 702 bool is_uint32, |
| 703 bool arguments_known, |
| 693 int arguments_index, | 704 int arguments_index, |
| 694 int arguments_count) { | 705 int arguments_count) { |
| 695 if (op == NULL) { | 706 if (op == NULL) { |
| 696 // TODO(twuerthinger): Introduce marker operands to indicate that this value | 707 // TODO(twuerthinger): Introduce marker operands to indicate that this value |
| 697 // is not present and must be reconstructed from the deoptimizer. Currently | 708 // is not present and must be reconstructed from the deoptimizer. Currently |
| 698 // this is only used for the arguments object. | 709 // this is only used for the arguments object. |
| 699 translation->StoreArgumentsObject(arguments_index, arguments_count); | 710 translation->StoreArgumentsObject( |
| 711 arguments_known, arguments_index, arguments_count); |
| 700 } else if (op->IsStackSlot()) { | 712 } else if (op->IsStackSlot()) { |
| 701 if (is_tagged) { | 713 if (is_tagged) { |
| 702 translation->StoreStackSlot(op->index()); | 714 translation->StoreStackSlot(op->index()); |
| 703 } else if (is_uint32) { | 715 } else if (is_uint32) { |
| 704 translation->StoreUint32StackSlot(op->index()); | 716 translation->StoreUint32StackSlot(op->index()); |
| 705 } else { | 717 } else { |
| 706 translation->StoreInt32StackSlot(op->index()); | 718 translation->StoreInt32StackSlot(op->index()); |
| 707 } | 719 } |
| 708 } else if (op->IsDoubleStackSlot()) { | 720 } else if (op->IsDoubleStackSlot()) { |
| 709 translation->StoreDoubleStackSlot(op->index()); | 721 translation->StoreDoubleStackSlot(op->index()); |
| (...skipping 5634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6344 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); | 6356 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); |
| 6345 __ ldr(result, FieldMemOperand(scratch, | 6357 __ ldr(result, FieldMemOperand(scratch, |
| 6346 FixedArray::kHeaderSize - kPointerSize)); | 6358 FixedArray::kHeaderSize - kPointerSize)); |
| 6347 __ bind(&done); | 6359 __ bind(&done); |
| 6348 } | 6360 } |
| 6349 | 6361 |
| 6350 | 6362 |
| 6351 #undef __ | 6363 #undef __ |
| 6352 | 6364 |
| 6353 } } // namespace v8::internal | 6365 } } // namespace v8::internal |
| OLD | NEW |