Reviewers: marja, Sven Panne,
Description:
Add a use counter API
This lets embedders track certain features of v8 and the number of times
they are used
BUG=none
[email protected],[email protected]
LOG=y
Please review this at https://codereview.chromium.org/346233002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+40, -0 lines):
M include/v8.h
M src/api.cc
M src/isolate.h
M src/isolate.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
f6c6ac3cf735e9005ef0ce4ee7a192cc46e0aa89..bc2ea0bb0af5e11e048280667909143dfba2a006
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4129,6 +4129,19 @@ class V8_EXPORT Isolate {
};
/**
+ * 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;
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
a6ea44eddc920b2b03f8cc60185e53279458641e..491119bc37a0a433ab58a2cc2226d335607e5aea
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6716,6 +6716,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();
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
a4b311f6ecacd7d4b4a760931475bf4d9405c2ec..0210f19d4f51728431f81639da067f6edfe76a3d
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -2343,6 +2343,18 @@ 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
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index
3cabea9c8549bc35a81ac4c082769d78c1d8c6b5..2a1187361f5a1bcda9f6659b6b8a9bb097a29380
100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -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;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.