OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 OS::MemMove(dst, src, static_cast<size_t>(byte_size)); | 476 OS::MemMove(dst, src, static_cast<size_t>(byte_size)); |
477 } | 477 } |
478 } | 478 } |
479 | 479 |
480 | 480 |
481 void Heap::ScavengePointer(HeapObject** p) { | 481 void Heap::ScavengePointer(HeapObject** p) { |
482 ScavengeObject(p, *p); | 482 ScavengeObject(p, *p); |
483 } | 483 } |
484 | 484 |
485 | 485 |
486 void Heap::AddressMemento(HeapObject* object) { | |
487 if ((FLAG_allocation_site_pretenuring || FLAG_trace_track_allocation_sites) | |
488 && object->IsJSObject()) { | |
489 AllocationMemento* memento = AllocationMemento::FindForJSObject( | |
490 JSObject::cast(object), true); | |
491 if (memento != NULL) { | |
492 ASSERT(memento->IsValid()); | |
493 | |
494 if (FLAG_allocation_site_pretenuring) { | |
495 // Update state | |
Hannes Payer (out of office)
2013/11/21 20:52:24
Remove this comment.
mvstanton
2013/11/22 11:18:51
Done.
| |
496 memento->GetAllocationSite()->IncrementMementoFoundCount(); | |
497 } | |
498 | |
499 // TODO(mvstanton): consider always updating this variable as long as | |
500 // we are tracking mementos for pretenuring purposes. | |
501 if (FLAG_trace_track_allocation_sites) { | |
502 object->GetIsolate()->heap()->allocation_mementos_found_++; | |
Hannes Payer (out of office)
2013/11/21 20:52:24
Do we still need this variable? We could just ask
mvstanton
2013/11/22 11:18:51
Done. Facilitated by moving the allocation site fe
| |
503 } | |
504 } | |
505 } | |
506 } | |
507 | |
508 | |
486 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { | 509 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { |
487 ASSERT(object->GetIsolate()->heap()->InFromSpace(object)); | 510 ASSERT(object->GetIsolate()->heap()->InFromSpace(object)); |
488 | 511 |
489 // We use the first word (where the map pointer usually is) of a heap | 512 // We use the first word (where the map pointer usually is) of a heap |
490 // object to record the forwarding pointer. A forwarding pointer can | 513 // object to record the forwarding pointer. A forwarding pointer can |
491 // point to an old space, the code space, or the to space of the new | 514 // point to an old space, the code space, or the to space of the new |
492 // generation. | 515 // generation. |
493 MapWord first_word = object->map_word(); | 516 MapWord first_word = object->map_word(); |
494 | 517 |
495 // If the first word is a forwarding address, the object has already been | 518 // If the first word is a forwarding address, the object has already been |
496 // copied. | 519 // copied. |
497 if (first_word.IsForwardingAddress()) { | 520 if (first_word.IsForwardingAddress()) { |
498 HeapObject* dest = first_word.ToForwardingAddress(); | 521 HeapObject* dest = first_word.ToForwardingAddress(); |
499 ASSERT(object->GetIsolate()->heap()->InFromSpace(*p)); | 522 ASSERT(object->GetIsolate()->heap()->InFromSpace(*p)); |
500 *p = dest; | 523 *p = dest; |
501 return; | 524 return; |
502 } | 525 } |
503 | 526 |
504 if (FLAG_trace_track_allocation_sites && object->IsJSObject()) { | 527 AddressMemento(object); |
505 if (AllocationMemento::FindForJSObject(JSObject::cast(object), true) != | |
506 NULL) { | |
507 object->GetIsolate()->heap()->allocation_mementos_found_++; | |
508 } | |
509 } | |
510 | 528 |
511 // AllocationMementos are unrooted and shouldn't survive a scavenge | 529 // AllocationMementos are unrooted and shouldn't survive a scavenge |
512 ASSERT(object->map() != object->GetHeap()->allocation_memento_map()); | 530 ASSERT(object->map() != object->GetHeap()->allocation_memento_map()); |
513 // Call the slow part of scavenge object. | 531 // Call the slow part of scavenge object. |
514 return ScavengeObjectSlow(p, object); | 532 return ScavengeObjectSlow(p, object); |
515 } | 533 } |
516 | 534 |
517 | 535 |
518 bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason) { | 536 bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason) { |
519 const char* collector_reason = NULL; | 537 const char* collector_reason = NULL; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
864 #ifdef DEBUG | 882 #ifdef DEBUG |
865 Isolate* isolate = Isolate::Current(); | 883 Isolate* isolate = Isolate::Current(); |
866 isolate->heap()->disallow_allocation_failure_ = old_state_; | 884 isolate->heap()->disallow_allocation_failure_ = old_state_; |
867 #endif | 885 #endif |
868 } | 886 } |
869 | 887 |
870 | 888 |
871 } } // namespace v8::internal | 889 } } // namespace v8::internal |
872 | 890 |
873 #endif // V8_HEAP_INL_H_ | 891 #endif // V8_HEAP_INL_H_ |
OLD | NEW |