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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 if (element.is_synced()) { | 182 if (element.is_synced()) { |
183 // Just spill. | 183 // Just spill. |
184 elements_[i] = FrameElement::MemoryElement(); | 184 elements_[i] = FrameElement::MemoryElement(); |
185 } else { | 185 } else { |
186 // Allocate to a register. | 186 // Allocate to a register. |
187 FrameElement backing_element; // Invalid if not a copy. | 187 FrameElement backing_element; // Invalid if not a copy. |
188 if (element.is_copy()) { | 188 if (element.is_copy()) { |
189 backing_element = elements_[element.index()]; | 189 backing_element = elements_[element.index()]; |
190 } | 190 } |
191 Result fresh = cgen()->allocator()->Allocate(); | 191 Result fresh = cgen()->allocator()->Allocate(); |
192 ASSERT(fresh.is_valid()); | 192 ASSERT(fresh.is_valid()); // A register was spilled if all were in use. |
193 elements_[i] = | 193 elements_[i] = |
194 FrameElement::RegisterElement(fresh.reg(), | 194 FrameElement::RegisterElement(fresh.reg(), |
195 FrameElement::NOT_SYNCED); | 195 FrameElement::NOT_SYNCED); |
196 Use(fresh.reg(), i); | 196 Use(fresh.reg(), i); |
197 | 197 |
198 // Emit a move. | 198 // Emit a move. |
199 if (element.is_constant()) { | 199 if (element.is_constant()) { |
200 if (cgen()->IsUnsafeSmi(element.handle())) { | 200 if (cgen()->IsUnsafeSmi(element.handle())) { |
201 cgen()->LoadUnsafeSmi(fresh.reg(), element.handle()); | 201 cgen()->LoadUnsafeSmi(fresh.reg(), element.handle()); |
202 } else { | 202 } else { |
203 __ Set(fresh.reg(), Immediate(element.handle())); | 203 __ Set(fresh.reg(), Immediate(element.handle())); |
204 } | 204 } |
205 } else { | 205 } else { |
206 ASSERT(element.is_copy()); | 206 ASSERT(element.is_copy()); |
207 // Copies are only backed by register or memory locations. | 207 // Copies are only backed by register or memory locations. |
208 if (backing_element.is_register()) { | 208 if (backing_element.is_register()) { |
209 // The backing store may have been spilled by allocating, | 209 // The backing store may have been spilled by allocating, |
210 // but that's OK. If it was, the value is right where we | 210 // but that's OK. If it was, the value is right where we |
211 // want it. | 211 // want it. |
212 if (!fresh.reg().is(backing_element.reg())) { | 212 if (!fresh.reg().is(backing_element.reg())) { |
213 __ mov(fresh.reg(), backing_element.reg()); | 213 __ mov(fresh.reg(), backing_element.reg()); |
214 } | 214 } |
215 } else { | 215 } else { |
216 ASSERT(backing_element.is_memory()); | 216 ASSERT(backing_element.is_memory()); |
217 __ mov(fresh.reg(), Operand(ebp, fp_relative(element.index()))); | 217 __ mov(fresh.reg(), Operand(ebp, fp_relative(element.index()))); |
218 } | 218 } |
219 } | 219 } |
220 } | 220 } |
221 // No need to set the copied flag---there are no copies of | 221 // No need to set the copied flag---there are no copies. |
222 // copies or constants so the original was not copied. | |
223 elements_[i].set_static_type(element.static_type()); | 222 elements_[i].set_static_type(element.static_type()); |
224 } else { | 223 } else { |
225 // Clear the copy flag of non-constant, non-copy elements above | 224 // Clear the copy flag of non-constant, non-copy elements. |
226 // the high water mark. They cannot be copied because copes are | 225 // They cannot be copied because copies are not allowed. |
227 // always higher than their backing store and copies are not | 226 // The copy flag is not relied on before the end of this loop, |
228 // allowed above the water mark. | 227 // including when registers are spilled. |
229 elements_[i].clear_copied(); | 228 elements_[i].clear_copied(); |
230 } | 229 } |
231 } | 230 } |
232 } | 231 } |
233 | 232 |
234 | 233 |
235 void VirtualFrame::MergeTo(VirtualFrame* expected) { | 234 void VirtualFrame::MergeTo(VirtualFrame* expected) { |
236 Comment cmnt(masm(), "[ Merge frame"); | 235 Comment cmnt(masm(), "[ Merge frame"); |
237 // We should always be merging the code generator's current frame to an | 236 // We should always be merging the code generator's current frame to an |
238 // expected frame. | 237 // expected frame. |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 ASSERT(stack_pointer_ == element_count() - 1); | 1078 ASSERT(stack_pointer_ == element_count() - 1); |
1080 elements_.Add(FrameElement::MemoryElement()); | 1079 elements_.Add(FrameElement::MemoryElement()); |
1081 stack_pointer_++; | 1080 stack_pointer_++; |
1082 __ push(immediate); | 1081 __ push(immediate); |
1083 } | 1082 } |
1084 | 1083 |
1085 | 1084 |
1086 #undef __ | 1085 #undef __ |
1087 | 1086 |
1088 } } // namespace v8::internal | 1087 } } // namespace v8::internal |
OLD | NEW |