summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/v8/include/v8.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/v8/include/v8.h')
-rw-r--r--src/3rdparty/v8/include/v8.h351
1 files changed, 310 insertions, 41 deletions
diff --git a/src/3rdparty/v8/include/v8.h b/src/3rdparty/v8/include/v8.h
index 3416cd4..27c5855 100644
--- a/src/3rdparty/v8/include/v8.h
+++ b/src/3rdparty/v8/include/v8.h
@@ -63,15 +63,16 @@
#else // _WIN32
// Setup for Linux shared library export.
-#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED)
+#if defined(__GNUC__) && ((__GNUC__ >= 4) || \
+ (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED)
#ifdef BUILDING_V8_SHARED
#define V8EXPORT __attribute__ ((visibility("default")))
#else
#define V8EXPORT
#endif
-#else // defined(__GNUC__) && (__GNUC__ >= 4)
+#else
#define V8EXPORT
-#endif // defined(__GNUC__) && (__GNUC__ >= 4)
+#endif
#endif // _WIN32
@@ -100,6 +101,7 @@ class Function;
class Date;
class ImplementationUtilities;
class Signature;
+class AccessorSignature;
template <class T> class Handle;
template <class T> class Local;
template <class T> class Persistent;
@@ -379,6 +381,7 @@ template <class T> class Persistent : public Handle<T> {
* cell remain and IsEmpty will still return false.
*/
inline void Dispose();
+ inline void Dispose(Isolate* isolate);
/**
* Make the reference to this object weak. When only weak handles
@@ -388,7 +391,7 @@ template <class T> class Persistent : public Handle<T> {
*/
inline void MakeWeak(void* parameters, WeakReferenceCallback callback);
- /** Clears the weak reference to this object.*/
+ /** Clears the weak reference to this object. */
inline void ClearWeak();
/**
@@ -399,15 +402,27 @@ template <class T> class Persistent : public Handle<T> {
* or followed by a global GC epilogue callback.
*/
inline void MarkIndependent();
+ inline void MarkIndependent(Isolate* isolate);
/**
- *Checks if the handle holds the only reference to an object.
+ * Marks the reference to this object partially dependent. Partially
+ * dependent handles only depend on other partially dependent handles and
+ * these dependencies are provided through object groups. It provides a way
+ * to build smaller object groups for young objects that represent only a
+ * subset of all external dependencies. This mark is automatically cleared
+ * after each garbage collection.
*/
+ inline void MarkPartiallyDependent();
+ inline void MarkPartiallyDependent(Isolate* isolate);
+
+ /** Returns true if this handle was previously marked as independent. */
+ inline bool IsIndependent() const;
+ inline bool IsIndependent(Isolate* isolate) const;
+
+ /** Checks if the handle holds the only reference to an object. */
inline bool IsNearDeath() const;
- /**
- * Returns true if the handle's reference is weak.
- */
+ /** Returns true if the handle's reference is weak. */
inline bool IsWeak() const;
/**
@@ -416,6 +431,12 @@ template <class T> class Persistent : public Handle<T> {
*/
inline void SetWrapperClassId(uint16_t class_id);
+ /**
+ * Returns the class ID previously assigned to this handle or 0 if no class
+ * ID was previously assigned.
+ */
+ inline uint16_t WrapperClassId() const;
+
private:
friend class ImplementationUtilities;
friend class ObjectTemplate;
@@ -1032,6 +1053,11 @@ class Boolean : public Primitive {
*/
class String : public Primitive {
public:
+ enum Encoding {
+ UNKNOWN_ENCODING = 0x1,
+ TWO_BYTE_ENCODING = 0x0,
+ ASCII_ENCODING = 0x4
+ };
/**
* Returns the number of characters in this string.
*/
@@ -1087,16 +1113,6 @@ class String : public Primitive {
V8EXPORT static uint32_t ComputeHash(char *string, int length);
/**
- * Returns true if this string is equal to the external
- * string data provided.
- */
- V8EXPORT bool Equals(uint16_t *string, int length);
- V8EXPORT bool Equals(char *string, int length);
- inline bool Equals(Handle<Value> that) const {
- return v8::Value::Equals(that);
- }
-
- /**
* Write the contents of the string to an external buffer.
* If no arguments are given, expects the buffer to be large
* enough to hold the entire string and NULL terminator. Copies
@@ -1124,11 +1140,10 @@ class String : public Primitive {
enum WriteOptions {
NO_OPTIONS = 0,
HINT_MANY_WRITES_EXPECTED = 1,
- NO_NULL_TERMINATION = 2
+ NO_NULL_TERMINATION = 2,
+ PRESERVE_ASCII_NULL = 4
};
- V8EXPORT uint16_t GetCharacter(int index);
-
// 16-bit character codes.
V8EXPORT int Write(uint16_t* buffer,
int start = 0,
@@ -1241,6 +1256,14 @@ class String : public Primitive {
};
/**
+ * If the string is an external string, return the ExternalStringResourceBase
+ * regardless of the encoding, otherwise return NULL. The encoding of the
+ * string is returned in encoding_out.
+ */
+ inline ExternalStringResourceBase* GetExternalStringResourceBase(
+ Encoding* encoding_out) const;
+
+ /**
* Get the ExternalStringResource for an external string. Returns
* NULL if IsExternal() doesn't return true.
*/
@@ -1403,6 +1426,8 @@ class String : public Primitive {
};
private:
+ V8EXPORT void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
+ Encoding encoding) const;
V8EXPORT void VerifyExternalStringResource(ExternalStringResource* val) const;
V8EXPORT static void CheckCast(v8::Value* obj);
};
@@ -1429,6 +1454,8 @@ class Integer : public Number {
public:
V8EXPORT static Local<Integer> New(int32_t value);
V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value);
+ V8EXPORT static Local<Integer> New(int32_t value, Isolate*);
+ V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*);
V8EXPORT int64_t Value() const;
static inline Integer* Cast(v8::Value* obj);
private:
@@ -1613,6 +1640,12 @@ class Object : public Value {
V8EXPORT Local<String> ObjectProtoToString();
/**
+ * Returns the function invoked as a constructor for this object.
+ * May be the null value.
+ */
+ V8EXPORT Local<Value> GetConstructor();
+
+ /**
* Returns the name of the function invoked as a constructor for this object.
*/
V8EXPORT Local<String> GetConstructorName();
@@ -2371,7 +2404,8 @@ class V8EXPORT FunctionTemplate : public Template {
AccessorSetter setter,
Handle<Value> data,
AccessControl settings,
- PropertyAttribute attributes);
+ PropertyAttribute attributes,
+ Handle<AccessorSignature> signature);
void SetNamedInstancePropertyHandler(NamedPropertyGetter getter,
NamedPropertySetter setter,
NamedPropertyQuery query,
@@ -2430,13 +2464,20 @@ class V8EXPORT ObjectTemplate : public Template {
* cross-context access.
* \param attribute The attributes of the property for which an accessor
* is added.
+ * \param signature The signature describes valid receivers for the accessor
+ * and is used to perform implicit instance checks against them. If the
+ * receiver is incompatible (i.e. is not an instance of the constructor as
+ * defined by FunctionTemplate::HasInstance()), an implicit TypeError is
+ * thrown and no callback is invoked.
*/
void SetAccessor(Handle<String> name,
AccessorGetter getter,
AccessorSetter setter = 0,
Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT,
- PropertyAttribute attribute = None);
+ PropertyAttribute attribute = None,
+ Handle<AccessorSignature> signature =
+ Handle<AccessorSignature>());
/**
* Sets a named property handler on the object template.
@@ -2545,7 +2586,7 @@ class V8EXPORT ObjectTemplate : public Template {
void SetHasExternalResource(bool value);
/**
- * Mark object instances of the template as using the user object
+ * Mark object instances of the template as using the user object
* comparison callback.
*/
void MarkAsUseUserObjectComparison();
@@ -2558,8 +2599,8 @@ class V8EXPORT ObjectTemplate : public Template {
/**
- * A Signature specifies which receivers and arguments a function can
- * legally be called with.
+ * A Signature specifies which receivers and arguments are valid
+ * parameters to a function.
*/
class V8EXPORT Signature : public Data {
public:
@@ -2573,6 +2614,19 @@ class V8EXPORT Signature : public Data {
/**
+ * An AccessorSignature specifies which receivers are valid parameters
+ * to an accessor callback.
+ */
+class V8EXPORT AccessorSignature : public Data {
+ public:
+ static Local<AccessorSignature> New(Handle<FunctionTemplate> receiver =
+ Handle<FunctionTemplate>());
+ private:
+ AccessorSignature();
+};
+
+
+/**
* A utility for determining the type of objects based on the template
* they were constructed from.
*/
@@ -2709,7 +2763,7 @@ bool V8EXPORT SetResourceConstraints(ResourceConstraints* constraints);
typedef void (*FatalErrorCallback)(const char* location, const char* message);
-typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> data);
+typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error);
/**
@@ -2777,8 +2831,8 @@ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
AccessType type,
Local<Value> data);
-// --- User Object Comparisoa nCallback ---
-typedef bool (*UserObjectComparisonCallback)(Local<Object> lhs,
+// --- User Object Comparison Callback ---
+typedef bool (*UserObjectComparisonCallback)(Local<Object> lhs,
Local<Object> rhs);
// --- AllowCodeGenerationFromStrings callbacks ---
@@ -2826,6 +2880,7 @@ class V8EXPORT HeapStatistics {
HeapStatistics();
size_t total_heap_size() { return total_heap_size_; }
size_t total_heap_size_executable() { return total_heap_size_executable_; }
+ size_t total_physical_size() { return total_physical_size_; }
size_t used_heap_size() { return used_heap_size_; }
size_t heap_size_limit() { return heap_size_limit_; }
@@ -2834,11 +2889,15 @@ class V8EXPORT HeapStatistics {
void set_total_heap_size_executable(size_t size) {
total_heap_size_executable_ = size;
}
+ void set_total_physical_size(size_t size) {
+ total_physical_size_ = size;
+ }
void set_used_heap_size(size_t size) { used_heap_size_ = size; }
void set_heap_size_limit(size_t size) { heap_size_limit_ = size; }
size_t total_heap_size_;
size_t total_heap_size_executable_;
+ size_t total_physical_size_;
size_t used_heap_size_;
size_t heap_size_limit_;
@@ -2992,17 +3051,86 @@ typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
* resolving the location of a return address on the stack. Profilers that
* change the return address on the stack can use this to resolve the stack
* location to whereever the profiler stashed the original return address.
- * When invoked, return_addr_location will point to a location on stack where
- * a machine return address resides, this function should return either the
- * same pointer, or a pointer to the profiler's copy of the original return
- * address.
+ *
+ * \param return_addr_location points to a location on stack where a machine
+ * return address resides.
+ * \returns either return_addr_location, or else a pointer to the profiler's
+ * copy of the original return address.
+ *
+ * \note the resolver function must not cause garbage collection.
*/
typedef uintptr_t (*ReturnAddressLocationResolver)(
uintptr_t return_addr_location);
/**
- * Interface for iterating though all external resources in the heap.
+ * FunctionEntryHook is the type of the profile entry hook called at entry to
+ * any generated function when function-level profiling is enabled.
+ *
+ * \param function the address of the function that's being entered.
+ * \param return_addr_location points to a location on stack where the machine
+ * return address resides. This can be used to identify the caller of
+ * \p function, and/or modified to divert execution when \p function exits.
+ *
+ * \note the entry hook must not cause garbage collection.
+ */
+typedef void (*FunctionEntryHook)(uintptr_t function,
+ uintptr_t return_addr_location);
+
+
+/**
+ * A JIT code event is issued each time code is added, moved or removed.
+ *
+ * \note removal events are not currently issued.
+ */
+struct JitCodeEvent {
+ enum EventType {
+ CODE_ADDED,
+ CODE_MOVED,
+ CODE_REMOVED
+ };
+
+ // Type of event.
+ EventType type;
+ // Start of the instructions.
+ void* code_start;
+ // Size of the instructions.
+ size_t code_len;
+
+ union {
+ // Only valid for CODE_ADDED.
+ struct {
+ // Name of the object associated with the code, note that the string is
+ // not zero-terminated.
+ const char* str;
+ // Number of chars in str.
+ size_t len;
+ } name;
+ // New location of instructions. Only valid for CODE_MOVED.
+ void* new_code_start;
+ };
+};
+
+/**
+ * Option flags passed to the SetJitCodeEventHandler function.
+ */
+enum JitCodeEventOptions {
+ kJitCodeEventDefault = 0,
+ // Generate callbacks for already existent code.
+ kJitCodeEventEnumExisting = 1
+};
+
+
+/**
+ * Callback function passed to SetJitCodeEventHandler.
+ *
+ * \param event code add, move or removal event.
+ */
+typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
+
+
+/**
+ * Interface for iterating through all external resources in the heap.
*/
class V8EXPORT ExternalResourceVisitor { // NOLINT
public:
@@ -3012,6 +3140,17 @@ class V8EXPORT ExternalResourceVisitor { // NOLINT
/**
+ * Interface for iterating through all the persistent handles in the heap.
+ */
+class V8EXPORT PersistentHandleVisitor { // NOLINT
+ public:
+ virtual ~PersistentHandleVisitor() {}
+ virtual void VisitPersistentHandle(Persistent<Value>,
+ uint16_t) {}
+};
+
+
+/**
* Container class for static utility functions.
*/
class V8EXPORT V8 {
@@ -3076,8 +3215,7 @@ class V8EXPORT V8 {
* The same message listener can be added more than once and in that
* case it will be called more than once for each message.
*/
- static bool AddMessageListener(MessageCallback that,
- Handle<Value> data = Handle<Value>());
+ static bool AddMessageListener(MessageCallback that);
/**
* Remove all message listeners from the specified callback function.
@@ -3226,7 +3364,10 @@ class V8EXPORT V8 {
* 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.
+ * 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.
* See v8-profiler.h for RetainedObjectInfo interface description.
*/
static void AddObjectGroup(Persistent<Value>* objects,
@@ -3265,6 +3406,43 @@ class V8EXPORT V8 {
ReturnAddressLocationResolver return_address_resolver);
/**
+ * 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 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.
+ */
+ static bool SetFunctionEntryHook(FunctionEntryHook entry_hook);
+
+ /**
+ * Allows the host application to provide the address of a function that is
+ * notified each time code is added, moved or removed.
+ *
+ * \param options options for the JIT code event handler.
+ * \param event_handler the JIT code event handler, which will be invoked
+ * each time code is added, moved or removed.
+ * \note \p event_handler won't get notified of existent code.
+ * \note since code removal notifications are not currently issued, the
+ * \p event_handler may get notifications of code that overlaps earlier
+ * code notifications. This happens when code areas are reused, and the
+ * earlier overlapping code areas should therefore be discarded.
+ * \note the events passed to \p event_handler and the strings they point to
+ * are not guaranteed to live past each call. The \p event_handler must
+ * copy strings and other parameters it needs to keep around.
+ * \note the set of events declared in JitCodeEvent::EventType is expected to
+ * grow over time, and the JitCodeEvent structure is expected to accrue
+ * new members. The \p event_handler function must ignore event codes
+ * it does not recognize to maintain future compatibility.
+ */
+ static void SetJitCodeEventHandler(JitCodeEventOptions options,
+ JitCodeEventHandler event_handler);
+
+ /**
* Adjusts the amount of registered external memory. Used to give
* V8 an indication of the amount of externally allocated memory
* that is kept alive by JavaScript objects. V8 uses this to decide
@@ -3379,12 +3557,18 @@ class V8EXPORT V8 {
/**
* Iterates through all external resources referenced from current isolate
- * heap. This method is not expected to be used except for debugging purposes
- * and may be quite slow.
+ * heap. GC is not invoked prior to iterating, therefore there is no
+ * guarantee that visited objects are still alive.
*/
static void VisitExternalResources(ExternalResourceVisitor* visitor);
/**
+ * Iterates through all the persistent handles in the current isolate's heap
+ * that have class_ids.
+ */
+ static void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
+
+ /**
* Optional notification that the embedder is idle.
* V8 uses the notification to reduce memory footprint.
* This call can be used repeatedly if the embedder remains idle.
@@ -3417,15 +3601,26 @@ class V8EXPORT V8 {
static internal::Object** GlobalizeReference(internal::Object** handle);
static void DisposeGlobal(internal::Object** global_handle);
+ static void DisposeGlobal(internal::Isolate* isolate,
+ internal::Object** global_handle);
static void MakeWeak(internal::Object** global_handle,
void* data,
WeakReferenceCallback);
static void ClearWeak(internal::Object** global_handle);
static void MarkIndependent(internal::Object** global_handle);
+ static void MarkIndependent(internal::Isolate* isolate,
+ internal::Object** global_handle);
+ static void MarkPartiallyDependent(internal::Object** global_handle);
+ static void MarkPartiallyDependent(internal::Isolate* isolate,
+ internal::Object** global_handle);
+ static bool IsGlobalIndependent(internal::Object** global_handle);
+ static bool IsGlobalIndependent(internal::Isolate* isolate,
+ internal::Object** global_handle);
static bool IsGlobalNearDeath(internal::Object** global_handle);
static bool IsGlobalWeak(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 Local;
@@ -3677,7 +3872,7 @@ class V8EXPORT Context {
* with the debugger to provide additional information on the context through
* the debugger API.
*/
- void SetData(Handle<String> data);
+ void SetData(Handle<Value> data);
Local<Value> GetData();
/**
@@ -3702,6 +3897,13 @@ class V8EXPORT Context {
bool IsCodeGenerationFromStringsAllowed();
/**
+ * Sets the error description for the exception that is thrown when
+ * code generation from strings is not allowed and 'eval' or the 'Function'
+ * constructor are called.
+ */
+ void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message);
+
+ /**
* Stack-allocated class which sets the execution context for all
* operations executed within a local scope.
*/
@@ -4010,7 +4212,9 @@ class Internals {
static const int kForeignAddressOffset = kApiPointerSize;
static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
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;
@@ -4019,7 +4223,7 @@ class Internals {
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
- static const int kEmptySymbolRootIndex = 128;
+ static const int kEmptySymbolRootIndex = 118;
static const int kJSObjectType = 0xaa;
static const int kFirstNonstringType = 0x80;
@@ -4139,6 +4343,21 @@ Persistent<T> Persistent<T>::New(Handle<T> that) {
template <class T>
+bool Persistent<T>::IsIndependent() const {
+ if (this->IsEmpty()) return false;
+ return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**this));
+}
+
+
+template <class T>
+bool Persistent<T>::IsIndependent(Isolate* isolate) const {
+ if (this->IsEmpty()) return false;
+ return V8::IsGlobalIndependent(reinterpret_cast<internal::Isolate*>(isolate),
+ reinterpret_cast<internal::Object**>(**this));
+}
+
+
+template <class T>
bool Persistent<T>::IsNearDeath() const {
if (this->IsEmpty()) return false;
return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this));
@@ -4160,6 +4379,14 @@ void Persistent<T>::Dispose() {
template <class T>
+void Persistent<T>::Dispose(Isolate* isolate) {
+ if (this->IsEmpty()) return;
+ V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate),
+ reinterpret_cast<internal::Object**>(**this));
+}
+
+
+template <class T>
Persistent<T>::Persistent() : Handle<T>() { }
template <class T>
@@ -4180,10 +4407,32 @@ void Persistent<T>::MarkIndependent() {
}
template <class T>
+void Persistent<T>::MarkIndependent(Isolate* isolate) {
+ V8::MarkIndependent(reinterpret_cast<internal::Isolate*>(isolate),
+ reinterpret_cast<internal::Object**>(**this));
+}
+
+template <class T>
+void Persistent<T>::MarkPartiallyDependent() {
+ V8::MarkPartiallyDependent(reinterpret_cast<internal::Object**>(**this));
+}
+
+template <class T>
+void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
+ V8::MarkPartiallyDependent(reinterpret_cast<internal::Isolate*>(isolate),
+ reinterpret_cast<internal::Object**>(**this));
+}
+
+template <class T>
void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class_id);
}
+template <class T>
+uint16_t Persistent<T>::WrapperClassId() const {
+ return V8::GetWrapperClassId(reinterpret_cast<internal::Object**>(**this));
+}
+
Arguments::Arguments(internal::Object** implicit_args,
internal::Object** values, int length,
bool is_construct_call)
@@ -4365,6 +4614,26 @@ String::ExternalStringResource* String::GetExternalStringResource() const {
}
+String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
+ String::Encoding* encoding_out) const {
+ typedef internal::Object O;
+ typedef internal::Internals I;
+ O* obj = *reinterpret_cast<O**>(const_cast<String*>(this));
+ int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
+ *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
+ ExternalStringResourceBase* resource = NULL;
+ if (type == I::kExternalAsciiRepresentationTag ||
+ type == I::kExternalTwoByteRepresentationTag) {
+ void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
+ resource = static_cast<ExternalStringResourceBase*>(value);
+ }
+#ifdef V8_ENABLE_CHECKS
+ VerifyExternalStringResourceBase(resource, *encoding_out);
+#endif
+ return resource;
+}
+
+
bool Value::IsUndefined() const {
#ifdef V8_ENABLE_CHECKS
return FullIsUndefined();