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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/d8.cc » ('j') | src/spaces.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 v8::Handle<Primitive> Undefined() { 518 v8::Handle<Primitive> Undefined() {
519 i::Isolate* isolate = i::Isolate::Current(); 519 i::Isolate* isolate = i::Isolate::Current();
520 if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) { 520 if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) {
521 return v8::Handle<v8::Primitive>(); 521 return v8::Handle<v8::Primitive>();
522 } 522 }
523 return v8::Handle<Primitive>(ToApi<Primitive>( 523 return v8::Handle<Primitive>(ToApi<Primitive>(
524 isolate->factory()->undefined_value())); 524 isolate->factory()->undefined_value()));
525 } 525 }
526 526
527 527
528 class internal::HeapVisualizerImplementation {
529 public:
530 static void Register(HeapVisualizer* that);
531 static void Deregister(HeapVisualizer* that);
532 };
533
534
535 void RegisterHeapVisualizer(HeapVisualizer* that) {
536 i::HeapVisualizerImplementation::Register(that);
537 }
538
539
540 void DeRegisterHeapVisualizer(HeapVisualizer* that) {
541 i::HeapVisualizerImplementation::Deregister(that);
542 }
543
544
545 void v8::internal::HeapVisualizerImplementation::Register(
546 HeapVisualizer* that) {
547 Heap* heap = Isolate::Current()->heap();
548 heap->UpdateVisualizer(that);
549
550 HeapVisualizer* prev = heap->visualizer();
551 that->set_next(prev);
552 heap->set_visualizer(that);
553 }
554
555
556 void v8::internal::HeapVisualizerImplementation::Deregister(
557 HeapVisualizer* that) {
558 Heap* heap = Isolate::Current()->heap();
559 HeapVisualizer* prev = NULL;
560 for (HeapVisualizer* current = heap->visualizer();
561 current != NULL;
562 current = current->next()) {
563 if (current == that) {
564 if (prev == NULL) {
565 heap->set_visualizer(that->next());
566 } else {
567 prev->set_next(that->next());
568 }
569 return;
570 }
571 }
572 UNREACHABLE(); // Tried to deregister unregistered visualizer.
573 }
574
575
576 void v8::HeapVisualizer::WriteX(unsigned char* bytes, int len) {
577 if (kBufferSize - buffer_fullness_ < len) {
578 Flush();
579 }
580 while (len > kBufferSize) {
581 memcpy(buffer_, bytes, kBufferSize);
582 len -= kBufferSize;
583 bytes += kBufferSize;
584 buffer_fullness_ = kBufferSize;
585 Flush();
586 }
587 memcpy(buffer_ + buffer_fullness_, bytes, len);
588 buffer_fullness_ += len;
589 }
590
591
528 v8::Handle<Primitive> Null() { 592 v8::Handle<Primitive> Null() {
529 i::Isolate* isolate = i::Isolate::Current(); 593 i::Isolate* isolate = i::Isolate::Current();
530 if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) { 594 if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) {
531 return v8::Handle<v8::Primitive>(); 595 return v8::Handle<v8::Primitive>();
532 } 596 }
533 return v8::Handle<Primitive>( 597 return v8::Handle<Primitive>(
534 ToApi<Primitive>(isolate->factory()->null_value())); 598 ToApi<Primitive>(isolate->factory()->null_value()));
535 } 599 }
536 600
537 601
(...skipping 5555 matching lines...) Expand 10 before | Expand all | Expand 10 after
6093 6157
6094 6158
6095 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 6159 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6096 HandleScopeImplementer* scope_implementer = 6160 HandleScopeImplementer* scope_implementer =
6097 reinterpret_cast<HandleScopeImplementer*>(storage); 6161 reinterpret_cast<HandleScopeImplementer*>(storage);
6098 scope_implementer->IterateThis(v); 6162 scope_implementer->IterateThis(v);
6099 return storage + ArchiveSpacePerThread(); 6163 return storage + ArchiveSpacePerThread();
6100 } 6164 }
6101 6165
6102 } } // namespace v8::internal 6166 } } // namespace v8::internal
OLDNEW
« 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