Add a use counter API
This lets embedders track certain features of v8 and the number of times they are used BUG=none R=svenpanne@chromium.org, marja@chromium.org LOG=y Review URL: https://codereview.chromium.org/346233002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21925 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
ec22430733
commit
ce02221828
18
include/v8.h
18
include/v8.h
@ -4128,6 +4128,19 @@ class V8_EXPORT Isolate {
|
||||
kMinorGarbageCollection
|
||||
};
|
||||
|
||||
/**
|
||||
* Features reported via the SetUseCounterCallback callback. Do not chang
|
||||
* assigned numbers of existing items; add new features to the end of this
|
||||
* list.
|
||||
*/
|
||||
enum UseCounterFeature {
|
||||
kUseAsm = 0
|
||||
};
|
||||
|
||||
typedef void (*UseCounterCallback)(Isolate* isolate,
|
||||
UseCounterFeature feature);
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new isolate. Does not change the currently entered
|
||||
* isolate.
|
||||
@ -4397,6 +4410,11 @@ class V8_EXPORT Isolate {
|
||||
*/
|
||||
bool WillAutorunMicrotasks() const;
|
||||
|
||||
/**
|
||||
* Sets a callback for counting the number of times a feature of V8 is used.
|
||||
*/
|
||||
void SetUseCounterCallback(UseCounterCallback callback);
|
||||
|
||||
private:
|
||||
template<class K, class V, class Traits> friend class PersistentValueMap;
|
||||
|
||||
|
@ -6718,6 +6718,11 @@ bool Isolate::WillAutorunMicrotasks() const {
|
||||
}
|
||||
|
||||
|
||||
void Isolate::SetUseCounterCallback(UseCounterCallback callback) {
|
||||
reinterpret_cast<i::Isolate*>(this)->SetUseCounterCallback(callback);
|
||||
}
|
||||
|
||||
|
||||
String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
|
||||
: str_(NULL), length_(0) {
|
||||
i::Isolate* isolate = i::Isolate::Current();
|
||||
|
@ -2343,6 +2343,19 @@ void Isolate::RunMicrotasks() {
|
||||
}
|
||||
|
||||
|
||||
void Isolate::SetUseCounterCallback(v8::Isolate::UseCounterCallback callback) {
|
||||
ASSERT(!use_counter_callback_);
|
||||
use_counter_callback_ = callback;
|
||||
}
|
||||
|
||||
|
||||
void Isolate::CountUsage(v8::Isolate::UseCounterFeature feature) {
|
||||
if (use_counter_callback_) {
|
||||
use_counter_callback_(reinterpret_cast<v8::Isolate*>(this), feature);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool StackLimitCheck::JsHasOverflowed() const {
|
||||
StackGuard* stack_guard = isolate_->stack_guard();
|
||||
#ifdef USE_SIMULATOR
|
||||
|
@ -1081,6 +1081,9 @@ class Isolate {
|
||||
void EnqueueMicrotask(Handle<Object> microtask);
|
||||
void RunMicrotasks();
|
||||
|
||||
void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback);
|
||||
void CountUsage(v8::Isolate::UseCounterFeature feature);
|
||||
|
||||
private:
|
||||
Isolate();
|
||||
|
||||
@ -1300,6 +1303,8 @@ class Isolate {
|
||||
// List of callbacks when a Call completes.
|
||||
List<CallCompletedCallback> call_completed_callbacks_;
|
||||
|
||||
v8::Isolate::UseCounterCallback use_counter_callback_;
|
||||
|
||||
friend class ExecutionAccess;
|
||||
friend class HandleScopeImplementer;
|
||||
friend class IsolateInitializer;
|
||||
|
Loading…
Reference in New Issue
Block a user