| v8.h | | v8.h | |
| | | | |
| skipping to change at line 113 | | skipping to change at line 113 | |
| class Data; | | class Data; | |
| class AccessorInfo; | | class AccessorInfo; | |
| class StackTrace; | | class StackTrace; | |
| class StackFrame; | | class StackFrame; | |
| | | | |
| namespace internal { | | namespace internal { | |
| | | | |
| class Arguments; | | class Arguments; | |
| class Object; | | class Object; | |
| class Heap; | | class Heap; | |
|
| class Top; | | class HeapObject; | |
| | | class Isolate; | |
| } | | } | |
| | | | |
| // --- W e a k H a n d l e s | | // --- W e a k H a n d l e s | |
| | | | |
| /** | | /** | |
| * A weak reference callback function. | | * A weak reference callback function. | |
| * | | * | |
| * This callback should either explicitly invoke Dispose on |object| if | | * This callback should either explicitly invoke Dispose on |object| if | |
| * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWe
ak. | | * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWe
ak. | |
| * | | * | |
| | | | |
| skipping to change at line 440 | | skipping to change at line 441 | |
| | | | |
| /** | | /** | |
| * Counts the number of allocated handles. | | * Counts the number of allocated handles. | |
| */ | | */ | |
| static int NumberOfHandles(); | | static int NumberOfHandles(); | |
| | | | |
| /** | | /** | |
| * Creates a new handle with the given value. | | * Creates a new handle with the given value. | |
| */ | | */ | |
| static internal::Object** CreateHandle(internal::Object* value); | | static internal::Object** CreateHandle(internal::Object* value); | |
|
| | | // Faster version, uses HeapObject to obtain the current Isolate. | |
| | | static internal::Object** CreateHandle(internal::HeapObject* value); | |
| | | | |
| private: | | private: | |
| // Make it impossible to create heap-allocated or illegal handle | | // Make it impossible to create heap-allocated or illegal handle | |
| // scopes by disallowing certain operations. | | // scopes by disallowing certain operations. | |
| HandleScope(const HandleScope&); | | HandleScope(const HandleScope&); | |
| void operator=(const HandleScope&); | | void operator=(const HandleScope&); | |
| void* operator new(size_t size); | | void* operator new(size_t size); | |
| void operator delete(void*, size_t); | | void operator delete(void*, size_t); | |
| | | | |
| // This Data class is accessible internally as HandleScopeData through a | | // This Data class is accessible internally as HandleScopeData through a | |
| | | | |
| skipping to change at line 456 | | skipping to change at line 459 | |
| void* operator new(size_t size); | | void* operator new(size_t size); | |
| void operator delete(void*, size_t); | | void operator delete(void*, size_t); | |
| | | | |
| // This Data class is accessible internally as HandleScopeData through a | | // This Data class is accessible internally as HandleScopeData through a | |
| // typedef in the ImplementationUtilities class. | | // typedef in the ImplementationUtilities class. | |
| class V8EXPORT Data { | | class V8EXPORT Data { | |
| public: | | public: | |
| internal::Object** next; | | internal::Object** next; | |
| internal::Object** limit; | | internal::Object** limit; | |
| int level; | | int level; | |
|
| | | | |
| inline void Initialize() { | | inline void Initialize() { | |
| next = limit = NULL; | | next = limit = NULL; | |
| level = 0; | | level = 0; | |
| } | | } | |
| }; | | }; | |
| | | | |
| void Leave(); | | void Leave(); | |
| | | | |
|
| | | internal::Isolate* isolate_; | |
| internal::Object** prev_next_; | | internal::Object** prev_next_; | |
| internal::Object** prev_limit_; | | internal::Object** prev_limit_; | |
| | | | |
| // Allow for the active closing of HandleScopes which allows to pass a ha
ndle | | // Allow for the active closing of HandleScopes which allows to pass a ha
ndle | |
| // from the HandleScope being closed to the next top most HandleScope. | | // from the HandleScope being closed to the next top most HandleScope. | |
| bool is_closed_; | | bool is_closed_; | |
| internal::Object** RawClose(internal::Object** value); | | internal::Object** RawClose(internal::Object** value); | |
| | | | |
| friend class ImplementationUtilities; | | friend class ImplementationUtilities; | |
| }; | | }; | |
| | | | |
| skipping to change at line 2485 | | skipping to change at line 2488 | |
| size_t total_heap_size_executable_; | | size_t total_heap_size_executable_; | |
| size_t used_heap_size_; | | size_t used_heap_size_; | |
| size_t heap_size_limit_; | | size_t heap_size_limit_; | |
| | | | |
| friend class V8; | | friend class V8; | |
| }; | | }; | |
| | | | |
| class RetainedObjectInfo; | | class RetainedObjectInfo; | |
| | | | |
| /** | | /** | |
|
| | | * 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. When V8 is initialized a | |
| | | * default isolate is implicitly created and entered. The embedder | |
| | | * can create additional isolates and use them in parallel in multiple | |
| | | * threads. An isolate can be entered by at most one thread at any | |
| | | * given time. The Locker/Unlocker API can be used to synchronize. | |
| | | */ | |
| | | class V8EXPORT Isolate { | |
| | | public: | |
| | | /** | |
| | | * Stack-allocated class which sets the isolate for all operations | |
| | | * executed within a local scope. | |
| | | */ | |
| | | class V8EXPORT Scope { | |
| | | public: | |
| | | explicit Scope(Isolate* isolate) : isolate_(isolate) { | |
| | | isolate->Enter(); | |
| | | } | |
| | | | |
| | | ~Scope() { isolate_->Exit(); } | |
| | | | |
| | | private: | |
| | | Isolate* const isolate_; | |
| | | | |
| | | // Prevent copying of Scope objects. | |
| | | Scope(const Scope&); | |
| | | Scope& operator=(const Scope&); | |
| | | }; | |
| | | | |
| | | /** | |
| | | * Creates a new isolate. Does not change the currently entered | |
| | | * isolate. | |
| | | * | |
| | | * When an isolate is no longer used its resources should be freed | |
| | | * by calling Dispose(). Using the delete operator is not allowed. | |
| | | */ | |
| | | static Isolate* New(); | |
| | | | |
| | | /** | |
| | | * Returns the entered isolate for the current thread or NULL in | |
| | | * case there is no current isolate. | |
| | | */ | |
| | | static Isolate* GetCurrent(); | |
| | | | |
| | | /** | |
| | | * Methods below this point require holding a lock (using Locker) in | |
| | | * a multi-threaded environment. | |
| | | */ | |
| | | | |
| | | /** | |
| | | * Sets this isolate as the entered one for the current thread. | |
| | | * Saves the previously entered one (if any), so that it can be | |
| | | * restored when exiting. Re-entering an isolate is allowed. | |
| | | */ | |
| | | void Enter(); | |
| | | | |
| | | /** | |
| | | * Exits this isolate by restoring the previously entered one in the | |
| | | * current thread. The isolate may still stay the same, if it was | |
| | | * entered more than once. | |
| | | * | |
| | | * Requires: this == Isolate::GetCurrent(). | |
| | | */ | |
| | | void Exit(); | |
| | | | |
| | | /** | |
| | | * Disposes the isolate. The isolate must not be entered by any | |
| | | * thread to be disposable. | |
| | | */ | |
| | | void Dispose(); | |
| | | | |
| | | private: | |
| | | | |
| | | Isolate(); | |
| | | Isolate(const Isolate&); | |
| | | ~Isolate(); | |
| | | Isolate& operator=(const Isolate&); | |
| | | void* operator new(size_t size); | |
| | | void operator delete(void*, size_t); | |
| | | }; | |
| | | | |
| | | /** | |
| * Container class for static utility functions. | | * Container class for static utility functions. | |
| */ | | */ | |
| class V8EXPORT V8 { | | class V8EXPORT V8 { | |
| public: | | public: | |
| /** Set the callback to invoke in case of fatal errors. */ | | /** Set the callback to invoke in case of fatal errors. */ | |
| static void SetFatalErrorHandler(FatalErrorCallback that); | | static void SetFatalErrorHandler(FatalErrorCallback that); | |
| | | | |
| /** | | /** | |
| * Ignore out-of-memory exceptions. | | * Ignore out-of-memory exceptions. | |
| * | | * | |
| | | | |
| skipping to change at line 2809 | | skipping to change at line 2895 | |
| * continue the propagation of the termination exception if needed. | | * continue the propagation of the termination exception if needed. | |
| * | | * | |
| * The thread id passed to TerminateExecution must have been | | * The thread id passed to TerminateExecution must have been | |
| * obtained by calling GetCurrentThreadId on the thread in question. | | * obtained by calling GetCurrentThreadId on the thread in question. | |
| * | | * | |
| * \param thread_id The thread id of the thread to terminate. | | * \param thread_id The thread id of the thread to terminate. | |
| */ | | */ | |
| static void TerminateExecution(int thread_id); | | static void TerminateExecution(int thread_id); | |
| | | | |
| /** | | /** | |
|
| * Forcefully terminate the current thread of JavaScript execution. | | * Forcefully terminate the current thread of JavaScript execution | |
| | | * in the given isolate. If no isolate is provided, the default | |
| | | * isolate is used. | |
| * | | * | |
| * This method can be used by any thread even if that thread has not | | * This method can be used by any thread even if that thread has not | |
| * acquired the V8 lock with a Locker object. | | * acquired the V8 lock with a Locker object. | |
|
| | | * | |
| | | * \param isolate The isolate in which to terminate the current JS execut | |
| | | ion. | |
| */ | | */ | |
|
| static void TerminateExecution(); | | static void TerminateExecution(Isolate* isolate = NULL); | |
| | | | |
| /** | | /** | |
| * Is V8 terminating JavaScript execution. | | * Is V8 terminating JavaScript execution. | |
| * | | * | |
| * Returns true if JavaScript execution is currently terminating | | * Returns true if JavaScript execution is currently terminating | |
| * because of a call to TerminateExecution. In that case there are | | * because of a call to TerminateExecution. In that case there are | |
| * still JavaScript frames on the stack and the termination | | * still JavaScript frames on the stack and the termination | |
| * exception is still active. | | * exception is still active. | |
| */ | | */ | |
| static bool IsExecutionTerminating(); | | static bool IsExecutionTerminating(); | |
| | | | |
| skipping to change at line 2991 | | skipping to change at line 3081 | |
| | | | |
| private: | | private: | |
| void* next_; | | void* next_; | |
| void* exception_; | | void* exception_; | |
| void* message_; | | void* message_; | |
| bool is_verbose_ : 1; | | bool is_verbose_ : 1; | |
| bool can_continue_ : 1; | | bool can_continue_ : 1; | |
| bool capture_message_ : 1; | | bool capture_message_ : 1; | |
| bool rethrow_ : 1; | | bool rethrow_ : 1; | |
| | | | |
|
| friend class v8::internal::Top; | | friend class v8::internal::Isolate; | |
| }; | | }; | |
| | | | |
| // --- C o n t e x t --- | | // --- C o n t e x t --- | |
| | | | |
| /** | | /** | |
| * Ignore | | * Ignore | |
| */ | | */ | |
| class V8EXPORT ExtensionConfiguration { | | class V8EXPORT ExtensionConfiguration { | |
| public: | | public: | |
| ExtensionConfiguration(int name_count, const char* names[]) | | ExtensionConfiguration(int name_count, const char* names[]) | |
| | | | |
| skipping to change at line 3150 | | skipping to change at line 3240 | |
| | | | |
| private: | | private: | |
| friend class Value; | | friend class Value; | |
| friend class Script; | | friend class Script; | |
| friend class Object; | | friend class Object; | |
| friend class Function; | | friend class Function; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Multiple threads in V8 are allowed, but only one thread at a time | | * Multiple threads in V8 are allowed, but only one thread at a time | |
|
| * is allowed to use V8. The definition of 'using V8' includes | | * is allowed to use any given V8 isolate. See Isolate class | |
| * accessing handles or holding onto object pointers obtained from V8 | | * comments. The definition of 'using V8 isolate' includes | |
| * handles. It is up to the user of V8 to ensure (perhaps with | | * accessing handles or holding onto object pointers obtained | |
| * locking) that this constraint is not violated. | | * from V8 handles while in the particular V8 isolate. It is up | |
| | | * to the user of V8 to ensure (perhaps with locking) that this | |
| | | * constraint is not violated. | |
| * | | * | |
|
| * If you wish to start using V8 in a thread you can do this by constructin | | * More then one thread and multiple V8 isolates can be used | |
| g | | * without any locking if each isolate is created and accessed | |
| * a v8::Locker object. After the code using V8 has completed for the | | * by a single thread only. For example, one thread can use | |
| * current thread you can call the destructor. This can be combined | | * multiple isolates or multiple threads can each create and run | |
| * with C++ scope-based construction as follows: | | * their own isolate. | |
| | | * | |
| | | * If you wish to start using V8 isolate in more then one thread | |
| | | * you can do this by constructing a v8::Locker object to guard | |
| | | * access to the isolate. After the code using V8 has completed | |
| | | * for the current thread you can call the destructor. This can | |
| | | * be combined with C++ scope-based construction as follows | |
| | | * (assumes the default isolate that is used if not specified as | |
| | | * a parameter for the Locker): | |
| * | | * | |
| * \code | | * \code | |
| * ... | | * ... | |
| * { | | * { | |
| * v8::Locker locker; | | * v8::Locker locker; | |
| * ... | | * ... | |
| * // Code using V8 goes here. | | * // Code using V8 goes here. | |
| * ... | | * ... | |
| * } // Destructor called here | | * } // Destructor called here | |
| * \endcode | | * \endcode | |
| | | | |
| skipping to change at line 3395 | | skipping to change at line 3496 | |
| * This class exports constants and functionality from within v8 that | | * This class exports constants and functionality from within v8 that | |
| * is necessary to implement inline functions in the v8 api. Don't | | * is necessary to implement inline functions in the v8 api. Don't | |
| * depend on functions and constants defined here. | | * depend on functions and constants defined here. | |
| */ | | */ | |
| class Internals { | | class Internals { | |
| public: | | public: | |
| | | | |
| // These values match non-compiler-dependent values defined within | | // These values match non-compiler-dependent values defined within | |
| // the implementation of v8. | | // the implementation of v8. | |
| static const int kHeapObjectMapOffset = 0; | | static const int kHeapObjectMapOffset = 0; | |
|
| static const int kMapInstanceTypeOffset = kApiPointerSize + kApiIntSize; | | static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSi
ze; | |
| static const int kStringResourceOffset = | | static const int kStringResourceOffset = | |
| InternalConstants<kApiPointerSize>::kStringResourceOffset; | | InternalConstants<kApiPointerSize>::kStringResourceOffset; | |
| | | | |
| static const int kProxyProxyOffset = kApiPointerSize; | | static const int kProxyProxyOffset = kApiPointerSize; | |
| static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | | static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | |
| static const int kFullStringRepresentationMask = 0x07; | | static const int kFullStringRepresentationMask = 0x07; | |
| static const int kExternalTwoByteRepresentationTag = 0x02; | | static const int kExternalTwoByteRepresentationTag = 0x02; | |
| | | | |
| static const int kJSObjectType = 0xa0; | | static const int kJSObjectType = 0xa0; | |
| static const int kFirstNonstringType = 0x80; | | static const int kFirstNonstringType = 0x80; | |
| | | | |
| skipping to change at line 3452 | | skipping to change at line 3553 | |
| static inline bool IsExternalTwoByteString(int instance_type) { | | static inline bool IsExternalTwoByteString(int instance_type) { | |
| int representation = (instance_type & kFullStringRepresentationMask); | | int representation = (instance_type & kFullStringRepresentationMask); | |
| return representation == kExternalTwoByteRepresentationTag; | | return representation == kExternalTwoByteRepresentationTag; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| static inline T ReadField(Object* ptr, int offset) { | | static inline T ReadField(Object* ptr, int offset) { | |
| uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectT
ag; | | uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectT
ag; | |
| return *reinterpret_cast<T*>(addr); | | return *reinterpret_cast<T*>(addr); | |
| } | | } | |
|
| | | | |
| | | static inline bool CanCastToHeapObject(void* o) { return false; } | |
| | | static inline bool CanCastToHeapObject(Context* o) { return true; } | |
| | | static inline bool CanCastToHeapObject(String* o) { return true; } | |
| | | static inline bool CanCastToHeapObject(Object* o) { return true; } | |
| | | static inline bool CanCastToHeapObject(Message* o) { return true; } | |
| | | static inline bool CanCastToHeapObject(StackTrace* o) { return true; } | |
| | | static inline bool CanCastToHeapObject(StackFrame* o) { return true; } | |
| }; | | }; | |
| | | | |
| } // namespace internal | | } // namespace internal | |
| | | | |
| template <class T> | | template <class T> | |
| Handle<T>::Handle() : val_(0) { } | | Handle<T>::Handle() : val_(0) { } | |
| | | | |
| template <class T> | | template <class T> | |
| Local<T>::Local() : Handle<T>() { } | | Local<T>::Local() : Handle<T>() { } | |
| | | | |
| template <class T> | | template <class T> | |
| Local<T> Local<T>::New(Handle<T> that) { | | Local<T> Local<T>::New(Handle<T> that) { | |
| if (that.IsEmpty()) return Local<T>(); | | if (that.IsEmpty()) return Local<T>(); | |
|
| internal::Object** p = reinterpret_cast<internal::Object**>(*that); | | T* that_ptr = *that; | |
| | | internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | |
| | | if (internal::Internals::CanCastToHeapObject(that_ptr)) { | |
| | | return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( | |
| | | reinterpret_cast<internal::HeapObject*>(*p)))); | |
| | | } | |
| return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); | | return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| Persistent<T> Persistent<T>::New(Handle<T> that) { | | Persistent<T> Persistent<T>::New(Handle<T> that) { | |
| if (that.IsEmpty()) return Persistent<T>(); | | if (that.IsEmpty()) return Persistent<T>(); | |
| internal::Object** p = reinterpret_cast<internal::Object**>(*that); | | internal::Object** p = reinterpret_cast<internal::Object**>(*that); | |
| return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); | | return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); | |
| } | | } | |
| | | | |
| | | | |
End of changes. 14 change blocks. |
| 16 lines changed or deleted | | 130 lines changed or added | |
|