v8.h   v8.h 
skipping to change at line 41 skipping to change at line 41
* *
* This set of documents provides reference material generated from the * This set of documents provides reference material generated from the
* V8 header file, include/v8.h. * V8 header file, include/v8.h.
* *
* For other documentation see http://code.google.com/apis/v8/ * For other documentation see http://code.google.com/apis/v8/
*/ */
#ifndef V8_H_ #ifndef V8_H_
#define V8_H_ #define V8_H_
// TODO(svenpanne) Remove me when the Chrome bindings are adapted.
#define V8_DISABLE_DEPRECATIONS 1
#include "v8stdint.h" #include "v8stdint.h"
#ifdef _WIN32 #ifdef _WIN32
// Setup for Windows DLL export/import. When building the V8 DLL the // Setup for Windows DLL export/import. When building the V8 DLL the
// BUILDING_V8_SHARED needs to be defined. When building a program which us es // BUILDING_V8_SHARED needs to be defined. When building a program which us es
// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
// static library or building a program which uses the V8 static library ne ither // static library or building a program which uses the V8 static library ne ither
// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
#if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
skipping to change at line 1073 skipping to change at line 1076
* A fast conservative check for non-ASCII characters. May * A fast conservative check for non-ASCII characters. May
* return true even for ASCII strings, but if it returns * return true even for ASCII strings, but if it returns
* false you can be sure that all characters are in the range * false you can be sure that all characters are in the range
* 0-127. * 0-127.
*/ */
bool MayContainNonAscii() const; bool MayContainNonAscii() const;
/** /**
* Returns whether this string contains only one byte data. * Returns whether this string contains only one byte data.
*/ */
V8EXPORT bool IsOneByte() const; bool IsOneByte() const;
/** /**
* Write the contents of the string to an external buffer. * Write the contents of the string to an external buffer.
* If no arguments are given, expects the buffer to be large * If no arguments are given, expects the buffer to be large
* enough to hold the entire string and NULL terminator. Copies * enough to hold the entire string and NULL terminator. Copies
* the contents of the string and the NULL terminator into the * the contents of the string and the NULL terminator into the
* buffer. * buffer.
* *
* WriteUtf8 will not write partial UTF-8 sequences, preferring to stop * WriteUtf8 will not write partial UTF-8 sequences, preferring to stop
* before the end of the buffer. * before the end of the buffer.
skipping to change at line 1118 skipping to change at line 1121
int Write(uint16_t* buffer, int Write(uint16_t* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
// ASCII characters. // ASCII characters.
int WriteAscii(char* buffer, int WriteAscii(char* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
// One byte characters. // One byte characters.
V8EXPORT int WriteOneByte(uint8_t* buffer, int WriteOneByte(uint8_t* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
// UTF-8 encoded characters. // UTF-8 encoded characters.
int WriteUtf8(char* buffer, int WriteUtf8(char* buffer,
int length = -1, int length = -1,
int* nchars_ref = NULL, int* nchars_ref = NULL,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
/** /**
* A zero length string. * A zero length string.
*/ */
static v8::Local<v8::String> Empty(); static v8::Local<v8::String> Empty();
skipping to change at line 3467 skipping to change at line 3470
static void MarkPartiallyDependent(internal::Object** global_handle); static void MarkPartiallyDependent(internal::Object** global_handle);
static void MarkPartiallyDependent(internal::Isolate* isolate, static void MarkPartiallyDependent(internal::Isolate* isolate,
internal::Object** global_handle); internal::Object** global_handle);
static bool IsGlobalIndependent(internal::Object** global_handle); static bool IsGlobalIndependent(internal::Object** global_handle);
static bool IsGlobalIndependent(internal::Isolate* isolate, static bool IsGlobalIndependent(internal::Isolate* isolate,
internal::Object** global_handle); internal::Object** global_handle);
static bool IsGlobalNearDeath(internal::Object** global_handle); static bool IsGlobalNearDeath(internal::Object** global_handle);
static bool IsGlobalWeak(internal::Object** global_handle); static bool IsGlobalWeak(internal::Object** global_handle);
static bool IsGlobalWeak(internal::Isolate* isolate, static bool IsGlobalWeak(internal::Isolate* isolate,
internal::Object** global_handle); internal::Object** global_handle);
static void SetWrapperClassId(internal::Object** global_handle,
uint16_t class_id);
static uint16_t GetWrapperClassId(internal::Object** global_handle);
template <class T> friend class Handle; template <class T> friend class Handle;
template <class T> friend class Local; template <class T> friend class Local;
template <class T> friend class Persistent; template <class T> friend class Persistent;
friend class Context; friend class Context;
}; };
/** /**
* An external exception handler. * An external exception handler.
*/ */
skipping to change at line 3718 skipping to change at line 3718
* context that was in place when entering the current context. * context that was in place when entering the current context.
*/ */
void Exit(); void Exit();
/** Returns true if the context has experienced an out of memory situatio n. */ /** Returns true if the context has experienced an out of memory situatio n. */
bool HasOutOfMemoryException(); bool HasOutOfMemoryException();
/** Returns true if V8 has a current context. */ /** Returns true if V8 has a current context. */
static bool InContext(); static bool InContext();
/** Returns an isolate associated with a current context. */
v8::Isolate* GetIsolate();
/** /**
* Gets the embedder data with the given index, which must have been set by a * Gets the embedder data with the given index, which must have been set by a
* previous call to SetEmbedderData with the same index. Note that index 0 * previous call to SetEmbedderData with the same index. Note that index 0
* currently has a special meaning for Chrome's debugger. * currently has a special meaning for Chrome's debugger.
*/ */
V8_INLINE(Local<Value> GetEmbedderData(int index)); V8_INLINE(Local<Value> GetEmbedderData(int index));
/** /**
* Sets the embedder data with the given index, growing the data as * Sets the embedder data with the given index, growing the data as
* needed. Note that index 0 currently has a special meaning for Chrome's * needed. Note that index 0 currently has a special meaning for Chrome's
skipping to change at line 3800 skipping to change at line 3803
friend class Value; friend class Value;
friend class Script; friend class Script;
friend class Object; friend class Object;
friend class Function; friend class Function;
Local<Value> SlowGetEmbedderData(int index); Local<Value> SlowGetEmbedderData(int index);
void* SlowGetAlignedPointerFromEmbedderData(int index); void* SlowGetAlignedPointerFromEmbedderData(int index);
}; };
/** /**
* 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 all
* is allowed to use any given V8 isolate. See Isolate class owed
* comments. The definition of 'using V8 isolate' includes * to use any given V8 isolate, see the comments in the Isolate class. The
* accessing handles or holding onto object pointers obtained * definition of 'using a V8 isolate' includes accessing handles or holding
* from V8 handles while in the particular V8 isolate. It is up onto
* to the user of V8 to ensure (perhaps with locking) that this * object pointers obtained from V8 handles while in the particular V8 isol
* constraint is not violated. In addition to any other synchronization ate.
* mechanism that may be used, the v8::Locker and v8::Unlocker classes * It is up to the user of V8 to ensure, perhaps with locking, that this
* must be used to signal thead switches to V8. * constraint is not violated. In addition to any other synchronization
* * mechanism that may be used, the v8::Locker and v8::Unlocker classes must
* v8::Locker is a scoped lock object. While it's be
* active (i.e. between its construction and destruction) the current threa * used to signal thead switches to V8.
d is *
* allowed to use the locked isolate. V8 guarantees that an isolate can be * v8::Locker is a scoped lock object. While it's active, i.e. between its
* locked by at most one thread at any time. In other words, the scope of a * construction and destruction, the current thread is allowed to use the l
* v8::Locker is a critical section. ocked
* isolate. V8 guarantees that an isolate can be locked by at most one thre
ad at
* any time. In other words, the scope of a v8::Locker is a critical sectio
n.
* *
* Sample usage: * Sample usage:
* \code * \code
* ... * ...
* { * {
* v8::Locker locker(isolate); * v8::Locker locker(isolate);
* v8::Isolate::Scope isolate_scope(isolate); * v8::Isolate::Scope isolate_scope(isolate);
* ... * ...
* // Code using V8 and isolate goes here. * // Code using V8 and isolate goes here.
* ... * ...
* } // Destructor called here * } // Destructor called here
* \endcode * \endcode
* *
* If you wish to stop using V8 in a thread A you can do this either * If you wish to stop using V8 in a thread A you can do this either by
* by destroying the v8::Locker object as above or by constructing a * destroying the v8::Locker object as above or by constructing a v8::Unloc
* v8::Unlocker object: ker
* object:
* *
* \code * \code
* { * {
* isolate->Exit(); * isolate->Exit();
* v8::Unlocker unlocker(isolate); * v8::Unlocker unlocker(isolate);
* ... * ...
* // Code not using V8 goes here while V8 can run in another thread. * // Code not using V8 goes here while V8 can run in another thread.
* ... * ...
* } // Destructor called here. * } // Destructor called here.
* isolate->Enter(); * isolate->Enter();
* \endcode * \endcode
* *
* The Unlocker object is intended for use in a long-running callback * The Unlocker object is intended for use in a long-running callback from
* from V8, where you want to release the V8 lock for other threads to V8,
* use. * where you want to release the V8 lock for other threads to use.
* *
* The v8::Locker is a recursive lock. That is, you can lock more than * The v8::Locker is a recursive lock, i.e. you can lock more than once in
* once in a given thread. This can be useful if you have code that can a
* be called either from code that holds the lock or from code that does * given thread. This can be useful if you have code that can be called eit
* not. The Unlocker is not recursive so you can not have several her
* Unlockers on the stack at once, and you can not use an Unlocker in a * from code that holds the lock or from code that does not. The Unlocker i
* thread that is not inside a Locker's scope. s
* not recursive so you can not have several Unlockers on the stack at once
, and
* you can not use an Unlocker in a thread that is not inside a Locker's sc
ope.
* *
* An unlocker will unlock several lockers if it has to and reinstate * An unlocker will unlock several lockers if it has to and reinstate the
* the correct depth of locking on its destruction. eg.: * correct depth of locking on its destruction, e.g.:
* *
* \code * \code
* // V8 not locked. * // V8 not locked.
* { * {
* v8::Locker locker(isolate); * v8::Locker locker(isolate);
* Isolate::Scope isolate_scope(isolate); * Isolate::Scope isolate_scope(isolate);
* // V8 locked. * // V8 locked.
* { * {
* v8::Locker another_locker(isolate); * v8::Locker another_locker(isolate);
* // V8 still locked (2 levels). * // V8 still locked (2 levels).
skipping to change at line 3878 skipping to change at line 3877
* v8::Unlocker unlocker(isolate); * v8::Unlocker unlocker(isolate);
* // V8 not locked. * // V8 not locked.
* } * }
* isolate->Enter(); * isolate->Enter();
* // V8 locked again (2 levels). * // V8 locked again (2 levels).
* } * }
* // V8 still locked (1 level). * // V8 still locked (1 level).
* } * }
* // V8 Now no longer locked. * // V8 Now no longer locked.
* \endcode * \endcode
*
*
*/ */
class V8EXPORT Unlocker { class V8EXPORT Unlocker {
public: public:
/** /**
* Initialize Unlocker for a given Isolate. NULL means default isolate. * Initialize Unlocker for a given Isolate.
*/ */
explicit Unlocker(Isolate* isolate = NULL); V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); }
/**
* Deprecated. Use Isolate version instead.
*/
V8_DEPRECATED(Unlocker());
~Unlocker(); ~Unlocker();
private: private:
void Initialize(Isolate* isolate);
internal::Isolate* isolate_; internal::Isolate* isolate_;
}; };
class V8EXPORT Locker { class V8EXPORT Locker {
public: public:
/** /**
* Initialize Locker for a given Isolate. NULL means default isolate. * Initialize Locker for a given Isolate.
*/
V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); }
/**
* Deprecated. Use Isolate version instead.
*/ */
explicit Locker(Isolate* isolate = NULL); V8_DEPRECATED(Locker());
~Locker(); ~Locker();
/** /**
* Start preemption. * Start preemption.
* *
* When preemption is started, a timer is fired every n milliseconds * When preemption is started, a timer is fired every n milliseconds
* that will switch between multiple threads that are in contention * that will switch between multiple threads that are in contention
* for the V8 lock. * for the V8 lock.
*/ */
static void StartPreemption(int every_n_ms); static void StartPreemption(int every_n_ms);
/** /**
* Stop preemption. * Stop preemption.
*/ */
static void StopPreemption(); static void StopPreemption();
/** /**
* Returns whether or not the locker for a given isolate, or default isol * Returns whether or not the locker for a given isolate, is locked by th
ate e
* if NULL is given, is locked by the current thread. * current thread.
*/ */
static bool IsLocked(Isolate* isolate = NULL); static bool IsLocked(Isolate* isolate);
/** /**
* Returns whether v8::Locker is being used by this V8 instance. * Returns whether v8::Locker is being used by this V8 instance.
*/ */
static bool IsActive(); static bool IsActive();
private: private:
void Initialize(Isolate* isolate);
bool has_lock_; bool has_lock_;
bool top_level_; bool top_level_;
internal::Isolate* isolate_; internal::Isolate* isolate_;
static bool active_; static bool active_;
// Disallow copying and assigning. // Disallow copying and assigning.
Locker(const Locker&); Locker(const Locker&);
void operator=(const Locker&); void operator=(const Locker&);
}; };
skipping to change at line 4067 skipping to change at line 4080
static const int kContextHeaderSize = 2 * kApiPointerSize; static const int kContextHeaderSize = 2 * kApiPointerSize;
static const int kContextEmbedderDataIndex = 54; static const int kContextEmbedderDataIndex = 54;
static const int kFullStringRepresentationMask = 0x07; static const int kFullStringRepresentationMask = 0x07;
static const int kStringEncodingMask = 0x4; static const int kStringEncodingMask = 0x4;
static const int kExternalTwoByteRepresentationTag = 0x02; static const int kExternalTwoByteRepresentationTag = 0x02;
static const int kExternalAsciiRepresentationTag = 0x06; static const int kExternalAsciiRepresentationTag = 0x06;
static const int kIsolateStateOffset = 0; static const int kIsolateStateOffset = 0;
static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
static const int kIsolateRootsOffset = 3 * kApiPointerSize; static const int kIsolateRootsOffset = 3 * kApiPointerSize;
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
static const int kUndefinedValueRootIndex = 5; static const int kUndefinedValueRootIndex = 5;
static const int kNullValueRootIndex = 7; static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8; static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9; static const int kFalseValueRootIndex = 9;
static const int kEmptySymbolRootIndex = 119; static const int kEmptySymbolRootIndex = 119;
static const int kNodeIsIndependentShift = 4;
static const int kNodeIsPartiallyDependentShift = 5;
static const int kJSObjectType = 0xab; static const int kJSObjectType = 0xab;
static const int kFirstNonstringType = 0x80; static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x82; static const int kOddballType = 0x82;
static const int kForeignType = 0x85; static const int kForeignType = 0x85;
static const int kUndefinedOddballKind = 5; static const int kUndefinedOddballKind = 5;
static const int kNullOddballKind = 3; static const int kNullOddballKind = 3;
V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) {
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
skipping to change at line 4111 skipping to change at line 4129
V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) {
int representation = (instance_type & kFullStringRepresentationMask); int representation = (instance_type & kFullStringRepresentationMask);
return representation == kExternalTwoByteRepresentationTag; return representation == kExternalTwoByteRepresentationTag;
} }
V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) { V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffs et; uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffs et;
return *reinterpret_cast<int*>(addr) == 1; return *reinterpret_cast<int*>(addr) == 1;
} }
V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift))
{
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
return *addr & (1 << shift);
}
V8_INLINE(static void UpdateNodeFlag(internal::Object** obj,
bool value, int shift)) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
uint8_t mask = 1 << shift;
*addr = (*addr & ~mask) | (value << shift);
}
V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
kIsolateEmbedderDataOffset; kIsolateEmbedderDataOffset;
*reinterpret_cast<void**>(addr) = data; *reinterpret_cast<void**>(addr) = data;
} }
V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
kIsolateEmbedderDataOffset; kIsolateEmbedderDataOffset;
return *reinterpret_cast<void**>(addr); return *reinterpret_cast<void**>(addr);
skipping to change at line 4198 skipping to change at line 4228
} }
template <class T> template <class T>
bool Persistent<T>::IsIndependent() const { bool Persistent<T>::IsIndependent() const {
if (this->IsEmpty()) return false; if (this->IsEmpty()) return false;
return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**thi s)); return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**thi s));
} }
template <class T> template <class T>
bool Persistent<T>::IsIndependent(Isolate* isolate) const { bool Persistent<T>::IsIndependent(Isolate* isolate) const {
typedef internal::Internals I;
if (this->IsEmpty()) return false; if (this->IsEmpty()) return false;
return V8::IsGlobalIndependent(reinterpret_cast<internal::Isolate*>(isola if (!I::IsInitialized(isolate)) return false;
te), return I::GetNodeFlag(reinterpret_cast<internal::Object**>(**this),
reinterpret_cast<internal::Object**>(**thi I::kNodeIsIndependentShift);
s));
} }
template <class T> template <class T>
bool Persistent<T>::IsNearDeath() const { bool Persistent<T>::IsNearDeath() const {
if (this->IsEmpty()) return false; if (this->IsEmpty()) return false;
return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this) ); return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this) );
} }
template <class T> template <class T>
bool Persistent<T>::IsWeak() const { bool Persistent<T>::IsWeak() const {
skipping to change at line 4266 skipping to change at line 4298
V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); V8::ClearWeak(reinterpret_cast<internal::Object**>(**this));
} }
template <class T> template <class T>
void Persistent<T>::MarkIndependent() { void Persistent<T>::MarkIndependent() {
V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this));
} }
template <class T> template <class T>
void Persistent<T>::MarkIndependent(Isolate* isolate) { void Persistent<T>::MarkIndependent(Isolate* isolate) {
V8::MarkIndependent(reinterpret_cast<internal::Isolate*>(isolate), typedef internal::Internals I;
reinterpret_cast<internal::Object**>(**this)); if (this->IsEmpty()) return;
if (!I::IsInitialized(isolate)) return;
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
true, I::kNodeIsIndependentShift);
} }
template <class T> template <class T>
void Persistent<T>::MarkPartiallyDependent() { void Persistent<T>::MarkPartiallyDependent() {
V8::MarkPartiallyDependent(reinterpret_cast<internal::Object**>(**this)); V8::MarkPartiallyDependent(reinterpret_cast<internal::Object**>(**this));
} }
template <class T> template <class T>
void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) { void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
V8::MarkPartiallyDependent(reinterpret_cast<internal::Isolate*>(isolate), typedef internal::Internals I;
reinterpret_cast<internal::Object**>(**this)); if (this->IsEmpty()) return;
if (!I::IsInitialized(isolate)) return;
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
true, I::kNodeIsPartiallyDependentShift);
} }
template <class T> template <class T>
void Persistent<T>::SetWrapperClassId(uint16_t class_id) { void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class typedef internal::Internals I;
_id); internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
*reinterpret_cast<uint16_t*>(addr) = class_id;
} }
template <class T> template <class T>
uint16_t Persistent<T>::WrapperClassId() const { uint16_t Persistent<T>::WrapperClassId() const {
return V8::GetWrapperClassId(reinterpret_cast<internal::Object**>(**this) typedef internal::Internals I;
); internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
return *reinterpret_cast<uint16_t*>(addr);
} }
Arguments::Arguments(internal::Object** implicit_args, Arguments::Arguments(internal::Object** implicit_args,
internal::Object** values, int length, internal::Object** values, int length,
bool is_construct_call) bool is_construct_call)
: implicit_args_(implicit_args), : implicit_args_(implicit_args),
values_(values), values_(values),
length_(length), length_(length),
is_construct_call_(is_construct_call) { } is_construct_call_(is_construct_call) { }
 End of changes. 27 change blocks. 
61 lines changed or deleted 115 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/