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

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
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 5293 matching lines...) Expand 10 before | Expand all | Expand 10 after
5304 DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<HeapObject> obj) { 5304 DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<HeapObject> obj) {
5305 Object* dep = weak_object_to_code_table()->Lookup(obj); 5305 Object* dep = weak_object_to_code_table()->Lookup(obj);
5306 if (dep->IsDependentCode()) return DependentCode::cast(dep); 5306 if (dep->IsDependentCode()) return DependentCode::cast(dep);
5307 return DependentCode::cast(empty_fixed_array()); 5307 return DependentCode::cast(empty_fixed_array());
5308 } 5308 }
5309 5309
5310 5310
5311 void Heap::AddRetainedMap(Handle<Map> map) { 5311 void Heap::AddRetainedMap(Handle<Map> map) {
5312 Handle<WeakCell> cell = Map::WeakCellForMap(map); 5312 Handle<WeakCell> cell = Map::WeakCellForMap(map);
5313 Handle<ArrayList> array(retained_maps(), isolate()); 5313 Handle<ArrayList> array(retained_maps(), isolate());
5314 if (array->IsFull()) {
5315 CompactRetainedMaps(*array);
5316 }
5314 array = ArrayList::Add( 5317 array = ArrayList::Add(
5315 array, cell, handle(Smi::FromInt(FLAG_retain_maps_for_n_gc), isolate()), 5318 array, cell, handle(Smi::FromInt(FLAG_retain_maps_for_n_gc), isolate()),
5316 ArrayList::kReloadLengthAfterAllocation); 5319 ArrayList::kReloadLengthAfterAllocation);
5317 if (*array != retained_maps()) { 5320 if (*array != retained_maps()) {
5318 set_retained_maps(*array); 5321 set_retained_maps(*array);
5319 } 5322 }
5320 } 5323 }
5321 5324
5322 5325
5326 void Heap::CompactRetainedMaps(ArrayList* retained_maps) {
5327 DCHECK_EQ(retained_maps, this->retained_maps());
5328 int length = retained_maps->Length();
5329 int new_length = 0;
5330 int new_number_of_disposed_maps = 0;
5331 // This loop compacts the array by removing cleared weak cells.
5332 for (int i = 0; i < length; i += 2) {
5333 DCHECK(retained_maps->Get(i)->IsWeakCell());
5334 WeakCell* cell = WeakCell::cast(retained_maps->Get(i));
5335 Object* age = retained_maps->Get(i + 1);
5336 if (cell->cleared()) continue;
5337 if (i != new_length) {
5338 retained_maps->Set(new_length, cell);
5339 retained_maps->Set(new_length + 1, age);
5340 }
5341 if (i < number_of_disposed_maps_) {
5342 new_number_of_disposed_maps += 2;
5343 }
5344 new_length += 2;
5345 }
5346 number_of_disposed_maps_ = new_number_of_disposed_maps;
5347 Object* undefined = undefined_value();
5348 for (int i = new_length; i < length; i++) {
5349 retained_maps->Clear(i, undefined);
5350 }
5351 if (new_length != length) retained_maps->SetLength(new_length);
5352 }
5353
5354
5323 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { 5355 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
5324 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); 5356 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot);
5325 } 5357 }
5326 5358
5327 #ifdef DEBUG 5359 #ifdef DEBUG
5328 5360
5329 class PrintHandleVisitor : public ObjectVisitor { 5361 class PrintHandleVisitor : public ObjectVisitor {
5330 public: 5362 public:
5331 void VisitPointers(Object** start, Object** end) override { 5363 void VisitPointers(Object** start, Object** end) override {
5332 for (Object** p = start; p < end; p++) 5364 for (Object** p = start; p < end; p++)
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
6103 } 6135 }
6104 6136
6105 6137
6106 // static 6138 // static
6107 int Heap::GetStaticVisitorIdForMap(Map* map) { 6139 int Heap::GetStaticVisitorIdForMap(Map* map) {
6108 return StaticVisitorBase::GetVisitorId(map); 6140 return StaticVisitorBase::GetVisitorId(map);
6109 } 6141 }
6110 6142
6111 } // namespace internal 6143 } // namespace internal
6112 } // namespace v8 6144 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.h » ('j') | src/heap/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698