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

Unified Diff: src/api.cc

Issue 8055029: Add experimental support for tracing the state of the VM heap to a file Base URL: http://v8.googlecode.com/svn/branches/experimental/heap-visualization/
Patch Set: Created 9 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 | « include/v8.h ('k') | src/d8.cc » ('j') | src/spaces.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 9457)
+++ src/api.cc (working copy)
@@ -525,6 +525,70 @@
}
+class internal::HeapVisualizerImplementation {
+ public:
+ static void Register(HeapVisualizer* that);
+ static void Deregister(HeapVisualizer* that);
+};
+
+
+void RegisterHeapVisualizer(HeapVisualizer* that) {
+ i::HeapVisualizerImplementation::Register(that);
+}
+
+
+void DeRegisterHeapVisualizer(HeapVisualizer* that) {
+ i::HeapVisualizerImplementation::Deregister(that);
+}
+
+
+void v8::internal::HeapVisualizerImplementation::Register(
+ HeapVisualizer* that) {
+ Heap* heap = Isolate::Current()->heap();
+ heap->UpdateVisualizer(that);
+
+ HeapVisualizer* prev = heap->visualizer();
+ that->set_next(prev);
+ heap->set_visualizer(that);
+}
+
+
+void v8::internal::HeapVisualizerImplementation::Deregister(
+ HeapVisualizer* that) {
+ Heap* heap = Isolate::Current()->heap();
+ HeapVisualizer* prev = NULL;
+ for (HeapVisualizer* current = heap->visualizer();
+ current != NULL;
+ current = current->next()) {
+ if (current == that) {
+ if (prev == NULL) {
+ heap->set_visualizer(that->next());
+ } else {
+ prev->set_next(that->next());
+ }
+ return;
+ }
+ }
+ UNREACHABLE(); // Tried to deregister unregistered visualizer.
+}
+
+
+void v8::HeapVisualizer::WriteX(unsigned char* bytes, int len) {
+ if (kBufferSize - buffer_fullness_ < len) {
+ Flush();
+ }
+ while (len > kBufferSize) {
+ memcpy(buffer_, bytes, kBufferSize);
+ len -= kBufferSize;
+ bytes += kBufferSize;
+ buffer_fullness_ = kBufferSize;
+ Flush();
+ }
+ memcpy(buffer_ + buffer_fullness_, bytes, len);
+ buffer_fullness_ += len;
+}
+
+
v8::Handle<Primitive> Null() {
i::Isolate* isolate = i::Isolate::Current();
if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) {
« no previous file with comments | « include/v8.h ('k') | src/d8.cc » ('j') | src/spaces.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698