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

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: add yet another missing file 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
Index: runtime/vm/heap.cc
diff --git a/runtime/vm/heap.cc b/runtime/vm/heap.cc
index 84f55df0d3f954157bc3432aa83bc725b0d63639..eb9dfcdb28e7fa850d9544864da3ff5e934db5d2 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -9,11 +9,13 @@
#include "vm/compiler_stats.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"
@@ -38,6 +40,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_ = HeapTrace::is_enabled() ? new HeapTrace : NULL;
siva 2012/12/05 16:06:40 new HeapTrace() ?
cshapiro 2012/12/08 03:23:08 Parenthesis are not required. We do not put paren
}
@@ -50,15 +53,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;
}
@@ -71,8 +76,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;
}
@@ -268,7 +277,7 @@ void Heap::PrintSizes() const {
}
-void Heap::Profile(Dart_HeapProfileWriteCallback callback, void* stream) const {
+void Heap::Profile(Dart_FileWriteCallback callback, void* stream) const {
HeapProfiler profiler(callback, stream);
// Dump the root set.

Powered by Google App Engine
This is Rietveld 408576698