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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 } | 486 } |
487 | 487 |
488 | 488 |
489 void Heap::UpdateAllocationSiteFeedback(HeapObject* object) { | 489 void Heap::UpdateAllocationSiteFeedback(HeapObject* object) { |
490 Heap* heap = object->GetHeap(); | 490 Heap* heap = object->GetHeap(); |
491 ASSERT(heap->InFromSpace(object)); | 491 ASSERT(heap->InFromSpace(object)); |
492 | 492 |
493 if (!FLAG_allocation_site_pretenuring || | 493 if (!FLAG_allocation_site_pretenuring || |
494 !AllocationSite::CanTrack(object->map()->instance_type())) return; | 494 !AllocationSite::CanTrack(object->map()->instance_type())) return; |
495 | 495 |
496 // Either object is the last object in the from space, or there is another | 496 // Check if there is potentially a memento behind the object. If |
497 // object of at least word size (the header map word) following it, so | 497 // the last word of the momento is on another page we return |
498 // suffices to compare ptr and top here. | 498 // immediatelly. Note that we do not have to compare with the current |
499 Address ptr = object->address() + object->Size(); | 499 // top pointer of the from space page, since we always install filler |
500 Address top = heap->new_space()->FromSpacePageHigh(); | 500 // objects above the top pointer of a from space page when performing |
501 ASSERT(ptr == top || ptr + HeapObject::kHeaderSize <= top); | 501 // a garbage collection. |
502 if (ptr == top) return; | 502 Address object_address = object->address(); |
| 503 Address memento_address = object_address + object->Size(); |
| 504 Address last_memento_word_address = memento_address + kPointerSize; |
| 505 if (!NewSpacePage::OnSamePage(object_address, |
| 506 last_memento_word_address)) { |
| 507 return; |
| 508 } |
503 | 509 |
504 HeapObject* candidate = HeapObject::FromAddress(ptr); | 510 HeapObject* candidate = HeapObject::FromAddress(memento_address); |
505 if (candidate->map() != heap->allocation_memento_map()) return; | 511 if (candidate->map() != heap->allocation_memento_map()) return; |
506 | 512 |
507 AllocationMemento* memento = AllocationMemento::cast(candidate); | 513 AllocationMemento* memento = AllocationMemento::cast(candidate); |
508 if (!memento->IsValid()) return; | 514 if (!memento->IsValid()) return; |
509 | 515 |
510 if (memento->GetAllocationSite()->IncrementMementoFoundCount() && | 516 if (memento->GetAllocationSite()->IncrementMementoFoundCount() && |
511 heap->allocation_sites_scratchpad_length < | 517 heap->allocation_sites_scratchpad_length < |
512 kAllocationSiteScratchpadSize) { | 518 kAllocationSiteScratchpadSize) { |
513 heap->allocation_sites_scratchpad[ | 519 heap->allocation_sites_scratchpad[ |
514 heap->allocation_sites_scratchpad_length++] = | 520 heap->allocation_sites_scratchpad_length++] = |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 #ifdef DEBUG | 839 #ifdef DEBUG |
834 Isolate* isolate = Isolate::Current(); | 840 Isolate* isolate = Isolate::Current(); |
835 isolate->heap()->disallow_allocation_failure_ = old_state_; | 841 isolate->heap()->disallow_allocation_failure_ = old_state_; |
836 #endif | 842 #endif |
837 } | 843 } |
838 | 844 |
839 | 845 |
840 } } // namespace v8::internal | 846 } } // namespace v8::internal |
841 | 847 |
842 #endif // V8_HEAP_INL_H_ | 848 #endif // V8_HEAP_INL_H_ |
OLD | NEW |