From ed3809c3181ac940ff9c89686180e2b5580ee50e Mon Sep 17 00:00:00 2001 From: "danno@chromium.org" Date: Thu, 21 Mar 2013 14:42:17 +0000 Subject: [PATCH] Maintain API compatibility with older versions of V8. Revert "Allow recording individual samples in addition to the aggregated CPU profiles" Revert "Isolatify CPU profiler" Revert "Isolatify HeapProfiler" Revert "Deprecate HeapSnapshot type" Revert "Isolatify CPU profiler public API" Revert "MSVS compilation fix after r14006" Revert "Add methods to allow resuming execution after calling TerminateExecution()." R=jkummerow@chromium.org,mstarzinger@chromium.org Review URL: https://codereview.chromium.org/12475016 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14031 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- AUTHORS | 1 - include/v8-profiler.h | 135 ++++--------------- include/v8.h | 62 ++------- src/api.cc | 224 +++++--------------------------- src/codegen.cc | 3 +- src/compiler.cc | 2 +- src/cpu-profiler.cc | 149 ++++++++++++++------- src/cpu-profiler.h | 103 ++++++++------- src/execution.cc | 7 - src/execution.h | 1 - src/heap-profiler.cc | 125 +++++++++++++++--- src/heap-profiler.h | 46 +++++-- src/heap-snapshot-generator.cc | 12 +- src/heap-snapshot-generator.h | 10 +- src/heap.cc | 4 +- src/isolate.cc | 32 +---- src/isolate.h | 11 +- src/log.cc | 16 +-- src/log.h | 1 - src/platform-cygwin.cc | 5 +- src/platform-freebsd.cc | 2 +- src/platform-linux.cc | 2 +- src/platform-macos.cc | 5 +- src/platform-openbsd.cc | 2 +- src/platform-solaris.cc | 2 +- src/platform-win32.cc | 5 +- src/profile-generator-inl.h | 3 +- src/profile-generator.cc | 19 +-- src/profile-generator.h | 19 +-- src/runtime.cc | 2 +- test/cctest/test-cpu-profiler.cc | 167 ++++++++++++------------ test/cctest/test-heap-profiler.cc | 230 ++++++++++++++------------------- test/cctest/test-profile-generator.cc | 113 ++-------------- test/cctest/test-thread-termination.cc | 37 ------ 34 files changed, 633 insertions(+), 924 deletions(-) diff --git a/AUTHORS b/AUTHORS index 1a927c4..d25fc5a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -9,7 +9,6 @@ ARM Ltd. Hewlett-Packard Development Company, LP Igalia, S.L. Joyent, Inc. -Bloomberg Finance L.P. Akinori MUSHA Alexander Botero-Lowry diff --git a/include/v8-profiler.h b/include/v8-profiler.h index 68f377c..90a3d4d 100644 --- a/include/v8-profiler.h +++ b/include/v8-profiler.h @@ -105,9 +105,6 @@ class V8EXPORT CpuProfileNode { /** Returns function entry UID. */ unsigned GetCallUid() const; - /** Returns id of the node. The id is unique within the tree */ - unsigned GetNodeId() const; - /** Returns child nodes count of the node. */ int GetChildrenCount() const; @@ -134,18 +131,6 @@ class V8EXPORT CpuProfile { const CpuProfileNode* GetTopDownRoot() const; /** - * Returns number of samples recorded. The samples are not recorded unless - * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true. - */ - int GetSamplesCount() const; - - /** - * Returns profile node corresponding to the top frame the sample at - * the given index. - */ - const CpuProfileNode* GetSample(int index) const; - - /** * Deletes the profile and removes it from CpuProfiler's list. * All pointers to nodes previously returned become invalid. * Profiles with the same uid but obtained using different @@ -158,8 +143,7 @@ class V8EXPORT CpuProfile { /** - * Interface for controlling CPU profiling. Instance of the - * profiler can be retrieved using v8::Isolate::GetCpuProfiler. + * Interface for controlling CPU profiling. */ class V8EXPORT CpuProfiler { public: @@ -172,34 +156,22 @@ class V8EXPORT CpuProfiler { * obtaining profiling results. */ - /** Deprecated. Use GetProfileCount instead. */ - static int GetProfilesCount(); /** * Returns the number of profiles collected (doesn't include * profiles that are being collected at the moment of call.) */ - int GetProfileCount(); + static int GetProfilesCount(); - /** Deprecated. Use GetCpuProfile instead. */ - static const CpuProfile* GetProfile( - int index, - Handle security_token = Handle()); /** Returns a profile by index. */ - const CpuProfile* GetCpuProfile( + static const CpuProfile* GetProfile( int index, Handle security_token = Handle()); - /** Deprecated. Use FindProfile instead. */ - static const CpuProfile* FindProfile( - unsigned uid, - Handle security_token = Handle()); /** Returns a profile by uid. */ - const CpuProfile* FindCpuProfile( + static const CpuProfile* FindProfile( unsigned uid, Handle security_token = Handle()); - /** Deprecated. Use StartCpuProfiling instead. */ - static void StartProfiling(Handle title, bool record_samples = false); /** * Starts collecting CPU profile. Title may be an empty string. It * is allowed to have several profiles being collected at @@ -207,38 +179,23 @@ class V8EXPORT CpuProfiler { * title are silently ignored. While collecting a profile, functions * from all security contexts are included in it. The token-based * filtering is only performed when querying for a profile. - * - * |record_samples| parameter controls whether individual samples should - * be recorded in addition to the aggregated tree. */ - void StartCpuProfiling(Handle title, bool record_samples = false); + static void StartProfiling(Handle title); - /** Deprecated. Use StopCpuProfiling instead. */ - static const CpuProfile* StopProfiling( - Handle title, - Handle security_token = Handle()); /** * Stops collecting CPU profile with a given title and returns it. * If the title given is empty, finishes the last profile started. */ - const CpuProfile* StopCpuProfiling( + static const CpuProfile* StopProfiling( Handle title, Handle security_token = Handle()); - /** Deprecated. Use DeleteAllCpuProfiles instead. */ - static void DeleteAllProfiles(); /** * Deletes all existing profiles, also cancelling all profiling * activity. All previously returned pointers to profiles and their * contents become invalid after this call. */ - void DeleteAllCpuProfiles(); - - private: - CpuProfiler(); - ~CpuProfiler(); - CpuProfiler(const CpuProfiler&); - CpuProfiler& operator=(const CpuProfiler&); + static void DeleteAllProfiles(); }; @@ -346,8 +303,8 @@ class V8EXPORT HeapSnapshot { kJSON = 0 // See format description near 'Serialize' method. }; - /** Deprecated. Returns kFull. */ - V8_DEPRECATED(Type GetType() const); + /** Returns heap snapshot type. */ + Type GetType() const; /** Returns heap snapshot UID (assigned by the profiler.) */ unsigned GetUid() const; @@ -410,8 +367,7 @@ class V8EXPORT HeapSnapshot { class RetainedObjectInfo; /** - * Interface for controlling heap profiling. Instance of the - * profiler can be retrieved using v8::Isolate::GetHeapProfiler. + * Interface for controlling heap profiling. */ class V8EXPORT HeapProfiler { public: @@ -424,28 +380,20 @@ class V8EXPORT HeapProfiler { typedef RetainedObjectInfo* (*WrapperInfoCallback) (uint16_t class_id, Handle wrapper); - /** Deprecated. Use GetSnapshotCount instead. */ - static int GetSnapshotsCount(); /** Returns the number of snapshots taken. */ - int GetSnapshotCount(); + static int GetSnapshotsCount(); - /** Deprecated. Use GetHeapSnapshot instead. */ - static const HeapSnapshot* GetSnapshot(int index); /** Returns a snapshot by index. */ - const HeapSnapshot* GetHeapSnapshot(int index); + static const HeapSnapshot* GetSnapshot(int index); - /** Deprecated. Use FindHeapSnapshot instead. */ - static const HeapSnapshot* FindSnapshot(unsigned uid); /** Returns a profile by uid. */ - const HeapSnapshot* FindHeapSnapshot(unsigned uid); + static const HeapSnapshot* FindSnapshot(unsigned uid); - /** Deprecated. Use GetObjectId instead. */ - static SnapshotObjectId GetSnapshotObjectId(Handle value); /** * Returns SnapshotObjectId for a heap object referenced by |value| if * it has been seen by the heap profiler, kUnknownObjectId otherwise. */ - SnapshotObjectId GetObjectId(Handle value); + static SnapshotObjectId GetSnapshotObjectId(Handle value); /** * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return @@ -458,42 +406,33 @@ class V8EXPORT HeapProfiler { * Callback interface for retrieving user friendly names of global objects. */ class ObjectNameResolver { - public: + public: /** * Returns name to be used in the heap snapshot for given node. Returned * string must stay alive until snapshot collection is completed. */ virtual const char* GetName(Handle object) = 0; - protected: + protected: virtual ~ObjectNameResolver() {} }; - /** Deprecated. Use TakeHeapSnapshot instead. */ - static const HeapSnapshot* TakeSnapshot( - Handle title, - HeapSnapshot::Type type = HeapSnapshot::kFull, - ActivityControl* control = NULL, - 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( + static const HeapSnapshot* TakeSnapshot( Handle title, + HeapSnapshot::Type type = HeapSnapshot::kFull, ActivityControl* control = NULL, ObjectNameResolver* global_object_name_resolver = NULL); - - /** Deprecated. Use StartTrackingHeapObjects instead. */ - static void StartHeapObjectsTracking(); /** * Starts tracking of heap objects population statistics. After calling * this method, all heap objects relocations done by the garbage collector * are being registered. */ - void StartTrackingHeapObjects(); + static void StartHeapObjectsTracking(); - /** Deprecated. Use GetHeapStats instead. */ - static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); /** * Adds a new time interval entry to the aggregated statistics array. The * time interval entry contains information on the current heap objects @@ -503,34 +442,26 @@ class V8EXPORT HeapProfiler { * HeapStatsUpdate structure instances. * The return value of the function is the last seen heap object Id. * - * StartTrackingHeapObjects must be called before the first call to this + * StartHeapObjectsTracking must be called before the first call to this * method. */ - SnapshotObjectId GetHeapStats(OutputStream* stream); + static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); - /** Deprecated. Use StopTrackingHeapObjects instead. */ - static void StopHeapObjectsTracking(); /** * Stops tracking of heap objects population statistics, cleans up all * collected data. StartHeapObjectsTracking must be called again prior to * calling PushHeapObjectsStats next time. */ - void StopTrackingHeapObjects(); + static void StopHeapObjectsTracking(); - /** Deprecated. Use DeleteAllHeapSnapshots instead. */ - static void DeleteAllSnapshots(); /** * Deletes all snapshots taken. All previously returned pointers to * snapshots and their contents become invalid after this call. */ - void DeleteAllHeapSnapshots(); + static void DeleteAllSnapshots(); - /** Deprecated. Use SetWrapperClassInfoProvider instead. */ - static void DefineWrapperClass( - uint16_t class_id, - WrapperInfoCallback callback); /** Binds a callback to embedder's class ID. */ - void SetWrapperClassInfoProvider( + static void DefineWrapperClass( uint16_t class_id, WrapperInfoCallback callback); @@ -541,21 +472,11 @@ class V8EXPORT HeapProfiler { */ static const uint16_t kPersistentHandleNoClassId = 0; - /** - * Deprecated. Returns the number of currently existing persistent handles. - */ + /** Returns the number of currently existing persistent handles. */ static int GetPersistentHandleCount(); - /** Deprecated. Use GetHeapProfilerMemorySize instead. */ - static size_t GetMemorySizeUsedByProfiler(); /** Returns memory used for profiler internal data and snapshots. */ - size_t GetProfilerMemorySize(); - - private: - HeapProfiler(); - ~HeapProfiler(); - HeapProfiler(const HeapProfiler&); - HeapProfiler& operator=(const HeapProfiler&); + static size_t GetMemorySizeUsedByProfiler(); }; @@ -635,7 +556,7 @@ class V8EXPORT RetainedObjectInfo { // NOLINT /** * A struct for exporting HeapStats data from V8, using "push" model. - * See HeapProfiler::GetHeapStats. + * See HeapProfiler::PushHeapObjectsStats. */ struct HeapStatsUpdate { HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size) diff --git a/include/v8.h b/include/v8.h index ff76eca..329576f 100644 --- a/include/v8.h +++ b/include/v8.h @@ -103,14 +103,12 @@ class Array; class Boolean; class BooleanObject; class Context; -class CpuProfiler; class Data; class Date; class DeclaredAccessorDescriptor; class External; class Function; class FunctionTemplate; -class HeapProfiler; class ImplementationUtilities; class Int32; class Integer; @@ -3024,18 +3022,6 @@ class V8EXPORT Isolate { */ intptr_t AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes); - /** - * Returns heap profiler for this isolate. Will return NULL until the isolate - * is initialized. - */ - HeapProfiler* GetHeapProfiler(); - - /** - * Returns CPU profiler for this isolate. Will return NULL until the isolate - * is initialized. - */ - CpuProfiler* GetCpuProfiler(); - private: Isolate(); Isolate(const Isolate&); @@ -3602,24 +3588,6 @@ class V8EXPORT V8 { static bool IsExecutionTerminating(Isolate* isolate = NULL); /** - * Resume execution capability in the given isolate, whose execution - * was previously forcefully terminated using TerminateExecution(). - * - * When execution is forcefully terminated using TerminateExecution(), - * the isolate can not resume execution until all JavaScript frames - * have propagated the uncatchable exception which is generated. This - * method allows the program embedding the engine to handle the - * termination event and resume execution capability, even if - * JavaScript frames remain on the stack. - * - * This method can be used by any thread even if that thread has not - * acquired the V8 lock with a Locker object. - * - * \param isolate The isolate in which to resume execution capability. - */ - static void CancelTerminateExecution(Isolate* isolate); - - /** * Releases any resources used by v8 and stops any utility threads * that may be running. Note that disposing v8 is permanent, it * cannot be reinitialized. @@ -3729,28 +3697,19 @@ class V8EXPORT TryCatch { bool HasCaught() const; /** - * For certain types of exceptions, it makes no sense to continue execution. - * - * If CanContinue returns false, the correct action is to perform any C++ - * cleanup needed and then return. If CanContinue returns false and - * HasTerminated returns true, it is possible to call - * CancelTerminateExecution in order to continue calling into the engine. - */ - bool CanContinue() const; - - /** - * Returns true if an exception has been caught due to script execution - * being terminated. + * For certain types of exceptions, it makes no sense to continue + * execution. * - * There is no JavaScript representation of an execution termination - * exception. Such exceptions are thrown when the TerminateExecution - * methods are called to terminate a long-running script. + * Currently, the only type of exception that can be caught by a + * TryCatch handler and for which it does not make sense to continue + * is termination exception. Such exceptions are thrown when the + * TerminateExecution methods are called to terminate a long-running + * script. * - * If such an exception has been thrown, HasTerminated will return true, - * indicating that it is possible to call CancelTerminateExecution in order - * to continue calling into the engine. + * If CanContinue returns false, the correct action is to perform + * any C++ cleanup needed and then return. */ - bool HasTerminated() const; + bool CanContinue() const; /** * Throws the exception caught by this TryCatch in a way that avoids @@ -3827,7 +3786,6 @@ class V8EXPORT TryCatch { bool can_continue_ : 1; bool capture_message_ : 1; bool rethrow_ : 1; - bool has_terminated_ : 1; friend class v8::internal::Isolate; }; diff --git a/src/api.cc b/src/api.cc index f002315..64c0022 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1885,8 +1885,7 @@ v8::TryCatch::TryCatch() is_verbose_(false), can_continue_(true), capture_message_(true), - rethrow_(false), - has_terminated_(false) { + rethrow_(false) { isolate_->RegisterTryCatchHandler(this); } @@ -1914,11 +1913,6 @@ bool v8::TryCatch::CanContinue() const { } -bool v8::TryCatch::HasTerminated() const { - return has_terminated_; -} - - v8::Handle v8::TryCatch::ReThrow() { if (!HasCaught()) return v8::Local(); rethrow_ = true; @@ -5813,20 +5807,6 @@ intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) { } -HeapProfiler* Isolate::GetHeapProfiler() { - i::HeapProfiler* heap_profiler = - reinterpret_cast(this)->heap_profiler(); - return reinterpret_cast(heap_profiler); -} - - -CpuProfiler* Isolate::GetCpuProfiler() { - i::CpuProfiler* cpu_profiler = - reinterpret_cast(this)->cpu_profiler(); - return reinterpret_cast(cpu_profiler); -} - - void V8::SetGlobalGCPrologueCallback(GCCallback callback) { i::Isolate* isolate = i::Isolate::Current(); if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCPrologueCallback()")) return; @@ -5962,12 +5942,6 @@ bool V8::IsExecutionTerminating(Isolate* isolate) { } -void V8::CancelTerminateExecution(Isolate* isolate) { - i::Isolate* i_isolate = reinterpret_cast(isolate); - i_isolate->stack_guard()->CancelTerminateExecution(); -} - - Isolate* Isolate::GetCurrent() { i::Isolate* isolate = i::Isolate::UncheckedCurrent(); return reinterpret_cast(isolate); @@ -6480,11 +6454,6 @@ unsigned CpuProfileNode::GetCallUid() const { } -unsigned CpuProfileNode::GetNodeId() const { - return reinterpret_cast(this)->id(); -} - - int CpuProfileNode::GetChildrenCount() const { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount"); @@ -6504,12 +6473,11 @@ const CpuProfileNode* CpuProfileNode::GetChild(int index) const { void CpuProfile::Delete() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfile::Delete"); - i::CpuProfiler* profiler = isolate->cpu_profiler(); - ASSERT(profiler != NULL); - profiler->DeleteProfile(reinterpret_cast(this)); - if (profiler->GetProfilesCount() == 0 && !profiler->HasDetachedProfiles()) { + i::CpuProfiler::DeleteProfile(reinterpret_cast(this)); + if (i::CpuProfiler::GetProfilesCount() == 0 && + !i::CpuProfiler::HasDetachedProfiles()) { // If this was the last profile, clean up all accessory data as well. - profiler->DeleteAllProfiles(); + i::CpuProfiler::DeleteAllProfiles(); } } @@ -6538,28 +6506,10 @@ const CpuProfileNode* CpuProfile::GetTopDownRoot() const { } -const CpuProfileNode* CpuProfile::GetSample(int index) const { - const i::CpuProfile* profile = reinterpret_cast(this); - return reinterpret_cast(profile->sample(index)); -} - - -int CpuProfile::GetSamplesCount() const { - return reinterpret_cast(this)->samples_count(); -} - - int CpuProfiler::GetProfilesCount() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount"); - i::CpuProfiler* profiler = isolate->cpu_profiler(); - ASSERT(profiler != NULL); - return profiler->GetProfilesCount(); -} - - -int CpuProfiler::GetProfileCount() { - return reinterpret_cast(this)->GetProfilesCount(); + return i::CpuProfiler::GetProfilesCount(); } @@ -6567,19 +6517,8 @@ const CpuProfile* CpuProfiler::GetProfile(int index, Handle security_token) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile"); - i::CpuProfiler* profiler = isolate->cpu_profiler(); - ASSERT(profiler != NULL); return reinterpret_cast( - profiler->GetProfile( - security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), - index)); -} - - -const CpuProfile* CpuProfiler::GetCpuProfile(int index, - Handle security_token) { - return reinterpret_cast( - reinterpret_cast(this)->GetProfile( + i::CpuProfiler::GetProfile( security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), index)); } @@ -6589,36 +6528,17 @@ const CpuProfile* CpuProfiler::FindProfile(unsigned uid, Handle security_token) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile"); - i::CpuProfiler* profiler = isolate->cpu_profiler(); - ASSERT(profiler != NULL); - return reinterpret_cast( - profiler->FindProfile( - security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), - uid)); -} - - -const CpuProfile* CpuProfiler::FindCpuProfile(unsigned uid, - Handle security_token) { return reinterpret_cast( - reinterpret_cast(this)->FindProfile( + i::CpuProfiler::FindProfile( security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), uid)); } -void CpuProfiler::StartProfiling(Handle title, bool record_samples) { +void CpuProfiler::StartProfiling(Handle title) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling"); - i::CpuProfiler* profiler = isolate->cpu_profiler(); - ASSERT(profiler != NULL); - profiler->StartProfiling(*Utils::OpenHandle(*title), record_samples); -} - - -void CpuProfiler::StartCpuProfiling(Handle title, bool record_samples) { - reinterpret_cast(this)->StartProfiling( - *Utils::OpenHandle(*title), record_samples); + i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title)); } @@ -6626,19 +6546,8 @@ const CpuProfile* CpuProfiler::StopProfiling(Handle title, Handle security_token) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling"); - i::CpuProfiler* profiler = isolate->cpu_profiler(); - ASSERT(profiler != NULL); - return reinterpret_cast( - profiler->StopProfiling( - security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), - *Utils::OpenHandle(*title))); -} - - -const CpuProfile* CpuProfiler::StopCpuProfiling(Handle title, - Handle security_token) { return reinterpret_cast( - reinterpret_cast(this)->StopProfiling( + i::CpuProfiler::StopProfiling( security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), *Utils::OpenHandle(*title))); } @@ -6647,14 +6556,7 @@ const CpuProfile* CpuProfiler::StopCpuProfiling(Handle title, void CpuProfiler::DeleteAllProfiles() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles"); - i::CpuProfiler* profiler = isolate->cpu_profiler(); - ASSERT(profiler != NULL); - profiler->DeleteAllProfiles(); -} - - -void CpuProfiler::DeleteAllCpuProfiles() { - reinterpret_cast(this)->DeleteAllProfiles(); + i::CpuProfiler::DeleteAllProfiles(); } @@ -6777,11 +6679,11 @@ static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { void HeapSnapshot::Delete() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); - if (isolate->heap_profiler()->GetSnapshotsCount() > 1) { + if (i::HeapProfiler::GetSnapshotsCount() > 1) { ToInternal(this)->Delete(); } else { // If this is the last snapshot, clean up all accessory data as well. - isolate->heap_profiler()->DeleteAllSnapshots(); + i::HeapProfiler::DeleteAllSnapshots(); } } @@ -6789,7 +6691,7 @@ void HeapSnapshot::Delete() { HeapSnapshot::Type HeapSnapshot::GetType() const { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetType"); - return kFull; + return static_cast(ToInternal(this)->type()); } @@ -6866,12 +6768,7 @@ void HeapSnapshot::Serialize(OutputStream* stream, int HeapProfiler::GetSnapshotsCount() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount"); - return isolate->heap_profiler()->GetSnapshotsCount(); -} - - -int HeapProfiler::GetSnapshotCount() { - return reinterpret_cast(this)->GetSnapshotsCount(); + return i::HeapProfiler::GetSnapshotsCount(); } @@ -6879,13 +6776,7 @@ const HeapSnapshot* HeapProfiler::GetSnapshot(int index) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot"); return reinterpret_cast( - isolate->heap_profiler()->GetSnapshot(index)); -} - - -const HeapSnapshot* HeapProfiler::GetHeapSnapshot(int index) { - return reinterpret_cast( - reinterpret_cast(this)->GetSnapshot(index)); + i::HeapProfiler::GetSnapshot(index)); } @@ -6893,13 +6784,7 @@ const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot"); return reinterpret_cast( - isolate->heap_profiler()->FindSnapshot(uid)); -} - - -const HeapSnapshot* HeapProfiler::FindHeapSnapshot(unsigned uid) { - return reinterpret_cast( - reinterpret_cast(this)->FindSnapshot(uid)); + i::HeapProfiler::FindSnapshot(uid)); } @@ -6907,13 +6792,7 @@ SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle value) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotObjectId"); i::Handle obj = Utils::OpenHandle(*value); - return isolate->heap_profiler()->GetSnapshotObjectId(obj); -} - - -SnapshotObjectId HeapProfiler::GetObjectId(Handle value) { - i::Handle obj = Utils::OpenHandle(*value); - return reinterpret_cast(this)->GetSnapshotObjectId(obj); + return i::HeapProfiler::GetSnapshotObjectId(obj); } @@ -6923,67 +6802,45 @@ 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), control, resolver)); -} - - -const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( - Handle title, - ActivityControl* control, - ObjectNameResolver* resolver) { - return reinterpret_cast( - reinterpret_cast(this)->TakeSnapshot( - *Utils::OpenHandle(*title), control, resolver)); + i::HeapProfiler::TakeSnapshot( + *Utils::OpenHandle(*title), internal_type, control, resolver)); } void HeapProfiler::StartHeapObjectsTracking() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::StartHeapObjectsTracking"); - isolate->heap_profiler()->StartHeapObjectsTracking(); -} - - -void HeapProfiler::StartTrackingHeapObjects() { - reinterpret_cast(this)->StartHeapObjectsTracking(); + i::HeapProfiler::StartHeapObjectsTracking(); } void HeapProfiler::StopHeapObjectsTracking() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::StopHeapObjectsTracking"); - isolate->heap_profiler()->StopHeapObjectsTracking(); -} - - -void HeapProfiler::StopTrackingHeapObjects() { - reinterpret_cast(this)->StopHeapObjectsTracking(); + i::HeapProfiler::StopHeapObjectsTracking(); } SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::PushHeapObjectsStats"); - return isolate->heap_profiler()->PushHeapObjectsStats(stream); -} - - -SnapshotObjectId HeapProfiler::GetHeapStats(OutputStream* stream) { - return reinterpret_cast(this)->PushHeapObjectsStats(stream); + return i::HeapProfiler::PushHeapObjectsStats(stream); } void HeapProfiler::DeleteAllSnapshots() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots"); - isolate->heap_profiler()->DeleteAllSnapshots(); -} - - -void HeapProfiler::DeleteAllHeapSnapshots() { - reinterpret_cast(this)->DeleteAllSnapshots(); + i::HeapProfiler::DeleteAllSnapshots(); } @@ -6994,13 +6851,6 @@ void HeapProfiler::DefineWrapperClass(uint16_t class_id, } -void HeapProfiler::SetWrapperClassInfoProvider(uint16_t class_id, - WrapperInfoCallback callback) { - reinterpret_cast(this)->DefineWrapperClass(class_id, - callback); -} - - int HeapProfiler::GetPersistentHandleCount() { i::Isolate* isolate = i::Isolate::Current(); return isolate->global_handles()->NumberOfGlobalHandles(); @@ -7008,13 +6858,7 @@ int HeapProfiler::GetPersistentHandleCount() { size_t HeapProfiler::GetMemorySizeUsedByProfiler() { - return i::Isolate::Current()->heap_profiler()->GetMemorySizeUsedByProfiler(); -} - - -size_t HeapProfiler::GetProfilerMemorySize() { - return reinterpret_cast(this)-> - GetMemorySizeUsedByProfiler(); + return i::HeapProfiler::GetMemorySizeUsedByProfiler(); } diff --git a/src/codegen.cc b/src/codegen.cc index 90ab2b5..508e221 100644 --- a/src/codegen.cc +++ b/src/codegen.cc @@ -171,8 +171,7 @@ void CodeGenerator::PrintCode(Handle code, CompilationInfo* info) { bool CodeGenerator::ShouldGenerateLog(Expression* type) { ASSERT(type != NULL); Isolate* isolate = Isolate::Current(); - if (!isolate->logger()->is_logging() && - !isolate->cpu_profiler()->is_profiling()) { + if (!isolate->logger()->is_logging() && !CpuProfiler::is_profiling(isolate)) { return false; } Handle name = Handle::cast(type->AsLiteral()->handle()); diff --git a/src/compiler.cc b/src/compiler.cc index 2c4dae5..21ea25f 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1134,7 +1134,7 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, // script name and line number. Check explicitly whether logging is // enabled as finding the line number is not free. if (info->isolate()->logger()->is_logging_code_events() || - info->isolate()->cpu_profiler()->is_profiling()) { + CpuProfiler::is_profiling(info->isolate())) { Handle