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

Unified Diff: runtime/vm/heap.cc

Issue 11428067: Merge the Merlin heap tracing to top-of-trunk. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years 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/vm/heap.h ('k') | runtime/vm/heap_trace.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap.cc
diff --git a/runtime/vm/heap.cc b/runtime/vm/heap.cc
index 79c335d6af4dba55ea28134da71b9621c060ca86..9d19e6ed6e153067d9955d05415fe2896c29d0d3 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -8,11 +8,13 @@
#include "platform/utils.h"
#include "vm/flags.h"
#include "vm/heap_profiler.h"
+#include "vm/heap_trace.h"
#include "vm/isolate.h"
#include "vm/object.h"
#include "vm/object_set.h"
#include "vm/os.h"
#include "vm/pages.h"
+#include "vm/raw_object.h"
#include "vm/scavenger.h"
#include "vm/stack_frame.h"
#include "vm/verifier.h"
@@ -37,6 +39,7 @@ Heap::Heap() : read_only_(false) {
(FLAG_new_gen_heap_size * MB),
kNewObjectAlignmentOffset);
old_space_ = new PageSpace(this, (FLAG_old_gen_heap_size * MB));
+ heap_trace_ = new HeapTrace;
}
@@ -49,15 +52,17 @@ Heap::~Heap() {
uword Heap::AllocateNew(intptr_t size) {
ASSERT(Isolate::Current()->no_gc_scope_depth() == 0);
uword addr = new_space_->TryAllocate(size);
- if (addr != 0) {
- return addr;
+ if (addr == 0) {
+ CollectGarbage(kNew);
+ addr = new_space_->TryAllocate(size);
+ if (addr == 0) {
+ return AllocateOld(size, HeapPage::kData);
+ }
}
- CollectGarbage(kNew);
- addr = new_space_->TryAllocate(size);
- if (addr != 0) {
- return addr;
+ if (HeapTrace::is_enabled()) {
+ heap_trace_->TraceAllocation(addr, size);
}
- return AllocateOld(size, HeapPage::kData);
+ return addr;
}
@@ -70,8 +75,12 @@ uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
if (addr == 0) {
OS::PrintErr("Exhausted heap space, trying to allocate %"Pd" bytes.\n",
size);
+ return 0;
}
}
+ if (HeapTrace::is_enabled()) {
+ heap_trace_->TraceAllocation(addr, size);
+ }
return addr;
}
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/heap_trace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698