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

Side by Side Diff: src/virtual-frame.cc

Issue 49029: Inline part of RawSyncElementAt, improve PrepareForCall (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 | « no previous file | src/virtual-frame-arm.h » ('j') | 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if (elements_[index].is_copied()) { 205 if (elements_[index].is_copied()) {
206 new_element.set_copied(); 206 new_element.set_copied();
207 } 207 }
208 if (elements_[index].is_register()) { 208 if (elements_[index].is_register()) {
209 Unuse(elements_[index].reg()); 209 Unuse(elements_[index].reg());
210 } 210 }
211 elements_[index] = new_element; 211 elements_[index] = new_element;
212 } 212 }
213 213
214 214
215 // Clear the dirty bits for the range of elements in [begin, end). 215 // Clear the dirty bits for the range of elements in
216 // [min(stack_pointer_ + 1,begin), end).
216 void VirtualFrame::SyncRange(int begin, int end) { 217 void VirtualFrame::SyncRange(int begin, int end) {
217 ASSERT(begin >= 0); 218 ASSERT(begin >= 0);
218 ASSERT(end <= elements_.length()); 219 ASSERT(end <= elements_.length());
219 for (int i = begin; i < end; i++) { 220 if (begin > stack_pointer_) {
220 RawSyncElementAt(i); 221 // Elements between stack_pointer_ + 1 and begin must also be synced.
222 for (int i = stack_pointer_ + 1; i < end; i++) {
223 SyncElementByPushing(i);
224 }
225 } else if (end <= stack_pointer_ + 1) {
226 for (int i = begin; i < end; i++) {
227 if (!elements_[i].is_synced()) {
228 SyncElementBelowStackPointer(i);
229 }
230 }
231 } else {
232 // Split into two ranges that each satisfy a condition above.
233 SyncRange(begin, stack_pointer_ + 1);
234 SyncRange(stack_pointer_ + 1, end);
221 } 235 }
222 } 236 }
223 237
224 238
225 // Clear the dirty bit for the element at a given index. 239 // Clear the dirty bit for the element at a given index.
226 void VirtualFrame::SyncElementAt(int index) { 240 void VirtualFrame::SyncElementAt(int index) {
227 if (index > stack_pointer_ + 1) { 241 if (index <= stack_pointer_) {
228 SyncRange(stack_pointer_ + 1, index); 242 if (!elements_[index].is_synced()) {
243 SyncElementBelowStackPointer(index);
244 }
245 } else {
246 for (int i = stack_pointer_ + 1; i <= index; i++) {
247 SyncElementByPushing(i);
248 }
229 } 249 }
230 RawSyncElementAt(index);
231 } 250 }
232 251
233 252
234 // Make the type of all elements be MEMORY. 253 // Make the type of all elements be MEMORY.
235 void VirtualFrame::SpillAll() { 254 void VirtualFrame::SpillAll() {
236 for (int i = 0; i < elements_.length(); i++) { 255 for (int i = 0; i < elements_.length(); i++) {
237 SpillElementAt(i); 256 SpillElementAt(i);
238 } 257 }
239 } 258 }
240 259
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 298 }
280 } 299 }
281 } 300 }
282 301
283 302
284 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) { 303 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) {
285 ASSERT(height() >= dropped_args); 304 ASSERT(height() >= dropped_args);
286 ASSERT(height() >= spilled_args); 305 ASSERT(height() >= spilled_args);
287 ASSERT(dropped_args <= spilled_args); 306 ASSERT(dropped_args <= spilled_args);
288 307
289 int arg_base_index = elements_.length() - spilled_args; 308 SyncRange(0, elements_.length());
290 // Spill the arguments. We spill from the top down so that the 309 // Spill registers.
291 // backing stores of register copies will be spilled only after all 310 for (int i = 0; i < kNumRegisters; i++) {
292 // the copies are spilled---it is better to spill via a 311 if (is_used(i)) {
293 // register-to-memory move than a memory-to-memory move. 312 SpillElementAt(register_locations_[i]);
294 for (int i = elements_.length() - 1; i >= arg_base_index; i--) {
295 SpillElementAt(i);
296 }
297
298 // Below the arguments, spill registers and sync everything else.
299 // Syncing is necessary for the locals and parameters to give the
300 // debugger a consistent view of the frame.
301 for (int i = arg_base_index - 1; i >= 0; i--) {
302 FrameElement element = elements_[i];
303 if (element.is_register()) {
304 SpillElementAt(i);
305 } else if (element.is_valid()) {
306 SyncElementAt(i);
307 } 313 }
308 } 314 }
309 315
316 // Spill the arguments.
317 for (int i = elements_.length() - spilled_args; i < elements_.length(); i++) {
318 if (!elements_[i].is_memory()) {
319 SpillElementAt(i);
320 }
321 }
322
310 // Forget the frame elements that will be popped by the call. 323 // Forget the frame elements that will be popped by the call.
311 Forget(dropped_args); 324 Forget(dropped_args);
312 } 325 }
313 326
314 327
315 void VirtualFrame::DetachFromCodeGenerator() { 328 void VirtualFrame::DetachFromCodeGenerator() {
316 // Tell the global register allocator that it is free to reallocate all 329 // Tell the global register allocator that it is free to reallocate all
317 // register references contained in this frame. The frame elements remain 330 // register references contained in this frame. The frame elements remain
318 // register references, so the frame-internal reference count is not 331 // register references, so the frame-internal reference count is not
319 // decremented. 332 // decremented.
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 #endif 558 #endif
546 if (stack_pointer_ != other->stack_pointer_) return false; 559 if (stack_pointer_ != other->stack_pointer_) return false;
547 for (int i = 0; i < elements_.length(); i++) { 560 for (int i = 0; i < elements_.length(); i++) {
548 if (!elements_[i].Equals(other->elements_[i])) return false; 561 if (!elements_[i].Equals(other->elements_[i])) return false;
549 } 562 }
550 563
551 return true; 564 return true;
552 } 565 }
553 566
554 } } // namespace v8::internal 567 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/virtual-frame-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698