| v8.h | | v8.h | |
| | | | |
| skipping to change at line 95 | | skipping to change at line 95 | |
| #endif | | #endif | |
| | | | |
| #if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS | | #if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS | |
| #define V8_DEPRECATED(declarator) declarator __attribute__ ((deprecated)) | | #define V8_DEPRECATED(declarator) declarator __attribute__ ((deprecated)) | |
| #elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS | | #elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS | |
| #define V8_DEPRECATED(declarator) __declspec(deprecated) declarator | | #define V8_DEPRECATED(declarator) __declspec(deprecated) declarator | |
| #else | | #else | |
| #define V8_DEPRECATED(declarator) declarator | | #define V8_DEPRECATED(declarator) declarator | |
| #endif | | #endif | |
| | | | |
|
| | | #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) | |
| | | #define V8_UNLIKELY(condition) __builtin_expect((condition), 0) | |
| | | #define V8_LIKELY(condition) __builtin_expect((condition), 1) | |
| | | #else | |
| | | #define V8_UNLIKELY(condition) (condition) | |
| | | #define V8_LIKELY(condition) (condition) | |
| | | #endif | |
| | | | |
| /** | | /** | |
| * The v8 JavaScript engine. | | * The v8 JavaScript engine. | |
| */ | | */ | |
| namespace v8 { | | namespace v8 { | |
| | | | |
| class AccessorInfo; | | class AccessorInfo; | |
| class AccessorSignature; | | class AccessorSignature; | |
| class Array; | | class Array; | |
| class Boolean; | | class Boolean; | |
| class BooleanObject; | | class BooleanObject; | |
| | | | |
| skipping to change at line 147 | | skipping to change at line 155 | |
| template <class T> class Persistent; | | template <class T> class Persistent; | |
| | | | |
| namespace internal { | | namespace internal { | |
| class Arguments; | | class Arguments; | |
| class Heap; | | class Heap; | |
| class HeapObject; | | class HeapObject; | |
| class Isolate; | | class Isolate; | |
| class Object; | | class Object; | |
| } | | } | |
| | | | |
|
| | | /** | |
| | | * General purpose unique identifier. | |
| | | */ | |
| | | class UniqueId { | |
| | | public: | |
| | | explicit UniqueId(intptr_t data) | |
| | | : data_(data) {} | |
| | | | |
| | | bool operator==(const UniqueId& other) const { | |
| | | return data_ == other.data_; | |
| | | } | |
| | | | |
| | | bool operator!=(const UniqueId& other) const { | |
| | | return data_ != other.data_; | |
| | | } | |
| | | | |
| | | bool operator<(const UniqueId& other) const { | |
| | | return data_ < other.data_; | |
| | | } | |
| | | | |
| | | private: | |
| | | intptr_t data_; | |
| | | }; | |
| | | | |
| // --- Weak Handles --- | | // --- Weak Handles --- | |
| | | | |
| /** | | /** | |
| * 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. | |
| * | | * | |
| * \param object the weak global object to be reclaimed by the garbage coll
ector | | * \param object the weak global object to be reclaimed by the garbage coll
ector | |
| * \param parameter the value passed in when making the weak global object | | * \param parameter the value passed in when making the weak global object | |
| | | | |
| skipping to change at line 376 | | skipping to change at line 408 | |
| * This check fails when trying to convert between incompatible | | * This check fails when trying to convert between incompatible | |
| * handles. For example, converting from a Handle<String> to a | | * handles. For example, converting from a Handle<String> to a | |
| * Handle<Number>. | | * Handle<Number>. | |
| */ | | */ | |
| TYPE_CHECK(T, S); | | TYPE_CHECK(T, S); | |
| } | | } | |
| | | | |
| template <class S> V8_INLINE(Persistent(S* that)) : Handle<T>(that) { } | | template <class S> V8_INLINE(Persistent(S* that)) : Handle<T>(that) { } | |
| | | | |
| /** | | /** | |
|
| | | * A constructor that creates a new global cell pointing to that. In cont | |
| | | rast | |
| | | * to the copy constructor, this creates a new persistent handle which ne | |
| | | eds | |
| | | * to be separately disposed. | |
| | | */ | |
| | | template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that) | |
| | | ) | |
| | | : Handle<T>(New(isolate, that)) { } | |
| | | | |
| | | /** | |
| * "Casts" a plain handle which is known to be a persistent handle | | * "Casts" a plain handle which is known to be a persistent handle | |
| * to a persistent handle. | | * to a persistent handle. | |
| */ | | */ | |
| template <class S> explicit V8_INLINE(Persistent(Handle<S> that)) | | template <class S> explicit V8_INLINE(Persistent(Handle<S> that)) | |
| : Handle<T>(*that) { } | | : Handle<T>(*that) { } | |
| | | | |
| template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that
)) { | | template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that
)) { | |
| #ifdef V8_ENABLE_CHECKS | | #ifdef V8_ENABLE_CHECKS | |
| // If we're going to perform the type check then we have to check | | // If we're going to perform the type check then we have to check | |
| // that the handle isn't empty before doing the checked cast. | | // that the handle isn't empty before doing the checked cast. | |
| | | | |
| skipping to change at line 1127 | | skipping to change at line 1167 | |
| */ | | */ | |
| int Length() const; | | int Length() const; | |
| | | | |
| /** | | /** | |
| * Returns the number of bytes in the UTF-8 encoded | | * Returns the number of bytes in the UTF-8 encoded | |
| * representation of this string. | | * representation of this string. | |
| */ | | */ | |
| int Utf8Length() const; | | int Utf8Length() const; | |
| | | | |
| /** | | /** | |
|
| * A fast conservative check for non-ASCII characters. May | | * This function is no longer useful. | |
| * return true even for ASCII strings, but if it returns | | | |
| * false you can be sure that all characters are in the range | | | |
| * 0-127. | | | |
| */ | | */ | |
|
| bool MayContainNonAscii() const; | | // TODO(dcarney): deprecate | |
| | | V8_INLINE(bool MayContainNonAscii()) const { return true; } | |
| | | | |
| /** | | /** | |
| * Returns whether this string contains only one byte data. | | * Returns whether this string contains only one byte data. | |
| */ | | */ | |
| 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 | |
| | | | |
| skipping to change at line 1944 | | skipping to change at line 1982 | |
| ScriptOrigin GetScriptOrigin() const; | | ScriptOrigin GetScriptOrigin() const; | |
| V8_INLINE(static Function* Cast(Value* obj)); | | V8_INLINE(static Function* Cast(Value* obj)); | |
| static const int kLineOffsetNotFound; | | static const int kLineOffsetNotFound; | |
| | | | |
| private: | | private: | |
| Function(); | | Function(); | |
| static void CheckCast(Value* obj); | | static void CheckCast(Value* obj); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
|
| | | * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). | |
| | | * This API is experimental and may change significantly. | |
| | | */ | |
| | | class V8EXPORT ArrayBuffer : public Object { | |
| | | public: | |
| | | /** | |
| | | * Data length in bytes. | |
| | | */ | |
| | | size_t ByteLength() const; | |
| | | /** | |
| | | * Raw pointer to the array buffer data | |
| | | */ | |
| | | void* Data() const; | |
| | | | |
| | | /** | |
| | | * Create a new ArrayBuffer. Allocate |byte_length| bytes. | |
| | | * Allocated memory will be owned by a created ArrayBuffer and | |
| | | * will be deallocated when it is garbage-collected. | |
| | | */ | |
| | | static Local<ArrayBuffer> New(size_t byte_length); | |
| | | | |
| | | /** | |
| | | * Create a new ArrayBuffer over an existing memory block. | |
| | | * The memory block will not be reclaimed when a created ArrayBuffer | |
| | | * is garbage-collected. | |
| | | */ | |
| | | static Local<ArrayBuffer> New(void* data, size_t byte_length); | |
| | | | |
| | | V8_INLINE(static ArrayBuffer* Cast(Value* obj)); | |
| | | | |
| | | private: | |
| | | ArrayBuffer(); | |
| | | static void CheckCast(Value* obj); | |
| | | }; | |
| | | | |
| | | /** | |
| * An instance of the built-in Date constructor (ECMA-262, 15.9). | | * An instance of the built-in Date constructor (ECMA-262, 15.9). | |
| */ | | */ | |
| class V8EXPORT Date : public Object { | | class V8EXPORT Date : public Object { | |
| public: | | public: | |
| static Local<Value> New(double time); | | static Local<Value> New(double time); | |
| | | | |
| /** | | /** | |
| * A specialization of Value::NumberValue that is more efficient | | * A specialization of Value::NumberValue that is more efficient | |
| * because we know the structure of this object. | | * because we know the structure of this object. | |
| */ | | */ | |
| | | | |
| skipping to change at line 2916 | | skipping to change at line 2990 | |
| * such operations will result in the allocation of objects. | | * such operations will result in the allocation of objects. | |
| */ | | */ | |
| enum GCType { | | enum GCType { | |
| kGCTypeScavenge = 1 << 0, | | kGCTypeScavenge = 1 << 0, | |
| kGCTypeMarkSweepCompact = 1 << 1, | | kGCTypeMarkSweepCompact = 1 << 1, | |
| kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact | | kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact | |
| }; | | }; | |
| | | | |
| enum GCCallbackFlags { | | enum GCCallbackFlags { | |
| kNoGCCallbackFlags = 0, | | kNoGCCallbackFlags = 0, | |
|
| kGCCallbackFlagCompacted = 1 << 0 | | kGCCallbackFlagCompacted = 1 << 0, | |
| | | kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1 | |
| }; | | }; | |
| | | | |
| typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags); | | typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags); | |
| typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags); | | typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags); | |
| | | | |
| typedef void (*GCCallback)(); | | typedef void (*GCCallback)(); | |
| | | | |
| /** | | /** | |
| * Collection of V8 heap information. | | * Collection of V8 heap information. | |
| * | | * | |
| | | | |
| skipping to change at line 3071 | | skipping to change at line 3146 | |
| | | | |
| /** | | /** | |
| * Returns CPU profiler for this isolate. Will return NULL until the isol
ate | | * Returns CPU profiler for this isolate. Will return NULL until the isol
ate | |
| * is initialized. | | * is initialized. | |
| */ | | */ | |
| CpuProfiler* GetCpuProfiler(); | | CpuProfiler* GetCpuProfiler(); | |
| | | | |
| /** Returns the context that is on the top of the stack. */ | | /** Returns the context that is on the top of the stack. */ | |
| Local<Context> GetCurrentContext(); | | Local<Context> GetCurrentContext(); | |
| | | | |
|
| | | /** | |
| | | * Allows the host application to group objects together. If one | |
| | | * object in the group is alive, all objects in the group are alive. | |
| | | * After each garbage collection, object groups are removed. It is | |
| | | * intended to be used in the before-garbage-collection callback | |
| | | * function, for instance to simulate DOM tree connections among JS | |
| | | * wrapper objects. Object groups for all dependent handles need to | |
| | | * be provided for kGCTypeMarkSweepCompact collections, for all other | |
| | | * garbage collection types it is sufficient to provide object groups | |
| | | * for partially dependent handles only. | |
| | | */ | |
| | | void SetObjectGroupId(const Persistent<Value>& object, | |
| | | UniqueId id); | |
| | | | |
| | | /** | |
| | | * Allows the host application to declare implicit references from an obj | |
| | | ect | |
| | | * group to an object. If the objects of the object group are alive, the | |
| | | child | |
| | | * object is alive too. After each garbage collection, all implicit refer | |
| | | ences | |
| | | * are removed. It is intended to be used in the before-garbage-collectio | |
| | | n | |
| | | * callback function. | |
| | | */ | |
| | | void SetReferenceFromGroup(UniqueId id, | |
| | | const Persistent<Value>& child); | |
| | | | |
| | | /** | |
| | | * Allows the host application to declare implicit references from an obj | |
| | | ect | |
| | | * to another object. If the parent object is alive, the child object is | |
| | | alive | |
| | | * too. After each garbage collection, all implicit references are remove | |
| | | d. It | |
| | | * is intended to be used in the before-garbage-collection callback funct | |
| | | ion. | |
| | | */ | |
| | | void SetReference(const Persistent<Object>& parent, | |
| | | const Persistent<Value>& child); | |
| | | | |
| private: | | private: | |
| Isolate(); | | Isolate(); | |
| Isolate(const Isolate&); | | Isolate(const Isolate&); | |
| ~Isolate(); | | ~Isolate(); | |
| Isolate& operator=(const Isolate&); | | Isolate& operator=(const Isolate&); | |
| void* operator new(size_t size); | | void* operator new(size_t size); | |
| void operator delete(void*, size_t); | | void operator delete(void*, size_t); | |
| }; | | }; | |
| | | | |
| class V8EXPORT StartupData { | | class V8EXPORT StartupData { | |
| | | | |
| skipping to change at line 3465 | | skipping to change at line 3573 | |
| * object in the group is alive, all objects in the group are alive. | | * object in the group is alive, all objects in the group are alive. | |
| * After each garbage collection, object groups are removed. It is | | * After each garbage collection, object groups are removed. It is | |
| * intended to be used in the before-garbage-collection callback | | * intended to be used in the before-garbage-collection callback | |
| * function, for instance to simulate DOM tree connections among JS | | * function, for instance to simulate DOM tree connections among JS | |
| * wrapper objects. Object groups for all dependent handles need to | | * wrapper objects. Object groups for all dependent handles need to | |
| * be provided for kGCTypeMarkSweepCompact collections, for all other | | * be provided for kGCTypeMarkSweepCompact collections, for all other | |
| * garbage collection types it is sufficient to provide object groups | | * garbage collection types it is sufficient to provide object groups | |
| * for partially dependent handles only. | | * for partially dependent handles only. | |
| * See v8-profiler.h for RetainedObjectInfo interface description. | | * See v8-profiler.h for RetainedObjectInfo interface description. | |
| */ | | */ | |
|
| | | // TODO(marja): deprecate AddObjectGroup. Use Isolate::SetObjectGroupId a | |
| | | nd | |
| | | // HeapProfiler::SetRetainedObjectInfo instead. | |
| static void AddObjectGroup(Persistent<Value>* objects, | | static void AddObjectGroup(Persistent<Value>* objects, | |
| size_t length, | | size_t length, | |
| RetainedObjectInfo* info = NULL); | | RetainedObjectInfo* info = NULL); | |
| static void AddObjectGroup(Isolate* isolate, | | static void AddObjectGroup(Isolate* isolate, | |
| Persistent<Value>* objects, | | Persistent<Value>* objects, | |
| size_t length, | | size_t length, | |
| RetainedObjectInfo* info = NULL); | | RetainedObjectInfo* info = NULL); | |
| | | | |
| /** | | /** | |
| * Allows the host application to declare implicit references between | | * Allows the host application to declare implicit references between | |
| * the objects: if |parent| is alive, all |children| are alive too. | | * the objects: if |parent| is alive, all |children| are alive too. | |
| * After each garbage collection, all implicit references | | * After each garbage collection, all implicit references | |
| * are removed. It is intended to be used in the before-garbage-collecti
on | | * are removed. It is intended to be used in the before-garbage-collecti
on | |
| * callback function. | | * callback function. | |
| */ | | */ | |
|
| | | // TODO(marja): Deprecate AddImplicitReferences. Use | |
| | | // Isolate::SetReferenceFromGroup instead. | |
| static void AddImplicitReferences(Persistent<Object> parent, | | static void AddImplicitReferences(Persistent<Object> parent, | |
| Persistent<Value>* children, | | Persistent<Value>* children, | |
| size_t length); | | size_t length); | |
| | | | |
| /** | | /** | |
| * Initializes from snapshot if possible. Otherwise, attempts to | | * Initializes from snapshot if possible. Otherwise, attempts to | |
| * initialize from scratch. This function is called implicitly if | | * initialize from scratch. This function is called implicitly if | |
| * you use the API without calling it first. | | * you use the API without calling it first. | |
| */ | | */ | |
| static bool Initialize(); | | static bool Initialize(); | |
| | | | |
| skipping to change at line 4339 | | skipping to change at line 4451 | |
| // the implementation of v8. | | // the implementation of v8. | |
| static const int kHeapObjectMapOffset = 0; | | static const int kHeapObjectMapOffset = 0; | |
| static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSi
ze; | | static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSi
ze; | |
| static const int kStringResourceOffset = 3 * kApiPointerSize; | | static const int kStringResourceOffset = 3 * kApiPointerSize; | |
| | | | |
| static const int kOddballKindOffset = 3 * kApiPointerSize; | | static const int kOddballKindOffset = 3 * kApiPointerSize; | |
| static const int kForeignAddressOffset = kApiPointerSize; | | static const int kForeignAddressOffset = kApiPointerSize; | |
| static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | | static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | |
| static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | | static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | |
| static const int kContextHeaderSize = 2 * kApiPointerSize; | | static const int kContextHeaderSize = 2 * kApiPointerSize; | |
|
| static const int kContextEmbedderDataIndex = 55; | | static const int kContextEmbedderDataIndex = 56; | |
| 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 kUndefinedValueRootIndex = 5; | | static const int kUndefinedValueRootIndex = 5; | |
| static const int kNullValueRootIndex = 7; | | static const int kNullValueRootIndex = 7; | |
| | | | |
| skipping to change at line 4752 | | skipping to change at line 4864 | |
| return SlowGetInternalField(index); | | return SlowGetInternalField(index); | |
| } | | } | |
| | | | |
| void* Object::GetAlignedPointerFromInternalField(int index) { | | void* Object::GetAlignedPointerFromInternalField(int index) { | |
| #ifndef V8_ENABLE_CHECKS | | #ifndef V8_ENABLE_CHECKS | |
| typedef internal::Object O; | | typedef internal::Object O; | |
| typedef internal::Internals I; | | typedef internal::Internals I; | |
| O* obj = *reinterpret_cast<O**>(this); | | O* obj = *reinterpret_cast<O**>(this); | |
| // Fast path: If the object is a plain JSObject, which is the common case
, we | | // Fast path: If the object is a plain JSObject, which is the common case
, we | |
| // know where to find the internal fields and can return the value direct
ly. | | // know where to find the internal fields and can return the value direct
ly. | |
|
| if (I::GetInstanceType(obj) == I::kJSObjectType) { | | if (V8_LIKELY(I::GetInstanceType(obj) == I::kJSObjectType)) { | |
| int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde
x); | | int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde
x); | |
| return I::ReadField<void*>(obj, offset); | | return I::ReadField<void*>(obj, offset); | |
| } | | } | |
| #endif | | #endif | |
| return SlowGetAlignedPointerFromInternalField(index); | | return SlowGetAlignedPointerFromInternalField(index); | |
| } | | } | |
| | | | |
| String* String::Cast(v8::Value* value) { | | String* String::Cast(v8::Value* value) { | |
| #ifdef V8_ENABLE_CHECKS | | #ifdef V8_ENABLE_CHECKS | |
| CheckCast(value); | | CheckCast(value); | |
| | | | |
| skipping to change at line 4959 | | skipping to change at line 5071 | |
| return static_cast<Object*>(value); | | return static_cast<Object*>(value); | |
| } | | } | |
| | | | |
| Array* Array::Cast(v8::Value* value) { | | Array* Array::Cast(v8::Value* value) { | |
| #ifdef V8_ENABLE_CHECKS | | #ifdef V8_ENABLE_CHECKS | |
| CheckCast(value); | | CheckCast(value); | |
| #endif | | #endif | |
| return static_cast<Array*>(value); | | return static_cast<Array*>(value); | |
| } | | } | |
| | | | |
|
| | | ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { | |
| | | #ifdef V8_ENABLE_CHECKS | |
| | | CheckCast(value); | |
| | | #endif | |
| | | return static_cast<ArrayBuffer*>(value); | |
| | | } | |
| | | | |
| Function* Function::Cast(v8::Value* value) { | | Function* Function::Cast(v8::Value* value) { | |
| #ifdef V8_ENABLE_CHECKS | | #ifdef V8_ENABLE_CHECKS | |
| CheckCast(value); | | CheckCast(value); | |
| #endif | | #endif | |
| return static_cast<Function*>(value); | | return static_cast<Function*>(value); | |
| } | | } | |
| | | | |
| External* External::Cast(v8::Value* value) { | | External* External::Cast(v8::Value* value) { | |
| #ifdef V8_ENABLE_CHECKS | | #ifdef V8_ENABLE_CHECKS | |
| CheckCast(value); | | CheckCast(value); | |
| | | | |
End of changes. 13 change blocks. |
| 8 lines changed or deleted | | 139 lines changed or added | |
|