| 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()")) {
|
|
|