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

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

Issue 2644523002: [heap] Provide ObjectMarking with marking transitions (Closed)
Patch Set: 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 | « no previous file | src/heap/incremental-marking.cc » ('j') | src/heap/incremental-marking.cc » ('J')
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 3153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 Marking::IsBlack(ObjectMarking::MarkBitFrom(object))) { 3164 Marking::IsBlack(ObjectMarking::MarkBitFrom(object))) {
3165 DCHECK(MemoryChunk::FromAddress(object->address())->SweepingDone()); 3165 DCHECK(MemoryChunk::FromAddress(object->address())->SweepingDone());
3166 MemoryChunk::IncrementLiveBytes(object, by); 3166 MemoryChunk::IncrementLiveBytes(object, by);
3167 } 3167 }
3168 } 3168 }
3169 3169
3170 3170
3171 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object, 3171 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object,
3172 int elements_to_trim) { 3172 int elements_to_trim) {
3173 CHECK_NOT_NULL(object); 3173 CHECK_NOT_NULL(object);
3174 DCHECK(CanMoveObjectStart(object));
3174 DCHECK(!object->IsFixedTypedArrayBase()); 3175 DCHECK(!object->IsFixedTypedArrayBase());
3175 DCHECK(!object->IsByteArray()); 3176 DCHECK(!object->IsByteArray());
3176 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize; 3177 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize;
3177 const int bytes_to_trim = elements_to_trim * element_size; 3178 const int bytes_to_trim = elements_to_trim * element_size;
3178 Map* map = object->map(); 3179 Map* map = object->map();
3179 3180
3180 // For now this trick is only applied to objects in new and paged space. 3181 // For now this trick is only applied to objects in new and paged space.
3181 // In large object space the object's start must coincide with chunk 3182 // In large object space the object's start must coincide with chunk
3182 // and thus the trick is just not applicable. 3183 // and thus the trick is just not applicable.
3183 DCHECK(!lo_space()->Contains(object)); 3184 DCHECK(!lo_space()->Contains(object));
(...skipping 30 matching lines...) Expand all
3214 Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(object))) { 3215 Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(object))) {
3215 Page* page = Page::FromAddress(old_start); 3216 Page* page = Page::FromAddress(old_start);
3216 page->markbits()->ClearRange( 3217 page->markbits()->ClearRange(
3217 page->AddressToMarkbitIndex(old_start), 3218 page->AddressToMarkbitIndex(old_start),
3218 page->AddressToMarkbitIndex(old_start + bytes_to_trim)); 3219 page->AddressToMarkbitIndex(old_start + bytes_to_trim));
3219 } 3220 }
3220 3221
3221 // Initialize header of the trimmed array. Since left trimming is only 3222 // Initialize header of the trimmed array. Since left trimming is only
3222 // performed on pages which are not concurrently swept creating a filler 3223 // performed on pages which are not concurrently swept creating a filler
3223 // object does not require synchronization. 3224 // object does not require synchronization.
3224 DCHECK(CanMoveObjectStart(object));
3225 Object** former_start = HeapObject::RawField(object, 0); 3225 Object** former_start = HeapObject::RawField(object, 0);
3226 int new_start_index = elements_to_trim * (element_size / kPointerSize); 3226 int new_start_index = elements_to_trim * (element_size / kPointerSize);
3227 former_start[new_start_index] = map; 3227 former_start[new_start_index] = map;
3228 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim); 3228 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim);
3229 3229
3230 FixedArrayBase* new_object = 3230 FixedArrayBase* new_object =
3231 FixedArrayBase::cast(HeapObject::FromAddress(new_start)); 3231 FixedArrayBase::cast(HeapObject::FromAddress(new_start));
3232 3232
3233 // Maintain consistency of live bytes during incremental marking 3233 // Maintain consistency of live bytes during incremental marking
3234 AdjustLiveBytes(new_object, -bytes_to_trim); 3234 AdjustLiveBytes(new_object, -bytes_to_trim);
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
4280 // Code space, map space, and large object space do not use black pages. 4280 // Code space, map space, and large object space do not use black pages.
4281 // Hence we have to color all objects of the reservation first black to avoid 4281 // Hence we have to color all objects of the reservation first black to avoid
4282 // unnecessary marking deque load. 4282 // unnecessary marking deque load.
4283 if (incremental_marking()->black_allocation()) { 4283 if (incremental_marking()->black_allocation()) {
4284 for (int i = OLD_SPACE; i < Serializer::kNumberOfSpaces; i++) { 4284 for (int i = OLD_SPACE; i < Serializer::kNumberOfSpaces; i++) {
4285 const Heap::Reservation& res = reservations[i]; 4285 const Heap::Reservation& res = reservations[i];
4286 for (auto& chunk : res) { 4286 for (auto& chunk : res) {
4287 Address addr = chunk.start; 4287 Address addr = chunk.start;
4288 while (addr < chunk.end) { 4288 while (addr < chunk.end) {
4289 HeapObject* obj = HeapObject::FromAddress(addr); 4289 HeapObject* obj = HeapObject::FromAddress(addr);
4290 Marking::MarkBlack(ObjectMarking::MarkBitFrom(obj)); 4290 ObjectMarking::WhiteToBlack(obj);
4291 addr += obj->Size(); 4291 addr += obj->Size();
4292 } 4292 }
4293 } 4293 }
4294 } 4294 }
4295 for (int i = OLD_SPACE; i < Serializer::kNumberOfSpaces; i++) { 4295 for (int i = OLD_SPACE; i < Serializer::kNumberOfSpaces; i++) {
4296 const Heap::Reservation& res = reservations[i]; 4296 const Heap::Reservation& res = reservations[i];
4297 for (auto& chunk : res) { 4297 for (auto& chunk : res) {
4298 Address addr = chunk.start; 4298 Address addr = chunk.start;
4299 while (addr < chunk.end) { 4299 while (addr < chunk.end) {
4300 HeapObject* obj = HeapObject::FromAddress(addr); 4300 HeapObject* obj = HeapObject::FromAddress(addr);
(...skipping 2266 matching lines...) Expand 10 before | Expand all | Expand 10 after
6567 } 6567 }
6568 6568
6569 6569
6570 // static 6570 // static
6571 int Heap::GetStaticVisitorIdForMap(Map* map) { 6571 int Heap::GetStaticVisitorIdForMap(Map* map) {
6572 return StaticVisitorBase::GetVisitorId(map); 6572 return StaticVisitorBase::GetVisitorId(map);
6573 } 6573 }
6574 6574
6575 } // namespace internal 6575 } // namespace internal
6576 } // namespace v8 6576 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/incremental-marking.cc » ('j') | src/heap/incremental-marking.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698