| 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/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); | 83 addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); |
| 84 if (addr == 0) { | 84 if (addr == 0) { |
| 85 OS::PrintErr("Exhausted heap space, trying to allocate %" Pd " bytes.\n", | 85 OS::PrintErr("Exhausted heap space, trying to allocate %" Pd " bytes.\n", |
| 86 size); | 86 size); |
| 87 return 0; | 87 return 0; |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 return addr; | 90 return addr; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void Heap::AllocateExternal(intptr_t size, Space space) { |
| 94 if (space == kNew) { |
| 95 new_space_->AllocateExternal(size); |
| 96 } else { |
| 97 ASSERT(space == kOld); |
| 98 old_space_->AllocateExternal(size); |
| 99 } |
| 100 } |
| 101 |
| 102 void Heap::FreeExternal(intptr_t size, Space space) { |
| 103 if (space == kNew) { |
| 104 new_space_->FreeExternal(size); |
| 105 } else { |
| 106 ASSERT(space == kOld); |
| 107 old_space_->FreeExternal(size); |
| 108 } |
| 109 } |
| 93 | 110 |
| 94 bool Heap::Contains(uword addr) const { | 111 bool Heap::Contains(uword addr) const { |
| 95 return new_space_->Contains(addr) || | 112 return new_space_->Contains(addr) || |
| 96 old_space_->Contains(addr); | 113 old_space_->Contains(addr); |
| 97 } | 114 } |
| 98 | 115 |
| 99 | 116 |
| 100 bool Heap::NewContains(uword addr) const { | 117 bool Heap::NewContains(uword addr) const { |
| 101 return new_space_->Contains(addr); | 118 return new_space_->Contains(addr); |
| 102 } | 119 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 intptr_t Heap::UsedInWords(Space space) const { | 334 intptr_t Heap::UsedInWords(Space space) const { |
| 318 return space == kNew ? new_space_->UsedInWords() : old_space_->UsedInWords(); | 335 return space == kNew ? new_space_->UsedInWords() : old_space_->UsedInWords(); |
| 319 } | 336 } |
| 320 | 337 |
| 321 | 338 |
| 322 intptr_t Heap::CapacityInWords(Space space) const { | 339 intptr_t Heap::CapacityInWords(Space space) const { |
| 323 return space == kNew ? new_space_->CapacityInWords() : | 340 return space == kNew ? new_space_->CapacityInWords() : |
| 324 old_space_->CapacityInWords(); | 341 old_space_->CapacityInWords(); |
| 325 } | 342 } |
| 326 | 343 |
| 344 intptr_t Heap::ExternalInWords(Space space) const { |
| 345 return space == kNew ? new_space_->ExternalInWords() : |
| 346 old_space_->ExternalInWords(); |
| 347 } |
| 327 | 348 |
| 328 int64_t Heap::GCTimeInMicros(Space space) const { | 349 int64_t Heap::GCTimeInMicros(Space space) const { |
| 329 if (space == kNew) { | 350 if (space == kNew) { |
| 330 return new_space_->gc_time_micros(); | 351 return new_space_->gc_time_micros(); |
| 331 } | 352 } |
| 332 return old_space_->gc_time_micros(); | 353 return old_space_->gc_time_micros(); |
| 333 } | 354 } |
| 334 | 355 |
| 335 | 356 |
| 336 intptr_t Heap::Collections(Space space) const { | 357 intptr_t Heap::Collections(Space space) const { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 heap->DisableGrowthControl(); | 531 heap->DisableGrowthControl(); |
| 511 } | 532 } |
| 512 | 533 |
| 513 | 534 |
| 514 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 535 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 515 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 536 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 516 heap->SetGrowthControlState(current_growth_controller_state_); | 537 heap->SetGrowthControlState(current_growth_controller_state_); |
| 517 } | 538 } |
| 518 | 539 |
| 519 } // namespace dart | 540 } // namespace dart |
| OLD | NEW |