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

Side by Side Diff: src/heap/heap.cc

Issue 2635973002: [heap] Don't allocate immovable code in LO space during serialization (Closed)
Patch Set: Add test Created 3 years, 11 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/heap/heap.h ('k') | src/isolate.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/heap.h" 5 #include "src/heap/heap.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/ast/context-slot-cache.h" 9 #include "src/ast/context-slot-cache.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 3133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3144 if (isolate()->heap_profiler()->is_sampling_allocations()) return false; 3144 if (isolate()->heap_profiler()->is_sampling_allocations()) return false;
3145 3145
3146 Address address = object->address(); 3146 Address address = object->address();
3147 3147
3148 if (lo_space()->Contains(object)) return false; 3148 if (lo_space()->Contains(object)) return false;
3149 3149
3150 // We can move the object start if the page was already swept. 3150 // We can move the object start if the page was already swept.
3151 return Page::FromAddress(address)->SweepingDone(); 3151 return Page::FromAddress(address)->SweepingDone();
3152 } 3152 }
3153 3153
3154 bool Heap::IsImmovable(HeapObject* object) {
3155 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address());
3156 return chunk->NeverEvacuate() || chunk->owner()->identity() == LO_SPACE;
3157 }
3158
3154 void Heap::AdjustLiveBytes(HeapObject* object, int by) { 3159 void Heap::AdjustLiveBytes(HeapObject* object, int by) {
3155 // As long as the inspected object is black and we are currently not iterating 3160 // As long as the inspected object is black and we are currently not iterating
3156 // the heap using HeapIterator, we can update the live byte count. We cannot 3161 // the heap using HeapIterator, we can update the live byte count. We cannot
3157 // update while using HeapIterator because the iterator is temporarily 3162 // update while using HeapIterator because the iterator is temporarily
3158 // marking the whole object graph, without updating live bytes. 3163 // marking the whole object graph, without updating live bytes.
3159 if (lo_space()->Contains(object)) { 3164 if (lo_space()->Contains(object)) {
3160 lo_space()->AdjustLiveBytes(by); 3165 lo_space()->AdjustLiveBytes(by);
3161 } else if (!in_heap_iterator() && 3166 } else if (!in_heap_iterator() &&
3162 !mark_compact_collector()->sweeping_in_progress() && 3167 !mark_compact_collector()->sweeping_in_progress() &&
3163 Marking::IsBlack(ObjectMarking::MarkBitFrom(object->address()))) { 3168 Marking::IsBlack(ObjectMarking::MarkBitFrom(object->address()))) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 3386
3382 3387
3383 AllocationResult Heap::AllocateCode(int object_size, bool immovable) { 3388 AllocationResult Heap::AllocateCode(int object_size, bool immovable) {
3384 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment)); 3389 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment));
3385 AllocationResult allocation = AllocateRaw(object_size, CODE_SPACE); 3390 AllocationResult allocation = AllocateRaw(object_size, CODE_SPACE);
3386 3391
3387 HeapObject* result = nullptr; 3392 HeapObject* result = nullptr;
3388 if (!allocation.To(&result)) return allocation; 3393 if (!allocation.To(&result)) return allocation;
3389 if (immovable) { 3394 if (immovable) {
3390 Address address = result->address(); 3395 Address address = result->address();
3396 MemoryChunk* chunk = MemoryChunk::FromAddress(address);
3391 // Code objects which should stay at a fixed address are allocated either 3397 // Code objects which should stay at a fixed address are allocated either
3392 // in the first page of code space (objects on the first page of each space 3398 // in the first page of code space (objects on the first page of each space
3393 // are never moved) or in large object space. 3399 // are never moved), in large object space, or (during snapshot creation)
3394 if (!code_space_->FirstPage()->Contains(address) && 3400 // the containing page is marked as immovable.
3395 MemoryChunk::FromAddress(address)->owner()->identity() != LO_SPACE) { 3401 if (!Heap::IsImmovable(result) &&
3396 // Discard the first code allocation, which was on a page where it could 3402 !code_space_->FirstPage()->Contains(address)) {
3397 // be moved. 3403 if (isolate()->serializer_enabled()) {
3398 CreateFillerObjectAt(result->address(), object_size, 3404 chunk->MarkNeverEvacuate();
3399 ClearRecordedSlots::kNo); 3405 } else {
3400 allocation = lo_space_->AllocateRaw(object_size, EXECUTABLE); 3406 // Discard the first code allocation, which was on a page where it could
3401 if (!allocation.To(&result)) return allocation; 3407 // be moved.
3402 OnAllocationEvent(result, object_size); 3408 CreateFillerObjectAt(result->address(), object_size,
3409 ClearRecordedSlots::kNo);
3410 allocation = lo_space_->AllocateRaw(object_size, EXECUTABLE);
3411 if (!allocation.To(&result)) return allocation;
3412 OnAllocationEvent(result, object_size);
3413 }
3403 } 3414 }
3404 } 3415 }
3405 3416
3406 result->set_map_no_write_barrier(code_map()); 3417 result->set_map_no_write_barrier(code_map());
3407 Code* code = Code::cast(result); 3418 Code* code = Code::cast(result);
3408 DCHECK(IsAligned(bit_cast<intptr_t>(code->address()), kCodeAlignment)); 3419 DCHECK(IsAligned(bit_cast<intptr_t>(code->address()), kCodeAlignment));
3409 DCHECK(!memory_allocator()->code_range()->valid() || 3420 DCHECK(!memory_allocator()->code_range()->valid() ||
3410 memory_allocator()->code_range()->contains(code->address()) || 3421 memory_allocator()->code_range()->contains(code->address()) ||
3411 object_size <= code_space()->AreaSize()); 3422 object_size <= code_space()->AreaSize());
3412 code->set_gc_metadata(Smi::kZero); 3423 code->set_gc_metadata(Smi::kZero);
(...skipping 3149 matching lines...) Expand 10 before | Expand all | Expand 10 after
6562 } 6573 }
6563 6574
6564 6575
6565 // static 6576 // static
6566 int Heap::GetStaticVisitorIdForMap(Map* map) { 6577 int Heap::GetStaticVisitorIdForMap(Map* map) {
6567 return StaticVisitorBase::GetVisitorId(map); 6578 return StaticVisitorBase::GetVisitorId(map);
6568 } 6579 }
6569 6580
6570 } // namespace internal 6581 } // namespace internal
6571 } // namespace v8 6582 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698