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

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

Issue 1481953002: Move map retaining to finalization of incremental marking. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/heap/incremental-marking.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/scopeinfo.h" 9 #include "src/ast/scopeinfo.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 5314 matching lines...) Expand 10 before | Expand all | Expand 10 after
5325 DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<HeapObject> obj) { 5325 DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<HeapObject> obj) {
5326 Object* dep = weak_object_to_code_table()->Lookup(obj); 5326 Object* dep = weak_object_to_code_table()->Lookup(obj);
5327 if (dep->IsDependentCode()) return DependentCode::cast(dep); 5327 if (dep->IsDependentCode()) return DependentCode::cast(dep);
5328 return DependentCode::cast(empty_fixed_array()); 5328 return DependentCode::cast(empty_fixed_array());
5329 } 5329 }
5330 5330
5331 5331
5332 void Heap::AddRetainedMap(Handle<Map> map) { 5332 void Heap::AddRetainedMap(Handle<Map> map) {
5333 Handle<WeakCell> cell = Map::WeakCellForMap(map); 5333 Handle<WeakCell> cell = Map::WeakCellForMap(map);
5334 Handle<ArrayList> array(retained_maps(), isolate()); 5334 Handle<ArrayList> array(retained_maps(), isolate());
5335 if (array->IsFull()) {
5336 CompactRetainedMaps(*array);
5337 }
5335 array = ArrayList::Add( 5338 array = ArrayList::Add(
5336 array, cell, handle(Smi::FromInt(FLAG_retain_maps_for_n_gc), isolate()), 5339 array, cell, handle(Smi::FromInt(FLAG_retain_maps_for_n_gc), isolate()),
5337 ArrayList::kReloadLengthAfterAllocation); 5340 ArrayList::kReloadLengthAfterAllocation);
5338 if (*array != retained_maps()) { 5341 if (*array != retained_maps()) {
5339 set_retained_maps(*array); 5342 set_retained_maps(*array);
5340 } 5343 }
5341 } 5344 }
5342 5345
5343 5346
5347 void Heap::CompactRetainedMaps(ArrayList* retained_maps) {
5348 DCHECK_EQ(retained_maps, this->retained_maps());
5349 int length = retained_maps->Length();
5350 int new_length = 0;
5351 int new_number_of_disposed_maps = 0;
5352 // This loop compacts the array by removing cleared weak cells.
5353 for (int i = 0; i < length; i += 2) {
5354 DCHECK(retained_maps->Get(i)->IsWeakCell());
5355 WeakCell* cell = WeakCell::cast(retained_maps->Get(i));
5356 Object* age = retained_maps->Get(i + 1);
5357 if (cell->cleared()) continue;
5358 if (i != new_length) {
5359 retained_maps->Set(new_length, cell);
5360 retained_maps->Set(new_length + 1, age);
5361 }
5362 if (i < number_of_disposed_maps_) {
5363 new_number_of_disposed_maps += 2;
5364 }
5365 new_length += 2;
5366 }
5367 number_of_disposed_maps_ = new_number_of_disposed_maps;
5368 Object* undefined = undefined_value();
5369 for (int i = new_length; i < length; i++) {
5370 retained_maps->Clear(i, undefined);
5371 }
5372 if (new_length != length) retained_maps->SetLength(new_length);
5373 }
5374
5375
5344 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { 5376 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
5345 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); 5377 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot);
5346 } 5378 }
5347 5379
5348 #ifdef DEBUG 5380 #ifdef DEBUG
5349 5381
5350 class PrintHandleVisitor : public ObjectVisitor { 5382 class PrintHandleVisitor : public ObjectVisitor {
5351 public: 5383 public:
5352 void VisitPointers(Object** start, Object** end) override { 5384 void VisitPointers(Object** start, Object** end) override {
5353 for (Object** p = start; p < end; p++) 5385 for (Object** p = start; p < end; p++)
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
6124 } 6156 }
6125 6157
6126 6158
6127 // static 6159 // static
6128 int Heap::GetStaticVisitorIdForMap(Map* map) { 6160 int Heap::GetStaticVisitorIdForMap(Map* map) {
6129 return StaticVisitorBase::GetVisitorId(map); 6161 return StaticVisitorBase::GetVisitorId(map);
6130 } 6162 }
6131 6163
6132 } // namespace internal 6164 } // namespace internal
6133 } // namespace v8 6165 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698