Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: runtime/vm/pages.cc

Issue 187113003: Track external allocated memory for weak persistent handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 PageSpace::PageSpace(Heap* heap, intptr_t max_capacity_in_words) 120 PageSpace::PageSpace(Heap* heap, intptr_t max_capacity_in_words)
121 : freelist_(), 121 : freelist_(),
122 heap_(heap), 122 heap_(heap),
123 pages_(NULL), 123 pages_(NULL),
124 pages_tail_(NULL), 124 pages_tail_(NULL),
125 large_pages_(NULL), 125 large_pages_(NULL),
126 max_capacity_in_words_(max_capacity_in_words), 126 max_capacity_in_words_(max_capacity_in_words),
127 capacity_in_words_(0), 127 capacity_in_words_(0),
128 used_in_words_(0), 128 used_in_words_(0),
129 external_allocated_in_words_(0),
129 sweeping_(false), 130 sweeping_(false),
130 page_space_controller_(FLAG_heap_growth_space_ratio, 131 page_space_controller_(FLAG_heap_growth_space_ratio,
131 FLAG_heap_growth_rate, 132 FLAG_heap_growth_rate,
132 FLAG_heap_growth_time_ratio), 133 FLAG_heap_growth_time_ratio),
133 gc_time_micros_(0), 134 gc_time_micros_(0),
134 collections_(0) { 135 collections_(0) {
135 } 136 }
136 137
137 138
138 PageSpace::~PageSpace() { 139 PageSpace::~PageSpace() {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 used_in_words_ += (size >> kWordSizeLog2); 266 used_in_words_ += (size >> kWordSizeLog2);
266 if (FLAG_compiler_stats && (type == HeapPage::kExecutable)) { 267 if (FLAG_compiler_stats && (type == HeapPage::kExecutable)) {
267 CompilerStats::code_allocated += size; 268 CompilerStats::code_allocated += size;
268 } 269 }
269 } 270 }
270 ASSERT((result & kObjectAlignmentMask) == kOldObjectAlignmentOffset); 271 ASSERT((result & kObjectAlignmentMask) == kOldObjectAlignmentOffset);
271 return result; 272 return result;
272 } 273 }
273 274
274 275
276 void PageSpace::AllocateExternal(intptr_t size) {
277 intptr_t size_in_words = size >> kWordSizeLog2;
278 external_allocated_in_words_ += size_in_words;
279 capacity_in_words_ += size_in_words;
280 used_in_words_ += size_in_words;
281 }
282
283
284 void PageSpace::FreeExternal(intptr_t size) {
285 intptr_t size_in_words = size >> kWordSizeLog2;
286 external_allocated_in_words_ -= size_in_words;
287 capacity_in_words_ -= size_in_words;
288 used_in_words_ -= size_in_words;
289 }
290
291
275 bool PageSpace::Contains(uword addr) const { 292 bool PageSpace::Contains(uword addr) const {
276 HeapPage* page = pages_; 293 HeapPage* page = pages_;
277 while (page != NULL) { 294 while (page != NULL) {
278 if (page->Contains(addr)) { 295 if (page->Contains(addr)) {
279 return true; 296 return true;
280 } 297 }
281 page = page->next(); 298 page = page->next();
282 } 299 }
283 300
284 page = large_pages_; 301 page = large_pages_;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 current_page = large_pages_; 551 current_page = large_pages_;
535 while (current_page != NULL) { 552 while (current_page != NULL) {
536 if (current_page->type() == HeapPage::kExecutable) { 553 if (current_page->type() == HeapPage::kExecutable) {
537 current_page->WriteProtect(true); 554 current_page->WriteProtect(true);
538 } 555 }
539 current_page = current_page->next(); 556 current_page = current_page->next();
540 } 557 }
541 } 558 }
542 559
543 // Record data and print if requested. 560 // Record data and print if requested.
561 used_in_words += external_allocated_in_words_;
Ivan Posva 2014/03/05 21:21:23 We probably want to track these separately in the
koda 2014/03/05 21:52:08 Done.
544 intptr_t used_before_in_words = used_in_words_; 562 intptr_t used_before_in_words = used_in_words_;
545 used_in_words_ = used_in_words; 563 used_in_words_ = used_in_words;
546 564
547 int64_t end = OS::GetCurrentTimeMicros(); 565 int64_t end = OS::GetCurrentTimeMicros();
548 566
549 // Record signals for growth control. 567 // Record signals for growth control.
550 page_space_controller_.EvaluateGarbageCollection(used_before_in_words, 568 page_space_controller_.EvaluateGarbageCollection(used_before_in_words,
551 used_in_words, 569 used_in_words,
552 start, end); 570 start, end);
553 571
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 return 0; 703 return 0;
686 } else { 704 } else {
687 ASSERT(total_time >= gc_time); 705 ASSERT(total_time >= gc_time);
688 int result= static_cast<int>((static_cast<double>(gc_time) / 706 int result= static_cast<int>((static_cast<double>(gc_time) /
689 static_cast<double>(total_time)) * 100); 707 static_cast<double>(total_time)) * 100);
690 return result; 708 return result;
691 } 709 }
692 } 710 }
693 711
694 } // namespace dart 712 } // namespace dart
OLDNEW
« runtime/vm/heap.h ('K') | « runtime/vm/pages.h ('k') | runtime/vm/scavenger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698