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

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

Issue 57052: * String type inference using compiler framework. (Closed)
Patch Set: Changes relative to head of bleeding edge (don't do diff with earlier versions) Created 11 years, 8 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
« no previous file with comments | « src/virtual-frame.h ('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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 case FrameElement::COPY: 86 case FrameElement::COPY:
87 // We do not allow copies of copies, so we follow one link to 87 // We do not allow copies of copies, so we follow one link to
88 // the actual backing store of a copy before making a copy. 88 // the actual backing store of a copy before making a copy.
89 index = target.index(); 89 index = target.index();
90 ASSERT(elements_[index].is_memory() || elements_[index].is_register()); 90 ASSERT(elements_[index].is_memory() || elements_[index].is_register());
91 // Fall through. 91 // Fall through.
92 92
93 case FrameElement::MEMORY: // Fall through. 93 case FrameElement::MEMORY: // Fall through.
94 case FrameElement::REGISTER: 94 case FrameElement::REGISTER:
95 // All copies are backed by memory or register locations. 95 // All copies are backed by memory or register locations.
96 result.type_ = 96 result.set_static_type(target.static_type());
97 FrameElement::TypeField::encode(FrameElement::COPY) 97 result.type_ = FrameElement::COPY;
98 | FrameElement::IsCopiedField::encode(false) 98 result.copied_ = false;
99 | FrameElement::SyncField::encode(FrameElement::NOT_SYNCED); 99 result.synced_ = false;
100 result.data_.index_ = index; 100 result.data_.index_ = index;
101 elements_[index].set_copied(); 101 elements_[index].set_copied();
102 break; 102 break;
103 103
104 case FrameElement::INVALID: 104 case FrameElement::INVALID:
105 // We should not try to copy invalid elements. 105 // We should not try to copy invalid elements.
106 UNREACHABLE(); 106 UNREACHABLE();
107 break; 107 break;
108 } 108 }
109 return result; 109 return result;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 SyncElementAt(index); 202 SyncElementAt(index);
203 // The element is now in memory. Its copied flag is preserved. 203 // The element is now in memory. Its copied flag is preserved.
204 FrameElement new_element = FrameElement::MemoryElement(); 204 FrameElement new_element = FrameElement::MemoryElement();
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 new_element.set_static_type(elements_[index].static_type());
211 elements_[index] = new_element; 212 elements_[index] = new_element;
212 } 213 }
213 214
214 215
215 // Clear the dirty bits for the range of elements in 216 // Clear the dirty bits for the range of elements in
216 // [min(stack_pointer_ + 1,begin), end). 217 // [min(stack_pointer_ + 1,begin), end).
217 void VirtualFrame::SyncRange(int begin, int end) { 218 void VirtualFrame::SyncRange(int begin, int end) {
218 ASSERT(begin >= 0); 219 ASSERT(begin >= 0);
219 ASSERT(end <= elements_.length()); 220 ASSERT(end <= elements_.length());
220 if (begin > stack_pointer_) { 221 if (begin > stack_pointer_) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 382
382 InvalidateFrameSlotAt(frame_index); 383 InvalidateFrameSlotAt(frame_index);
383 384
384 FrameElement new_element; 385 FrameElement new_element;
385 if (value->is_register()) { 386 if (value->is_register()) {
386 if (is_used(value->reg())) { 387 if (is_used(value->reg())) {
387 // The register already appears on the frame. Either the existing 388 // The register already appears on the frame. Either the existing
388 // register element, or the new element at frame_index, must be made 389 // register element, or the new element at frame_index, must be made
389 // a copy. 390 // a copy.
390 int i = register_index(value->reg()); 391 int i = register_index(value->reg());
392 ASSERT(value->static_type() == elements_[i].static_type());
393
391 if (i < frame_index) { 394 if (i < frame_index) {
392 // The register FrameElement is lower in the frame than the new copy. 395 // The register FrameElement is lower in the frame than the new copy.
393 elements_[frame_index] = CopyElementAt(i); 396 elements_[frame_index] = CopyElementAt(i);
394 } else { 397 } else {
395 // There was an early bailout for the case of setting a 398 // There was an early bailout for the case of setting a
396 // register element to itself. 399 // register element to itself.
397 ASSERT(i != frame_index); 400 ASSERT(i != frame_index);
398 elements_[frame_index] = elements_[i]; 401 elements_[frame_index] = elements_[i];
399 elements_[i] = CopyElementAt(frame_index); 402 elements_[i] = CopyElementAt(frame_index);
400 if (elements_[frame_index].is_synced()) { 403 if (elements_[frame_index].is_synced()) {
401 elements_[i].set_sync(); 404 elements_[i].set_sync();
402 } 405 }
403 elements_[frame_index].clear_sync(); 406 elements_[frame_index].clear_sync();
404 register_locations_[value->reg().code()] = frame_index; 407 register_locations_[value->reg().code()] = frame_index;
405 for (int j = i + 1; j < elements_.length(); j++) { 408 for (int j = i + 1; j < elements_.length(); j++) {
406 if (elements_[j].is_copy() && elements_[j].index() == i) { 409 if (elements_[j].is_copy() && elements_[j].index() == i) {
407 elements_[j].set_index(frame_index); 410 elements_[j].set_index(frame_index);
408 } 411 }
409 } 412 }
410 } 413 }
411 } else { 414 } else {
412 // The register value->reg() was not already used on the frame. 415 // The register value->reg() was not already used on the frame.
413 Use(value->reg(), frame_index); 416 Use(value->reg(), frame_index);
414 elements_[frame_index] = 417 elements_[frame_index] =
415 FrameElement::RegisterElement(value->reg(), 418 FrameElement::RegisterElement(value->reg(),
416 FrameElement::NOT_SYNCED); 419 FrameElement::NOT_SYNCED,
420 value->static_type());
417 } 421 }
418 } else { 422 } else {
419 ASSERT(value->is_constant()); 423 ASSERT(value->is_constant());
420 elements_[frame_index] = 424 elements_[frame_index] =
421 FrameElement::ConstantElement(value->handle(), 425 FrameElement::ConstantElement(value->handle(),
422 FrameElement::NOT_SYNCED); 426 FrameElement::NOT_SYNCED);
423 } 427 }
424 value->Unuse(); 428 value->Unuse();
425 } 429 }
426 430
427 431
428 void VirtualFrame::PushFrameSlotAt(int index) { 432 void VirtualFrame::PushFrameSlotAt(int index) {
429 FrameElement new_element = CopyElementAt(index); 433 FrameElement new_element = CopyElementAt(index);
430 elements_.Add(new_element); 434 elements_.Add(new_element);
431 } 435 }
432 436
433 437
434 Result VirtualFrame::CallStub(CodeStub* stub, int arg_count) { 438 Result VirtualFrame::CallStub(CodeStub* stub, int arg_count) {
435 PrepareForCall(arg_count, arg_count); 439 PrepareForCall(arg_count, arg_count);
436 return RawCallStub(stub); 440 return RawCallStub(stub);
437 } 441 }
438 442
439 443
440 void VirtualFrame::Push(Register reg) { 444 void VirtualFrame::Push(Register reg, StaticType static_type) {
441 if (is_used(reg)) { 445 if (is_used(reg)) {
442 elements_.Add(CopyElementAt(register_index(reg))); 446 int index = register_index(reg);
447 FrameElement element = CopyElementAt(index);
448 ASSERT(static_type.merge(element.static_type()) == element.static_type());
449 elements_.Add(element);
443 } else { 450 } else {
444 Use(reg, elements_.length()); 451 Use(reg, elements_.length());
445 elements_.Add(FrameElement::RegisterElement(reg, FrameElement::NOT_SYNCED)); 452 FrameElement element =
453 FrameElement::RegisterElement(reg,
454 FrameElement::NOT_SYNCED,
455 static_type);
456 elements_.Add(element);
446 } 457 }
447 } 458 }
448 459
449 460
450 void VirtualFrame::Push(Handle<Object> value) { 461 void VirtualFrame::Push(Handle<Object> value) {
451 elements_.Add(FrameElement::ConstantElement(value, 462 FrameElement element =
452 FrameElement::NOT_SYNCED)); 463 FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED);
464 elements_.Add(element);
453 } 465 }
454 466
455 467
456 void VirtualFrame::Push(Result* result) { 468 void VirtualFrame::Push(Result* result) {
457 if (result->is_register()) { 469 if (result->is_register()) {
458 Push(result->reg()); 470 Push(result->reg(), result->static_type());
459 } else { 471 } else {
460 ASSERT(result->is_constant()); 472 ASSERT(result->is_constant());
461 Push(result->handle()); 473 Push(result->handle());
462 } 474 }
463 result->Unuse(); 475 result->Unuse();
464 } 476 }
465 477
466 478
467 void VirtualFrame::Nip(int num_dropped) { 479 void VirtualFrame::Nip(int num_dropped) {
468 ASSERT(num_dropped >= 0); 480 ASSERT(num_dropped >= 0);
469 if (num_dropped == 0) return; 481 if (num_dropped == 0) return;
470 Result tos = Pop(); 482 Result tos = Pop();
471 if (num_dropped > 1) { 483 if (num_dropped > 1) {
472 Drop(num_dropped - 1); 484 Drop(num_dropped - 1);
473 } 485 }
474 SetElementAt(0, &tos); 486 SetElementAt(0, &tos);
475 } 487 }
476 488
477 489
478 bool FrameElement::Equals(FrameElement other) { 490 bool FrameElement::Equals(FrameElement other) {
479 if (type_ != other.type_) return false; 491 if (type_ != other.type_ ||
492 copied_ != other.copied_ ||
493 synced_ != other.synced_) return false;
480 494
481 if (is_register()) { 495 if (is_register()) {
482 if (!reg().is(other.reg())) return false; 496 if (!reg().is(other.reg())) return false;
483 } else if (is_constant()) { 497 } else if (is_constant()) {
484 if (!handle().is_identical_to(other.handle())) return false; 498 if (!handle().is_identical_to(other.handle())) return false;
485 } else if (is_copy()) { 499 } else if (is_copy()) {
486 if (index() != other.index()) return false; 500 if (index() != other.index()) return false;
487 } 501 }
488 502
489 return true; 503 return true;
(...skipping 19 matching lines...) Expand all
509 #endif 523 #endif
510 if (stack_pointer_ != other->stack_pointer_) return false; 524 if (stack_pointer_ != other->stack_pointer_) return false;
511 for (int i = 0; i < elements_.length(); i++) { 525 for (int i = 0; i < elements_.length(); i++) {
512 if (!elements_[i].Equals(other->elements_[i])) return false; 526 if (!elements_[i].Equals(other->elements_[i])) return false;
513 } 527 }
514 528
515 return true; 529 return true;
516 } 530 }
517 531
518 } } // namespace v8::internal 532 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/virtual-frame.h ('k') | src/virtual-frame-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698