| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 } else { | 605 } else { |
| 606 // Anything else can be handled normally. | 606 // Anything else can be handled normally. |
| 607 Load(expr); | 607 Load(expr); |
| 608 } | 608 } |
| 609 } | 609 } |
| 610 | 610 |
| 611 | 611 |
| 612 ArgumentsAllocationMode CodeGenerator::ArgumentsMode() { | 612 ArgumentsAllocationMode CodeGenerator::ArgumentsMode() { |
| 613 if (scope()->arguments() == NULL) return NO_ARGUMENTS_ALLOCATION; | 613 if (scope()->arguments() == NULL) return NO_ARGUMENTS_ALLOCATION; |
| 614 | 614 |
| 615 // In strict mode there is no need for shadow arguments. | |
| 616 ASSERT(scope()->arguments_shadow() != NULL || scope()->is_strict_mode()); | |
| 617 // We don't want to do lazy arguments allocation for functions that | 615 // We don't want to do lazy arguments allocation for functions that |
| 618 // have heap-allocated contexts, because it interfers with the | 616 // have heap-allocated contexts, because it interfers with the |
| 619 // uninitialized const tracking in the context objects. | 617 // uninitialized const tracking in the context objects. |
| 620 return (scope()->num_heap_slots() > 0 || scope()->is_strict_mode()) | 618 return (scope()->num_heap_slots() > 0 || scope()->is_strict_mode()) |
| 621 ? EAGER_ARGUMENTS_ALLOCATION | 619 ? EAGER_ARGUMENTS_ALLOCATION |
| 622 : LAZY_ARGUMENTS_ALLOCATION; | 620 : LAZY_ARGUMENTS_ALLOCATION; |
| 623 } | 621 } |
| 624 | 622 |
| 625 | 623 |
| 626 Result CodeGenerator::StoreArgumentsObject(bool initial) { | 624 Result CodeGenerator::StoreArgumentsObject(bool initial) { |
| 627 ArgumentsAllocationMode mode = ArgumentsMode(); | 625 ArgumentsAllocationMode mode = ArgumentsMode(); |
| 628 ASSERT(mode != NO_ARGUMENTS_ALLOCATION); | 626 ASSERT(mode != NO_ARGUMENTS_ALLOCATION); |
| 629 | 627 |
| 630 Comment cmnt(masm_, "[ store arguments object"); | 628 Comment cmnt(masm_, "[ store arguments object"); |
| 631 if (mode == LAZY_ARGUMENTS_ALLOCATION && initial) { | 629 if (mode == LAZY_ARGUMENTS_ALLOCATION && initial) { |
| 632 // When using lazy arguments allocation, we store the arguments marker value | 630 // When using lazy arguments allocation, we store the arguments marker value |
| 633 // as a sentinel indicating that the arguments object hasn't been | 631 // as a sentinel indicating that the arguments object hasn't been |
| 634 // allocated yet. | 632 // allocated yet. |
| 635 frame_->Push(Factory::arguments_marker()); | 633 frame_->Push(Factory::arguments_marker()); |
| 636 } else { | 634 } else { |
| 637 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT); | 635 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT); |
| 638 frame_->PushFunction(); | 636 frame_->PushFunction(); |
| 639 frame_->PushReceiverSlotAddress(); | 637 frame_->PushReceiverSlotAddress(); |
| 640 frame_->Push(Smi::FromInt(scope()->num_parameters())); | 638 frame_->Push(Smi::FromInt(scope()->num_parameters())); |
| 641 Result result = frame_->CallStub(&stub, 3); | 639 Result result = frame_->CallStub(&stub, 3); |
| 642 frame_->Push(&result); | 640 frame_->Push(&result); |
| 643 } | 641 } |
| 644 | 642 |
| 645 Variable* arguments = scope()->arguments(); | 643 Variable* arguments = scope()->arguments(); |
| 646 Variable* shadow = scope()->arguments_shadow(); | |
| 647 ASSERT(arguments != NULL && arguments->AsSlot() != NULL); | 644 ASSERT(arguments != NULL && arguments->AsSlot() != NULL); |
| 648 ASSERT((shadow != NULL && shadow->AsSlot() != NULL) || | |
| 649 scope()->is_strict_mode()); | |
| 650 | 645 |
| 651 JumpTarget done; | 646 JumpTarget done; |
| 652 bool skip_arguments = false; | 647 bool skip_arguments = false; |
| 653 if (mode == LAZY_ARGUMENTS_ALLOCATION && !initial) { | 648 if (mode == LAZY_ARGUMENTS_ALLOCATION && !initial) { |
| 654 // We have to skip storing into the arguments slot if it has | 649 // We have to skip storing into the arguments slot if it has |
| 655 // already been written to. This can happen if the a function | 650 // already been written to. This can happen if the a function |
| 656 // has a local variable named 'arguments'. | 651 // has a local variable named 'arguments'. |
| 657 LoadFromSlot(arguments->AsSlot(), NOT_INSIDE_TYPEOF); | 652 LoadFromSlot(arguments->AsSlot(), NOT_INSIDE_TYPEOF); |
| 658 Result probe = frame_->Pop(); | 653 Result probe = frame_->Pop(); |
| 659 if (probe.is_constant()) { | 654 if (probe.is_constant()) { |
| 660 // We have to skip updating the arguments object if it has | 655 // We have to skip updating the arguments object if it has |
| 661 // been assigned a proper value. | 656 // been assigned a proper value. |
| 662 skip_arguments = !probe.handle()->IsArgumentsMarker(); | 657 skip_arguments = !probe.handle()->IsArgumentsMarker(); |
| 663 } else { | 658 } else { |
| 664 __ CompareRoot(probe.reg(), Heap::kArgumentsMarkerRootIndex); | 659 __ CompareRoot(probe.reg(), Heap::kArgumentsMarkerRootIndex); |
| 665 probe.Unuse(); | 660 probe.Unuse(); |
| 666 done.Branch(not_equal); | 661 done.Branch(not_equal); |
| 667 } | 662 } |
| 668 } | 663 } |
| 669 if (!skip_arguments) { | 664 if (!skip_arguments) { |
| 670 StoreToSlot(arguments->AsSlot(), NOT_CONST_INIT); | 665 StoreToSlot(arguments->AsSlot(), NOT_CONST_INIT); |
| 671 if (mode == LAZY_ARGUMENTS_ALLOCATION) done.Bind(); | 666 if (mode == LAZY_ARGUMENTS_ALLOCATION) done.Bind(); |
| 672 } | 667 } |
| 673 if (shadow != NULL) { | |
| 674 StoreToSlot(shadow->AsSlot(), NOT_CONST_INIT); | |
| 675 } | |
| 676 return frame_->Pop(); | 668 return frame_->Pop(); |
| 677 } | 669 } |
| 678 | 670 |
| 679 //------------------------------------------------------------------------------ | 671 //------------------------------------------------------------------------------ |
| 680 // CodeGenerator implementation of variables, lookups, and stores. | 672 // CodeGenerator implementation of variables, lookups, and stores. |
| 681 | 673 |
| 682 Reference::Reference(CodeGenerator* cgen, | 674 Reference::Reference(CodeGenerator* cgen, |
| 683 Expression* expression, | 675 Expression* expression, |
| 684 bool persist_after_get) | 676 bool persist_after_get) |
| 685 : cgen_(cgen), | 677 : cgen_(cgen), |
| (...skipping 8149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8835 } | 8827 } |
| 8836 | 8828 |
| 8837 #endif | 8829 #endif |
| 8838 | 8830 |
| 8839 | 8831 |
| 8840 #undef __ | 8832 #undef __ |
| 8841 | 8833 |
| 8842 } } // namespace v8::internal | 8834 } } // namespace v8::internal |
| 8843 | 8835 |
| 8844 #endif // V8_TARGET_ARCH_X64 | 8836 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |