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