OLD | NEW |
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (count > 0) { | 122 if (count > 0) { |
123 Comment cmnt(masm(), "[ Allocate space for locals"); | 123 Comment cmnt(masm(), "[ Allocate space for locals"); |
124 // The locals are initialized to a constant (the undefined value), but | 124 // The locals are initialized to a constant (the undefined value), but |
125 // we sync them with the actual frame to allocate space for spilling | 125 // we sync them with the actual frame to allocate space for spilling |
126 // them later. First sync everything above the stack pointer so we can | 126 // them later. First sync everything above the stack pointer so we can |
127 // use pushes to allocate and initialize the locals. | 127 // use pushes to allocate and initialize the locals. |
128 SyncRange(stack_pointer_ + 1, element_count() - 1); | 128 SyncRange(stack_pointer_ + 1, element_count() - 1); |
129 Handle<Object> undefined = Factory::undefined_value(); | 129 Handle<Object> undefined = Factory::undefined_value(); |
130 FrameElement initial_value = | 130 FrameElement initial_value = |
131 FrameElement::ConstantElement(undefined, FrameElement::SYNCED); | 131 FrameElement::ConstantElement(undefined, FrameElement::SYNCED); |
132 __ movq(kScratchRegister, undefined, RelocInfo::EMBEDDED_OBJECT); | 132 if (count == 1) { |
| 133 __ Push(undefined); |
| 134 } else if (count < kLocalVarBound) { |
| 135 // For less locals the unrolled loop is more compact. |
| 136 __ movq(kScratchRegister, undefined, RelocInfo::EMBEDDED_OBJECT); |
| 137 for (int i = 0; i < count; i++) { |
| 138 __ push(kScratchRegister); |
| 139 } |
| 140 } else { |
| 141 // For more locals a loop in generated code is more compact. |
| 142 Label alloc_locals_loop; |
| 143 Result cnt = cgen()->allocator()->Allocate(); |
| 144 ASSERT(cnt.is_valid()); |
| 145 __ movq(cnt.reg(), Immediate(count)); |
| 146 __ movq(kScratchRegister, undefined, RelocInfo::EMBEDDED_OBJECT); |
| 147 __ bind(&alloc_locals_loop); |
| 148 __ push(kScratchRegister); |
| 149 __ decl(cnt.reg()); |
| 150 __ j(not_zero, &alloc_locals_loop); |
| 151 } |
133 for (int i = 0; i < count; i++) { | 152 for (int i = 0; i < count; i++) { |
134 elements_.Add(initial_value); | 153 elements_.Add(initial_value); |
135 stack_pointer_++; | 154 stack_pointer_++; |
136 __ push(kScratchRegister); | |
137 } | 155 } |
138 } | 156 } |
139 } | 157 } |
140 | 158 |
141 | 159 |
142 void VirtualFrame::SaveContextRegister() { | 160 void VirtualFrame::SaveContextRegister() { |
143 ASSERT(elements_[context_index()].is_memory()); | 161 ASSERT(elements_[context_index()].is_memory()); |
144 __ movq(Operand(rbp, fp_relative(context_index())), rsi); | 162 __ movq(Operand(rbp, fp_relative(context_index())), rsi); |
145 } | 163 } |
146 | 164 |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 // Grow the expression stack by handler size less one (the return | 1080 // Grow the expression stack by handler size less one (the return |
1063 // address is already pushed by a call instruction). | 1081 // address is already pushed by a call instruction). |
1064 Adjust(kHandlerSize - 1); | 1082 Adjust(kHandlerSize - 1); |
1065 __ PushTryHandler(IN_JAVASCRIPT, type); | 1083 __ PushTryHandler(IN_JAVASCRIPT, type); |
1066 } | 1084 } |
1067 | 1085 |
1068 | 1086 |
1069 #undef __ | 1087 #undef __ |
1070 | 1088 |
1071 } } // namespace v8::internal | 1089 } } // namespace v8::internal |
OLD | NEW |