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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // (memory elements are always synced). | 68 // (memory elements are always synced). |
69 UNREACHABLE(); | 69 UNREACHABLE(); |
70 break; | 70 break; |
71 | 71 |
72 case FrameElement::REGISTER: | 72 case FrameElement::REGISTER: |
73 __ mov(Operand(ebp, fp_relative(index)), element.reg()); | 73 __ mov(Operand(ebp, fp_relative(index)), element.reg()); |
74 break; | 74 break; |
75 | 75 |
76 case FrameElement::CONSTANT: | 76 case FrameElement::CONSTANT: |
77 if (cgen()->IsUnsafeSmi(element.handle())) { | 77 if (cgen()->IsUnsafeSmi(element.handle())) { |
78 Result temp = cgen()->allocator()->Allocate(); | 78 cgen()->StoreUnsafeSmiToLocal(fp_relative(index), element.handle()); |
79 ASSERT(temp.is_valid()); | |
80 cgen()->LoadUnsafeSmi(temp.reg(), element.handle()); | |
81 __ mov(Operand(ebp, fp_relative(index)), temp.reg()); | |
82 } else { | 79 } else { |
83 __ Set(Operand(ebp, fp_relative(index)), | 80 __ Set(Operand(ebp, fp_relative(index)), |
84 Immediate(element.handle())); | 81 Immediate(element.handle())); |
85 } | 82 } |
86 break; | 83 break; |
87 | 84 |
88 case FrameElement::COPY: { | 85 case FrameElement::COPY: { |
89 int backing_index = element.index(); | 86 int backing_index = element.index(); |
90 FrameElement backing_element = elements_[backing_index]; | 87 FrameElement backing_element = elements_[backing_index]; |
91 if (backing_element.is_memory()) { | 88 if (backing_element.is_memory()) { |
(...skipping 28 matching lines...) Expand all Loading... |
120 // No memory elements exist above the stack pointer. | 117 // No memory elements exist above the stack pointer. |
121 UNREACHABLE(); | 118 UNREACHABLE(); |
122 break; | 119 break; |
123 | 120 |
124 case FrameElement::REGISTER: | 121 case FrameElement::REGISTER: |
125 __ push(element.reg()); | 122 __ push(element.reg()); |
126 break; | 123 break; |
127 | 124 |
128 case FrameElement::CONSTANT: | 125 case FrameElement::CONSTANT: |
129 if (cgen()->IsUnsafeSmi(element.handle())) { | 126 if (cgen()->IsUnsafeSmi(element.handle())) { |
130 Result temp = cgen()->allocator()->Allocate(); | 127 cgen()->PushUnsafeSmi(element.handle()); |
131 ASSERT(temp.is_valid()); | |
132 cgen()->LoadUnsafeSmi(temp.reg(), element.handle()); | |
133 __ push(temp.reg()); | |
134 } else { | 128 } else { |
135 __ push(Immediate(element.handle())); | 129 __ push(Immediate(element.handle())); |
136 } | 130 } |
137 break; | 131 break; |
138 | 132 |
139 case FrameElement::COPY: { | 133 case FrameElement::COPY: { |
140 int backing_index = element.index(); | 134 int backing_index = element.index(); |
141 FrameElement backing = elements_[backing_index]; | 135 FrameElement backing = elements_[backing_index]; |
142 ASSERT(backing.is_memory() || backing.is_register()); | 136 ASSERT(backing.is_memory() || backing.is_register()); |
143 if (backing.is_memory()) { | 137 if (backing.is_memory()) { |
(...skipping 10 matching lines...) Expand all Loading... |
154 | 148 |
155 // Clear the dirty bits for the range of elements in | 149 // Clear the dirty bits for the range of elements in |
156 // [min(stack_pointer_ + 1,begin), end]. | 150 // [min(stack_pointer_ + 1,begin), end]. |
157 void VirtualFrame::SyncRange(int begin, int end) { | 151 void VirtualFrame::SyncRange(int begin, int end) { |
158 ASSERT(begin >= 0); | 152 ASSERT(begin >= 0); |
159 ASSERT(end < element_count()); | 153 ASSERT(end < element_count()); |
160 // Sync elements below the range if they have not been materialized | 154 // Sync elements below the range if they have not been materialized |
161 // on the stack. | 155 // on the stack. |
162 int start = Min(begin, stack_pointer_ + 1); | 156 int start = Min(begin, stack_pointer_ + 1); |
163 | 157 |
164 // If positive we have to adjust the stack pointer. | 158 // Emit normal push instructions for elements above stack pointer |
165 int delta = end - stack_pointer_; | 159 // and use mov instructions if we are below stack pointer. |
166 if (delta > 0) { | |
167 stack_pointer_ = end; | |
168 __ sub(Operand(esp), Immediate(delta * kPointerSize)); | |
169 } | |
170 | |
171 for (int i = start; i <= end; i++) { | 160 for (int i = start; i <= end; i++) { |
172 if (!elements_[i].is_synced()) SyncElementBelowStackPointer(i); | 161 if (!elements_[i].is_synced()) { |
| 162 if (i <= stack_pointer_) { |
| 163 SyncElementBelowStackPointer(i); |
| 164 } else { |
| 165 SyncElementByPushing(i); |
| 166 } |
| 167 } |
173 } | 168 } |
174 } | 169 } |
175 | 170 |
176 | 171 |
177 void VirtualFrame::MakeMergable() { | 172 void VirtualFrame::MakeMergable() { |
178 for (int i = 0; i < element_count(); i++) { | 173 for (int i = 0; i < element_count(); i++) { |
179 FrameElement element = elements_[i]; | 174 FrameElement element = elements_[i]; |
180 | 175 |
181 if (element.is_constant() || element.is_copy()) { | 176 if (element.is_constant() || element.is_copy()) { |
182 if (element.is_synced()) { | 177 if (element.is_synced()) { |
183 // Just spill. | 178 // Just spill. |
184 elements_[i] = FrameElement::MemoryElement(); | 179 elements_[i] = FrameElement::MemoryElement(); |
185 } else { | 180 } else { |
186 // Allocate to a register. | 181 // Allocate to a register. |
187 FrameElement backing_element; // Invalid if not a copy. | 182 FrameElement backing_element; // Invalid if not a copy. |
188 if (element.is_copy()) { | 183 if (element.is_copy()) { |
189 backing_element = elements_[element.index()]; | 184 backing_element = elements_[element.index()]; |
190 } | 185 } |
191 Result fresh = cgen()->allocator()->Allocate(); | 186 Result fresh = cgen()->allocator()->Allocate(); |
192 ASSERT(fresh.is_valid()); // A register was spilled if all were in use. | 187 ASSERT(fresh.is_valid()); // A register was spilled if all were in use. |
193 elements_[i] = | 188 elements_[i] = |
194 FrameElement::RegisterElement(fresh.reg(), | 189 FrameElement::RegisterElement(fresh.reg(), |
195 FrameElement::NOT_SYNCED); | 190 FrameElement::NOT_SYNCED); |
196 Use(fresh.reg(), i); | 191 Use(fresh.reg(), i); |
197 | 192 |
198 // Emit a move. | 193 // Emit a move. |
199 if (element.is_constant()) { | 194 if (element.is_constant()) { |
200 if (cgen()->IsUnsafeSmi(element.handle())) { | 195 if (cgen()->IsUnsafeSmi(element.handle())) { |
201 cgen()->LoadUnsafeSmi(fresh.reg(), element.handle()); | 196 cgen()->MoveUnsafeSmi(fresh.reg(), element.handle()); |
202 } else { | 197 } else { |
203 __ Set(fresh.reg(), Immediate(element.handle())); | 198 __ Set(fresh.reg(), Immediate(element.handle())); |
204 } | 199 } |
205 } else { | 200 } else { |
206 ASSERT(element.is_copy()); | 201 ASSERT(element.is_copy()); |
207 // Copies are only backed by register or memory locations. | 202 // Copies are only backed by register or memory locations. |
208 if (backing_element.is_register()) { | 203 if (backing_element.is_register()) { |
209 // The backing store may have been spilled by allocating, | 204 // The backing store may have been spilled by allocating, |
210 // but that's OK. If it was, the value is right where we | 205 // but that's OK. If it was, the value is right where we |
211 // want it. | 206 // want it. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 Unuse(source.reg()); | 287 Unuse(source.reg()); |
293 if (!source.is_synced()) { | 288 if (!source.is_synced()) { |
294 __ mov(Operand(ebp, fp_relative(i)), source.reg()); | 289 __ mov(Operand(ebp, fp_relative(i)), source.reg()); |
295 } | 290 } |
296 break; | 291 break; |
297 | 292 |
298 case FrameElement::CONSTANT: | 293 case FrameElement::CONSTANT: |
299 if (!source.is_synced()) { | 294 if (!source.is_synced()) { |
300 if (cgen()->IsUnsafeSmi(source.handle())) { | 295 if (cgen()->IsUnsafeSmi(source.handle())) { |
301 esi_caches = i; | 296 esi_caches = i; |
302 cgen()->LoadUnsafeSmi(esi, source.handle()); | 297 cgen()->MoveUnsafeSmi(esi, source.handle()); |
303 __ mov(Operand(ebp, fp_relative(i)), esi); | 298 __ mov(Operand(ebp, fp_relative(i)), esi); |
304 } else { | 299 } else { |
305 __ Set(Operand(ebp, fp_relative(i)), Immediate(source.handle())); | 300 __ Set(Operand(ebp, fp_relative(i)), Immediate(source.handle())); |
306 } | 301 } |
307 } | 302 } |
308 break; | 303 break; |
309 | 304 |
310 case FrameElement::COPY: | 305 case FrameElement::COPY: |
311 if (!source.is_synced()) { | 306 if (!source.is_synced()) { |
312 int backing_index = source.index(); | 307 int backing_index = source.index(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 // elements were. | 395 // elements were. |
401 continue; | 396 continue; |
402 break; | 397 break; |
403 case FrameElement::MEMORY: | 398 case FrameElement::MEMORY: |
404 ASSERT(index <= stack_pointer_); | 399 ASSERT(index <= stack_pointer_); |
405 __ mov(target_reg, Operand(ebp, fp_relative(index))); | 400 __ mov(target_reg, Operand(ebp, fp_relative(index))); |
406 break; | 401 break; |
407 | 402 |
408 case FrameElement::CONSTANT: | 403 case FrameElement::CONSTANT: |
409 if (cgen()->IsUnsafeSmi(source.handle())) { | 404 if (cgen()->IsUnsafeSmi(source.handle())) { |
410 cgen()->LoadUnsafeSmi(target_reg, source.handle()); | 405 cgen()->MoveUnsafeSmi(target_reg, source.handle()); |
411 } else { | 406 } else { |
412 __ Set(target_reg, Immediate(source.handle())); | 407 __ Set(target_reg, Immediate(source.handle())); |
413 } | 408 } |
414 break; | 409 break; |
415 | 410 |
416 case FrameElement::COPY: { | 411 case FrameElement::COPY: { |
417 int backing_index = source.index(); | 412 int backing_index = source.index(); |
418 FrameElement backing = elements_[backing_index]; | 413 FrameElement backing = elements_[backing_index]; |
419 ASSERT(backing.is_memory() || backing.is_register()); | 414 ASSERT(backing.is_memory() || backing.is_register()); |
420 if (backing.is_memory()) { | 415 if (backing.is_memory()) { |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 ASSERT(stack_pointer_ == element_count() - 1); | 1073 ASSERT(stack_pointer_ == element_count() - 1); |
1079 elements_.Add(FrameElement::MemoryElement()); | 1074 elements_.Add(FrameElement::MemoryElement()); |
1080 stack_pointer_++; | 1075 stack_pointer_++; |
1081 __ push(immediate); | 1076 __ push(immediate); |
1082 } | 1077 } |
1083 | 1078 |
1084 | 1079 |
1085 #undef __ | 1080 #undef __ |
1086 | 1081 |
1087 } } // namespace v8::internal | 1082 } } // namespace v8::internal |
OLD | NEW |