From 8204dfa186ab3e7a88aaf9482fdaddec833fa18b Mon Sep 17 00:00:00 2001 From: "yurys@chromium.org" Date: Wed, 20 Mar 2013 12:41:00 +0000 Subject: [PATCH] Deprecate HeapSnapshot type There is only one type of heap snapshot - kFull and we are not going to add any new types. BUG=None Review URL: https://codereview.chromium.org/12943004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14005 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8-profiler.h | 5 ++--- src/api.cc | 15 +++------------ src/heap-profiler.cc | 26 +++++++------------------- src/heap-profiler.h | 2 -- src/heap-snapshot-generator.cc | 12 ++++-------- src/heap-snapshot-generator.h | 10 +--------- 6 files changed, 17 insertions(+), 53 deletions(-) diff --git a/include/v8-profiler.h b/include/v8-profiler.h index 7dd874f..34e2dbe 100644 --- a/include/v8-profiler.h +++ b/include/v8-profiler.h @@ -321,8 +321,8 @@ class V8EXPORT HeapSnapshot { kJSON = 0 // See format description near 'Serialize' method. }; - /** Returns heap snapshot type. */ - Type GetType() const; + /** Deprecated. Returns kFull. */ + V8_DEPRECATED(Type GetType() const); /** Returns heap snapshot UID (assigned by the profiler.) */ unsigned GetUid() const; @@ -451,7 +451,6 @@ class V8EXPORT HeapProfiler { ObjectNameResolver* global_object_name_resolver = NULL); /** * Takes a heap snapshot and returns it. Title may be an empty string. - * See HeapSnapshot::Type for types description. */ const HeapSnapshot* TakeHeapSnapshot( Handle title, diff --git a/src/api.cc b/src/api.cc index 1d75db5..909dd09 100644 --- a/src/api.cc +++ b/src/api.cc @@ -6727,7 +6727,7 @@ void HeapSnapshot::Delete() { HeapSnapshot::Type HeapSnapshot::GetType() const { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetType"); - return static_cast(ToInternal(this)->type()); + return kFull; } @@ -6861,17 +6861,9 @@ const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle title, ObjectNameResolver* resolver) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot"); - i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull; - switch (type) { - case HeapSnapshot::kFull: - internal_type = i::HeapSnapshot::kFull; - break; - default: - UNREACHABLE(); - } return reinterpret_cast( isolate->heap_profiler()->TakeSnapshot( - *Utils::OpenHandle(*title), internal_type, control, resolver)); + *Utils::OpenHandle(*title), control, resolver)); } @@ -6881,8 +6873,7 @@ const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( ObjectNameResolver* resolver) { return reinterpret_cast( reinterpret_cast(this)->TakeSnapshot( - *Utils::OpenHandle(*title), i::HeapSnapshot::kFull, - control, resolver)); + *Utils::OpenHandle(*title), control, resolver)); } diff --git a/src/heap-profiler.cc b/src/heap-profiler.cc index a7f6c36..5c1badf 100644 --- a/src/heap-profiler.cc +++ b/src/heap-profiler.cc @@ -72,25 +72,15 @@ v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback( HeapSnapshot* HeapProfiler::TakeSnapshot( const char* name, - int type, v8::ActivityControl* control, v8::HeapProfiler::ObjectNameResolver* resolver) { - HeapSnapshot::Type s_type = static_cast(type); - HeapSnapshot* result = - snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); - bool generation_completed = true; - switch (s_type) { - case HeapSnapshot::kFull: { - HeapSnapshotGenerator generator(result, control, resolver, heap()); - generation_completed = generator.GenerateSnapshot(); - break; + HeapSnapshot* result = snapshots_->NewSnapshot(name, next_snapshot_uid_++); + { + HeapSnapshotGenerator generator(result, control, resolver, heap()); + if (!generator.GenerateSnapshot()) { + delete result; + result = NULL; } - default: - UNREACHABLE(); - } - if (!generation_completed) { - delete result; - result = NULL; } snapshots_->SnapshotGenerationFinished(result); return result; @@ -99,11 +89,9 @@ HeapSnapshot* HeapProfiler::TakeSnapshot( HeapSnapshot* HeapProfiler::TakeSnapshot( String* name, - int type, v8::ActivityControl* control, v8::HeapProfiler::ObjectNameResolver* resolver) { - return TakeSnapshot(snapshots_->names()->GetName(name), type, control, - resolver); + return TakeSnapshot(snapshots_->names()->GetName(name), control, resolver); } void HeapProfiler::StartHeapObjectsTracking() { diff --git a/src/heap-profiler.h b/src/heap-profiler.h index 75b1af1..3f3138d 100644 --- a/src/heap-profiler.h +++ b/src/heap-profiler.h @@ -53,12 +53,10 @@ class HeapProfiler { HeapSnapshot* TakeSnapshot( const char* name, - int type, v8::ActivityControl* control, v8::HeapProfiler::ObjectNameResolver* resolver); HeapSnapshot* TakeSnapshot( String* name, - int type, v8::ActivityControl* control, v8::HeapProfiler::ObjectNameResolver* resolver); diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc index 824e507..fb239aa 100644 --- a/src/heap-snapshot-generator.cc +++ b/src/heap-snapshot-generator.cc @@ -189,7 +189,7 @@ template <> struct SnapshotSizeConstants<4> { static const int kExpectedHeapGraphEdgeSize = 12; static const int kExpectedHeapEntrySize = 24; static const int kExpectedHeapSnapshotsCollectionSize = 100; - static const int kExpectedHeapSnapshotSize = 136; + static const int kExpectedHeapSnapshotSize = 132; static const size_t kMaxSerializableSnapshotRawSize = 256 * MB; }; @@ -197,7 +197,7 @@ template <> struct SnapshotSizeConstants<8> { static const int kExpectedHeapGraphEdgeSize = 24; static const int kExpectedHeapEntrySize = 32; static const int kExpectedHeapSnapshotsCollectionSize = 152; - static const int kExpectedHeapSnapshotSize = 168; + static const int kExpectedHeapSnapshotSize = 160; static const uint64_t kMaxSerializableSnapshotRawSize = static_cast(6000) * MB; }; @@ -205,11 +205,9 @@ template <> struct SnapshotSizeConstants<8> { } // namespace HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection, - HeapSnapshot::Type type, const char* title, unsigned uid) : collection_(collection), - type_(type), title_(title), uid_(uid), root_index_(HeapEntry::kNoEntry), @@ -599,11 +597,10 @@ HeapSnapshotsCollection::~HeapSnapshotsCollection() { } -HeapSnapshot* HeapSnapshotsCollection::NewSnapshot(HeapSnapshot::Type type, - const char* name, +HeapSnapshot* HeapSnapshotsCollection::NewSnapshot(const char* name, unsigned uid) { is_tracking_objects_ = true; // Start watching for heap objects moves. - return new HeapSnapshot(this, type, name, uid); + return new HeapSnapshot(this, name, uid); } @@ -2410,7 +2407,6 @@ void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) { HeapSnapshot* HeapSnapshotJSONSerializer::CreateFakeSnapshot() { HeapSnapshot* result = new HeapSnapshot(snapshot_->collection(), - HeapSnapshot::kFull, snapshot_->title(), snapshot_->uid()); result->AddRootEntry(); diff --git a/src/heap-snapshot-generator.h b/src/heap-snapshot-generator.h index 08c2fe7..a4fcef7 100644 --- a/src/heap-snapshot-generator.h +++ b/src/heap-snapshot-generator.h @@ -157,18 +157,12 @@ class HeapSnapshotsCollection; // HeapSnapshotGenerator fills in a HeapSnapshot. class HeapSnapshot { public: - enum Type { - kFull = v8::HeapSnapshot::kFull - }; - HeapSnapshot(HeapSnapshotsCollection* collection, - Type type, const char* title, unsigned uid); void Delete(); HeapSnapshotsCollection* collection() { return collection_; } - Type type() { return type_; } const char* title() { return title_; } unsigned uid() { return uid_; } size_t RawSnapshotSize() const; @@ -203,7 +197,6 @@ class HeapSnapshot { private: HeapSnapshotsCollection* collection_; - Type type_; const char* title_; unsigned uid_; int root_index_; @@ -305,8 +298,7 @@ class HeapSnapshotsCollection { void StartHeapObjectsTracking() { is_tracking_objects_ = true; } void StopHeapObjectsTracking() { ids_.StopHeapObjectsTracking(); } - HeapSnapshot* NewSnapshot( - HeapSnapshot::Type type, const char* name, unsigned uid); + HeapSnapshot* NewSnapshot(const char* name, unsigned uid); void SnapshotGenerationFinished(HeapSnapshot* snapshot); List* snapshots() { return &snapshots_; } HeapSnapshot* GetSnapshot(unsigned uid); -- 2.7.4