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

Unified Diff: runtime/vm/heap.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/heap_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap.cc
diff --git a/runtime/vm/heap.cc b/runtime/vm/heap.cc
index f73af75a691500ace737cf7f002409c86a3f3011..9d741133bed6c7389dc7f13d93589601162f4115 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -47,7 +47,6 @@ Heap::Heap(Isolate* isolate,
stats_.num_ = 0;
}
-
Heap::~Heap() {
delete barrier_;
delete barrier_done_;
@@ -58,7 +57,6 @@ Heap::~Heap() {
}
}
-
uword Heap::AllocateNew(intptr_t size) {
ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
// Currently, only the Dart thread may allocate in new space.
@@ -77,7 +75,6 @@ uword Heap::AllocateNew(intptr_t size) {
return addr;
}
-
uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
uword addr = old_space_.TryAllocate(size, type);
@@ -125,7 +122,6 @@ uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
return 0;
}
-
void Heap::AllocateExternal(intptr_t size, Space space) {
ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
if (space == kNew) {
@@ -163,44 +159,36 @@ bool Heap::Contains(uword addr) const {
return new_space_.Contains(addr) || old_space_.Contains(addr);
}
-
bool Heap::NewContains(uword addr) const {
return new_space_.Contains(addr);
}
-
bool Heap::OldContains(uword addr) const {
return old_space_.Contains(addr);
}
-
bool Heap::CodeContains(uword addr) const {
return old_space_.Contains(addr, HeapPage::kExecutable);
}
-
bool Heap::DataContains(uword addr) const {
return old_space_.DataContains(addr);
}
-
void Heap::VisitObjects(ObjectVisitor* visitor) const {
new_space_.VisitObjects(visitor);
old_space_.VisitObjects(visitor);
}
-
void Heap::VisitObjectsNoImagePages(ObjectVisitor* visitor) const {
new_space_.VisitObjects(visitor);
old_space_.VisitObjectsNoImagePages(visitor);
}
-
void Heap::VisitObjectsImagePages(ObjectVisitor* visitor) const {
old_space_.VisitObjectsImagePages(visitor);
}
-
HeapIterationScope::HeapIterationScope(bool writable)
: StackResource(Thread::Current()),
old_space_(isolate()->heap()->old_space()),
@@ -228,7 +216,6 @@ HeapIterationScope::HeapIterationScope(bool writable)
}
}
-
HeapIterationScope::~HeapIterationScope() {
if (writable_) {
thread()->heap()->WriteProtectCode(true);
@@ -244,7 +231,6 @@ HeapIterationScope::~HeapIterationScope() {
ml.NotifyAll();
}
-
void Heap::IterateObjects(ObjectVisitor* visitor) const {
// The visitor must not allocate from the heap.
NoSafepointScope no_safepoint_scope_;
@@ -252,25 +238,21 @@ void Heap::IterateObjects(ObjectVisitor* visitor) const {
IterateOldObjects(visitor);
}
-
void Heap::IterateOldObjects(ObjectVisitor* visitor) const {
HeapIterationScope heap_iteration_scope;
old_space_.VisitObjects(visitor);
}
-
void Heap::IterateOldObjectsNoImagePages(ObjectVisitor* visitor) const {
HeapIterationScope heap_iteration_scope;
old_space_.VisitObjectsNoImagePages(visitor);
}
-
void Heap::VisitObjectPointers(ObjectPointerVisitor* visitor) const {
new_space_.VisitObjectPointers(visitor);
old_space_.VisitObjectPointers(visitor);
}
-
RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) const {
// Only executable pages can have RawInstructions objects.
RawObject* raw_obj = old_space_.FindObject(visitor, HeapPage::kExecutable);
@@ -279,18 +261,15 @@ RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) const {
return reinterpret_cast<RawInstructions*>(raw_obj);
}
-
RawObject* Heap::FindOldObject(FindObjectVisitor* visitor) const {
HeapIterationScope heap_iteration_scope;
return old_space_.FindObject(visitor, HeapPage::kData);
}
-
RawObject* Heap::FindNewObject(FindObjectVisitor* visitor) const {
return new_space_.FindObject(visitor);
}
-
RawObject* Heap::FindObject(FindObjectVisitor* visitor) const {
// The visitor must not allocate from the heap.
NoSafepointScope no_safepoint_scope;
@@ -306,7 +285,6 @@ RawObject* Heap::FindObject(FindObjectVisitor* visitor) const {
return raw_obj;
}
-
bool Heap::BeginNewSpaceGC(Thread* thread) {
MonitorLocker ml(&gc_in_progress_monitor_);
bool start_gc_on_thread = true;
@@ -321,7 +299,6 @@ bool Heap::BeginNewSpaceGC(Thread* thread) {
return false;
}
-
void Heap::EndNewSpaceGC() {
MonitorLocker ml(&gc_in_progress_monitor_);
ASSERT(gc_new_space_in_progress_);
@@ -329,7 +306,6 @@ void Heap::EndNewSpaceGC() {
ml.NotifyAll();
}
-
bool Heap::BeginOldSpaceGC(Thread* thread) {
MonitorLocker ml(&gc_in_progress_monitor_);
bool start_gc_on_thread = true;
@@ -344,7 +320,6 @@ bool Heap::BeginOldSpaceGC(Thread* thread) {
return false;
}
-
void Heap::EndOldSpaceGC() {
MonitorLocker ml(&gc_in_progress_monitor_);
ASSERT(gc_old_space_in_progress_);
@@ -352,7 +327,6 @@ void Heap::EndOldSpaceGC() {
ml.NotifyAll();
}
-
#ifndef PRODUCT
void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) {
ClassTable* class_table = isolate()->class_table();
@@ -364,7 +338,6 @@ void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) {
}
#endif
-
void Heap::EvacuateNewSpace(Thread* thread, GCReason reason) {
ASSERT(reason == kFull);
if (BeginNewSpaceGC(thread)) {
@@ -381,7 +354,6 @@ void Heap::EvacuateNewSpace(Thread* thread, GCReason reason) {
}
}
-
void Heap::CollectNewSpaceGarbage(Thread* thread,
ApiCallbacks api_callbacks,
GCReason reason) {
@@ -405,7 +377,6 @@ void Heap::CollectNewSpaceGarbage(Thread* thread,
}
}
-
void Heap::CollectOldSpaceGarbage(Thread* thread,
ApiCallbacks api_callbacks,
GCReason reason) {
@@ -427,7 +398,6 @@ void Heap::CollectOldSpaceGarbage(Thread* thread,
}
}
-
void Heap::CollectGarbage(Space space,
ApiCallbacks api_callbacks,
GCReason reason) {
@@ -447,7 +417,6 @@ void Heap::CollectGarbage(Space space,
}
}
-
void Heap::CollectGarbage(Space space) {
Thread* thread = Thread::Current();
if (space == kOld) {
@@ -458,7 +427,6 @@ void Heap::CollectGarbage(Space space) {
}
}
-
void Heap::CollectAllGarbage() {
Thread* thread = Thread::Current();
@@ -468,7 +436,6 @@ void Heap::CollectAllGarbage() {
CollectOldSpaceGarbage(thread, kInvokeApiCallbacks, kFull);
}
-
void Heap::WaitForSweeperTasks(Thread* thread) {
MonitorLocker ml(old_space_.tasks_lock());
while (old_space_.tasks() > 0) {
@@ -476,7 +443,6 @@ void Heap::WaitForSweeperTasks(Thread* thread) {
}
}
-
void Heap::UpdateGlobalMaxUsed() {
ASSERT(isolate_ != NULL);
// We are accessing the used in words count for both new and old space
@@ -486,29 +452,24 @@ void Heap::UpdateGlobalMaxUsed() {
(UsedInWords(Heap::kOld) * kWordSize));
}
-
void Heap::InitGrowthControl() {
old_space_.InitGrowthControl();
}
-
void Heap::SetGrowthControlState(bool state) {
old_space_.SetGrowthControlState(state);
}
-
bool Heap::GrowthControlState() {
return old_space_.GrowthControlState();
}
-
void Heap::WriteProtect(bool read_only) {
read_only_ = read_only;
new_space_.WriteProtect(read_only);
old_space_.WriteProtect(read_only);
}
-
intptr_t Heap::TopOffset(Heap::Space space) {
if (space == kNew) {
return OFFSET_OF(Heap, new_space_) + Scavenger::top_offset();
@@ -518,7 +479,6 @@ intptr_t Heap::TopOffset(Heap::Space space) {
}
}
-
intptr_t Heap::EndOffset(Heap::Space space) {
if (space == kNew) {
return OFFSET_OF(Heap, new_space_) + Scavenger::end_offset();
@@ -528,7 +488,6 @@ intptr_t Heap::EndOffset(Heap::Space space) {
}
}
-
void Heap::Init(Isolate* isolate,
intptr_t max_new_gen_words,
intptr_t max_old_gen_words,
@@ -539,7 +498,6 @@ void Heap::Init(Isolate* isolate,
isolate->set_heap(heap);
}
-
void Heap::RegionName(Heap* heap, Space space, char* name, intptr_t name_size) {
const bool no_isolate_name = (heap == NULL) || (heap->isolate() == NULL) ||
(heap->isolate()->debugger_name() == NULL);
@@ -562,13 +520,11 @@ void Heap::RegionName(Heap* heap, Space space, char* name, intptr_t name_size) {
OS::SNPrint(name, name_size, "dart-%s %s", space_name, isolate_name);
}
-
void Heap::AddRegionsToObjectSet(ObjectSet* set) const {
new_space_.AddRegionsToObjectSet(set);
old_space_.AddRegionsToObjectSet(set);
}
-
ObjectSet* Heap::CreateAllocatedObjectSet(
Zone* zone,
MarkExpectation mark_expectation) const {
@@ -598,13 +554,11 @@ ObjectSet* Heap::CreateAllocatedObjectSet(
return allocated_set;
}
-
bool Heap::Verify(MarkExpectation mark_expectation) const {
HeapIterationScope heap_iteration_scope;
return VerifyGC(mark_expectation);
}
-
bool Heap::VerifyGC(MarkExpectation mark_expectation) const {
StackZone stack_zone(Thread::Current());
ObjectSet* allocated_set =
@@ -616,7 +570,6 @@ bool Heap::VerifyGC(MarkExpectation mark_expectation) const {
return true;
}
-
void Heap::PrintSizes() const {
OS::PrintErr(
"New space (%" Pd64 "k of %" Pd64
@@ -626,24 +579,20 @@ void Heap::PrintSizes() const {
(UsedInWords(kOld) / KBInWords), (CapacityInWords(kOld) / KBInWords));
}
-
int64_t Heap::UsedInWords(Space space) const {
return space == kNew ? new_space_.UsedInWords() : old_space_.UsedInWords();
}
-
int64_t Heap::CapacityInWords(Space space) const {
return space == kNew ? new_space_.CapacityInWords()
: old_space_.CapacityInWords();
}
-
int64_t Heap::ExternalInWords(Space space) const {
return space == kNew ? new_space_.ExternalInWords()
: old_space_.ExternalInWords();
}
-
int64_t Heap::GCTimeInMicros(Space space) const {
if (space == kNew) {
return new_space_.gc_time_micros();
@@ -651,7 +600,6 @@ int64_t Heap::GCTimeInMicros(Space space) const {
return old_space_.gc_time_micros();
}
-
intptr_t Heap::Collections(Space space) const {
if (space == kNew) {
return new_space_.collections();
@@ -659,7 +607,6 @@ intptr_t Heap::Collections(Space space) const {
return old_space_.collections();
}
-
const char* Heap::GCReasonToString(GCReason gc_reason) {
switch (gc_reason) {
case kNewSpace:
@@ -680,7 +627,6 @@ const char* Heap::GCReasonToString(GCReason gc_reason) {
}
}
-
int64_t Heap::PeerCount() const {
return new_weak_tables_[kPeers]->count() + old_weak_tables_[kPeers]->count();
}
@@ -692,19 +638,16 @@ int64_t Heap::HashCount() const {
}
#endif
-
int64_t Heap::ObjectIdCount() const {
return new_weak_tables_[kObjectIds]->count() +
old_weak_tables_[kObjectIds]->count();
}
-
void Heap::ResetObjectIdTable() {
new_weak_tables_[kObjectIds]->Reset();
old_weak_tables_[kObjectIds]->Reset();
}
-
intptr_t Heap::GetWeakEntry(RawObject* raw_obj, WeakSelector sel) const {
if (raw_obj->IsNewObject()) {
return new_weak_tables_[sel]->GetValue(raw_obj);
@@ -713,7 +656,6 @@ intptr_t Heap::GetWeakEntry(RawObject* raw_obj, WeakSelector sel) const {
return old_weak_tables_[sel]->GetValue(raw_obj);
}
-
void Heap::SetWeakEntry(RawObject* raw_obj, WeakSelector sel, intptr_t val) {
if (raw_obj->IsNewObject()) {
new_weak_tables_[sel]->SetValue(raw_obj, val);
@@ -723,7 +665,6 @@ void Heap::SetWeakEntry(RawObject* raw_obj, WeakSelector sel, intptr_t val) {
}
}
-
#ifndef PRODUCT
void Heap::PrintToJSONObject(Space space, JSONObject* object) const {
if (space == kNew) {
@@ -734,7 +675,6 @@ void Heap::PrintToJSONObject(Space space, JSONObject* object) const {
}
#endif // PRODUCT
-
void Heap::RecordBeforeGC(Space space, GCReason reason) {
ASSERT((space == kNew && gc_new_space_in_progress_) ||
(space == kOld && gc_old_space_in_progress_));
@@ -750,7 +690,6 @@ void Heap::RecordBeforeGC(Space space, GCReason reason) {
stats_.data_[i] = 0;
}
-
void Heap::RecordAfterGC(Space space) {
stats_.after_.micros_ = OS::GetCurrentMonotonicMicros();
int64_t delta = stats_.after_.micros_ - stats_.before_.micros_;
@@ -775,7 +714,6 @@ void Heap::RecordAfterGC(Space space) {
#endif // !PRODUCT
}
-
void Heap::PrintStats() {
if (!FLAG_verbose_gc) return;
@@ -842,7 +780,6 @@ void Heap::PrintStats() {
// clang-format on
}
-
void Heap::PrintStatsToTimeline(TimelineEventScope* event) {
#if !defined(PRODUCT)
if ((event == NULL) || !event->enabled()) {
@@ -878,7 +815,6 @@ void Heap::PrintStatsToTimeline(TimelineEventScope* event) {
#endif // !defined(PRODUCT)
}
-
NoHeapGrowthControlScope::NoHeapGrowthControlScope()
: StackResource(Thread::Current()) {
Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
@@ -886,19 +822,16 @@ NoHeapGrowthControlScope::NoHeapGrowthControlScope()
heap->DisableGrowthControl();
}
-
NoHeapGrowthControlScope::~NoHeapGrowthControlScope() {
Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
heap->SetGrowthControlState(current_growth_controller_state_);
}
-
WritableVMIsolateScope::WritableVMIsolateScope(Thread* thread)
: StackResource(thread) {
Dart::vm_isolate()->heap()->WriteProtect(false);
}
-
WritableVMIsolateScope::~WritableVMIsolateScope() {
ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0);
Dart::vm_isolate()->heap()->WriteProtect(true);
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/heap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698