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/pages.h" | 5 #include "vm/pages.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/compiler_stats.h" | 8 #include "vm/compiler_stats.h" |
| 9 #include "vm/gc_marker.h" | 9 #include "vm/gc_marker.h" |
| 10 #include "vm/gc_sweeper.h" | 10 #include "vm/gc_sweeper.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 HeapPage* result = Initialize(memory, type); | 82 HeapPage* result = Initialize(memory, type); |
| 83 if (result == NULL) { | 83 if (result == NULL) { |
| 84 delete memory; // Release reservation to OS. | 84 delete memory; // Release reservation to OS. |
| 85 return NULL; | 85 return NULL; |
| 86 } | 86 } |
| 87 return result; | 87 return result; |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 void HeapPage::Deallocate() { | 91 void HeapPage::Deallocate() { |
| 92 // The memory for this object will become unavailable after the delete below. | 92 // For a regular heap pages, the memory for this object will become |
| 93 // unavailable after the delete below. | |
| 94 bool is_embedder_allocated = embedder_allocated(); | |
| 93 delete memory_; | 95 delete memory_; |
| 96 | |
| 97 // For a heap page from a snapshot, the HeapPage object lives in the malloc | |
| 98 // heap rather than the page itself. | |
| 99 if (is_embedder_allocated) { | |
| 100 free(this); | |
|
Florian Schneider
2017/01/24 02:06:07
Maybe change this to new/delete instead of malloc/
rmacnak
2017/01/24 03:28:36
Trying this out, I see the original reason this us
| |
| 101 } | |
| 94 } | 102 } |
| 95 | 103 |
| 96 | 104 |
| 97 void HeapPage::VisitObjects(ObjectVisitor* visitor) const { | 105 void HeapPage::VisitObjects(ObjectVisitor* visitor) const { |
| 98 NoSafepointScope no_safepoint; | 106 NoSafepointScope no_safepoint; |
| 99 uword obj_addr = object_start(); | 107 uword obj_addr = object_start(); |
| 100 uword end_addr = object_end(); | 108 uword end_addr = object_end(); |
| 101 while (obj_addr < end_addr) { | 109 while (obj_addr < end_addr) { |
| 102 RawObject* raw_obj = RawObject::FromAddr(obj_addr); | 110 RawObject* raw_obj = RawObject::FromAddr(obj_addr); |
| 103 visitor->VisitObject(raw_obj); | 111 visitor->VisitObject(raw_obj); |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 return 0; | 1291 return 0; |
| 1284 } else { | 1292 } else { |
| 1285 ASSERT(total_time >= gc_time); | 1293 ASSERT(total_time >= gc_time); |
| 1286 int result = static_cast<int>( | 1294 int result = static_cast<int>( |
| 1287 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); | 1295 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); |
| 1288 return result; | 1296 return result; |
| 1289 } | 1297 } |
| 1290 } | 1298 } |
| 1291 | 1299 |
| 1292 } // namespace dart | 1300 } // namespace dart |
| OLD | NEW |