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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 : LAZY_ARGUMENTS_ALLOCATION; | 738 : LAZY_ARGUMENTS_ALLOCATION; |
739 } | 739 } |
740 | 740 |
741 | 741 |
742 Result CodeGenerator::StoreArgumentsObject(bool initial) { | 742 Result CodeGenerator::StoreArgumentsObject(bool initial) { |
743 ArgumentsAllocationMode mode = ArgumentsMode(); | 743 ArgumentsAllocationMode mode = ArgumentsMode(); |
744 ASSERT(mode != NO_ARGUMENTS_ALLOCATION); | 744 ASSERT(mode != NO_ARGUMENTS_ALLOCATION); |
745 | 745 |
746 Comment cmnt(masm_, "[ store arguments object"); | 746 Comment cmnt(masm_, "[ store arguments object"); |
747 if (mode == LAZY_ARGUMENTS_ALLOCATION && initial) { | 747 if (mode == LAZY_ARGUMENTS_ALLOCATION && initial) { |
748 // When using lazy arguments allocation, we store the hole value | 748 // When using lazy arguments allocation, we store the arguments marker value |
749 // as a sentinel indicating that the arguments object hasn't been | 749 // as a sentinel indicating that the arguments object hasn't been |
750 // allocated yet. | 750 // allocated yet. |
751 frame_->Push(Factory::the_hole_value()); | 751 frame_->Push(Factory::arguments_marker()); |
752 } else { | 752 } else { |
753 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT); | 753 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT); |
754 frame_->PushFunction(); | 754 frame_->PushFunction(); |
755 frame_->PushReceiverSlotAddress(); | 755 frame_->PushReceiverSlotAddress(); |
756 frame_->Push(Smi::FromInt(scope()->num_parameters())); | 756 frame_->Push(Smi::FromInt(scope()->num_parameters())); |
757 Result result = frame_->CallStub(&stub, 3); | 757 Result result = frame_->CallStub(&stub, 3); |
758 frame_->Push(&result); | 758 frame_->Push(&result); |
759 } | 759 } |
760 | 760 |
761 Variable* arguments = scope()->arguments(); | 761 Variable* arguments = scope()->arguments(); |
762 Variable* shadow = scope()->arguments_shadow(); | 762 Variable* shadow = scope()->arguments_shadow(); |
763 ASSERT(arguments != NULL && arguments->AsSlot() != NULL); | 763 ASSERT(arguments != NULL && arguments->AsSlot() != NULL); |
764 ASSERT(shadow != NULL && shadow->AsSlot() != NULL); | 764 ASSERT(shadow != NULL && shadow->AsSlot() != NULL); |
765 JumpTarget done; | 765 JumpTarget done; |
766 bool skip_arguments = false; | 766 bool skip_arguments = false; |
767 if (mode == LAZY_ARGUMENTS_ALLOCATION && !initial) { | 767 if (mode == LAZY_ARGUMENTS_ALLOCATION && !initial) { |
768 // We have to skip storing into the arguments slot if it has | 768 // We have to skip storing into the arguments slot if it has |
769 // already been written to. This can happen if the a function | 769 // already been written to. This can happen if the a function |
770 // has a local variable named 'arguments'. | 770 // has a local variable named 'arguments'. |
771 LoadFromSlot(arguments->AsSlot(), NOT_INSIDE_TYPEOF); | 771 LoadFromSlot(arguments->AsSlot(), NOT_INSIDE_TYPEOF); |
772 Result probe = frame_->Pop(); | 772 Result probe = frame_->Pop(); |
773 if (probe.is_constant()) { | 773 if (probe.is_constant()) { |
774 // We have to skip updating the arguments object if it has | 774 // We have to skip updating the arguments object if it has |
775 // been assigned a proper value. | 775 // been assigned a proper value. |
776 skip_arguments = !probe.handle()->IsTheHole(); | 776 skip_arguments = !probe.handle()->IsArgumentsMarker(); |
777 } else { | 777 } else { |
778 __ cmp(Operand(probe.reg()), Immediate(Factory::the_hole_value())); | 778 __ cmp(Operand(probe.reg()), Immediate(Factory::arguments_marker())); |
779 probe.Unuse(); | 779 probe.Unuse(); |
780 done.Branch(not_equal); | 780 done.Branch(not_equal); |
781 } | 781 } |
782 } | 782 } |
783 if (!skip_arguments) { | 783 if (!skip_arguments) { |
784 StoreToSlot(arguments->AsSlot(), NOT_CONST_INIT); | 784 StoreToSlot(arguments->AsSlot(), NOT_CONST_INIT); |
785 if (mode == LAZY_ARGUMENTS_ALLOCATION) done.Bind(); | 785 if (mode == LAZY_ARGUMENTS_ALLOCATION) done.Bind(); |
786 } | 786 } |
787 StoreToSlot(shadow->AsSlot(), NOT_CONST_INIT); | 787 StoreToSlot(shadow->AsSlot(), NOT_CONST_INIT); |
788 return frame_->Pop(); | 788 return frame_->Pop(); |
(...skipping 2498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3287 // Check if the arguments object has been lazily allocated | 3287 // Check if the arguments object has been lazily allocated |
3288 // already. If so, just use that instead of copying the arguments | 3288 // already. If so, just use that instead of copying the arguments |
3289 // from the stack. This also deals with cases where a local variable | 3289 // from the stack. This also deals with cases where a local variable |
3290 // named 'arguments' has been introduced. | 3290 // named 'arguments' has been introduced. |
3291 frame_->Dup(); | 3291 frame_->Dup(); |
3292 Result probe = frame_->Pop(); | 3292 Result probe = frame_->Pop(); |
3293 { VirtualFrame::SpilledScope spilled_scope; | 3293 { VirtualFrame::SpilledScope spilled_scope; |
3294 Label slow, done; | 3294 Label slow, done; |
3295 bool try_lazy = true; | 3295 bool try_lazy = true; |
3296 if (probe.is_constant()) { | 3296 if (probe.is_constant()) { |
3297 try_lazy = probe.handle()->IsTheHole(); | 3297 try_lazy = probe.handle()->IsArgumentsMarker(); |
3298 } else { | 3298 } else { |
3299 __ cmp(Operand(probe.reg()), Immediate(Factory::the_hole_value())); | 3299 __ cmp(Operand(probe.reg()), Immediate(Factory::arguments_marker())); |
3300 probe.Unuse(); | 3300 probe.Unuse(); |
3301 __ j(not_equal, &slow); | 3301 __ j(not_equal, &slow); |
3302 } | 3302 } |
3303 | 3303 |
3304 if (try_lazy) { | 3304 if (try_lazy) { |
3305 Label build_args; | 3305 Label build_args; |
3306 // Get rid of the arguments object probe. | 3306 // Get rid of the arguments object probe. |
3307 frame_->Drop(); // Can be called on a spilled frame. | 3307 frame_->Drop(); // Can be called on a spilled frame. |
3308 // Stack now has 3 elements on it. | 3308 // Stack now has 3 elements on it. |
3309 // Contents of stack at this point: | 3309 // Contents of stack at this point: |
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5061 // Bail out quickly if we're not using lazy arguments allocation. | 5061 // Bail out quickly if we're not using lazy arguments allocation. |
5062 if (ArgumentsMode() != LAZY_ARGUMENTS_ALLOCATION) return; | 5062 if (ArgumentsMode() != LAZY_ARGUMENTS_ALLOCATION) return; |
5063 | 5063 |
5064 // ... or if the slot isn't a non-parameter arguments slot. | 5064 // ... or if the slot isn't a non-parameter arguments slot. |
5065 if (slot->type() == Slot::PARAMETER || !slot->is_arguments()) return; | 5065 if (slot->type() == Slot::PARAMETER || !slot->is_arguments()) return; |
5066 | 5066 |
5067 // If the loaded value is a constant, we know if the arguments | 5067 // If the loaded value is a constant, we know if the arguments |
5068 // object has been lazily loaded yet. | 5068 // object has been lazily loaded yet. |
5069 Result result = frame()->Pop(); | 5069 Result result = frame()->Pop(); |
5070 if (result.is_constant()) { | 5070 if (result.is_constant()) { |
5071 if (result.handle()->IsTheHole()) { | 5071 if (result.handle()->IsArgumentsMarker()) { |
5072 result = StoreArgumentsObject(false); | 5072 result = StoreArgumentsObject(false); |
5073 } | 5073 } |
5074 frame()->Push(&result); | 5074 frame()->Push(&result); |
5075 return; | 5075 return; |
5076 } | 5076 } |
5077 ASSERT(result.is_register()); | 5077 ASSERT(result.is_register()); |
5078 // The loaded value is in a register. If it is the sentinel that | 5078 // The loaded value is in a register. If it is the sentinel that |
5079 // indicates that we haven't loaded the arguments object yet, we | 5079 // indicates that we haven't loaded the arguments object yet, we |
5080 // need to do it now. | 5080 // need to do it now. |
5081 JumpTarget exit; | 5081 JumpTarget exit; |
5082 __ cmp(Operand(result.reg()), Immediate(Factory::the_hole_value())); | 5082 __ cmp(Operand(result.reg()), Immediate(Factory::arguments_marker())); |
5083 frame()->Push(&result); | 5083 frame()->Push(&result); |
5084 exit.Branch(not_equal); | 5084 exit.Branch(not_equal); |
5085 | 5085 |
5086 result = StoreArgumentsObject(false); | 5086 result = StoreArgumentsObject(false); |
5087 frame()->SetElementAt(0, &result); | 5087 frame()->SetElementAt(0, &result); |
5088 result.Unuse(); | 5088 result.Unuse(); |
5089 exit.Bind(); | 5089 exit.Bind(); |
5090 return; | 5090 return; |
5091 } | 5091 } |
5092 | 5092 |
(...skipping 5134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10227 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size); | 10227 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size); |
10228 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size); | 10228 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size); |
10229 return FUNCTION_CAST<MemCopyFunction>(chunk->GetStartAddress()); | 10229 return FUNCTION_CAST<MemCopyFunction>(chunk->GetStartAddress()); |
10230 } | 10230 } |
10231 | 10231 |
10232 #undef __ | 10232 #undef __ |
10233 | 10233 |
10234 } } // namespace v8::internal | 10234 } } // namespace v8::internal |
10235 | 10235 |
10236 #endif // V8_TARGET_ARCH_IA32 | 10236 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |