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