v8-profiler.h | v8-profiler.h | |||
---|---|---|---|---|
skipping to change at line 38 | skipping to change at line 38 | |||
#ifndef V8_V8_PROFILER_H_ | #ifndef V8_V8_PROFILER_H_ | |||
#define V8_V8_PROFILER_H_ | #define V8_V8_PROFILER_H_ | |||
#include "v8.h" | #include "v8.h" | |||
/** | /** | |||
* Profiler support for the V8 JavaScript engine. | * Profiler support for the V8 JavaScript engine. | |||
*/ | */ | |||
namespace v8 { | namespace v8 { | |||
class HeapGraphNode; | ||||
struct HeapStatsUpdate; | ||||
typedef uint32_t SnapshotObjectId; | typedef uint32_t SnapshotObjectId; | |||
/** | /** | |||
* CpuProfileNode represents a node in a call graph. | * CpuProfileNode represents a node in a call graph. | |||
*/ | */ | |||
class V8_EXPORT CpuProfileNode { | class V8_EXPORT CpuProfileNode { | |||
public: | public: | |||
/** Returns function name (empty string for anonymous functions.) */ | /** Returns function name (empty string for anonymous functions.) */ | |||
Handle<String> GetFunctionName() const; | Handle<String> GetFunctionName() const; | |||
skipping to change at line 185 | skipping to change at line 188 | |||
*/ | */ | |||
void SetIdle(bool is_idle); | void SetIdle(bool is_idle); | |||
private: | private: | |||
CpuProfiler(); | CpuProfiler(); | |||
~CpuProfiler(); | ~CpuProfiler(); | |||
CpuProfiler(const CpuProfiler&); | CpuProfiler(const CpuProfiler&); | |||
CpuProfiler& operator=(const CpuProfiler&); | CpuProfiler& operator=(const CpuProfiler&); | |||
}; | }; | |||
class HeapGraphNode; | ||||
/** | /** | |||
* HeapSnapshotEdge represents a directed connection between heap | * HeapSnapshotEdge represents a directed connection between heap | |||
* graph nodes: from retainers to retained nodes. | * graph nodes: from retainers to retained nodes. | |||
*/ | */ | |||
class V8_EXPORT HeapGraphEdge { | class V8_EXPORT HeapGraphEdge { | |||
public: | public: | |||
enum Type { | enum Type { | |||
kContextVariable = 0, // A variable from a function context. | kContextVariable = 0, // A variable from a function context. | |||
kElement = 1, // An element of an array. | kElement = 1, // An element of an array. | |||
kProperty = 2, // A named object property. | kProperty = 2, // A named object property. | |||
skipping to change at line 275 | skipping to change at line 276 | |||
size_t GetShallowSize() const; | size_t GetShallowSize() const; | |||
/** Returns child nodes count of the node. */ | /** Returns child nodes count of the node. */ | |||
int GetChildrenCount() const; | int GetChildrenCount() const; | |||
/** Retrieves a child by index. */ | /** Retrieves a child by index. */ | |||
const HeapGraphEdge* GetChild(int index) const; | const HeapGraphEdge* GetChild(int index) const; | |||
}; | }; | |||
/** | /** | |||
* An interface for exporting data from V8, using "push" model. | ||||
*/ | ||||
class V8_EXPORT OutputStream { // NOLINT | ||||
public: | ||||
enum WriteResult { | ||||
kContinue = 0, | ||||
kAbort = 1 | ||||
}; | ||||
virtual ~OutputStream() {} | ||||
/** Notify about the end of stream. */ | ||||
virtual void EndOfStream() = 0; | ||||
/** Get preferred output chunk size. Called only once. */ | ||||
virtual int GetChunkSize() { return 1024; } | ||||
/** | ||||
* Writes the next chunk of snapshot data into the stream. Writing | ||||
* can be stopped by returning kAbort as function result. EndOfStream | ||||
* will not be called in case writing was aborted. | ||||
*/ | ||||
virtual WriteResult WriteAsciiChunk(char* data, int size) = 0; | ||||
/** | ||||
* Writes the next chunk of heap stats data into the stream. Writing | ||||
* can be stopped by returning kAbort as function result. EndOfStream | ||||
* will not be called in case writing was aborted. | ||||
*/ | ||||
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate* data, int count) | ||||
{ | ||||
return kAbort; | ||||
}; | ||||
}; | ||||
/** | ||||
* HeapSnapshots record the state of the JS heap at some moment. | * HeapSnapshots record the state of the JS heap at some moment. | |||
*/ | */ | |||
class V8_EXPORT HeapSnapshot { | class V8_EXPORT HeapSnapshot { | |||
public: | public: | |||
enum SerializationFormat { | enum SerializationFormat { | |||
kJSON = 0 // See format description near 'Serialize' method. | kJSON = 0 // See format description near 'Serialize' method. | |||
}; | }; | |||
/** Returns heap snapshot UID (assigned by the profiler.) */ | /** Returns heap snapshot UID (assigned by the profiler.) */ | |||
unsigned GetUid() const; | unsigned GetUid() const; | |||
skipping to change at line 340 | skipping to change at line 371 | |||
* edges: [edges array], | * edges: [edges array], | |||
* strings: [strings array] | * strings: [strings array] | |||
* } | * } | |||
* | * | |||
* Nodes reference strings, other nodes, and edges by their indexes | * Nodes reference strings, other nodes, and edges by their indexes | |||
* in corresponding arrays. | * in corresponding arrays. | |||
*/ | */ | |||
void Serialize(OutputStream* stream, SerializationFormat format) const; | void Serialize(OutputStream* stream, SerializationFormat format) const; | |||
}; | }; | |||
class RetainedObjectInfo; | /** | |||
* An interface for reporting progress and controlling long-running | ||||
* activities. | ||||
*/ | ||||
class V8_EXPORT ActivityControl { // NOLINT | ||||
public: | ||||
enum ControlOption { | ||||
kContinue = 0, | ||||
kAbort = 1 | ||||
}; | ||||
virtual ~ActivityControl() {} | ||||
/** | ||||
* Notify about current progress. The activity can be stopped by | ||||
* returning kAbort as the callback result. | ||||
*/ | ||||
virtual ControlOption ReportProgressValue(int done, int total) = 0; | ||||
}; | ||||
/** | /** | |||
* Interface for controlling heap profiling. Instance of the | * Interface for controlling heap profiling. Instance of the | |||
* profiler can be retrieved using v8::Isolate::GetHeapProfiler. | * profiler can be retrieved using v8::Isolate::GetHeapProfiler. | |||
*/ | */ | |||
class V8_EXPORT HeapProfiler { | class V8_EXPORT HeapProfiler { | |||
public: | public: | |||
/** | /** | |||
* Callback function invoked for obtaining RetainedObjectInfo for | * Callback function invoked for obtaining RetainedObjectInfo for | |||
* the given JavaScript wrapper object. It is prohibited to enter V8 | * the given JavaScript wrapper object. It is prohibited to enter V8 | |||
End of changes. 4 change blocks. | ||||
3 lines changed or deleted | 51 lines changed or added | |||
v8.h | v8.h | |||
---|---|---|---|---|
skipping to change at line 2577 | skipping to change at line 2577 | |||
Function(); | Function(); | |||
static void CheckCast(Value* obj); | static void CheckCast(Value* obj); | |||
}; | }; | |||
/** | /** | |||
* An instance of the built-in Promise constructor (ES6 draft). | * An instance of the built-in Promise constructor (ES6 draft). | |||
* This API is experimental. Only works with --harmony flag. | * This API is experimental. Only works with --harmony flag. | |||
*/ | */ | |||
class V8_EXPORT Promise : public Object { | class V8_EXPORT Promise : public Object { | |||
public: | public: | |||
/** | class V8_EXPORT Resolver : public Object { | |||
* Create a new Promise in pending state. | public: | |||
*/ | /** | |||
static Local<Promise> New(Isolate* isolate); | * Create a new resolver, along with an associated promise in pending s | |||
tate. | ||||
*/ | ||||
static Local<Resolver> New(Isolate* isolate); | ||||
/** | /** | |||
* Resolve/reject a promise with a given value. | * Extract the associated promise. | |||
* Ignored if the promise is not unresolved. | */ | |||
*/ | Local<Promise> GetPromise(); | |||
void Resolve(Handle<Value> value); | ||||
void Reject(Handle<Value> value); | /** | |||
* Resolve/reject the associated promise with a given value. | ||||
* Ignored if the promise is no longer pending. | ||||
*/ | ||||
void Resolve(Handle<Value> value); | ||||
void Reject(Handle<Value> value); | ||||
V8_INLINE static Resolver* Cast(Value* obj); | ||||
private: | ||||
Resolver(); | ||||
static void CheckCast(Value* obj); | ||||
}; | ||||
/** | /** | |||
* Register a resolution/rejection handler with a promise. | * Register a resolution/rejection handler with a promise. | |||
* The handler is given the respective resolution/rejection value as | * The handler is given the respective resolution/rejection value as | |||
* an argument. If the promise is already resolved/rejected, the handler is | * an argument. If the promise is already resolved/rejected, the handler is | |||
* invoked at the end of turn. | * invoked at the end of turn. | |||
*/ | */ | |||
Local<Promise> Chain(Handle<Function> handler); | Local<Promise> Chain(Handle<Function> handler); | |||
Local<Promise> Catch(Handle<Function> handler); | Local<Promise> Catch(Handle<Function> handler); | |||
skipping to change at line 4138 | skipping to change at line 4152 | |||
typedef void (*GCPrologueCallback)(Isolate* isolate, | typedef void (*GCPrologueCallback)(Isolate* isolate, | |||
GCType type, | GCType type, | |||
GCCallbackFlags flags); | GCCallbackFlags flags); | |||
typedef void (*GCEpilogueCallback)(Isolate* isolate, | typedef void (*GCEpilogueCallback)(Isolate* isolate, | |||
GCType type, | GCType type, | |||
GCCallbackFlags flags); | GCCallbackFlags flags); | |||
/** | /** | |||
* Enables the host application to receive a notification before a | * Enables the host application to receive a notification before a | |||
* garbage collection. Allocations are not allowed in the | * garbage collection. Allocations are allowed in the callback function, | |||
* callback function, you therefore cannot manipulate objects (set | * but the callback is not re-entrant: if the allocation inside it will | |||
* or delete properties for example) since it is possible such | * trigger the garbage collection, the callback won't be called again. | |||
* operations will result in the allocation of objects. It is possible | * It is possible to specify the GCType filter for your callback. But it | |||
* to specify the GCType filter for your callback. But it is not possible | is | |||
to | * not possible to register the same callback function two times with | |||
* register the same callback function two times with different | * different GCType filters. | |||
* GCType filters. | ||||
*/ | */ | |||
void AddGCPrologueCallback( | void AddGCPrologueCallback( | |||
GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll); | GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll); | |||
/** | /** | |||
* This function removes callback which was installed by | * This function removes callback which was installed by | |||
* AddGCPrologueCallback function. | * AddGCPrologueCallback function. | |||
*/ | */ | |||
void RemoveGCPrologueCallback(GCPrologueCallback callback); | void RemoveGCPrologueCallback(GCPrologueCallback callback); | |||
/** | /** | |||
* Enables the host application to receive a notification after a | * Enables the host application to receive a notification after a | |||
* garbage collection. Allocations are not allowed in the | * garbage collection. Allocations are allowed in the callback function, | |||
* callback function, you therefore cannot manipulate objects (set | * but the callback is not re-entrant: if the allocation inside it will | |||
* or delete properties for example) since it is possible such | * trigger the garbage collection, the callback won't be called again. | |||
* operations will result in the allocation of objects. It is possible | * It is possible to specify the GCType filter for your callback. But it | |||
* to specify the GCType filter for your callback. But it is not possible | is | |||
to | * not possible to register the same callback function two times with | |||
* register the same callback function two times with different | * different GCType filters. | |||
* GCType filters. | ||||
*/ | */ | |||
void AddGCEpilogueCallback( | void AddGCEpilogueCallback( | |||
GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); | GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); | |||
/** | /** | |||
* This function removes callback which was installed by | * This function removes callback which was installed by | |||
* AddGCEpilogueCallback function. | * AddGCEpilogueCallback function. | |||
*/ | */ | |||
void RemoveGCEpilogueCallback(GCEpilogueCallback callback); | void RemoveGCEpilogueCallback(GCEpilogueCallback callback); | |||
skipping to change at line 5245 | skipping to change at line 5257 | |||
bool top_level_; | bool top_level_; | |||
internal::Isolate* isolate_; | internal::Isolate* isolate_; | |||
static bool active_; | static bool active_; | |||
// Disallow copying and assigning. | // Disallow copying and assigning. | |||
Locker(const Locker&); | Locker(const Locker&); | |||
void operator=(const Locker&); | void operator=(const Locker&); | |||
}; | }; | |||
/** | ||||
* A struct for exporting HeapStats data from V8, using "push" model. | ||||
*/ | ||||
struct HeapStatsUpdate; | ||||
/** | ||||
* An interface for exporting data from V8, using "push" model. | ||||
*/ | ||||
class V8_EXPORT OutputStream { // NOLINT | ||||
public: | ||||
enum OutputEncoding { | ||||
kAscii = 0 // 7-bit ASCII. | ||||
}; | ||||
enum WriteResult { | ||||
kContinue = 0, | ||||
kAbort = 1 | ||||
}; | ||||
virtual ~OutputStream() {} | ||||
/** Notify about the end of stream. */ | ||||
virtual void EndOfStream() = 0; | ||||
/** Get preferred output chunk size. Called only once. */ | ||||
virtual int GetChunkSize() { return 1024; } | ||||
/** Get preferred output encoding. Called only once. */ | ||||
virtual OutputEncoding GetOutputEncoding() { return kAscii; } | ||||
/** | ||||
* Writes the next chunk of snapshot data into the stream. Writing | ||||
* can be stopped by returning kAbort as function result. EndOfStream | ||||
* will not be called in case writing was aborted. | ||||
*/ | ||||
virtual WriteResult WriteAsciiChunk(char* data, int size) = 0; | ||||
/** | ||||
* Writes the next chunk of heap stats data into the stream. Writing | ||||
* can be stopped by returning kAbort as function result. EndOfStream | ||||
* will not be called in case writing was aborted. | ||||
*/ | ||||
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate* data, int count) | ||||
{ | ||||
return kAbort; | ||||
}; | ||||
}; | ||||
/** | ||||
* An interface for reporting progress and controlling long-running | ||||
* activities. | ||||
*/ | ||||
class V8_EXPORT ActivityControl { // NOLINT | ||||
public: | ||||
enum ControlOption { | ||||
kContinue = 0, | ||||
kAbort = 1 | ||||
}; | ||||
virtual ~ActivityControl() {} | ||||
/** | ||||
* Notify about current progress. The activity can be stopped by | ||||
* returning kAbort as the callback result. | ||||
*/ | ||||
virtual ControlOption ReportProgressValue(int done, int total) = 0; | ||||
}; | ||||
// --- Implementation --- | // --- Implementation --- | |||
namespace internal { | namespace internal { | |||
const int kApiPointerSize = sizeof(void*); // NOLINT | const int kApiPointerSize = sizeof(void*); // NOLINT | |||
const int kApiIntSize = sizeof(int); // NOLINT | const int kApiIntSize = sizeof(int); // NOLINT | |||
// Tag information for HeapObject. | // Tag information for HeapObject. | |||
const int kHeapObjectTag = 1; | const int kHeapObjectTag = 1; | |||
const int kHeapObjectTagSize = 2; | const int kHeapObjectTagSize = 2; | |||
skipping to change at line 6135 | skipping to change at line 6089 | |||
return static_cast<Array*>(value); | return static_cast<Array*>(value); | |||
} | } | |||
Promise* Promise::Cast(v8::Value* value) { | Promise* Promise::Cast(v8::Value* value) { | |||
#ifdef V8_ENABLE_CHECKS | #ifdef V8_ENABLE_CHECKS | |||
CheckCast(value); | CheckCast(value); | |||
#endif | #endif | |||
return static_cast<Promise*>(value); | return static_cast<Promise*>(value); | |||
} | } | |||
Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) { | ||||
#ifdef V8_ENABLE_CHECKS | ||||
CheckCast(value); | ||||
#endif | ||||
return static_cast<Promise::Resolver*>(value); | ||||
} | ||||
ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { | ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { | |||
#ifdef V8_ENABLE_CHECKS | #ifdef V8_ENABLE_CHECKS | |||
CheckCast(value); | CheckCast(value); | |||
#endif | #endif | |||
return static_cast<ArrayBuffer*>(value); | return static_cast<ArrayBuffer*>(value); | |||
} | } | |||
ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) { | ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) { | |||
#ifdef V8_ENABLE_CHECKS | #ifdef V8_ENABLE_CHECKS | |||
CheckCast(value); | CheckCast(value); | |||
End of changes. 6 change blocks. | ||||
85 lines changed or deleted | 46 lines changed or added | |||