Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: src/x64/codegen-x64.cc

Issue 151075: X64: Make lazy arguments objects work (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/codegen-x64.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 Load(node->else_expression(), typeof_state()); 1807 Load(node->else_expression(), typeof_state());
1808 } 1808 }
1809 } 1809 }
1810 1810
1811 exit.Bind(); 1811 exit.Bind();
1812 } 1812 }
1813 1813
1814 1814
1815 void CodeGenerator::VisitSlot(Slot* node) { 1815 void CodeGenerator::VisitSlot(Slot* node) {
1816 Comment cmnt(masm_, "[ Slot"); 1816 Comment cmnt(masm_, "[ Slot");
1817 LoadFromSlot(node, typeof_state()); 1817 LoadFromSlotCheckForArguments(node, typeof_state());
1818 } 1818 }
1819 1819
1820 1820
1821 void CodeGenerator::VisitVariableProxy(VariableProxy* node) { 1821 void CodeGenerator::VisitVariableProxy(VariableProxy* node) {
1822 Comment cmnt(masm_, "[ VariableProxy"); 1822 Comment cmnt(masm_, "[ VariableProxy");
1823 Variable* var = node->var(); 1823 Variable* var = node->var();
1824 Expression* expr = var->rewrite(); 1824 Expression* expr = var->rewrite();
1825 if (expr != NULL) { 1825 if (expr != NULL) {
1826 Visit(expr); 1826 Visit(expr);
1827 } else { 1827 } else {
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
3836 // because it will always be a context slot. 3836 // because it will always be a context slot.
3837 ASSERT(slot->type() == Slot::CONTEXT); 3837 ASSERT(slot->type() == Slot::CONTEXT);
3838 Result temp = allocator_->Allocate(); 3838 Result temp = allocator_->Allocate();
3839 ASSERT(temp.is_valid()); 3839 ASSERT(temp.is_valid());
3840 __ movq(temp.reg(), SlotOperand(slot, temp.reg())); 3840 __ movq(temp.reg(), SlotOperand(slot, temp.reg()));
3841 frame_->Push(&temp); 3841 frame_->Push(&temp);
3842 } 3842 }
3843 } 3843 }
3844 3844
3845 3845
3846 void CodeGenerator::LoadFromSlotCheckForArguments(Slot* slot,
3847 TypeofState state) {
3848 LoadFromSlot(slot, state);
3849
3850 // Bail out quickly if we're not using lazy arguments allocation.
3851 if (ArgumentsMode() != LAZY_ARGUMENTS_ALLOCATION) return;
3852
3853 // ... or if the slot isn't a non-parameter arguments slot.
3854 if (slot->type() == Slot::PARAMETER || !slot->is_arguments()) return;
3855
3856 // Pop the loaded value from the stack.
3857 Result value = frame_->Pop();
3858
3859 // If the loaded value is a constant, we know if the arguments
3860 // object has been lazily loaded yet.
3861 if (value.is_constant()) {
3862 if (value.handle()->IsTheHole()) {
3863 Result arguments = StoreArgumentsObject(false);
3864 frame_->Push(&arguments);
3865 } else {
3866 frame_->Push(&value);
3867 }
3868 return;
3869 }
3870
3871 // The loaded value is in a register. If it is the sentinel that
3872 // indicates that we haven't loaded the arguments object yet, we
3873 // need to do it now.
3874 JumpTarget exit;
3875 __ Cmp(value.reg(), Factory::the_hole_value());
3876 frame_->Push(&value);
3877 exit.Branch(not_equal);
3878 Result arguments = StoreArgumentsObject(false);
3879 frame_->SetElementAt(0, &arguments);
3880 exit.Bind();
3881 }
3882
3883
3846 void CodeGenerator::StoreToSlot(Slot* slot, InitState init_state) { 3884 void CodeGenerator::StoreToSlot(Slot* slot, InitState init_state) {
3847 // TODO(X64): Enable more types of slot. 3885 // TODO(X64): Enable more types of slot.
3848 3886
3849 if (slot->type() == Slot::LOOKUP) { 3887 if (slot->type() == Slot::LOOKUP) {
3850 ASSERT(slot->var()->is_dynamic()); 3888 ASSERT(slot->var()->is_dynamic());
3851 3889
3852 // For now, just do a runtime call. Since the call is inevitable, 3890 // For now, just do a runtime call. Since the call is inevitable,
3853 // we eagerly sync the virtual frame so we can directly push the 3891 // we eagerly sync the virtual frame so we can directly push the
3854 // arguments into place. 3892 // arguments into place.
3855 frame_->SyncRange(0, frame_->element_count() - 1); 3893 frame_->SyncRange(0, frame_->element_count() - 1);
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
5045 void Reference::GetValue(TypeofState typeof_state) { 5083 void Reference::GetValue(TypeofState typeof_state) {
5046 ASSERT(!cgen_->in_spilled_code()); 5084 ASSERT(!cgen_->in_spilled_code());
5047 ASSERT(cgen_->HasValidEntryRegisters()); 5085 ASSERT(cgen_->HasValidEntryRegisters());
5048 ASSERT(!is_illegal()); 5086 ASSERT(!is_illegal());
5049 MacroAssembler* masm = cgen_->masm(); 5087 MacroAssembler* masm = cgen_->masm();
5050 switch (type_) { 5088 switch (type_) {
5051 case SLOT: { 5089 case SLOT: {
5052 Comment cmnt(masm, "[ Load from Slot"); 5090 Comment cmnt(masm, "[ Load from Slot");
5053 Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot(); 5091 Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
5054 ASSERT(slot != NULL); 5092 ASSERT(slot != NULL);
5055 cgen_->LoadFromSlot(slot, typeof_state); 5093 cgen_->LoadFromSlotCheckForArguments(slot, typeof_state);
5056 break; 5094 break;
5057 } 5095 }
5058 5096
5059 case NAMED: { 5097 case NAMED: {
5060 // TODO(1241834): Make sure that it is safe to ignore the 5098 // TODO(1241834): Make sure that it is safe to ignore the
5061 // distinction between expressions in a typeof and not in a 5099 // distinction between expressions in a typeof and not in a
5062 // typeof. If there is a chance that reference errors can be 5100 // typeof. If there is a chance that reference errors can be
5063 // thrown below, we must distinguish between the two kinds of 5101 // thrown below, we must distinguish between the two kinds of
5064 // loads (typeof expression loads must not throw a reference 5102 // loads (typeof expression loads must not throw a reference
5065 // error). 5103 // error).
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
6700 int CompareStub::MinorKey() { 6738 int CompareStub::MinorKey() {
6701 // Encode the two parameters in a unique 16 bit value. 6739 // Encode the two parameters in a unique 16 bit value.
6702 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 6740 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
6703 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 6741 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
6704 } 6742 }
6705 6743
6706 6744
6707 #undef __ 6745 #undef __
6708 6746
6709 } } // namespace v8::internal 6747 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/codegen-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698