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

Unified Diff: runtime/vm/pages.cc

Issue 531153003: Add lost usage update to TryAllocateInternal. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.cc
===================================================================
--- runtime/vm/pages.cc (revision 39776)
+++ runtime/vm/pages.cc (working copy)
@@ -324,6 +324,9 @@
bool is_locked) {
ASSERT(size >= kObjectAlignment);
ASSERT(Utils::IsAligned(size, kObjectAlignment));
+#ifdef DEBUG
+ SpaceUsage usage_before = usage_;
+#endif
uword result = 0;
if (size < kAllocatablePageSize) {
if (is_locked) {
@@ -333,6 +336,9 @@
}
if (result == 0) {
result = TryAllocateInFreshPage(size, type, growth_policy, is_locked);
+ // usage_ is updated by the call above.
+ } else {
+ usage_.used_in_words += size >> kWordSizeLog2;
}
} else {
// Large page allocation.
@@ -355,9 +361,19 @@
}
}
if (result != 0) {
+#ifdef DEBUG
+ // A successful allocation should increase usage_.
+ ASSERT(usage_before.used_in_words < usage_.used_in_words);
+#endif
if (FLAG_compiler_stats && (type == HeapPage::kExecutable)) {
CompilerStats::code_allocated += size;
}
+ } else {
+#ifdef DEBUG
+ // A failed allocation should not change usage_.
+ ASSERT(usage_before.used_in_words == usage_.used_in_words);
+ ASSERT(usage_before.capacity_in_words == usage_.capacity_in_words);
+#endif
}
ASSERT((result & kObjectAlignmentMask) == kOldObjectAlignmentOffset);
return result;
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698