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
};
/**
+ * 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.
*
*/
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;
}
+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();
}
+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
void EnqueueMicrotask(Handle<Object> microtask);
void RunMicrotasks();
+ void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback);
+ void CountUsage(v8::Isolate::UseCounterFeature feature);
+
private:
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;