diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-02 17:11:31 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-06 16:53:06 +0200 |
commit | 704fd8f3745527fc080f96e54e5ec1857c505399 (patch) | |
tree | bff68e8a731f3618d3e8f1708aa9de194bc1f612 /deps/v8/include | |
parent | eec43351c44c0bec31a83e1a28be15e30722936a (diff) | |
download | node-new-704fd8f3745527fc080f96e54e5ec1857c505399.tar.gz |
v8: upgrade to v3.20.2
Diffstat (limited to 'deps/v8/include')
-rw-r--r-- | deps/v8/include/v8-profiler.h | 69 | ||||
-rw-r--r-- | deps/v8/include/v8.h | 342 |
2 files changed, 223 insertions, 188 deletions
diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index d740df3bb7..df3bd9ff6b 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -75,6 +75,9 @@ class V8EXPORT CpuProfileNode { /** Returns function name (empty string for anonymous functions.) */ Handle<String> GetFunctionName() const; + /** Returns id of the script where function is located. */ + int GetScriptId() const; + /** Returns resource name for script from where the function originates. */ Handle<String> GetScriptResourceName() const; @@ -172,18 +175,12 @@ class V8EXPORT CpuProfiler { * obtaining profiling results. */ - /** Deprecated. Use GetProfileCount instead. */ - V8_DEPRECATED(static int GetProfilesCount()); /** * Returns the number of profiles collected (doesn't include * profiles that are being collected at the moment of call.) */ int GetProfileCount(); - /** Deprecated. Use GetCpuProfile instead. */ - V8_DEPRECATED(static const CpuProfile* GetProfile( - int index, - Handle<Value> security_token = Handle<Value>())); /** Deprecated. Use GetCpuProfile with single parameter. */ V8_DEPRECATED(const CpuProfile* GetCpuProfile( int index, @@ -191,18 +188,11 @@ class V8EXPORT CpuProfiler { /** Returns a profile by index. */ const CpuProfile* GetCpuProfile(int index); - /** Deprecated. Use FindProfile instead. */ - V8_DEPRECATED(static const CpuProfile* FindProfile( - unsigned uid, - Handle<Value> security_token = Handle<Value>())); /** Returns a profile by uid. */ V8_DEPRECATED(const CpuProfile* FindCpuProfile( unsigned uid, Handle<Value> security_token = Handle<Value>())); - /** Deprecated. Use StartCpuProfiling instead. */ - V8_DEPRECATED(static void StartProfiling(Handle<String> title, - bool record_samples = false)); /** * Starts collecting CPU profile. Title may be an empty string. It * is allowed to have several profiles being collected at @@ -216,10 +206,6 @@ class V8EXPORT CpuProfiler { */ void StartCpuProfiling(Handle<String> title, bool record_samples = false); - /** Deprecated. Use StopCpuProfiling instead. */ - V8_DEPRECATED(static const CpuProfile* StopProfiling( - Handle<String> title, - Handle<Value> security_token = Handle<Value>())); /** * Deprecated. Use StopCpuProfiling with one parameter instead. */ @@ -232,8 +218,6 @@ class V8EXPORT CpuProfiler { */ const CpuProfile* StopCpuProfiling(Handle<String> title); - /** Deprecated. Use DeleteAllCpuProfiles instead. */ - V8_DEPRECATED(static void DeleteAllProfiles()); /** * Deletes all existing profiles, also cancelling all profiling * activity. All previously returned pointers to profiles and their @@ -346,16 +330,10 @@ class V8EXPORT HeapGraphNode { */ class V8EXPORT HeapSnapshot { public: - enum Type { - kFull = 0 // Heap snapshot with all instances and references. - }; enum SerializationFormat { kJSON = 0 // See format description near 'Serialize' method. }; - /** Deprecated. Returns kFull. */ - V8_DEPRECATED(Type GetType() const); - /** Returns heap snapshot UID (assigned by the profiler.) */ unsigned GetUid() const; @@ -431,24 +409,12 @@ class V8EXPORT HeapProfiler { typedef RetainedObjectInfo* (*WrapperInfoCallback) (uint16_t class_id, Handle<Value> wrapper); - /** Deprecated. Use GetSnapshotCount instead. */ - V8_DEPRECATED(static int GetSnapshotsCount()); /** Returns the number of snapshots taken. */ int GetSnapshotCount(); - /** Deprecated. Use GetHeapSnapshot instead. */ - V8_DEPRECATED(static const HeapSnapshot* GetSnapshot(int index)); /** Returns a snapshot by index. */ const HeapSnapshot* GetHeapSnapshot(int index); - /** Deprecated. Use FindHeapSnapshot instead. */ - V8_DEPRECATED(static const HeapSnapshot* FindSnapshot(unsigned uid)); - /** Returns a profile by uid. */ - V8_DEPRECATED(const HeapSnapshot* FindHeapSnapshot(unsigned uid)); - - /** Deprecated. Use GetObjectId instead. */ - V8_DEPRECATED(static SnapshotObjectId GetSnapshotObjectId( - Handle<Value> value)); /** * Returns SnapshotObjectId for a heap object referenced by |value| if * it has been seen by the heap profiler, kUnknownObjectId otherwise. @@ -476,12 +442,6 @@ class V8EXPORT HeapProfiler { virtual ~ObjectNameResolver() {} }; - /** Deprecated. Use TakeHeapSnapshot instead. */ - V8_DEPRECATED(static const HeapSnapshot* TakeSnapshot( - Handle<String> title, - HeapSnapshot::Type type = HeapSnapshot::kFull, - ActivityControl* control = NULL, - ObjectNameResolver* global_object_name_resolver = NULL)); /** * Takes a heap snapshot and returns it. Title may be an empty string. */ @@ -490,9 +450,6 @@ class V8EXPORT HeapProfiler { ActivityControl* control = NULL, ObjectNameResolver* global_object_name_resolver = NULL); - - /** Deprecated. Use StartTrackingHeapObjects instead. */ - V8_DEPRECATED(static void StartHeapObjectsTracking()); /** * Starts tracking of heap objects population statistics. After calling * this method, all heap objects relocations done by the garbage collector @@ -500,9 +457,6 @@ class V8EXPORT HeapProfiler { */ void StartTrackingHeapObjects(); - /** Deprecated. Use GetHeapStats instead. */ - V8_DEPRECATED(static SnapshotObjectId PushHeapObjectsStats( - OutputStream* stream)); /** * Adds a new time interval entry to the aggregated statistics array. The * time interval entry contains information on the current heap objects @@ -517,8 +471,6 @@ class V8EXPORT HeapProfiler { */ SnapshotObjectId GetHeapStats(OutputStream* stream); - /** Deprecated. Use StopTrackingHeapObjects instead. */ - V8_DEPRECATED(static void StopHeapObjectsTracking()); /** * Stops tracking of heap objects population statistics, cleans up all * collected data. StartHeapObjectsTracking must be called again prior to @@ -526,18 +478,12 @@ class V8EXPORT HeapProfiler { */ void StopTrackingHeapObjects(); - /** Deprecated. Use DeleteAllHeapSnapshots instead. */ - V8_DEPRECATED(static void DeleteAllSnapshots()); /** * Deletes all snapshots taken. All previously returned pointers to * snapshots and their contents become invalid after this call. */ void DeleteAllHeapSnapshots(); - /** Deprecated. Use SetWrapperClassInfoProvider instead. */ - V8_DEPRECATED(static void DefineWrapperClass( - uint16_t class_id, - WrapperInfoCallback callback)); /** Binds a callback to embedder's class ID. */ void SetWrapperClassInfoProvider( uint16_t class_id, @@ -550,13 +496,6 @@ class V8EXPORT HeapProfiler { */ static const uint16_t kPersistentHandleNoClassId = 0; - /** - * Deprecated. Returns the number of currently existing persistent handles. - */ - V8_DEPRECATED(static int GetPersistentHandleCount()); - - /** Deprecated. Use GetHeapProfilerMemorySize instead. */ - V8_DEPRECATED(static size_t GetMemorySizeUsedByProfiler()); /** Returns memory used for profiler internal data and snapshots. */ size_t GetProfilerMemorySize(); @@ -590,7 +529,7 @@ class V8EXPORT HeapProfiler { * objects for heap snapshots, he can do it in a GC prologue * handler, and / or by assigning wrapper class ids in the following way: * - * 1. Bind a callback to class id by calling DefineWrapperClass. + * 1. Bind a callback to class id by calling SetWrapperClassInfoProvider. * 2. Call SetWrapperClassId on certain persistent handles. * * V8 takes ownership of RetainedObjectInfo instances passed to it and diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index c0bec79b01..3afb83572a 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -123,7 +123,6 @@ class ImplementationUtilities; class Int32; class Integer; class Isolate; -class LocalContext; class Number; class NumberObject; class Object; @@ -155,6 +154,7 @@ class Isolate; class DeclaredAccessorDescriptor; class ObjectOperationDescriptor; class RawOperationDescriptor; +class CallHandlerHelper; namespace internal { class Arguments; @@ -162,8 +162,7 @@ class Heap; class HeapObject; class Isolate; class Object; -template<typename T> -class CustomArguments; +template<typename T> class CustomArguments; class PropertyCallbackArguments; class FunctionCallbackArguments; } @@ -222,8 +221,6 @@ class WeakReferenceCallbacks { } -#define V8_USE_UNSAFE_HANDLES - /** * An object reference managed by the v8 garbage collector. * @@ -365,21 +362,19 @@ template <class T> class Handle { #endif private: + friend class Utils; template<class F> friend class Persistent; template<class F> friend class Local; friend class Arguments; template<class F> friend class FunctionCallbackInfo; template<class F> friend class PropertyCallbackInfo; - friend class String; - friend class Object; + template<class F> friend class internal::CustomArguments; friend class AccessorInfo; friend Handle<Primitive> Undefined(Isolate* isolate); friend Handle<Primitive> Null(Isolate* isolate); friend Handle<Boolean> True(Isolate* isolate); friend Handle<Boolean> False(Isolate* isolate); friend class Context; - friend class InternalHandleHelper; - friend class LocalContext; friend class HandleScope; #ifndef V8_USE_UNSAFE_HANDLES @@ -454,6 +449,7 @@ template <class T> class Local : public Handle<T> { #endif private: + friend class Utils; template<class F> friend class Persistent; template<class F> friend class Handle; friend class Arguments; @@ -463,8 +459,7 @@ template <class T> class Local : public Handle<T> { friend class Object; friend class AccessorInfo; friend class Context; - friend class InternalHandleHelper; - friend class LocalContext; + template<class F> friend class internal::CustomArguments; friend class HandleScope; V8_INLINE(static Local<T> New(Isolate* isolate, T* that)); @@ -496,10 +491,10 @@ template <class T> class Persistent // NOLINT public: #ifndef V8_USE_UNSAFE_HANDLES V8_INLINE(Persistent()) : val_(0) { } - V8_INLINE(~Persistent()) { - // TODO(dcarney): add this back before cutover. - // Dispose(); - } + // TODO(dcarney): add this back before cutover. +// V8_INLINE(~Persistent()) { +// Dispose(); +// } V8_INLINE(bool IsEmpty() const) { return val_ == 0; } // TODO(dcarney): remove somehow before cutover // The handle should either be 0, or a pointer to a live cell. @@ -511,11 +506,11 @@ template <class T> class Persistent // NOLINT * to be separately disposed. */ template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that)) - : val_(*New(isolate, that)) { } + : val_(New(isolate, *that)) { } template <class S> V8_INLINE(Persistent(Isolate* isolate, - Persistent<S>& that)) // NOLINT - : val_(*New(isolate, that)) { } + const Persistent<S>& that)) // NOLINT + : val_(New(isolate, *that)) { } #else /** @@ -594,15 +589,9 @@ template <class T> class Persistent // NOLINT } #endif +#ifdef V8_USE_UNSAFE_HANDLES V8_DEPRECATED(static Persistent<T> New(Handle<T> that)); - - /** - * Creates a new persistent handle for an existing local or persistent handle. - */ - // TODO(dcarney): remove before cutover V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that)); -#ifndef V8_USE_UNSAFE_HANDLES - // TODO(dcarney): remove before cutover V8_INLINE(static Persistent<T> New(Isolate* isolate, Persistent<T> that)); #endif @@ -652,23 +641,17 @@ template <class T> class Persistent // NOLINT P* parameters, typename WeakReferenceCallbacks<T, P>::Revivable callback)); - // TODO(dcarney): deprecate template<typename S, typename P> - V8_INLINE(void MakeWeak( + V8_DEPRECATED(void MakeWeak( Isolate* isolate, P* parameters, - typename WeakReferenceCallbacks<S, P>::Revivable callback)) { - MakeWeak<S, P>(parameters, callback); - } + typename WeakReferenceCallbacks<S, P>::Revivable callback)); - // TODO(dcarney): deprecate template<typename P> - V8_INLINE(void MakeWeak( + V8_DEPRECATED(void MakeWeak( Isolate* isolate, P* parameters, - typename WeakReferenceCallbacks<T, P>::Revivable callback)) { - MakeWeak<P>(parameters, callback); - } + typename WeakReferenceCallbacks<T, P>::Revivable callback)); V8_INLINE(void ClearWeak()); @@ -779,11 +762,7 @@ template <class T> class Persistent // NOLINT #endif // TODO(dcarney): remove before cutover template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { } - // TODO(dcarney): remove before cutover - template <class S> V8_INLINE(Persistent(Persistent<S> that)) - : val_(*that) { - TYPE_CHECK(T, S); - } + // TODO(dcarney): remove before cutover V8_INLINE(T* operator*() const) { return val_; } @@ -794,16 +773,13 @@ template <class T> class Persistent // NOLINT #endif private: + friend class Utils; template<class F> friend class Handle; template<class F> friend class Local; + template<class F> friend class Persistent; template<class F> friend class ReturnValue; - friend class ImplementationUtilities; - friend class ObjectTemplate; - friend class Context; - friend class InternalHandleHelper; - friend class LocalContext; - V8_INLINE(static Persistent<T> New(Isolate* isolate, T* that)); + V8_INLINE(static T* New(Isolate* isolate, T* that)); #ifndef V8_USE_UNSAFE_HANDLES T* val_; @@ -1067,10 +1043,16 @@ class V8EXPORT Script { /** * Returns the script id value. + * DEPRECATED: Please use GetId(). */ Local<Value> Id(); /** + * Returns the script id. + */ + int GetId(); + + /** * Associate an additional data object with the script. This is mainly used * with the debugger as this data object is only available through the * debugger API. @@ -1087,6 +1069,8 @@ class V8EXPORT Script { * -1 will be returned if no information available. */ int GetLineNumber(int code_pos); + + static const int kNoScriptId = 0; }; @@ -1386,6 +1370,12 @@ class V8EXPORT Value : public Data { bool IsArrayBuffer() const; /** + * Returns true if this value is an ArrayBufferView. + * This is an experimental feature. + */ + bool IsArrayBufferView() const; + + /** * Returns true if this value is one of TypedArrays. * This is an experimental feature. */ @@ -1445,6 +1435,12 @@ class V8EXPORT Value : public Data { */ bool IsFloat64Array() const; + /** + * Returns true if this value is a DataView. + * This is an experimental feature. + */ + bool IsDataView() const; + Local<Boolean> ToBoolean() const; Local<Number> ToNumber() const; Local<String> ToString() const; @@ -2078,13 +2074,12 @@ class V8EXPORT Object : public Value { bool Delete(uint32_t index); - // TODO(dcarney): deprecate - bool SetAccessor(Handle<String> name, - AccessorGetter getter, - AccessorSetter setter = 0, - Handle<Value> data = Handle<Value>(), - AccessControl settings = DEFAULT, - PropertyAttribute attribute = None); + V8_DEPRECATED(bool SetAccessor(Handle<String> name, + AccessorGetter getter, + AccessorSetter setter = 0, + Handle<Value> data = Handle<Value>(), + AccessControl settings = DEFAULT, + PropertyAttribute attribute = None)); bool SetAccessor(Handle<String> name, AccessorGetterCallback getter, AccessorSetterCallback setter = 0, @@ -2360,7 +2355,18 @@ class V8EXPORT Function : public Object { * kLineOffsetNotFound if no information available. */ int GetScriptColumnNumber() const; + + /** + * Returns scriptId object. + * DEPRECATED: use ScriptId() instead. + */ Handle<Value> GetScriptId() const; + + /** + * Returns scriptId. + */ + int ScriptId() const; + ScriptOrigin GetScriptOrigin() const; V8_INLINE(static Function* Cast(Value* obj)); static const int kLineOffsetNotFound; @@ -2484,33 +2490,51 @@ class V8EXPORT ArrayBuffer : public Object { /** - * A base class for an instance of TypedArray series of constructors - * (ES6 draft 15.13.6). + * A base class for an instance of one of "views" over ArrayBuffer, + * including TypedArrays and DataView (ES6 draft 15.13). + * * This API is experimental and may change significantly. */ -class V8EXPORT TypedArray : public Object { +class V8EXPORT ArrayBufferView : public Object { public: /** * Returns underlying ArrayBuffer. */ Local<ArrayBuffer> Buffer(); /** - * Byte offset in |Buffer| + * Byte offset in |Buffer|. */ size_t ByteOffset(); /** - * Numbe of elements in this typed array. - */ - size_t Length(); - /** - * Size of typed array in bytes (e.g. for Int16Array, 2*|Length|). + * Size of a view in bytes. */ size_t ByteLength(); /** - * Base address of typed array. + * Base address of a view. */ void* BaseAddress(); + V8_INLINE(static ArrayBufferView* Cast(Value* obj)); + + private: + ArrayBufferView(); + static void CheckCast(Value* obj); +}; + + +/** + * A base class for an instance of TypedArray series of constructors + * (ES6 draft 15.13.6). + * This API is experimental and may change significantly. + */ +class V8EXPORT TypedArray : public ArrayBufferView { + public: + /** + * Number of elements in this typed array + * (e.g. for Int16Array, |ByteLength|/2). + */ + size_t Length(); + V8_INLINE(static TypedArray* Cast(Value* obj)); private: @@ -2663,6 +2687,22 @@ class V8EXPORT Float64Array : public TypedArray { /** + * An instance of DataView constructor (ES6 draft 15.13.7). + * This API is experimental and may change significantly. + */ +class V8EXPORT DataView : public ArrayBufferView { + public: + static Local<DataView> New(Handle<ArrayBuffer> array_buffer, + size_t byte_offset, size_t length); + V8_INLINE(static DataView* Cast(Value* obj)); + + private: + DataView(); + static void CheckCast(Value* obj); +}; + + +/** * An instance of the built-in Date constructor (ECMA-262, 15.9). */ class V8EXPORT Date : public Object { @@ -3220,14 +3260,13 @@ typedef bool (*IndexedSecurityCallback)(Local<Object> host, class V8EXPORT FunctionTemplate : public Template { public: /** Creates a function template.*/ - // TODO(dcarney): deprecate - static Local<FunctionTemplate> New( - InvocationCallback callback = 0, + V8_DEPRECATED(static Local<FunctionTemplate> New( + InvocationCallback callback, Handle<Value> data = Handle<Value>(), Handle<Signature> signature = Handle<Signature>(), - int length = 0); + int length = 0)); static Local<FunctionTemplate> New( - FunctionCallback callback, // TODO(dcarney): add back default param. + FunctionCallback callback = 0, Handle<Value> data = Handle<Value>(), Handle<Signature> signature = Handle<Signature>(), int length = 0); @@ -3240,9 +3279,8 @@ class V8EXPORT FunctionTemplate : public Template { * callback is called whenever the function created from this * FunctionTemplate is called. */ - // TODO(dcarney): deprecate - void SetCallHandler(InvocationCallback callback, - Handle<Value> data = Handle<Value>()); + V8_DEPRECATED(void SetCallHandler(InvocationCallback callback, + Handle<Value> data = Handle<Value>())); void SetCallHandler(FunctionCallback callback, Handle<Value> data = Handle<Value>()); @@ -3296,6 +3334,9 @@ class V8EXPORT FunctionTemplate : public Template { private: FunctionTemplate(); + // TODO(dcarney): Remove with SetCallHandler. + friend class v8::CallHandlerHelper; + void SetCallHandlerInternal(InvocationCallback callback, Handle<Value> data); friend class Context; friend class ObjectTemplate; }; @@ -3344,15 +3385,14 @@ class V8EXPORT ObjectTemplate : public Template { * defined by FunctionTemplate::HasInstance()), an implicit TypeError is * thrown and no callback is invoked. */ - // TODO(dcarney): deprecate - void SetAccessor(Handle<String> name, - AccessorGetter getter, - AccessorSetter setter = 0, - Handle<Value> data = Handle<Value>(), - AccessControl settings = DEFAULT, - PropertyAttribute attribute = None, - Handle<AccessorSignature> signature = - Handle<AccessorSignature>()); + V8_DEPRECATED(void SetAccessor(Handle<String> name, + AccessorGetter getter, + AccessorSetter setter = 0, + Handle<Value> data = Handle<Value>(), + AccessControl settings = DEFAULT, + PropertyAttribute attribute = None, + Handle<AccessorSignature> signature = + Handle<AccessorSignature>())); void SetAccessor(Handle<String> name, AccessorGetterCallback getter, AccessorSetterCallback setter = 0, @@ -3387,13 +3427,13 @@ class V8EXPORT ObjectTemplate : public Template { * \param data A piece of data that will be passed to the callbacks * whenever they are invoked. */ - // TODO(dcarney): deprecate - void SetNamedPropertyHandler(NamedPropertyGetter getter, - NamedPropertySetter setter = 0, - NamedPropertyQuery query = 0, - NamedPropertyDeleter deleter = 0, - NamedPropertyEnumerator enumerator = 0, - Handle<Value> data = Handle<Value>()); + V8_DEPRECATED(void SetNamedPropertyHandler( + NamedPropertyGetter getter, + NamedPropertySetter setter = 0, + NamedPropertyQuery query = 0, + NamedPropertyDeleter deleter = 0, + NamedPropertyEnumerator enumerator = 0, + Handle<Value> data = Handle<Value>())); void SetNamedPropertyHandler( NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter = 0, @@ -3418,13 +3458,13 @@ class V8EXPORT ObjectTemplate : public Template { * \param data A piece of data that will be passed to the callbacks * whenever they are invoked. */ - // TODO(dcarney): deprecate - void SetIndexedPropertyHandler(IndexedPropertyGetter getter, - IndexedPropertySetter setter = 0, - IndexedPropertyQuery query = 0, - IndexedPropertyDeleter deleter = 0, - IndexedPropertyEnumerator enumerator = 0, - Handle<Value> data = Handle<Value>()); + V8_DEPRECATED(void SetIndexedPropertyHandler( + IndexedPropertyGetter getter, + IndexedPropertySetter setter = 0, + IndexedPropertyQuery query = 0, + IndexedPropertyDeleter deleter = 0, + IndexedPropertyEnumerator enumerator = 0, + Handle<Value> data = Handle<Value>())); void SetIndexedPropertyHandler( IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter = 0, @@ -3439,9 +3479,9 @@ class V8EXPORT ObjectTemplate : public Template { * behave like normal JavaScript objects that cannot be called as a * function. */ - // TODO(dcarney): deprecate - void SetCallAsFunctionHandler(InvocationCallback callback, - Handle<Value> data = Handle<Value>()); + V8_DEPRECATED(void SetCallAsFunctionHandler( + InvocationCallback callback, + Handle<Value> data = Handle<Value>())); void SetCallAsFunctionHandler(FunctionCallback callback, Handle<Value> data = Handle<Value>()); @@ -3953,8 +3993,9 @@ class V8EXPORT Isolate { HeapProfiler* GetHeapProfiler(); /** - * Returns CPU profiler for this isolate. Will return NULL until the isolate - * is initialized. + * Returns CPU profiler for this isolate. Will return NULL unless the isolate + * is initialized. It is the embedder's responsibility to stop all CPU + * profiling activities if it has started any. */ CpuProfiler* GetCpuProfiler(); @@ -4437,18 +4478,25 @@ class V8EXPORT V8 { ReturnAddressLocationResolver return_address_resolver); /** + * Deprecated, use the variant with the Isolate parameter below instead. + */ + V8_DEPRECATED(static bool SetFunctionEntryHook(FunctionEntryHook entry_hook)); + + /** * Allows the host application to provide the address of a function that's * invoked on entry to every V8-generated function. * Note that \p entry_hook is invoked at the very start of each * generated function. * + * \param isolate the isolate to operate on. * \param entry_hook a function that will be invoked on entry to every * V8-generated function. * \returns true on success on supported platforms, false on failure. - * \note Setting a new entry hook function when one is already active will - * fail. + * \note Setting an entry hook can only be done very early in an isolates + * lifetime, and once set, the entry hook cannot be revoked. */ - static bool SetFunctionEntryHook(FunctionEntryHook entry_hook); + static bool SetFunctionEntryHook(Isolate* isolate, + FunctionEntryHook entry_hook); /** * Allows the host application to provide the address of a function that is @@ -4776,7 +4824,10 @@ class V8EXPORT TryCatch { v8::internal::Isolate* isolate_; void* next_; void* exception_; - void* message_; + void* message_obj_; + void* message_script_; + int message_start_pos_; + int message_end_pos_; bool is_verbose_ : 1; bool can_continue_ : 1; bool capture_message_ : 1; @@ -5320,20 +5371,19 @@ class Internals { static const int kJSObjectHeaderSize = 3 * kApiPointerSize; static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; static const int kContextHeaderSize = 2 * kApiPointerSize; - static const int kContextEmbedderDataIndex = 64; + static const int kContextEmbedderDataIndex = 65; static const int kFullStringRepresentationMask = 0x07; static const int kStringEncodingMask = 0x4; static const int kExternalTwoByteRepresentationTag = 0x02; static const int kExternalAsciiRepresentationTag = 0x06; - static const int kIsolateStateOffset = 0; static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; static const int kIsolateRootsOffset = 3 * kApiPointerSize; static const int kUndefinedValueRootIndex = 5; static const int kNullValueRootIndex = 7; static const int kTrueValueRootIndex = 8; static const int kFalseValueRootIndex = 9; - static const int kEmptyStringRootIndex = 130; + static const int kEmptyStringRootIndex = 131; static const int kNodeClassIdOffset = 1 * kApiPointerSize; static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; @@ -5343,14 +5393,21 @@ class Internals { static const int kNodeIsIndependentShift = 4; static const int kNodeIsPartiallyDependentShift = 5; - static const int kJSObjectType = 0xaf; + static const int kJSObjectType = 0xb0; static const int kFirstNonstringType = 0x80; static const int kOddballType = 0x83; - static const int kForeignType = 0x87; + static const int kForeignType = 0x88; static const int kUndefinedOddballKind = 5; static const int kNullOddballKind = 3; + static void CheckInitializedImpl(v8::Isolate* isolate); + V8_INLINE(static void CheckInitialized(v8::Isolate* isolate)) { +#ifdef V8_ENABLE_CHECKS + CheckInitializedImpl(isolate); +#endif + } + V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == kHeapObjectTag); @@ -5384,11 +5441,6 @@ class Internals { return representation == kExternalTwoByteRepresentationTag; } - V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) { - uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; - 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); @@ -5510,6 +5562,7 @@ Local<T> Local<T>::New(Isolate* isolate, T* that) { } +#ifdef V8_USE_UNSAFE_HANDLES template <class T> Persistent<T> Persistent<T>::New(Handle<T> that) { return New(Isolate::GetCurrent(), that.val_); @@ -5521,20 +5574,20 @@ Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) { return New(Isolate::GetCurrent(), that.val_); } -#ifndef V8_USE_UNSAFE_HANDLES template <class T> Persistent<T> Persistent<T>::New(Isolate* isolate, Persistent<T> that) { return New(Isolate::GetCurrent(), that.val_); } #endif + template <class T> -Persistent<T> Persistent<T>::New(Isolate* isolate, T* that) { - if (that == NULL) return Persistent<T>(); +T* Persistent<T>::New(Isolate* isolate, T* that) { + if (that == NULL) return NULL; internal::Object** p = reinterpret_cast<internal::Object**>(that); - return Persistent<T>(reinterpret_cast<T*>( + return reinterpret_cast<T*>( V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), - p))); + p)); } @@ -5598,6 +5651,26 @@ void Persistent<T>::MakeWeak( template <class T> +template <typename S, typename P> +void Persistent<T>::MakeWeak( + Isolate* isolate, + P* parameters, + typename WeakReferenceCallbacks<S, P>::Revivable callback) { + MakeWeak<S, P>(parameters, callback); +} + + +template <class T> +template<typename P> +void Persistent<T>::MakeWeak( + Isolate* isolate, + P* parameters, + typename WeakReferenceCallbacks<T, P>::Revivable callback) { + MakeWeak<P>(parameters, callback); +} + + +template <class T> void Persistent<T>::ClearWeak() { V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); } @@ -5716,11 +5789,13 @@ void ReturnValue<T>::Set(const Handle<S> handle) { template<typename T> void ReturnValue<T>::Set(double i) { + TYPE_CHECK(T, Number); Set(Number::New(GetIsolate(), i)); } template<typename T> void ReturnValue<T>::Set(int32_t i) { + TYPE_CHECK(T, Integer); typedef internal::Internals I; if (V8_LIKELY(I::IsValidSmi(i))) { *value_ = I::IntToSmi(i); @@ -5731,6 +5806,7 @@ void ReturnValue<T>::Set(int32_t i) { template<typename T> void ReturnValue<T>::Set(uint32_t i) { + TYPE_CHECK(T, Integer); typedef internal::Internals I; // Can't simply use INT32_MAX here for whatever reason. bool fits_into_int32_t = (i & (1 << 31)) == 0; @@ -5743,6 +5819,7 @@ void ReturnValue<T>::Set(uint32_t i) { template<typename T> void ReturnValue<T>::Set(bool value) { + TYPE_CHECK(T, Boolean); typedef internal::Internals I; int root_index; if (value) { @@ -5755,18 +5832,21 @@ void ReturnValue<T>::Set(bool value) { template<typename T> void ReturnValue<T>::SetNull() { + TYPE_CHECK(T, Primitive); typedef internal::Internals I; *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex); } template<typename T> void ReturnValue<T>::SetUndefined() { + TYPE_CHECK(T, Primitive); typedef internal::Internals I; *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex); } template<typename T> void ReturnValue<T>::SetEmptyString() { + TYPE_CHECK(T, String); typedef internal::Internals I; *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex); } @@ -5936,7 +6016,7 @@ String* String::Cast(v8::Value* value) { Local<String> String::Empty(Isolate* isolate) { typedef internal::Object* S; typedef internal::Internals I; - if (!I::IsInitialized(isolate)) return Empty(); + I::CheckInitialized(isolate); S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); return Local<String>(reinterpret_cast<String*>(slot)); } @@ -6160,6 +6240,14 @@ ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { } +ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) { +#ifdef V8_ENABLE_CHECKS + CheckCast(value); +#endif + return static_cast<ArrayBufferView*>(value); +} + + TypedArray* TypedArray::Cast(v8::Value* value) { #ifdef V8_ENABLE_CHECKS CheckCast(value); @@ -6240,6 +6328,14 @@ Uint8ClampedArray* Uint8ClampedArray::Cast(v8::Value* value) { } +DataView* DataView::Cast(v8::Value* value) { +#ifdef V8_ENABLE_CHECKS + CheckCast(value); +#endif + return static_cast<DataView*>(value); +} + + Function* Function::Cast(v8::Value* value) { #ifdef V8_ENABLE_CHECKS CheckCast(value); @@ -6289,7 +6385,7 @@ ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const { Handle<Primitive> Undefined(Isolate* isolate) { typedef internal::Object* S; typedef internal::Internals I; - if (!I::IsInitialized(isolate)) return Undefined(); + I::CheckInitialized(isolate); S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); } @@ -6298,7 +6394,7 @@ Handle<Primitive> Undefined(Isolate* isolate) { Handle<Primitive> Null(Isolate* isolate) { typedef internal::Object* S; typedef internal::Internals I; - if (!I::IsInitialized(isolate)) return Null(); + I::CheckInitialized(isolate); S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); } @@ -6307,7 +6403,7 @@ Handle<Primitive> Null(Isolate* isolate) { Handle<Boolean> True(Isolate* isolate) { typedef internal::Object* S; typedef internal::Internals I; - if (!I::IsInitialized(isolate)) return True(); + I::CheckInitialized(isolate); S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); } @@ -6316,7 +6412,7 @@ Handle<Boolean> True(Isolate* isolate) { Handle<Boolean> False(Isolate* isolate) { typedef internal::Object* S; typedef internal::Internals I; - if (!I::IsInitialized(isolate)) return False(); + I::CheckInitialized(isolate); S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); } |