Skip to content

Commit

Permalink
Merge commit '29157ad7bff859837056a5755109c5ac65fbe012' into hj-dev-p…
Browse files Browse the repository at this point in the history
…alfia
  • Loading branch information
Akos Palfi committed Apr 2, 2013
2 parents 15c2f59 + 29157ad commit bada9f9
Show file tree
Hide file tree
Showing 74 changed files with 2,135 additions and 1,063 deletions.
135 changes: 107 additions & 28 deletions include/v8-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ 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;

Expand All @@ -130,6 +133,18 @@ class V8EXPORT CpuProfile {
/** Returns the root node of the top down call tree. */
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.
Expand All @@ -143,7 +158,8 @@ class V8EXPORT CpuProfile {


/**
* Interface for controlling CPU profiling.
* Interface for controlling CPU profiling. Instance of the
* profiler can be retrieved using v8::Isolate::GetCpuProfiler.
*/
class V8EXPORT CpuProfiler {
public:
Expand All @@ -156,46 +172,73 @@ 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.)
*/
static int GetProfilesCount();
int GetProfileCount();

/** Returns a profile by index. */
/** Deprecated. Use GetCpuProfile instead. */
static const CpuProfile* GetProfile(
int index,
Handle<Value> security_token = Handle<Value>());
/** Returns a profile by index. */
const CpuProfile* GetCpuProfile(
int index,
Handle<Value> security_token = Handle<Value>());

/** Returns a profile by uid. */
/** Deprecated. Use FindProfile instead. */
static const CpuProfile* FindProfile(
unsigned uid,
Handle<Value> security_token = Handle<Value>());
/** Returns a profile by uid. */
const CpuProfile* FindCpuProfile(
unsigned uid,
Handle<Value> security_token = Handle<Value>());

/** Deprecated. Use StartCpuProfiling instead. */
static void StartProfiling(Handle<String> 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
* once. Attempts to start collecting several profiles with the same
* 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.
*/
static void StartProfiling(Handle<String> title);
void StartCpuProfiling(Handle<String> title, bool record_samples = false);

/** Deprecated. Use StopCpuProfiling instead. */
static const CpuProfile* StopProfiling(
Handle<String> title,
Handle<Value> security_token = Handle<Value>());
/**
* Stops collecting CPU profile with a given title and returns it.
* If the title given is empty, finishes the last profile started.
*/
static const CpuProfile* StopProfiling(
const CpuProfile* StopCpuProfiling(
Handle<String> title,
Handle<Value> security_token = Handle<Value>());

/** 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.
*/
static void DeleteAllProfiles();
void DeleteAllCpuProfiles();

private:
CpuProfiler();
~CpuProfiler();
CpuProfiler(const CpuProfiler&);
CpuProfiler& operator=(const CpuProfiler&);
};


Expand Down Expand Up @@ -303,8 +346,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;
Expand Down Expand Up @@ -367,7 +410,8 @@ class V8EXPORT HeapSnapshot {
class RetainedObjectInfo;

/**
* Interface for controlling heap profiling.
* Interface for controlling heap profiling. Instance of the
* profiler can be retrieved using v8::Isolate::GetHeapProfiler.
*/
class V8EXPORT HeapProfiler {
public:
Expand All @@ -380,20 +424,28 @@ class V8EXPORT HeapProfiler {
typedef RetainedObjectInfo* (*WrapperInfoCallback)
(uint16_t class_id, Handle<Value> wrapper);

/** Returns the number of snapshots taken. */
/** Deprecated. Use GetSnapshotCount instead. */
static int GetSnapshotsCount();
/** Returns the number of snapshots taken. */
int GetSnapshotCount();

/** Returns a snapshot by index. */
/** Deprecated. Use GetHeapSnapshot instead. */
static const HeapSnapshot* GetSnapshot(int index);
/** Returns a snapshot by index. */
const HeapSnapshot* GetHeapSnapshot(int index);

/** Returns a profile by uid. */
/** Deprecated. Use FindHeapSnapshot instead. */
static const HeapSnapshot* FindSnapshot(unsigned uid);
/** Returns a profile by uid. */
const HeapSnapshot* FindHeapSnapshot(unsigned uid);

/** Deprecated. Use GetObjectId instead. */
static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
/**
* Returns SnapshotObjectId for a heap object referenced by |value| if
* it has been seen by the heap profiler, kUnknownObjectId otherwise.
*/
static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
SnapshotObjectId GetObjectId(Handle<Value> value);

/**
* A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return
Expand All @@ -406,33 +458,42 @@ 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> object) = 0;
protected:
protected:
virtual ~ObjectNameResolver() {}
};

/** Deprecated. Use TakeHeapSnapshot instead. */
static const HeapSnapshot* TakeSnapshot(
Handle<String> 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.
*/
static const HeapSnapshot* TakeSnapshot(
const HeapSnapshot* TakeHeapSnapshot(
Handle<String> 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.
*/
static void StartHeapObjectsTracking();
void StartTrackingHeapObjects();

/** 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
Expand All @@ -442,28 +503,36 @@ class V8EXPORT HeapProfiler {
* HeapStatsUpdate structure instances.
* The return value of the function is the last seen heap object Id.
*
* StartHeapObjectsTracking must be called before the first call to this
* StartTrackingHeapObjects must be called before the first call to this
* method.
*/
static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
SnapshotObjectId GetHeapStats(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.
*/
static void StopHeapObjectsTracking();
void StopTrackingHeapObjects();

/** 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.
*/
static void DeleteAllSnapshots();
void DeleteAllHeapSnapshots();

/** Binds a callback to embedder's class ID. */
/** Deprecated. Use SetWrapperClassInfoProvider instead. */
static void DefineWrapperClass(
uint16_t class_id,
WrapperInfoCallback callback);
/** Binds a callback to embedder's class ID. */
void SetWrapperClassInfoProvider(
uint16_t class_id,
WrapperInfoCallback callback);

/**
* Default value of persistent handle class ID. Must not be used to
Expand All @@ -472,11 +541,21 @@ class V8EXPORT HeapProfiler {
*/
static const uint16_t kPersistentHandleNoClassId = 0;

/** Returns the number of currently existing persistent handles. */
/**
* Deprecated. Returns the number of currently existing persistent handles.
*/
static int GetPersistentHandleCount();

/** Returns memory used for profiler internal data and snapshots. */
/** 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&);
};


Expand Down Expand Up @@ -556,7 +635,7 @@ class V8EXPORT RetainedObjectInfo { // NOLINT

/**
* A struct for exporting HeapStats data from V8, using "push" model.
* See HeapProfiler::PushHeapObjectsStats.
* See HeapProfiler::GetHeapStats.
*/
struct HeapStatsUpdate {
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
Expand Down
14 changes: 14 additions & 0 deletions include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ 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;
Expand Down Expand Up @@ -3022,6 +3024,18 @@ 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&);
Expand Down
Loading

0 comments on commit bada9f9

Please sign in to comment.