| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/heap.h" | 5 #include "vm/heap.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/heap_histogram.h" | 10 #include "vm/heap_histogram.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); | 84 addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); |
| 85 if (addr == 0) { | 85 if (addr == 0) { |
| 86 OS::PrintErr("Exhausted heap space, trying to allocate %" Pd " bytes.\n", | 86 OS::PrintErr("Exhausted heap space, trying to allocate %" Pd " bytes.\n", |
| 87 size); | 87 size); |
| 88 return 0; | 88 return 0; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 return addr; | 91 return addr; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void Heap::AllocateExternal(intptr_t size, RawObject* ref) { |
| 95 if (ref->IsHeapObject() && ref->IsNewObject()) { |
| 96 new_space_->AllocateExternal(size); |
| 97 } else { |
| 98 old_space_->AllocateExternal(size); |
| 99 } |
| 100 } |
| 101 |
| 102 void Heap::FreeExternal(intptr_t size, RawObject* ref) { |
| 103 if (ref->IsHeapObject() && ref->IsNewObject()) { |
| 104 new_space_->FreeExternal(size); |
| 105 } else { |
| 106 old_space_->FreeExternal(size); |
| 107 } |
| 108 } |
| 94 | 109 |
| 95 bool Heap::Contains(uword addr) const { | 110 bool Heap::Contains(uword addr) const { |
| 96 return new_space_->Contains(addr) || | 111 return new_space_->Contains(addr) || |
| 97 old_space_->Contains(addr); | 112 old_space_->Contains(addr); |
| 98 } | 113 } |
| 99 | 114 |
| 100 | 115 |
| 101 bool Heap::NewContains(uword addr) const { | 116 bool Heap::NewContains(uword addr) const { |
| 102 return new_space_->Contains(addr); | 117 return new_space_->Contains(addr); |
| 103 } | 118 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 intptr_t Heap::UsedInWords(Space space) const { | 342 intptr_t Heap::UsedInWords(Space space) const { |
| 328 return space == kNew ? new_space_->UsedInWords() : old_space_->UsedInWords(); | 343 return space == kNew ? new_space_->UsedInWords() : old_space_->UsedInWords(); |
| 329 } | 344 } |
| 330 | 345 |
| 331 | 346 |
| 332 intptr_t Heap::CapacityInWords(Space space) const { | 347 intptr_t Heap::CapacityInWords(Space space) const { |
| 333 return space == kNew ? new_space_->CapacityInWords() : | 348 return space == kNew ? new_space_->CapacityInWords() : |
| 334 old_space_->CapacityInWords(); | 349 old_space_->CapacityInWords(); |
| 335 } | 350 } |
| 336 | 351 |
| 352 intptr_t Heap::ExternalAllocatedInWords(Space space) const { |
| 353 return space == kNew ? new_space_->ExternalAllocatedInWords() : |
| 354 old_space_->ExternalAllocatedInWords(); |
| 355 } |
| 337 | 356 |
| 338 int64_t Heap::GCTimeInMicros(Space space) const { | 357 int64_t Heap::GCTimeInMicros(Space space) const { |
| 339 if (space == kNew) { | 358 if (space == kNew) { |
| 340 return new_space_->gc_time_micros(); | 359 return new_space_->gc_time_micros(); |
| 341 } | 360 } |
| 342 return old_space_->gc_time_micros(); | 361 return old_space_->gc_time_micros(); |
| 343 } | 362 } |
| 344 | 363 |
| 345 | 364 |
| 346 intptr_t Heap::Collections(Space space) const { | 365 intptr_t Heap::Collections(Space space) const { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 heap->DisableGrowthControl(); | 539 heap->DisableGrowthControl(); |
| 521 } | 540 } |
| 522 | 541 |
| 523 | 542 |
| 524 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 543 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 525 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 544 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 526 heap->SetGrowthControlState(current_growth_controller_state_); | 545 heap->SetGrowthControlState(current_growth_controller_state_); |
| 527 } | 546 } |
| 528 | 547 |
| 529 } // namespace dart | 548 } // namespace dart |
| OLD | NEW |