| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, Space space) { | 94 void Heap::AllocateExternal(intptr_t size, Space space) { |
| 95 ASSERT(isolate()->no_gc_scope_depth() == 0); |
| 95 if (space == kNew) { | 96 if (space == kNew) { |
| 96 new_space_->AllocateExternal(size); | 97 new_space_->AllocateExternal(size); |
| 97 if (new_space_->ExternalInWords() > (FLAG_new_gen_ext_limit * MBInWords)) { | 98 if (new_space_->ExternalInWords() > (FLAG_new_gen_ext_limit * MBInWords)) { |
| 98 // Attempt to free some external allocation by a scavenge. (If the total | 99 // Attempt to free some external allocation by a scavenge. (If the total |
| 99 // remains above the limit, next external alloc will trigger another.) | 100 // remains above the limit, next external alloc will trigger another.) |
| 100 CollectGarbage(kNew); | 101 CollectGarbage(kNew); |
| 101 } | 102 } |
| 102 } else { | 103 } else { |
| 103 ASSERT(space == kOld); | 104 ASSERT(space == kOld); |
| 104 old_space_->AllocateExternal(size); | 105 old_space_->AllocateExternal(size); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 heap->DisableGrowthControl(); | 579 heap->DisableGrowthControl(); |
| 579 } | 580 } |
| 580 | 581 |
| 581 | 582 |
| 582 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 583 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 583 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 584 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 584 heap->SetGrowthControlState(current_growth_controller_state_); | 585 heap->SetGrowthControlState(current_growth_controller_state_); |
| 585 } | 586 } |
| 586 | 587 |
| 587 } // namespace dart | 588 } // namespace dart |
| OLD | NEW |