| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 LoadFromSlotCheckForArguments(variable->AsSlot(), INSIDE_TYPEOF); | 723 LoadFromSlotCheckForArguments(variable->AsSlot(), INSIDE_TYPEOF); |
| 724 } else { | 724 } else { |
| 725 // Anything else can be handled normally. | 725 // Anything else can be handled normally. |
| 726 Load(expr); | 726 Load(expr); |
| 727 } | 727 } |
| 728 } | 728 } |
| 729 | 729 |
| 730 | 730 |
| 731 ArgumentsAllocationMode CodeGenerator::ArgumentsMode() { | 731 ArgumentsAllocationMode CodeGenerator::ArgumentsMode() { |
| 732 if (scope()->arguments() == NULL) return NO_ARGUMENTS_ALLOCATION; | 732 if (scope()->arguments() == NULL) return NO_ARGUMENTS_ALLOCATION; |
| 733 ASSERT(scope()->arguments_shadow() != NULL); | 733 |
| 734 // In strict mode there is no need for shadow arguments. |
| 735 ASSERT(scope()->arguments_shadow() != NULL || scope()->is_strict_mode()); |
| 736 |
| 734 // We don't want to do lazy arguments allocation for functions that | 737 // We don't want to do lazy arguments allocation for functions that |
| 735 // have heap-allocated contexts, because it interfers with the | 738 // have heap-allocated contexts, because it interfers with the |
| 736 // uninitialized const tracking in the context objects. | 739 // uninitialized const tracking in the context objects. |
| 737 return (scope()->num_heap_slots() > 0) | 740 return (scope()->num_heap_slots() > 0 || scope()->is_strict_mode()) |
| 738 ? EAGER_ARGUMENTS_ALLOCATION | 741 ? EAGER_ARGUMENTS_ALLOCATION |
| 739 : LAZY_ARGUMENTS_ALLOCATION; | 742 : LAZY_ARGUMENTS_ALLOCATION; |
| 740 } | 743 } |
| 741 | 744 |
| 742 | 745 |
| 743 Result CodeGenerator::StoreArgumentsObject(bool initial) { | 746 Result CodeGenerator::StoreArgumentsObject(bool initial) { |
| 744 ArgumentsAllocationMode mode = ArgumentsMode(); | 747 ArgumentsAllocationMode mode = ArgumentsMode(); |
| 745 ASSERT(mode != NO_ARGUMENTS_ALLOCATION); | 748 ASSERT(mode != NO_ARGUMENTS_ALLOCATION); |
| 746 | 749 |
| 747 Comment cmnt(masm_, "[ store arguments object"); | 750 Comment cmnt(masm_, "[ store arguments object"); |
| 748 if (mode == LAZY_ARGUMENTS_ALLOCATION && initial) { | 751 if (mode == LAZY_ARGUMENTS_ALLOCATION && initial) { |
| 749 // When using lazy arguments allocation, we store the arguments marker value | 752 // When using lazy arguments allocation, we store the arguments marker value |
| 750 // as a sentinel indicating that the arguments object hasn't been | 753 // as a sentinel indicating that the arguments object hasn't been |
| 751 // allocated yet. | 754 // allocated yet. |
| 752 frame_->Push(FACTORY->arguments_marker()); | 755 frame_->Push(FACTORY->arguments_marker()); |
| 753 } else { | 756 } else { |
| 754 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT); | 757 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT); |
| 755 frame_->PushFunction(); | 758 frame_->PushFunction(); |
| 756 frame_->PushReceiverSlotAddress(); | 759 frame_->PushReceiverSlotAddress(); |
| 757 frame_->Push(Smi::FromInt(scope()->num_parameters())); | 760 frame_->Push(Smi::FromInt(scope()->num_parameters())); |
| 758 Result result = frame_->CallStub(&stub, 3); | 761 Result result = frame_->CallStub(&stub, 3); |
| 759 frame_->Push(&result); | 762 frame_->Push(&result); |
| 760 } | 763 } |
| 761 | 764 |
| 762 Variable* arguments = scope()->arguments(); | 765 Variable* arguments = scope()->arguments(); |
| 763 Variable* shadow = scope()->arguments_shadow(); | 766 Variable* shadow = scope()->arguments_shadow(); |
| 767 |
| 764 ASSERT(arguments != NULL && arguments->AsSlot() != NULL); | 768 ASSERT(arguments != NULL && arguments->AsSlot() != NULL); |
| 765 ASSERT(shadow != NULL && shadow->AsSlot() != NULL); | 769 ASSERT((shadow != NULL && shadow->AsSlot() != NULL) || |
| 770 scope()->is_strict_mode()); |
| 771 |
| 766 JumpTarget done; | 772 JumpTarget done; |
| 767 bool skip_arguments = false; | 773 bool skip_arguments = false; |
| 768 if (mode == LAZY_ARGUMENTS_ALLOCATION && !initial) { | 774 if (mode == LAZY_ARGUMENTS_ALLOCATION && !initial) { |
| 769 // We have to skip storing into the arguments slot if it has | 775 // We have to skip storing into the arguments slot if it has |
| 770 // already been written to. This can happen if the a function | 776 // already been written to. This can happen if the a function |
| 771 // has a local variable named 'arguments'. | 777 // has a local variable named 'arguments'. |
| 772 LoadFromSlot(arguments->AsSlot(), NOT_INSIDE_TYPEOF); | 778 LoadFromSlot(arguments->AsSlot(), NOT_INSIDE_TYPEOF); |
| 773 Result probe = frame_->Pop(); | 779 Result probe = frame_->Pop(); |
| 774 if (probe.is_constant()) { | 780 if (probe.is_constant()) { |
| 775 // We have to skip updating the arguments object if it has | 781 // We have to skip updating the arguments object if it has |
| 776 // been assigned a proper value. | 782 // been assigned a proper value. |
| 777 skip_arguments = !probe.handle()->IsArgumentsMarker(); | 783 skip_arguments = !probe.handle()->IsArgumentsMarker(); |
| 778 } else { | 784 } else { |
| 779 __ cmp(Operand(probe.reg()), Immediate(FACTORY->arguments_marker())); | 785 __ cmp(Operand(probe.reg()), Immediate(FACTORY->arguments_marker())); |
| 780 probe.Unuse(); | 786 probe.Unuse(); |
| 781 done.Branch(not_equal); | 787 done.Branch(not_equal); |
| 782 } | 788 } |
| 783 } | 789 } |
| 784 if (!skip_arguments) { | 790 if (!skip_arguments) { |
| 785 StoreToSlot(arguments->AsSlot(), NOT_CONST_INIT); | 791 StoreToSlot(arguments->AsSlot(), NOT_CONST_INIT); |
| 786 if (mode == LAZY_ARGUMENTS_ALLOCATION) done.Bind(); | 792 if (mode == LAZY_ARGUMENTS_ALLOCATION) done.Bind(); |
| 787 } | 793 } |
| 788 StoreToSlot(shadow->AsSlot(), NOT_CONST_INIT); | 794 if (shadow != NULL) { |
| 795 StoreToSlot(shadow->AsSlot(), NOT_CONST_INIT); |
| 796 } |
| 789 return frame_->Pop(); | 797 return frame_->Pop(); |
| 790 } | 798 } |
| 791 | 799 |
| 792 //------------------------------------------------------------------------------ | 800 //------------------------------------------------------------------------------ |
| 793 // CodeGenerator implementation of variables, lookups, and stores. | 801 // CodeGenerator implementation of variables, lookups, and stores. |
| 794 | 802 |
| 795 Reference::Reference(CodeGenerator* cgen, | 803 Reference::Reference(CodeGenerator* cgen, |
| 796 Expression* expression, | 804 Expression* expression, |
| 797 bool persist_after_get) | 805 bool persist_after_get) |
| 798 : cgen_(cgen), | 806 : cgen_(cgen), |
| (...skipping 9555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10354 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size); | 10362 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size); |
| 10355 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size); | 10363 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size); |
| 10356 return FUNCTION_CAST<MemCopyFunction>(chunk->GetStartAddress()); | 10364 return FUNCTION_CAST<MemCopyFunction>(chunk->GetStartAddress()); |
| 10357 } | 10365 } |
| 10358 | 10366 |
| 10359 #undef __ | 10367 #undef __ |
| 10360 | 10368 |
| 10361 } } // namespace v8::internal | 10369 } } // namespace v8::internal |
| 10362 | 10370 |
| 10363 #endif // V8_TARGET_ARCH_IA32 | 10371 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |