Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: include/v8.h

Issue 652193006: move functions in v8::V8 that should be on v8::Isolate (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index f70f45769bb5ca58ff6d178b7129f92448301e8c..92eb11bceca4c6d91db2c1c546d89a5262418a12 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4401,6 +4401,27 @@ typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
/**
+ * Interface for iterating through all external resources in the heap.
+ */
+class V8_EXPORT ExternalResourceVisitor { // NOLINT
+ public:
+ virtual ~ExternalResourceVisitor() {}
+ virtual void VisitExternalString(Handle<String> string) {}
+};
+
+
+/**
+ * Interface for iterating through all the persistent handles in the heap.
+ */
+class V8_EXPORT PersistentHandleVisitor { // NOLINT
+ public:
+ virtual ~PersistentHandleVisitor() {}
+ virtual void VisitPersistentHandle(Persistent<Value>* value,
+ uint16_t class_id) {}
+};
+
+
+/**
* Isolate represents an isolated instance of the V8 engine. V8 isolates have
* completely separate states. Objects from one isolate must not be used in
* other isolates. The embedder can create multiple isolates and use them in
@@ -4759,6 +4780,42 @@ class V8_EXPORT Isolate {
*/
void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
+
+ /**
+ * Forcefully terminate the current thread of JavaScript execution
+ * in the given isolate.
+ *
+ * This method can be used by any thread even if that thread has not
+ * acquired the V8 lock with a Locker object.
+ */
+ void TerminateExecution();
+
+ /**
+ * Is V8 terminating JavaScript execution.
+ *
+ * Returns true if JavaScript execution is currently terminating
+ * because of a call to TerminateExecution. In that case there are
+ * still JavaScript frames on the stack and the termination
+ * exception is still active.
+ */
+ bool IsExecutionTerminating();
+
+ /**
+ * Resume execution capability in the given isolate, whose execution
+ * was previously forcefully terminated using TerminateExecution().
+ *
+ * When execution is forcefully terminated using TerminateExecution(),
+ * the isolate can not resume execution until all JavaScript frames
+ * have propagated the uncatchable exception which is generated. This
+ * method allows the program embedding the engine to handle the
+ * termination event and resume execution capability, even if
+ * JavaScript frames remain on the stack.
+ *
+ * This method can be used by any thread even if that thread has not
+ * acquired the V8 lock with a Locker object.
+ */
+ void CancelTerminateExecution();
+
/**
* Request V8 to interrupt long running JavaScript code and invoke
* the given |callback| passing the given |data| to it. After |callback|
@@ -4940,6 +4997,84 @@ class V8_EXPORT Isolate {
*/
void GetCodeRange(void** start, size_t* length_in_bytes);
+ /** Set the callback to invoke in case of fatal errors. */
+ void SetFatalErrorHandler(FatalErrorCallback that);
+
+ /**
+ * Set the callback to invoke to check if code generation from
+ * strings should be allowed.
+ */
+ void SetAllowCodeGenerationFromStringsCallback(
+ AllowCodeGenerationFromStringsCallback callback);
+
+ /**
+ * Check if V8 is dead and therefore unusable. This is the case after
+ * fatal errors such as out-of-memory situations.
+ */
+ bool IsDead();
+
+ /**
+ * Adds a message listener.
+ *
+ * The same message listener can be added more than once and in that
+ * case it will be called more than once for each message.
+ *
+ * If data is specified, it will be passed to the callback when it is called.
+ * Otherwise, the exception object will be passed to the callback instead.
+ */
+ bool AddMessageListener(MessageCallback that,
+ Handle<Value> data = Handle<Value>());
+
+ /**
+ * Remove all message listeners from the specified callback function.
+ */
+ void RemoveMessageListeners(MessageCallback that);
+
+ /** Callback function for reporting failed access checks.*/
+ void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
+
+ /**
+ * Tells V8 to capture current stack trace when uncaught exception occurs
+ * and report it to the message listeners. The option is off by default.
+ */
+ void SetCaptureStackTraceForUncaughtExceptions(
+ bool capture, int frame_limit = 10,
+ StackTrace::StackTraceOptions options = StackTrace::kOverview);
+
+ /**
+ * Enables the host application to provide a mechanism to be notified
+ * and perform custom logging when V8 Allocates Executable Memory.
+ */
+ void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
+ ObjectSpace space, AllocationAction action);
+
+ /**
+ * Removes callback that was installed by AddMemoryAllocationCallback.
+ */
+ void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
+
+ /**
+ * Iterates through all external resources referenced from current isolate
+ * heap. GC is not invoked prior to iterating, therefore there is no
+ * guarantee that visited objects are still alive.
+ */
+ void VisitExternalResources(ExternalResourceVisitor* visitor);
+
+ /**
+ * Iterates through all the persistent handles in the current isolate's heap
+ * that have class_ids.
+ */
+ void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
+
+ /**
+ * Iterates through all the persistent handles in the current isolate's heap
+ * that have class_ids and are candidates to be marked as partially dependent
+ * handles. This will visit handles to young objects created since the last
+ * garbage collection but is free to visit an arbitrary superset of these
+ * objects.
+ */
+ void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor);
+
private:
template<class K, class V, class Traits> friend class PersistentValueMap;
@@ -5019,39 +5154,20 @@ typedef uintptr_t (*ReturnAddressLocationResolver)(
/**
- * Interface for iterating through all external resources in the heap.
- */
-class V8_EXPORT ExternalResourceVisitor { // NOLINT
- public:
- virtual ~ExternalResourceVisitor() {}
- virtual void VisitExternalString(Handle<String> string) {}
-};
-
-
-/**
- * Interface for iterating through all the persistent handles in the heap.
- */
-class V8_EXPORT PersistentHandleVisitor { // NOLINT
- public:
- virtual ~PersistentHandleVisitor() {}
- virtual void VisitPersistentHandle(Persistent<Value>* value,
- uint16_t class_id) {}
-};
-
-
-/**
* Container class for static utility functions.
*/
class V8_EXPORT V8 {
public:
/** Set the callback to invoke in case of fatal errors. */
- static void SetFatalErrorHandler(FatalErrorCallback that);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void SetFatalErrorHandler(FatalErrorCallback that);
/**
* Set the callback to invoke to check if code generation from
* strings should be allowed.
*/
- static void SetAllowCodeGenerationFromStringsCallback(
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void SetAllowCodeGenerationFromStringsCallback(
AllowCodeGenerationFromStringsCallback that);
/**
@@ -5063,10 +5179,11 @@ class V8_EXPORT V8 {
static void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator);
/**
- * Check if V8 is dead and therefore unusable. This is the case after
- * fatal errors such as out-of-memory situations.
- */
- static bool IsDead();
+ * Check if V8 is dead and therefore unusable. This is the case after
+ * fatal errors such as out-of-memory situations.
+ */
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static bool IsDead();
/**
* The following 4 functions are to be used when V8 is built with
@@ -5119,21 +5236,23 @@ class V8_EXPORT V8 {
* If data is specified, it will be passed to the callback when it is called.
* Otherwise, the exception object will be passed to the callback instead.
*/
- static bool AddMessageListener(MessageCallback that,
- Handle<Value> data = Handle<Value>());
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static bool AddMessageListener(
+ MessageCallback that, Handle<Value> data = Handle<Value>());
/**
* Remove all message listeners from the specified callback function.
*/
- static void RemoveMessageListeners(MessageCallback that);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void RemoveMessageListeners(MessageCallback that);
/**
* Tells V8 to capture current stack trace when uncaught exception occurs
* and report it to the message listeners. The option is off by default.
*/
- static void SetCaptureStackTraceForUncaughtExceptions(
- bool capture,
- int frame_limit = 10,
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void SetCaptureStackTraceForUncaughtExceptions(
+ bool capture, int frame_limit = 10,
StackTrace::StackTraceOptions options = StackTrace::kOverview);
/**
@@ -5152,7 +5271,9 @@ class V8_EXPORT V8 {
static const char* GetVersion();
/** Callback function for reporting failed access checks.*/
- static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void SetFailedAccessCheckCallbackFunction(
+ FailedAccessCheckCallback);
/**
* Enables the host application to receive a notification before a
@@ -5164,6 +5285,7 @@ class V8_EXPORT V8 {
* register the same callback function two times with different
* GCType filters.
*/
+ // TODO(dcarney): deprecate this.
static void AddGCPrologueCallback(
GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll);
@@ -5171,7 +5293,8 @@ class V8_EXPORT V8 {
* This function removes callback which was installed by
* AddGCPrologueCallback function.
*/
- static void RemoveGCPrologueCallback(GCPrologueCallback callback);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void RemoveGCPrologueCallback(GCPrologueCallback callback);
/**
* Enables the host application to receive a notification after a
@@ -5183,6 +5306,7 @@ class V8_EXPORT V8 {
* register the same callback function two times with different
* GCType filters.
*/
+ // TODO(dcarney): deprecate this.
static void AddGCEpilogueCallback(
GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll);
@@ -5190,20 +5314,24 @@ class V8_EXPORT V8 {
* This function removes callback which was installed by
* AddGCEpilogueCallback function.
*/
- static void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
/**
* Enables the host application to provide a mechanism to be notified
* and perform custom logging when V8 Allocates Executable Memory.
*/
- static void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
- ObjectSpace space,
- AllocationAction action);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void AddMemoryAllocationCallback(
+ MemoryAllocationCallback callback, ObjectSpace space,
+ AllocationAction action);
/**
* Removes callback that was installed by AddMemoryAllocationCallback.
*/
- static void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void RemoveMemoryAllocationCallback(
+ MemoryAllocationCallback callback);
/**
* Initializes V8. This function needs to be called before the first Isolate
@@ -5233,7 +5361,8 @@ class V8_EXPORT V8 {
*
* \param isolate The isolate in which to terminate the current JS execution.
*/
- static void TerminateExecution(Isolate* isolate);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void TerminateExecution(Isolate* isolate);
/**
* Is V8 terminating JavaScript execution.
@@ -5245,7 +5374,8 @@ class V8_EXPORT V8 {
*
* \param isolate The isolate in which to check.
*/
- static bool IsExecutionTerminating(Isolate* isolate = NULL);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static bool IsExecutionTerminating(Isolate* isolate = NULL);
/**
* Resume execution capability in the given isolate, whose execution
@@ -5263,7 +5393,8 @@ class V8_EXPORT V8 {
*
* \param isolate The isolate in which to resume execution capability.
*/
- static void CancelTerminateExecution(Isolate* isolate);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void CancelTerminateExecution(Isolate* isolate);
/**
* Releases any resources used by v8 and stops any utility threads
@@ -5281,19 +5412,24 @@ class V8_EXPORT V8 {
* heap. GC is not invoked prior to iterating, therefore there is no
* guarantee that visited objects are still alive.
*/
- static void VisitExternalResources(ExternalResourceVisitor* visitor);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void VisitExternalResources(
+ ExternalResourceVisitor* visitor);
/**
* Iterates through all the persistent handles in the current isolate's heap
* that have class_ids.
*/
- static void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void VisitHandlesWithClassIds(
+ PersistentHandleVisitor* visitor);
/**
* Iterates through all the persistent handles in isolate's heap that have
* class_ids.
*/
- static void VisitHandlesWithClassIds(
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void VisitHandlesWithClassIds(
Isolate* isolate, PersistentHandleVisitor* visitor);
/**
@@ -5303,7 +5439,8 @@ class V8_EXPORT V8 {
* garbage collection but is free to visit an arbitrary superset of these
* objects.
*/
- static void VisitHandlesForPartialDependence(
+ // TODO(dcarney): deprecate this.
+ V8_INLINE static void VisitHandlesForPartialDependence(
Isolate* isolate, PersistentHandleVisitor* visitor);
/**
@@ -7076,6 +7213,119 @@ void* Context::GetAlignedPointerFromEmbedderData(int index) {
}
+void V8::SetAllowCodeGenerationFromStringsCallback(
+ AllowCodeGenerationFromStringsCallback callback) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->SetAllowCodeGenerationFromStringsCallback(callback);
+}
+
+
+bool V8::IsDead() {
+ Isolate* isolate = Isolate::GetCurrent();
+ return isolate->IsDead();
+}
+
+
+bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
+ Isolate* isolate = Isolate::GetCurrent();
+ return isolate->AddMessageListener(that, data);
+}
+
+
+void V8::RemoveMessageListeners(MessageCallback that) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->RemoveMessageListeners(that);
+}
+
+
+void V8::SetFailedAccessCheckCallbackFunction(
+ FailedAccessCheckCallback callback) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->SetFailedAccessCheckCallbackFunction(callback);
+}
+
+
+void V8::SetCaptureStackTraceForUncaughtExceptions(
+ bool capture, int frame_limit, StackTrace::StackTraceOptions options) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->SetCaptureStackTraceForUncaughtExceptions(capture, frame_limit,
+ options);
+}
+
+
+void V8::SetFatalErrorHandler(FatalErrorCallback callback) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->SetFatalErrorHandler(callback);
+}
+
+
+void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->RemoveGCPrologueCallback(
+ reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback));
+}
+
+
+void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->RemoveGCEpilogueCallback(
+ reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback));
+}
+
+
+void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback,
+ ObjectSpace space,
+ AllocationAction action) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->AddMemoryAllocationCallback(callback, space, action);
+}
+
+
+void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->RemoveMemoryAllocationCallback(callback);
+}
+
+
+void V8::TerminateExecution(Isolate* isolate) { isolate->TerminateExecution(); }
+
+
+bool V8::IsExecutionTerminating(Isolate* isolate) {
+ if (isolate == NULL) {
+ isolate = Isolate::GetCurrent();
+ }
+ return isolate->IsExecutionTerminating();
+}
+
+
+void V8::CancelTerminateExecution(Isolate* isolate) {
+ isolate->CancelTerminateExecution();
+}
+
+
+void V8::VisitExternalResources(ExternalResourceVisitor* visitor) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->VisitExternalResources(visitor);
+}
+
+
+void V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
+ Isolate* isolate = Isolate::GetCurrent();
+ isolate->VisitHandlesWithClassIds(visitor);
+}
+
+
+void V8::VisitHandlesWithClassIds(Isolate* isolate,
+ PersistentHandleVisitor* visitor) {
+ isolate->VisitHandlesWithClassIds(visitor);
+}
+
+
+void V8::VisitHandlesForPartialDependence(Isolate* isolate,
+ PersistentHandleVisitor* visitor) {
+ isolate->VisitHandlesForPartialDependence(visitor);
+}
+
/**
* \example shell.cc
* A simple shell that takes a list of expressions on the
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698