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

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

Issue 53005: Add pointers to a VirtualFrame that keep track of the indexes of register... (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 | « src/jump-target.cc ('k') | 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 elements_(original->elements_.length()), 56 elements_(original->elements_.length()),
57 parameter_count_(original->parameter_count_), 57 parameter_count_(original->parameter_count_),
58 local_count_(original->local_count_), 58 local_count_(original->local_count_),
59 stack_pointer_(original->stack_pointer_), 59 stack_pointer_(original->stack_pointer_),
60 frame_pointer_(original->frame_pointer_), 60 frame_pointer_(original->frame_pointer_),
61 frame_registers_(original->frame_registers_) { 61 frame_registers_(original->frame_registers_) {
62 // Copy all the elements from the original. 62 // Copy all the elements from the original.
63 for (int i = 0; i < original->elements_.length(); i++) { 63 for (int i = 0; i < original->elements_.length(); i++) {
64 elements_.Add(original->elements_[i]); 64 elements_.Add(original->elements_[i]);
65 } 65 }
66 for (int i = 0; i < kNumRegisters; i++) {
67 register_locations_[i] = original->register_locations_[i];
68 }
66 } 69 }
67 70
68 71
69 FrameElement VirtualFrame::CopyElementAt(int index) { 72 FrameElement VirtualFrame::CopyElementAt(int index) {
70 ASSERT(index >= 0); 73 ASSERT(index >= 0);
71 ASSERT(index < elements_.length()); 74 ASSERT(index < elements_.length());
72 75
73 FrameElement target = elements_[index]; 76 FrameElement target = elements_[index];
74 FrameElement result; 77 FrameElement result;
75 78
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 for (int i = 0; i < count; i++) { 146 for (int i = 0; i < count; i++) {
144 FrameElement last = elements_.RemoveLast(); 147 FrameElement last = elements_.RemoveLast();
145 if (last.is_register()) { 148 if (last.is_register()) {
146 // A hack to properly count register references for the code 149 // A hack to properly count register references for the code
147 // generator's current frame and also for other frames. The 150 // generator's current frame and also for other frames. The
148 // same code appears in PrepareMergeTo. 151 // same code appears in PrepareMergeTo.
149 if (cgen_->frame() == this) { 152 if (cgen_->frame() == this) {
150 Unuse(last.reg()); 153 Unuse(last.reg());
151 } else { 154 } else {
152 frame_registers_.Unuse(last.reg()); 155 frame_registers_.Unuse(last.reg());
156 register_locations_[last.reg().code()] = kIllegalIndex;
153 } 157 }
154 } 158 }
155 } 159 }
156 } 160 }
157 161
158 162
159 void VirtualFrame::Use(Register reg) { 163 void VirtualFrame::Use(Register reg, int index) {
164 ASSERT(frame_registers_.count(reg) == 0);
165 ASSERT(register_locations_[reg.code()] == kIllegalIndex);
166 register_locations_[reg.code()] = index;
160 frame_registers_.Use(reg); 167 frame_registers_.Use(reg);
161 cgen_->allocator()->Use(reg); 168 cgen_->allocator()->Use(reg);
162 } 169 }
163 170
164 171
165 void VirtualFrame::Unuse(Register reg) { 172 void VirtualFrame::Unuse(Register reg) {
173 ASSERT(frame_registers_.count(reg) == 1);
174 ASSERT(register_locations_[reg.code()] != kIllegalIndex);
175 register_locations_[reg.code()] = kIllegalIndex;
166 frame_registers_.Unuse(reg); 176 frame_registers_.Unuse(reg);
167 cgen_->allocator()->Unuse(reg); 177 cgen_->allocator()->Unuse(reg);
168 } 178 }
169 179
170 180
171 void VirtualFrame::Spill(Register target) { 181 void VirtualFrame::Spill(Register target) {
172 if (!frame_registers_.is_used(target)) return; 182 if (!frame_registers_.is_used(target)) return;
173 for (int i = 0; i < elements_.length(); i++) { 183 for (int i = 0; i < elements_.length(); i++) {
174 if (elements_[i].is_register() && elements_[i].reg().is(target)) { 184 if (elements_[i].is_register() && elements_[i].reg().is(target)) {
175 SpillElementAt(i); 185 SpillElementAt(i);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // they are already synced. We perform those moves here, before 273 // they are already synced. We perform those moves here, before
264 // merging. 274 // merging.
265 if (source.is_register()) { 275 if (source.is_register()) {
266 // If the frame is the code generator's current frame, we have 276 // If the frame is the code generator's current frame, we have
267 // to decrement both the frame-internal and global register 277 // to decrement both the frame-internal and global register
268 // counts. 278 // counts.
269 if (cgen_->frame() == this) { 279 if (cgen_->frame() == this) {
270 Unuse(source.reg()); 280 Unuse(source.reg());
271 } else { 281 } else {
272 frame_registers_.Unuse(source.reg()); 282 frame_registers_.Unuse(source.reg());
283 register_locations_[source.reg().code()] = kIllegalIndex;
273 } 284 }
274 } 285 }
275 elements_[i] = target; 286 elements_[i] = target;
276 } else if (target.is_register() && !target.is_synced() && 287 } else if (target.is_register() && !target.is_synced() &&
277 !source.is_memory()) { 288 !source.is_memory()) {
278 // If an element's target is a register that doesn't need to be 289 // If an element's target is a register that doesn't need to be
279 // synced, and the element is not in memory, then the sync state 290 // synced, and the element is not in memory, then the sync state
280 // of the element is irrelevant. We clear the sync bit. 291 // of the element is irrelevant. We clear the sync bit.
281 ASSERT(source.is_valid()); 292 ASSERT(source.is_valid());
282 elements_[i].clear_sync(); 293 elements_[i].clear_sync();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 return; 386 return;
376 } 387 }
377 388
378 InvalidateFrameSlotAt(frame_index); 389 InvalidateFrameSlotAt(frame_index);
379 390
380 FrameElement new_element; 391 FrameElement new_element;
381 if (value->is_register()) { 392 if (value->is_register()) {
382 // There are two cases depending no whether the register already 393 // There are two cases depending no whether the register already
383 // occurs in the frame or not. 394 // occurs in the frame or not.
384 if (register_count(value->reg()) == 0) { 395 if (register_count(value->reg()) == 0) {
385 Use(value->reg()); 396 Use(value->reg(), frame_index);
386 elements_[frame_index] = 397 elements_[frame_index] =
387 FrameElement::RegisterElement(value->reg(), 398 FrameElement::RegisterElement(value->reg(),
388 FrameElement::NOT_SYNCED); 399 FrameElement::NOT_SYNCED);
389 } else { 400 } else {
390 int i = 0; 401 int i = 0;
391 for (; i < elements_.length(); i++) { 402 for (; i < elements_.length(); i++) {
392 if (elements_[i].is_register() && elements_[i].reg().is(value->reg())) { 403 if (elements_[i].is_register() && elements_[i].reg().is(value->reg())) {
393 break; 404 break;
394 } 405 }
395 } 406 }
396 ASSERT(i < elements_.length()); 407 ASSERT(i < elements_.length());
397 408
398 if (i < frame_index) { 409 if (i < frame_index) {
399 // The register backing store is lower in the frame than its copy. 410 // The register backing store is lower in the frame than its copy.
400 elements_[frame_index] = CopyElementAt(i); 411 elements_[frame_index] = CopyElementAt(i);
401 } else { 412 } else {
402 // There was an early bailout for the case of setting a 413 // There was an early bailout for the case of setting a
403 // register element to itself. 414 // register element to itself.
404 ASSERT(i != frame_index); 415 ASSERT(i != frame_index);
405 elements_[frame_index] = elements_[i]; 416 elements_[frame_index] = elements_[i];
406 elements_[i] = CopyElementAt(frame_index); 417 elements_[i] = CopyElementAt(frame_index);
407 if (elements_[frame_index].is_synced()) { 418 if (elements_[frame_index].is_synced()) {
408 elements_[i].set_sync(); 419 elements_[i].set_sync();
409 } 420 }
410 elements_[frame_index].clear_sync(); 421 elements_[frame_index].clear_sync();
422 register_locations_[value->reg().code()] = frame_index;
411 for (int j = i + 1; j < elements_.length(); j++) { 423 for (int j = i + 1; j < elements_.length(); j++) {
412 if (elements_[j].is_copy() && elements_[j].index() == i) { 424 if (elements_[j].is_copy() && elements_[j].index() == i) {
413 elements_[j].set_index(frame_index); 425 elements_[j].set_index(frame_index);
414 } 426 }
415 } 427 }
416 } 428 }
417 } 429 }
418 } else { 430 } else {
419 ASSERT(value->is_constant()); 431 ASSERT(value->is_constant());
420 elements_[frame_index] = 432 elements_[frame_index] =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 break; 492 break;
481 } 493 }
482 PrepareForCall(spilled_args, dropped_args); 494 PrepareForCall(spilled_args, dropped_args);
483 return RawCallCodeObject(code, rmode); 495 return RawCallCodeObject(code, rmode);
484 } 496 }
485 497
486 498
487 void VirtualFrame::Push(Register reg) { 499 void VirtualFrame::Push(Register reg) {
488 FrameElement new_element; 500 FrameElement new_element;
489 if (register_count(reg) == 0) { 501 if (register_count(reg) == 0) {
490 Use(reg); 502 Use(reg, elements_.length());
491 new_element = 503 new_element =
492 FrameElement::RegisterElement(reg, FrameElement::NOT_SYNCED); 504 FrameElement::RegisterElement(reg, FrameElement::NOT_SYNCED);
493 } else { 505 } else {
494 for (int i = 0; i < elements_.length(); i++) { 506 for (int i = 0; i < elements_.length(); i++) {
495 FrameElement element = elements_[i]; 507 FrameElement element = elements_[i];
496 if (element.is_register() && element.reg().is(reg)) { 508 if (element.is_register() && element.reg().is(reg)) {
497 new_element = CopyElementAt(i); 509 new_element = CopyElementAt(i);
498 break; 510 break;
499 } 511 }
500 } 512 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 if (cgen_ != other->cgen_) return false; 565 if (cgen_ != other->cgen_) return false;
554 if (masm_ != other->masm_) return false; 566 if (masm_ != other->masm_) return false;
555 if (parameter_count_ != other->parameter_count_) return false; 567 if (parameter_count_ != other->parameter_count_) return false;
556 if (local_count_ != other->local_count_) return false; 568 if (local_count_ != other->local_count_) return false;
557 if (frame_pointer_ != other->frame_pointer_) return false; 569 if (frame_pointer_ != other->frame_pointer_) return false;
558 570
559 for (int i = 0; i < kNumRegisters; i++) { 571 for (int i = 0; i < kNumRegisters; i++) {
560 if (frame_registers_.count(i) != other->frame_registers_.count(i)) { 572 if (frame_registers_.count(i) != other->frame_registers_.count(i)) {
561 return false; 573 return false;
562 } 574 }
575 if (register_locations_[i] != other->register_locations_[i]) {
576 return false;
577 }
563 } 578 }
564 if (elements_.length() != other->elements_.length()) return false; 579 if (elements_.length() != other->elements_.length()) return false;
565 #endif 580 #endif
566 if (stack_pointer_ != other->stack_pointer_) return false; 581 if (stack_pointer_ != other->stack_pointer_) return false;
567 for (int i = 0; i < elements_.length(); i++) { 582 for (int i = 0; i < elements_.length(); i++) {
568 if (!elements_[i].Equals(other->elements_[i])) return false; 583 if (!elements_[i].Equals(other->elements_[i])) return false;
569 } 584 }
570 585
571 return true; 586 return true;
572 } 587 }
573 588
574 } } // namespace v8::internal 589 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jump-target.cc ('k') | src/virtual-frame-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698