Chromium Code Reviews| 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" |
| 11 #include "vm/lockers.h" | |
| 11 #include "vm/object.h" | 12 #include "vm/object.h" |
| 12 #include "vm/object_set.h" | 13 #include "vm/object_set.h" |
| 13 #include "vm/os.h" | 14 #include "vm/os.h" |
| 14 #include "vm/pages.h" | 15 #include "vm/pages.h" |
| 15 #include "vm/raw_object.h" | 16 #include "vm/raw_object.h" |
| 16 #include "vm/scavenger.h" | 17 #include "vm/scavenger.h" |
| 17 #include "vm/service.h" | 18 #include "vm/service.h" |
| 18 #include "vm/stack_frame.h" | 19 #include "vm/stack_frame.h" |
| 19 #include "vm/tags.h" | 20 #include "vm/tags.h" |
| 20 #include "vm/verifier.h" | 21 #include "vm/verifier.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 return addr; | 77 return addr; |
| 77 } | 78 } |
| 78 | 79 |
| 79 | 80 |
| 80 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) { | 81 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) { |
| 81 ASSERT(isolate()->no_gc_scope_depth() == 0); | 82 ASSERT(isolate()->no_gc_scope_depth() == 0); |
| 82 uword addr = old_space_->TryAllocate(size, type); | 83 uword addr = old_space_->TryAllocate(size, type); |
| 83 if (addr == 0) { | 84 if (addr == 0) { |
| 84 CollectAllGarbage(); | 85 { |
| 85 addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); | 86 MonitorLocker ml(old_space_->tasks_lock()); |
| 87 addr = old_space_->TryAllocate(size, type); | |
| 88 while ((addr == 0) && (old_space_->tasks())) { | |
|
koda
2014/08/26 23:34:48
Add missing "> 0" (or, per my other comment, "has_
Ivan Posva
2014/08/27 01:00:22
Uiuiuiui! That should not have happened.
| |
| 89 ml.Wait(); | |
| 90 addr = old_space_->TryAllocate(size, type); | |
| 91 } | |
| 92 } | |
| 86 if (addr == 0) { | 93 if (addr == 0) { |
| 87 OS::PrintErr("Exhausted heap space, trying to allocate %" Pd " bytes.\n", | 94 CollectAllGarbage(); |
| 88 size); | 95 addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); |
|
koda
2014/08/26 23:34:48
Explain why there's no point in waiting for sweepe
Ivan Posva
2014/08/27 01:00:22
We should be waiting for sweepers here, but I miss
| |
| 89 return 0; | 96 if (addr == 0) { |
| 97 OS::PrintErr( | |
| 98 "Exhausted heap space, trying to allocate %" Pd " bytes.\n", size); | |
| 99 return 0; | |
| 100 } | |
| 90 } | 101 } |
| 91 } | 102 } |
| 92 return addr; | 103 return addr; |
| 93 } | 104 } |
| 94 | 105 |
| 95 void Heap::AllocateExternal(intptr_t size, Space space) { | 106 void Heap::AllocateExternal(intptr_t size, Space space) { |
| 96 ASSERT(isolate()->no_gc_scope_depth() == 0); | 107 ASSERT(isolate()->no_gc_scope_depth() == 0); |
| 97 if (space == kNew) { | 108 if (space == kNew) { |
| 98 new_space_->AllocateExternal(size); | 109 new_space_->AllocateExternal(size); |
| 99 if (new_space_->ExternalInWords() > (FLAG_new_gen_ext_limit * MBInWords)) { | 110 if (new_space_->ExternalInWords() > (FLAG_new_gen_ext_limit * MBInWords)) { |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 heap->DisableGrowthControl(); | 612 heap->DisableGrowthControl(); |
| 602 } | 613 } |
| 603 | 614 |
| 604 | 615 |
| 605 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 616 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 606 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 617 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 607 heap->SetGrowthControlState(current_growth_controller_state_); | 618 heap->SetGrowthControlState(current_growth_controller_state_); |
| 608 } | 619 } |
| 609 | 620 |
| 610 } // namespace dart | 621 } // namespace dart |
| OLD | NEW |