Skip to content

Instantly share code, notes, and snippets.

@ofrobots
Created April 25, 2016 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ofrobots/40d1f40b89047250eac2fc78f51bc777 to your computer and use it in GitHub Desktop.
Save ofrobots/40d1f40b89047250eac2fc78f51bc777 to your computer and use it in GitHub Desktop.
diff --git a/include/v8.h b/include/v8.h
index 9a57776..9ccbc6e 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -12,15 +12,15 @@
* For other documentation see http://code.google.com/apis/v8/
*/
-#ifndef V8_H_
-#define V8_H_
+#ifndef INCLUDE_V8_H_
+#define INCLUDE_V8_H_
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
-#include "v8-version.h"
-#include "v8config.h"
+#include "v8-version.h" // NOLINT(build/include)
+#include "v8config.h" // NOLINT(build/include)
// We reserve the V8_* prefix for macros defined in V8 public API and
// assume there are no name conflicts with the embedder's code.
@@ -92,6 +92,7 @@ class ObjectTemplate;
class Platform;
class Primitive;
class Promise;
+class Proxy;
class RawOperationDescriptor;
class Script;
class SharedArrayBuffer;
@@ -103,6 +104,7 @@ class String;
class StringObject;
class Symbol;
class SymbolObject;
+class Private;
class Uint32;
class Utils;
class Value;
@@ -112,8 +114,8 @@ class MaybeLocal;
template <class T> class Eternal;
template<class T> class NonCopyablePersistentTraits;
template<class T> class PersistentBase;
-template<class T,
- class M = NonCopyablePersistentTraits<T> > class Persistent;
+template <class T, class M = NonCopyablePersistentTraits<T> >
+class Persistent;
template <class T>
class Global;
template<class K, class V, class T> class PersistentValueMap;
@@ -135,6 +137,10 @@ class CallHandlerHelper;
class EscapableHandleScope;
template<typename T> class ReturnValue;
+namespace experimental {
+class FastAccessorBuilder;
+} // namespace experimental
+
namespace internal {
class Arguments;
class Heap;
@@ -146,7 +152,7 @@ template<typename T> class CustomArguments;
class PropertyCallbackArguments;
class FunctionCallbackArguments;
class GlobalHandles;
-}
+} // namespace internal
/**
@@ -311,6 +317,7 @@ class Local {
friend class String;
friend class Object;
friend class Context;
+ friend class Private;
template<class F> friend class internal::CustomArguments;
friend Local<Primitive> Undefined(Isolate* isolate);
friend Local<Primitive> Null(Isolate* isolate);
@@ -322,9 +329,7 @@ class Local {
friend class PersistentValueMapBase;
template<class F1, class F2> friend class PersistentValueVector;
- template <class S>
- V8_INLINE Local(S* that)
- : val_(that) {}
+ explicit V8_INLINE Local(T* that) : val_(that) {}
V8_INLINE static Local<T> New(Isolate* isolate, T* that);
T* val_;
};
@@ -418,16 +423,19 @@ class WeakCallbackInfo {
V8_INLINE T* GetParameter() const { return parameter_; }
V8_INLINE void* GetInternalField(int index) const;
- V8_INLINE V8_DEPRECATE_SOON("use indexed version",
- void* GetInternalField1() const) {
+ V8_INLINE V8_DEPRECATED("use indexed version",
+ void* GetInternalField1() const) {
return internal_fields_[0];
}
- V8_INLINE V8_DEPRECATE_SOON("use indexed version",
- void* GetInternalField2() const) {
+ V8_INLINE V8_DEPRECATED("use indexed version",
+ void* GetInternalField2() const) {
return internal_fields_[1];
}
- bool IsFirstPass() const { return callback_ != nullptr; }
+ V8_DEPRECATED("Not realiable once SetSecondPassCallback() was used.",
+ bool IsFirstPass() const) {
+ return callback_ != nullptr;
+ }
// When first called, the embedder MUST Reset() the Global which triggered the
// callback. The Global itself is unusable for anything else. No v8 other api
@@ -549,13 +557,13 @@ template <class T> class PersistentBase {
* critical form of resource management!
*/
template <typename P>
- V8_INLINE V8_DEPRECATE_SOON(
+ V8_INLINE V8_DEPRECATED(
"use WeakCallbackInfo version",
void SetWeak(P* parameter,
typename WeakCallbackData<T, P>::Callback callback));
template <typename S, typename P>
- V8_INLINE V8_DEPRECATE_SOON(
+ V8_INLINE V8_DEPRECATED(
"use WeakCallbackInfo version",
void SetWeak(P* parameter,
typename WeakCallbackData<S, P>::Callback callback));
@@ -567,7 +575,7 @@ template <class T> class PersistentBase {
// specify a parameter for the callback or the location of two internal
// fields in the dying object.
template <typename P>
- V8_INLINE V8_DEPRECATE_SOON(
+ V8_INLINE V8_DEPRECATED(
"use SetWeak",
void SetPhantom(P* parameter,
typename WeakCallbackInfo<P>::Callback callback,
@@ -603,6 +611,13 @@ template <class T> class PersistentBase {
*/
V8_INLINE void MarkPartiallyDependent();
+ /**
+ * Marks the reference to this object as active. The scavenge garbage
+ * collection should not reclaim the objects marked as active.
+ * This bit is cleared after the each garbage collection pass.
+ */
+ V8_INLINE void MarkActive();
+
V8_INLINE bool IsIndependent() const;
/** Checks if the handle holds the only reference to an object. */
@@ -773,7 +788,7 @@ template <class T, class M> class Persistent : public PersistentBase<T> {
template<class F1, class F2> friend class Persistent;
template<class F> friend class ReturnValue;
- template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { }
+ explicit V8_INLINE Persistent(T* that) : PersistentBase<T>(that) {}
V8_INLINE T* operator*() const { return this->val_; }
template<class S, class M2>
V8_INLINE void Copy(const Persistent<S, M2>& that);
@@ -815,7 +830,7 @@ class Global : public PersistentBase<T> {
/**
* Move constructor.
*/
- V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) {
+ V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) { // NOLINT
other.val_ = nullptr;
}
V8_INLINE ~Global() { this->Reset(); }
@@ -823,7 +838,7 @@ class Global : public PersistentBase<T> {
* Move via assignment.
*/
template <class S>
- V8_INLINE Global& operator=(Global<S>&& rhs) {
+ V8_INLINE Global& operator=(Global<S>&& rhs) { // NOLINT
TYPE_CHECK(T, S);
if (this != &rhs) {
this->Reset();
@@ -835,7 +850,7 @@ class Global : public PersistentBase<T> {
/**
* Pass allows returning uniques from functions, etc.
*/
- Global Pass() { return static_cast<Global&&>(*this); }
+ Global Pass() { return static_cast<Global&&>(*this); } // NOLINT
/*
* For compatibility with Chromium's base::Bind (base::Passed).
@@ -872,7 +887,7 @@ using UniquePersistent = Global<T>;
*/
class V8_EXPORT HandleScope {
public:
- HandleScope(Isolate* isolate);
+ explicit HandleScope(Isolate* isolate);
~HandleScope();
@@ -925,7 +940,7 @@ class V8_EXPORT HandleScope {
*/
class V8_EXPORT EscapableHandleScope : public HandleScope {
public:
- EscapableHandleScope(Isolate* isolate);
+ explicit EscapableHandleScope(Isolate* isolate);
V8_INLINE ~EscapableHandleScope() {}
/**
@@ -966,8 +981,8 @@ class V8_EXPORT SealHandleScope {
void operator delete(void*, size_t);
internal::Isolate* isolate_;
- int prev_level_;
internal::Object** prev_limit_;
+ int prev_sealed_level_;
};
@@ -1304,10 +1319,10 @@ class V8_EXPORT ScriptCompiler {
* \return Compiled script object (context independent; for running it must be
* bound to a context).
*/
- static V8_DEPRECATE_SOON("Use maybe version",
- Local<UnboundScript> CompileUnbound(
- Isolate* isolate, Source* source,
- CompileOptions options = kNoCompileOptions));
+ static V8_DEPRECATED("Use maybe version",
+ Local<UnboundScript> CompileUnbound(
+ Isolate* isolate, Source* source,
+ CompileOptions options = kNoCompileOptions));
static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundScript(
Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions);
@@ -1323,7 +1338,7 @@ class V8_EXPORT ScriptCompiler {
* when this function was called. When run it will always use this
* context.
*/
- static V8_DEPRECATE_SOON(
+ static V8_DEPRECATED(
"Use maybe version",
Local<Script> Compile(Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions));
@@ -1353,11 +1368,11 @@ class V8_EXPORT ScriptCompiler {
* (ScriptStreamingTask has been run). V8 doesn't construct the source string
* during streaming, so the embedder needs to pass the full source here.
*/
- static V8_DEPRECATE_SOON(
- "Use maybe version",
- Local<Script> Compile(Isolate* isolate, StreamedSource* source,
- Local<String> full_source_string,
- const ScriptOrigin& origin));
+ static V8_DEPRECATED("Use maybe version",
+ Local<Script> Compile(Isolate* isolate,
+ StreamedSource* source,
+ Local<String> full_source_string,
+ const ScriptOrigin& origin));
static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
Local<Context> context, StreamedSource* source,
Local<String> full_source_string, const ScriptOrigin& origin);
@@ -1483,7 +1498,7 @@ class V8_EXPORT Message {
* Returns the index within the line of the last character where
* the error occurred.
*/
- V8_DEPRECATE_SOON("Use maybe version", int GetEndColumn() const);
+ V8_DEPRECATED("Use maybe version", int GetEndColumn() const);
V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const;
/**
@@ -1652,8 +1667,8 @@ class V8_EXPORT JSON {
* \param json_string The string to parse.
* \return The corresponding value if successfully parsed.
*/
- static V8_DEPRECATE_SOON("Use maybe version",
- Local<Value> Parse(Local<String> json_string));
+ static V8_DEPRECATED("Use maybe version",
+ Local<Value> Parse(Local<String> json_string));
static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse(
Isolate* isolate, Local<String> json_string);
};
@@ -1728,7 +1743,8 @@ class V8_EXPORT Value : public Data {
bool IsFunction() const;
/**
- * Returns true if this value is an array.
+ * Returns true if this value is an array. Note that it will return false for
+ * an Proxy for an array.
*/
bool IsArray() const;
@@ -1941,6 +1957,11 @@ class V8_EXPORT Value : public Data {
*/
bool IsSharedArrayBuffer() const;
+ /**
+ * Returns true if this value is a JavaScript Proxy.
+ */
+ bool IsProxy() const;
+
V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
Local<Context> context) const;
@@ -1964,34 +1985,34 @@ class V8_EXPORT Value : public Data {
Local<Number> ToNumber(Isolate* isolate) const);
V8_DEPRECATE_SOON("Use maybe version",
Local<String> ToString(Isolate* isolate) const);
- V8_DEPRECATE_SOON("Use maybe version",
- Local<String> ToDetailString(Isolate* isolate) const);
+ V8_DEPRECATED("Use maybe version",
+ Local<String> ToDetailString(Isolate* isolate) const);
V8_DEPRECATE_SOON("Use maybe version",
Local<Object> ToObject(Isolate* isolate) const);
V8_DEPRECATE_SOON("Use maybe version",
Local<Integer> ToInteger(Isolate* isolate) const);
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Uint32> ToUint32(Isolate* isolate) const);
+ V8_DEPRECATED("Use maybe version",
+ Local<Uint32> ToUint32(Isolate* isolate) const);
V8_DEPRECATE_SOON("Use maybe version",
Local<Int32> ToInt32(Isolate* isolate) const);
inline V8_DEPRECATE_SOON("Use maybe version",
Local<Boolean> ToBoolean() const);
- inline V8_DEPRECATE_SOON("Use maybe version", Local<Number> ToNumber() const);
+ inline V8_DEPRECATED("Use maybe version", Local<Number> ToNumber() const);
inline V8_DEPRECATE_SOON("Use maybe version", Local<String> ToString() const);
- inline V8_DEPRECATE_SOON("Use maybe version",
- Local<String> ToDetailString() const);
+ inline V8_DEPRECATED("Use maybe version",
+ Local<String> ToDetailString() const);
inline V8_DEPRECATE_SOON("Use maybe version", Local<Object> ToObject() const);
inline V8_DEPRECATE_SOON("Use maybe version",
Local<Integer> ToInteger() const);
- inline V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToUint32() const);
- inline V8_DEPRECATE_SOON("Use maybe version", Local<Int32> ToInt32() const);
+ inline V8_DEPRECATED("Use maybe version", Local<Uint32> ToUint32() const);
+ inline V8_DEPRECATED("Use maybe version", Local<Int32> ToInt32() const);
/**
* Attempts to convert a string to an array index.
* Returns an empty handle if the conversion fails.
*/
- V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToArrayIndex() const);
+ V8_DEPRECATED("Use maybe version", Local<Uint32> ToArrayIndex() const);
V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToArrayIndex(
Local<Context> context) const;
@@ -2179,6 +2200,8 @@ class V8_EXPORT String : public Name {
public:
virtual ~ExternalStringResourceBase() {}
+ virtual bool IsCompressible() const { return false; }
+
protected:
ExternalStringResourceBase() {}
@@ -2295,7 +2318,7 @@ class V8_EXPORT String : public Name {
int length = -1);
/** Allocates a new string from Latin-1 data.*/
- static V8_DEPRECATE_SOON(
+ static V8_DEPRECATED(
"Use maybe version",
Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data,
NewStringType type = kNormalString,
@@ -2334,10 +2357,9 @@ class V8_EXPORT String : public Name {
* should the underlying buffer be deallocated or modified except through the
* destructor of the external string resource.
*/
- static V8_DEPRECATE_SOON(
- "Use maybe version",
- Local<String> NewExternal(Isolate* isolate,
- ExternalStringResource* resource));
+ static V8_DEPRECATED("Use maybe version",
+ Local<String> NewExternal(
+ Isolate* isolate, ExternalStringResource* resource));
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalTwoByte(
Isolate* isolate, ExternalStringResource* resource);
@@ -2447,8 +2469,8 @@ class V8_EXPORT Symbol : public Name {
Local<Value> Name() const;
// Create a symbol. If name is not empty, it will be used as the description.
- static Local<Symbol> New(
- Isolate *isolate, Local<String> name = Local<String>());
+ static Local<Symbol> New(Isolate* isolate,
+ Local<String> name = Local<String>());
// Access global symbol registry.
// Note that symbols created this way are never collected, so
@@ -2465,6 +2487,7 @@ class V8_EXPORT Symbol : public Name {
static Local<Symbol> GetIterator(Isolate* isolate);
static Local<Symbol> GetUnscopables(Isolate* isolate);
static Local<Symbol> GetToStringTag(Isolate* isolate);
+ static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate);
V8_INLINE static Symbol* Cast(v8::Value* obj);
@@ -2475,6 +2498,34 @@ class V8_EXPORT Symbol : public Name {
/**
+ * A private symbol
+ *
+ * This is an experimental feature. Use at your own risk.
+ */
+class V8_EXPORT Private : public Data {
+ public:
+ // Returns the print name string of the private symbol, or undefined if none.
+ Local<Value> Name() const;
+
+ // Create a private symbol. If name is not empty, it will be the description.
+ static Local<Private> New(Isolate* isolate,
+ Local<String> name = Local<String>());
+
+ // Retrieve a global private symbol. If a symbol with this name has not
+ // been retrieved in the same isolate before, it is created.
+ // Note that private symbols created this way are never collected, so
+ // they should only be used for statically fixed properties.
+ // Also, there is only one global name space for the names used as keys.
+ // To minimize the potential for clashes, use qualified names as keys,
+ // e.g., "Class#property".
+ static Local<Private> ForApi(Isolate* isolate, Local<String> name);
+
+ private:
+ Private();
+};
+
+
+/**
* A JavaScript number value (ECMA-262, 4.3.20)
*/
class V8_EXPORT Number : public Primitive {
@@ -2625,10 +2676,10 @@ class V8_EXPORT Object : public Value {
// will only be returned if the interceptor doesn't return a value.
//
// Note also that this only works for named properties.
- V8_DEPRECATE_SOON("Use CreateDataProperty",
- bool ForceSet(Local<Value> key, Local<Value> value,
- PropertyAttribute attribs = None));
- V8_DEPRECATE_SOON("Use CreateDataProperty",
+ V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty",
+ bool ForceSet(Local<Value> key, Local<Value> value,
+ PropertyAttribute attribs = None));
+ V8_DEPRECATE_SOON("Use CreateDataProperty / DefineOwnProperty",
Maybe<bool> ForceSet(Local<Context> context,
Local<Value> key, Local<Value> value,
PropertyAttribute attribs = None));
@@ -2646,16 +2697,16 @@ class V8_EXPORT Object : public Value {
* any combination of ReadOnly, DontEnum and DontDelete. Returns
* None when the property doesn't exist.
*/
- V8_DEPRECATE_SOON("Use maybe version",
- PropertyAttribute GetPropertyAttributes(Local<Value> key));
+ V8_DEPRECATED("Use maybe version",
+ PropertyAttribute GetPropertyAttributes(Local<Value> key));
V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetPropertyAttributes(
Local<Context> context, Local<Value> key);
/**
* Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3.
*/
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Value> GetOwnPropertyDescriptor(Local<String> key));
+ V8_DEPRECATED("Use maybe version",
+ Local<Value> GetOwnPropertyDescriptor(Local<String> key));
V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
Local<Context> context, Local<String> key);
@@ -2667,27 +2718,27 @@ class V8_EXPORT Object : public Value {
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Delete(Local<Context> context, Local<Value> key);
- V8_DEPRECATE_SOON("Use maybe version", bool Has(uint32_t index));
+ V8_DEPRECATED("Use maybe version", bool Has(uint32_t index));
V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index);
- V8_DEPRECATE_SOON("Use maybe version", bool Delete(uint32_t index));
+ V8_DEPRECATED("Use maybe version", bool Delete(uint32_t index));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Delete(Local<Context> context, uint32_t index);
- V8_DEPRECATE_SOON("Use maybe version",
- bool SetAccessor(Local<String> name,
- AccessorGetterCallback getter,
- AccessorSetterCallback setter = 0,
- Local<Value> data = Local<Value>(),
- AccessControl settings = DEFAULT,
- PropertyAttribute attribute = None));
- V8_DEPRECATE_SOON("Use maybe version",
- bool SetAccessor(Local<Name> name,
- AccessorNameGetterCallback getter,
- AccessorNameSetterCallback setter = 0,
- Local<Value> data = Local<Value>(),
- AccessControl settings = DEFAULT,
- PropertyAttribute attribute = None));
+ V8_DEPRECATED("Use maybe version",
+ bool SetAccessor(Local<String> name,
+ AccessorGetterCallback getter,
+ AccessorSetterCallback setter = 0,
+ Local<Value> data = Local<Value>(),
+ AccessControl settings = DEFAULT,
+ PropertyAttribute attribute = None));
+ V8_DEPRECATED("Use maybe version",
+ bool SetAccessor(Local<Name> name,
+ AccessorNameGetterCallback getter,
+ AccessorNameSetterCallback setter = 0,
+ Local<Value> data = Local<Value>(),
+ AccessControl settings = DEFAULT,
+ PropertyAttribute attribute = None));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name,
AccessorNameGetterCallback getter,
@@ -2702,6 +2753,18 @@ class V8_EXPORT Object : public Value {
AccessControl settings = DEFAULT);
/**
+ * Functionality for private properties.
+ * This is an experimental feature, use at your own risk.
+ * Note: Private properties are not inherited. Do not rely on this, since it
+ * may change.
+ */
+ Maybe<bool> HasPrivate(Local<Context> context, Local<Private> key);
+ Maybe<bool> SetPrivate(Local<Context> context, Local<Private> key,
+ Local<Value> value);
+ Maybe<bool> DeletePrivate(Local<Context> context, Local<Private> key);
+ MaybeLocal<Value> GetPrivate(Local<Context> context, Local<Private> key);
+
+ /**
* Returns an array containing the names of the enumerable properties
* of this object, including properties from prototype objects. The
* array returned by this method contains the same values as would
@@ -2732,8 +2795,7 @@ class V8_EXPORT Object : public Value {
* be skipped by __proto__ and it does not consult the security
* handler.
*/
- V8_DEPRECATE_SOON("Use maybe version",
- bool SetPrototype(Local<Value> prototype));
+ V8_DEPRECATED("Use maybe version", bool SetPrototype(Local<Value> prototype));
V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototype(Local<Context> context,
Local<Value> prototype);
@@ -2748,7 +2810,7 @@ class V8_EXPORT Object : public Value {
* This is different from Value::ToString() that may call
* user-defined toString function. This one does not.
*/
- V8_DEPRECATE_SOON("Use maybe version", Local<String> ObjectProtoToString());
+ V8_DEPRECATED("Use maybe version", Local<String> ObjectProtoToString());
V8_WARN_UNUSED_RESULT MaybeLocal<String> ObjectProtoToString(
Local<Context> context);
@@ -2793,8 +2855,7 @@ class V8_EXPORT Object : public Value {
void SetAlignedPointerInInternalField(int index, void* value);
// Testers for local properties.
- V8_DEPRECATE_SOON("Use maybe version",
- bool HasOwnProperty(Local<String> key));
+ V8_DEPRECATED("Use maybe version", bool HasOwnProperty(Local<String> key));
V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
Local<Name> key);
V8_DEPRECATE_SOON("Use maybe version",
@@ -2814,7 +2875,7 @@ class V8_EXPORT Object : public Value {
* If result.IsEmpty() no real property was located in the prototype chain.
* This means interceptors in the prototype chain are not called.
*/
- V8_DEPRECATE_SOON(
+ V8_DEPRECATED(
"Use maybe version",
Local<Value> GetRealNamedPropertyInPrototypeChain(Local<String> key));
V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedPropertyInPrototypeChain(
@@ -2825,7 +2886,7 @@ class V8_EXPORT Object : public Value {
* which can be None or any combination of ReadOnly, DontEnum and DontDelete.
* Interceptors in the prototype chain are not called.
*/
- V8_DEPRECATE_SOON(
+ V8_DEPRECATED(
"Use maybe version",
Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain(
Local<String> key));
@@ -2838,8 +2899,8 @@ class V8_EXPORT Object : public Value {
* in the prototype chain.
* This means interceptors in the prototype chain are not called.
*/
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Value> GetRealNamedProperty(Local<String> key));
+ V8_DEPRECATED("Use maybe version",
+ Local<Value> GetRealNamedProperty(Local<String> key));
V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedProperty(
Local<Context> context, Local<Name> key);
@@ -2848,9 +2909,9 @@ class V8_EXPORT Object : public Value {
* None or any combination of ReadOnly, DontEnum and DontDelete.
* Interceptors in the prototype chain are not called.
*/
- V8_DEPRECATE_SOON("Use maybe version",
- Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
- Local<String> key));
+ V8_DEPRECATED("Use maybe version",
+ Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
+ Local<String> key));
V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
Local<Context> context, Local<Name> key);
@@ -2869,16 +2930,12 @@ class V8_EXPORT Object : public Value {
*/
int GetIdentityHash();
- /**
- * Access hidden properties on JavaScript objects. These properties are
- * hidden from the executing JavaScript and only accessible through the V8
- * C++ API. Hidden properties introduced by V8 internally (for example the
- * identity hash) are prefixed with "v8::".
- */
- // TODO(dcarney): convert these to take a isolate and optionally bailout?
- bool SetHiddenValue(Local<String> key, Local<Value> value);
- Local<Value> GetHiddenValue(Local<String> key);
- bool DeleteHiddenValue(Local<String> key);
+ V8_DEPRECATED("Use v8::Object::SetPrivate instead.",
+ bool SetHiddenValue(Local<String> key, Local<Value> value));
+ V8_DEPRECATED("Use v8::Object::GetPrivate instead.",
+ Local<Value> GetHiddenValue(Local<String> key));
+ V8_DEPRECATED("Use v8::Object::DeletePrivate instead.",
+ bool DeleteHiddenValue(Local<String> key));
/**
* Clone this object with a fast but shallow copy. Values will point
@@ -2903,9 +2960,9 @@ class V8_EXPORT Object : public Value {
* Call an Object as a function if a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method.
*/
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Value> CallAsFunction(Local<Value> recv, int argc,
- Local<Value> argv[]));
+ V8_DEPRECATED("Use maybe version",
+ Local<Value> CallAsFunction(Local<Value> recv, int argc,
+ Local<Value> argv[]));
V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsFunction(Local<Context> context,
Local<Value> recv,
int argc,
@@ -2916,9 +2973,8 @@ class V8_EXPORT Object : public Value {
* ObjectTemplate::SetCallAsFunctionHandler method.
* Note: This method behaves like the Function::NewInstance method.
*/
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Value> CallAsConstructor(int argc,
- Local<Value> argv[]));
+ V8_DEPRECATED("Use maybe version",
+ Local<Value> CallAsConstructor(int argc, Local<Value> argv[]));
V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsConstructor(
Local<Context> context, int argc, Local<Value> argv[]);
@@ -2950,10 +3006,11 @@ class V8_EXPORT Array : public Object {
* Clones an element at index |index|. Returns an empty
* handle if cloning fails (for any reason).
*/
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Object> CloneElementAt(uint32_t index));
- V8_WARN_UNUSED_RESULT MaybeLocal<Object> CloneElementAt(
- Local<Context> context, uint32_t index);
+ V8_DEPRECATED("Cloning is not supported.",
+ Local<Object> CloneElementAt(uint32_t index));
+ V8_DEPRECATED("Cloning is not supported.",
+ MaybeLocal<Object> CloneElementAt(Local<Context> context,
+ uint32_t index));
/**
* Creates a JavaScript array with the given length. If the length
@@ -2996,15 +3053,6 @@ class V8_EXPORT Map : public Object {
*/
static Local<Map> New(Isolate* isolate);
- /**
- * Creates a new Map containing the elements of array, which must be formatted
- * in the same manner as the array returned from AsArray().
- * Guaranteed to be side-effect free if the array contains no holes.
- */
- static V8_WARN_UNUSED_RESULT V8_DEPRECATED(
- "Use mutation methods instead",
- MaybeLocal<Map> FromArray(Local<Context> context, Local<Array> array));
-
V8_INLINE static Map* Cast(Value* obj);
private:
@@ -3037,14 +3085,6 @@ class V8_EXPORT Set : public Object {
*/
static Local<Set> New(Isolate* isolate);
- /**
- * Creates a new Set containing the items in array.
- * Guaranteed to be side-effect free if the array contains no holes.
- */
- static V8_WARN_UNUSED_RESULT V8_DEPRECATED(
- "Use mutation methods instead",
- MaybeLocal<Set> FromArray(Local<Context> context, Local<Array> array));
-
V8_INLINE static Set* Cast(Value* obj);
private:
@@ -3108,7 +3148,8 @@ class FunctionCallbackInfo {
public:
V8_INLINE int Length() const;
V8_INLINE Local<Value> operator[](int i) const;
- V8_INLINE Local<Function> Callee() const;
+ V8_INLINE V8_DEPRECATED("Use Data() to explicitly pass Callee instead",
+ Local<Function> Callee() const);
V8_INLINE Local<Object> This() const;
V8_INLINE Local<Object> Holder() const;
V8_INLINE bool IsConstructCall() const;
@@ -3152,19 +3193,21 @@ class PropertyCallbackInfo {
V8_INLINE Local<Object> This() const;
V8_INLINE Local<Object> Holder() const;
V8_INLINE ReturnValue<T> GetReturnValue() const;
+ V8_INLINE bool ShouldThrowOnError() const;
// This shouldn't be public, but the arm compiler needs it.
- static const int kArgsLength = 6;
+ static const int kArgsLength = 7;
protected:
friend class MacroAssembler;
friend class internal::PropertyCallbackArguments;
friend class internal::CustomArguments<PropertyCallbackInfo>;
- static const int kHolderIndex = 0;
- static const int kIsolateIndex = 1;
- static const int kReturnValueDefaultValueIndex = 2;
- static const int kReturnValueIndex = 3;
- static const int kDataIndex = 4;
- static const int kThisIndex = 5;
+ static const int kShouldThrowOnErrorIndex = 0;
+ static const int kHolderIndex = 1;
+ static const int kIsolateIndex = 2;
+ static const int kReturnValueDefaultValueIndex = 3;
+ static const int kReturnValueIndex = 4;
+ static const int kDataIndex = 5;
+ static const int kThisIndex = 6;
V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
internal::Object** args_;
@@ -3192,13 +3235,12 @@ class V8_EXPORT Function : public Object {
Local<Function> New(Isolate* isolate, FunctionCallback callback,
Local<Value> data = Local<Value>(), int length = 0));
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Object> NewInstance(int argc, Local<Value> argv[])
- const);
+ V8_DEPRECATED("Use maybe version",
+ Local<Object> NewInstance(int argc, Local<Value> argv[]) const);
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
Local<Context> context, int argc, Local<Value> argv[]) const;
- V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance() const);
+ V8_DEPRECATED("Use maybe version", Local<Object> NewInstance() const);
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
Local<Context> context) const {
return NewInstance(context, 0, nullptr);
@@ -3223,6 +3265,12 @@ class V8_EXPORT Function : public Object {
Local<Value> GetInferredName() const;
/**
+ * displayName if it is set, otherwise name if it is configured, otherwise
+ * function name, otherwise inferred name.
+ */
+ Local<Value> GetDebugName() const;
+
+ /**
* User-defined name assigned to the "displayName" property of this function.
* Used to facilitate debugging and profiling of JavaScript code.
*/
@@ -3311,18 +3359,19 @@ class V8_EXPORT Promise : public Object {
* an argument. If the promise is already resolved/rejected, the handler is
* invoked at the end of turn.
*/
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Promise> Chain(Local<Function> handler));
- V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Chain(Local<Context> context,
- Local<Function> handler);
+ V8_DEPRECATED("Use maybe version of Then",
+ Local<Promise> Chain(Local<Function> handler));
+ V8_DEPRECATED("Use Then",
+ V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Chain(
+ Local<Context> context, Local<Function> handler));
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Promise> Catch(Local<Function> handler));
+ V8_DEPRECATED("Use maybe version",
+ Local<Promise> Catch(Local<Function> handler));
V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Catch(Local<Context> context,
Local<Function> handler);
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Promise> Then(Local<Function> handler));
+ V8_DEPRECATED("Use maybe version",
+ Local<Promise> Then(Local<Function> handler));
V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Then(Local<Context> context,
Local<Function> handler);
@@ -3340,6 +3389,32 @@ class V8_EXPORT Promise : public Object {
};
+/**
+ * An instance of the built-in Proxy constructor (ECMA-262, 6th Edition,
+ * 26.2.1).
+ */
+class V8_EXPORT Proxy : public Object {
+ public:
+ Local<Object> GetTarget();
+ Local<Value> GetHandler();
+ bool IsRevoked();
+ void Revoke();
+
+ /**
+ * Creates a new empty Map.
+ */
+ static MaybeLocal<Proxy> New(Local<Context> context,
+ Local<Object> local_target,
+ Local<Object> local_handler);
+
+ V8_INLINE static Proxy* Cast(Value* obj);
+
+ private:
+ Proxy();
+ static void CheckCast(Value* obj);
+};
+
+
#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
// The number of required internal fields can be defined by embedder.
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
@@ -3897,7 +3972,8 @@ class V8_EXPORT NumberObject : public Object {
*/
class V8_EXPORT BooleanObject : public Object {
public:
- static Local<Value> New(bool value);
+ static Local<Value> New(Isolate* isolate, bool value);
+ V8_DEPRECATED("Pass an isolate", static Local<Value> New(bool value));
bool ValueOf() const;
@@ -3955,7 +4031,9 @@ class V8_EXPORT RegExp : public Object {
kNone = 0,
kGlobal = 1,
kIgnoreCase = 2,
- kMultiline = 4
+ kMultiline = 4,
+ kSticky = 8,
+ kUnicode = 16
};
/**
@@ -4007,6 +4085,15 @@ class V8_EXPORT External : public Value {
};
+#define V8_INTRINSICS_LIST(F) F(ArrayProto_values, array_values_iterator)
+
+enum Intrinsic {
+#define V8_DECL_INTRINSIC(name, iname) k##name,
+ V8_INTRINSICS_LIST(V8_DECL_INTRINSIC)
+#undef V8_DECL_INTRINSIC
+};
+
+
// --- Templates ---
@@ -4069,6 +4156,13 @@ class V8_EXPORT Template : public Data {
Local<AccessorSignature> signature = Local<AccessorSignature>(),
AccessControl settings = DEFAULT);
+ /**
+ * During template instantiation, sets the value with the intrinsic property
+ * from the correct context.
+ */
+ void SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic,
+ PropertyAttribute attribute = None);
+
private:
Template();
@@ -4228,6 +4322,16 @@ enum AccessType {
/**
+ * Returns true if the given context should be allowed to access the given
+ * object.
+ */
+typedef bool (*AccessCheckCallback)(Local<Context> accessing_context,
+ Local<Object> accessed_object,
+ Local<Value> data);
+typedef bool (*DeprecatedAccessCheckCallback)(Local<Context> accessing_context,
+ Local<Object> accessed_object);
+
+/**
* Returns true if cross-context access should be allowed to the named
* property with the given key on the host object.
*/
@@ -4350,6 +4454,16 @@ class V8_EXPORT FunctionTemplate : public Template {
Local<Value> data = Local<Value>(),
Local<Signature> signature = Local<Signature>(), int length = 0);
+ /**
+ * Creates a function template with a fast handler. If a fast handler is set,
+ * the callback cannot be null.
+ */
+ static Local<FunctionTemplate> NewWithFastHandler(
+ Isolate* isolate, FunctionCallback callback,
+ experimental::FastAccessorBuilder* fast_handler = nullptr,
+ Local<Value> data = Local<Value>(),
+ Local<Signature> signature = Local<Signature>(), int length = 0);
+
/** Returns the unique function instance in the current execution context.*/
V8_DEPRECATE_SOON("Use maybe version", Local<Function> GetFunction());
V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
@@ -4360,8 +4474,9 @@ class V8_EXPORT FunctionTemplate : public Template {
* callback is called whenever the function created from this
* FunctionTemplate is called.
*/
- void SetCallHandler(FunctionCallback callback,
- Local<Value> data = Local<Value>());
+ void SetCallHandler(
+ FunctionCallback callback, Local<Value> data = Local<Value>(),
+ experimental::FastAccessorBuilder* fast_handler = nullptr);
/** Set the predefined length property for the FunctionTemplate. */
void SetLength(int length);
@@ -4512,7 +4627,7 @@ class V8_EXPORT ObjectTemplate : public Template {
static Local<ObjectTemplate> New(
Isolate* isolate,
Local<FunctionTemplate> constructor = Local<FunctionTemplate>());
- static V8_DEPRECATE_SOON("Use isolate version", Local<ObjectTemplate> New());
+ static V8_DEPRECATED("Use isolate version", Local<ObjectTemplate> New());
/** Creates a new instance of this template.*/
V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance());
@@ -4635,16 +4750,25 @@ class V8_EXPORT ObjectTemplate : public Template {
void MarkAsUndetectable();
/**
- * Sets access check callbacks on the object template and enables
- * access checks.
+ * Sets access check callback on the object template and enables access
+ * checks.
*
* When accessing properties on instances of this object template,
* the access check callback will be called to determine whether or
* not to allow cross-context access to the properties.
*/
- void SetAccessCheckCallbacks(NamedSecurityCallback named_handler,
- IndexedSecurityCallback indexed_handler,
- Local<Value> data = Local<Value>());
+ void SetAccessCheckCallback(AccessCheckCallback callback,
+ Local<Value> data = Local<Value>());
+ V8_DEPRECATED(
+ "Use SetAccessCheckCallback with new AccessCheckCallback signature.",
+ void SetAccessCheckCallback(DeprecatedAccessCheckCallback callback,
+ Local<Value> data = Local<Value>()));
+
+ V8_DEPRECATED(
+ "Use SetAccessCheckCallback instead",
+ void SetAccessCheckCallbacks(NamedSecurityCallback named_handler,
+ IndexedSecurityCallback indexed_handler,
+ Local<Value> data = Local<Value>()));
/**
* Gets the number of internal fields for objects generated from
@@ -4695,21 +4819,6 @@ class V8_EXPORT AccessorSignature : public Data {
};
-/**
- * A utility for determining the type of objects based on the template
- * they were constructed from.
- */
-class V8_EXPORT TypeSwitch : public Data {
- public:
- static Local<TypeSwitch> New(Local<FunctionTemplate> type);
- static Local<TypeSwitch> New(int argc, Local<FunctionTemplate> types[]);
- int match(Local<Value> value);
-
- private:
- TypeSwitch();
-};
-
-
// --- Extensions ---
class V8_EXPORT ExternalOneByteStringResourceImpl
@@ -4855,7 +4964,9 @@ class V8_EXPORT Exception {
* Will try to reconstruct the original stack trace from the exception value,
* or capture the current stack trace if not available.
*/
- static Local<Message> CreateMessage(Local<Value> exception);
+ static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
+ V8_DEPRECATED("Use version with an Isolate*",
+ static Local<Message> CreateMessage(Local<Value> exception));
/**
* Returns the original stack trace that was captured at the creation time
@@ -4898,8 +5009,10 @@ typedef void (*MemoryAllocationCallback)(ObjectSpace space,
AllocationAction action,
int size);
-// --- Leave Script Callback ---
-typedef void (*CallCompletedCallback)();
+// --- Enter/Leave Script Callback ---
+typedef void (*BeforeCallEnteredCallback)(Isolate*);
+typedef void (*CallCompletedCallback)(Isolate*);
+typedef void (*DeprecatedCallCompletedCallback)();
// --- Promise Reject Callback ---
enum PromiseRejectEvent {
@@ -4920,8 +5033,10 @@ class PromiseRejectMessage {
V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
V8_INLINE Local<Value> GetValue() const { return value_; }
- // DEPRECATED. Use v8::Exception::CreateMessage(GetValue())->GetStackTrace()
- V8_INLINE Local<StackTrace> GetStackTrace() const { return stack_trace_; }
+ V8_DEPRECATED("Use v8::Exception::CreateMessage(GetValue())->GetStackTrace()",
+ V8_INLINE Local<StackTrace> GetStackTrace() const) {
+ return stack_trace_;
+ }
private:
Local<Promise> promise_;
@@ -4966,19 +5081,26 @@ enum GCType {
kGCTypeIncrementalMarking | kGCTypeProcessWeakCallbacks
};
+/**
+ * GCCallbackFlags is used to notify additional information about the GC
+ * callback.
+ * - kGCCallbackFlagConstructRetainedObjectInfos: The GC callback is for
+ * constructing retained object infos.
+ * - kGCCallbackFlagForced: The GC callback is for a forced GC for testing.
+ * - kGCCallbackFlagSynchronousPhantomCallbackProcessing: The GC callback
+ * is called synchronously without getting posted to an idle task.
+ * - kGCCallbackFlagCollectAllAvailableGarbage: The GC callback is called
+ * in a phase where V8 is trying to collect all available garbage
+ * (e.g., handling a low memory notification).
+ */
enum GCCallbackFlags {
kNoGCCallbackFlags = 0,
kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
kGCCallbackFlagForced = 1 << 2,
- kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3
+ kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3,
+ kGCCallbackFlagCollectAllAvailableGarbage = 1 << 4,
};
-V8_DEPRECATE_SOON("Use GCCallBack instead",
- typedef void (*GCPrologueCallback)(GCType type,
- GCCallbackFlags flags));
-V8_DEPRECATE_SOON("Use GCCallBack instead",
- typedef void (*GCEpilogueCallback)(GCType type,
- GCCallbackFlags flags));
typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
typedef void (*InterruptCallback)(Isolate* isolate, void* data);
@@ -4999,6 +5121,7 @@ class V8_EXPORT HeapStatistics {
size_t total_available_size() { return total_available_size_; }
size_t used_heap_size() { return used_heap_size_; }
size_t heap_size_limit() { return heap_size_limit_; }
+ size_t does_zap_garbage() { return does_zap_garbage_; }
private:
size_t total_heap_size_;
@@ -5007,6 +5130,7 @@ class V8_EXPORT HeapStatistics {
size_t total_available_size_;
size_t used_heap_size_;
size_t heap_size_limit_;
+ bool does_zap_garbage_;
friend class V8;
friend class Isolate;
@@ -5344,6 +5468,30 @@ class V8_EXPORT Isolate {
kSlotsBufferOverflow = 5,
kObjectObserve = 6,
kForcedGC = 7,
+ kSloppyMode = 8,
+ kStrictMode = 9,
+ kStrongMode = 10,
+ kRegExpPrototypeStickyGetter = 11,
+ kRegExpPrototypeToString = 12,
+ kRegExpPrototypeUnicodeGetter = 13,
+ kIntlV8Parse = 14,
+ kIntlPattern = 15,
+ kIntlResolved = 16,
+ kPromiseChain = 17,
+ kPromiseAccept = 18,
+ kPromiseDefer = 19,
+ kHtmlCommentInExternalScript = 20,
+ kHtmlComment = 21,
+ kSloppyModeBlockScopedFunctionRedefinition = 22,
+ kForInInitializer = 23,
+ kArrayProtectorDirtied = 24,
+ kArraySpeciesModified = 25,
+ kArrayPrototypeConstructorModified = 26,
+ kArrayInstanceProtoModified = 27,
+ kArrayInstanceConstructorModified = 28,
+
+ // If you add new values here, you'll also need to update V8Initializer.cpp
+ // in Chromium.
kUseCounterFeatureCount // This enum value must be last.
};
@@ -5371,6 +5519,19 @@ class V8_EXPORT Isolate {
static Isolate* GetCurrent();
/**
+ * Custom callback used by embedders to help V8 determine if it should abort
+ * when it throws and no internal handler is predicted to catch the
+ * exception. If --abort-on-uncaught-exception is used on the command line,
+ * then V8 will abort if either:
+ * - no custom callback is set.
+ * - the custom callback set returns true.
+ * Otherwise, the custom callback will not be called and V8 will not abort.
+ */
+ typedef bool (*AbortOnUncaughtExceptionCallback)(Isolate*);
+ void SetAbortOnUncaughtExceptionCallback(
+ AbortOnUncaughtExceptionCallback callback);
+
+ /**
* Methods below this point require holding a lock (using Locker) in
* a multi-threaded environment.
*/
@@ -5398,6 +5559,15 @@ class V8_EXPORT Isolate {
void Dispose();
/**
+ * Discards all V8 thread-specific data for the Isolate. Should be used
+ * if a thread is terminating and it has used an Isolate that will outlive
+ * the thread -- all thread-specific data for an Isolate is discarded when
+ * an Isolate is disposed so this call is pointless if an Isolate is about
+ * to be Disposed.
+ */
+ void DiscardThreadSpecificMetadata();
+
+ /**
* Associate embedder-specific data with the isolate. |slot| has to be
* between 0 and GetNumberOfDataSlots() - 1.
*/
@@ -5501,7 +5671,10 @@ class V8_EXPORT Isolate {
/** Returns true if this isolate has a current context. */
bool InContext();
- /** Returns the context that is on the top of the stack. */
+ /**
+ * Returns the context of the currently running JavaScript, or the context
+ * on the top of the stack if no JavaScript is running.
+ */
Local<Context> GetCurrentContext();
/**
@@ -5509,9 +5682,12 @@ class V8_EXPORT Isolate {
* context of the top-most JavaScript frame. If there are no
* JavaScript frames an empty handle is returned.
*/
- Local<Context> GetCallingContext();
+ V8_DEPRECATE_SOON(
+ "Calling context concept is not compatible with tail calls, and will be "
+ "removed.",
+ Local<Context> GetCallingContext());
- /** Returns the last entered context. */
+ /** Returns the last context entered through V8's C++ API. */
Local<Context> GetEnteredContext();
/**
@@ -5555,14 +5731,6 @@ class V8_EXPORT Isolate {
template<typename T, typename S>
void SetReference(const Persistent<T>& parent, const Persistent<S>& child);
- V8_DEPRECATE_SOON("Use GCCallBack instead",
- typedef void (*GCPrologueCallback)(Isolate* isolate,
- GCType type,
- GCCallbackFlags flags));
- V8_DEPRECATE_SOON("Use GCCallBack instead",
- typedef void (*GCEpilogueCallback)(Isolate* isolate,
- GCType type,
- GCCallbackFlags flags));
typedef void (*GCCallback)(Isolate* isolate, GCType type,
GCCallbackFlags flags);
@@ -5665,6 +5833,19 @@ class V8_EXPORT Isolate {
void SetEventLogger(LogEventCallback that);
/**
+ * Adds a callback to notify the host application right before a script
+ * is about to run. If a script re-enters the runtime during executing, the
+ * BeforeCallEnteredCallback is invoked for each re-entrance.
+ * Executing scripts inside the callback will re-trigger the callback.
+ */
+ void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
+
+ /**
+ * Removes callback that was installed by AddBeforeCallEnteredCallback.
+ */
+ void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
+
+ /**
* Adds a callback to notify the host application when a script finished
* running. If a script re-enters the runtime during executing, the
* CallCompletedCallback is only invoked when the outer-most script
@@ -5672,12 +5853,18 @@ class V8_EXPORT Isolate {
* further callbacks.
*/
void AddCallCompletedCallback(CallCompletedCallback callback);
+ V8_DEPRECATE_SOON(
+ "Use callback with parameter",
+ void AddCallCompletedCallback(DeprecatedCallCompletedCallback callback));
/**
* Removes callback that was installed by AddCallCompletedCallback.
*/
void RemoveCallCompletedCallback(CallCompletedCallback callback);
-
+ V8_DEPRECATE_SOON(
+ "Use callback with parameter",
+ void RemoveCallCompletedCallback(
+ DeprecatedCallCompletedCallback callback));
/**
* Set callback to notify about promise reject with no handler, or
@@ -5749,8 +5936,8 @@ class V8_EXPORT Isolate {
*/
bool IdleNotificationDeadline(double deadline_in_seconds);
- V8_DEPRECATE_SOON("use IdleNotificationDeadline()",
- bool IdleNotification(int idle_time_in_ms));
+ V8_DEPRECATED("use IdleNotificationDeadline()",
+ bool IdleNotification(int idle_time_in_ms));
/**
* Optional notification that the system is running low on memory.
@@ -5770,6 +5957,18 @@ class V8_EXPORT Isolate {
int ContextDisposedNotification(bool dependant_context = true);
/**
+ * Optional notification that the isolate switched to the foreground.
+ * V8 uses these notifications to guide heuristics.
+ */
+ void IsolateInForegroundNotification();
+
+ /**
+ * Optional notification that the isolate switched to the background.
+ * V8 uses these notifications to guide heuristics.
+ */
+ void IsolateInBackgroundNotification();
+
+ /**
* Allows the host application to provide the address of a function that is
* notified each time code is added, moved or removed.
*
@@ -5898,6 +6097,13 @@ class V8_EXPORT Isolate {
*/
void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor);
+ /**
+ * Iterates through all the persistent handles in the current isolate's heap
+ * that have class_ids and are weak to be marked as inactive if there is no
+ * pending activity for the handle.
+ */
+ void VisitWeakHandles(PersistentHandleVisitor* visitor);
+
private:
template <class K, class V, class Traits>
friend class PersistentValueMapBase;
@@ -5912,7 +6118,7 @@ class V8_EXPORT Isolate {
void SetObjectGroupId(internal::Object** object, UniqueId id);
void SetReferenceFromGroup(UniqueId id, internal::Object** object);
void SetReference(internal::Object** parent, internal::Object** child);
- void CollectAllGarbage(const char* gc_reason);
+ void ReportExternalAllocationLimitReached();
};
class V8_EXPORT StartupData {
@@ -5952,7 +6158,7 @@ typedef uintptr_t (*ReturnAddressLocationResolver)(
class V8_EXPORT V8 {
public:
/** Set the callback to invoke in case of fatal errors. */
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void SetFatalErrorHandler(FatalErrorCallback that));
@@ -5960,7 +6166,7 @@ class V8_EXPORT V8 {
* Set the callback to invoke to check if code generation from
* strings should be allowed.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version", void SetAllowCodeGenerationFromStringsCallback(
AllowCodeGenerationFromStringsCallback that));
@@ -5968,7 +6174,7 @@ class V8_EXPORT V8 {
* Check if V8 is dead and therefore unusable. This is the case after
* fatal errors such as out-of-memory situations.
*/
- V8_INLINE static V8_DEPRECATE_SOON("no alternative", bool IsDead());
+ V8_INLINE static V8_DEPRECATED("Use isolate version", bool IsDead());
/**
* Hand startup data to V8, in case the embedder has chosen to build
@@ -6004,7 +6210,7 @@ class V8_EXPORT V8 {
* If data is specified, it will be passed to the callback when it is called.
* Otherwise, the exception object will be passed to the callback instead.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
bool AddMessageListener(MessageCallback that,
Local<Value> data = Local<Value>()));
@@ -6012,14 +6218,14 @@ class V8_EXPORT V8 {
/**
* Remove all message listeners from the specified callback function.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version", void RemoveMessageListeners(MessageCallback that));
/**
* Tells V8 to capture current stack trace when uncaught exception occurs
* and report it to the message listeners. The option is off by default.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void SetCaptureStackTraceForUncaughtExceptions(
bool capture, int frame_limit = 10,
@@ -6041,7 +6247,7 @@ class V8_EXPORT V8 {
static const char* GetVersion();
/** Callback function for reporting failed access checks.*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback));
@@ -6055,7 +6261,7 @@ class V8_EXPORT V8 {
* register the same callback function two times with different
* GCType filters.
*/
- static V8_DEPRECATE_SOON(
+ static V8_DEPRECATED(
"Use isolate version",
void AddGCPrologueCallback(GCCallback callback,
GCType gc_type_filter = kGCTypeAll));
@@ -6064,7 +6270,7 @@ class V8_EXPORT V8 {
* This function removes callback which was installed by
* AddGCPrologueCallback function.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void RemoveGCPrologueCallback(GCCallback callback));
@@ -6078,7 +6284,7 @@ class V8_EXPORT V8 {
* register the same callback function two times with different
* GCType filters.
*/
- static V8_DEPRECATE_SOON(
+ static V8_DEPRECATED(
"Use isolate version",
void AddGCEpilogueCallback(GCCallback callback,
GCType gc_type_filter = kGCTypeAll));
@@ -6087,7 +6293,7 @@ class V8_EXPORT V8 {
* This function removes callback which was installed by
* AddGCEpilogueCallback function.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void RemoveGCEpilogueCallback(GCCallback callback));
@@ -6095,7 +6301,7 @@ class V8_EXPORT V8 {
* Enables the host application to provide a mechanism to be notified
* and perform custom logging when V8 Allocates Executable Memory.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
ObjectSpace space,
@@ -6104,7 +6310,7 @@ class V8_EXPORT V8 {
/**
* Removes callback that was installed by AddMemoryAllocationCallback.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback));
@@ -6136,8 +6342,8 @@ class V8_EXPORT V8 {
*
* \param isolate The isolate in which to terminate the current JS execution.
*/
- V8_INLINE static V8_DEPRECATE_SOON("Use isolate version",
- void TerminateExecution(Isolate* isolate));
+ V8_INLINE static V8_DEPRECATED("Use isolate version",
+ void TerminateExecution(Isolate* isolate));
/**
* Is V8 terminating JavaScript execution.
@@ -6149,7 +6355,7 @@ class V8_EXPORT V8 {
*
* \param isolate The isolate in which to check.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
bool IsExecutionTerminating(Isolate* isolate = NULL));
@@ -6169,7 +6375,7 @@ class V8_EXPORT V8 {
*
* \param isolate The isolate in which to resume execution capability.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version", void CancelTerminateExecution(Isolate* isolate));
/**
@@ -6188,15 +6394,15 @@ class V8_EXPORT V8 {
* heap. GC is not invoked prior to iterating, therefore there is no
* guarantee that visited objects are still alive.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
- "Use isoalte version",
+ V8_INLINE static V8_DEPRECATED(
+ "Use isolate version",
void VisitExternalResources(ExternalResourceVisitor* visitor));
/**
* Iterates through all the persistent handles in the current isolate's heap
* that have class_ids.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor));
@@ -6204,7 +6410,7 @@ class V8_EXPORT V8 {
* Iterates through all the persistent handles in isolate's heap that have
* class_ids.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void VisitHandlesWithClassIds(Isolate* isolate,
PersistentHandleVisitor* visitor));
@@ -6216,7 +6422,7 @@ class V8_EXPORT V8 {
* garbage collection but is free to visit an arbitrary superset of these
* objects.
*/
- V8_INLINE static V8_DEPRECATE_SOON(
+ V8_INLINE static V8_DEPRECATED(
"Use isolate version",
void VisitHandlesForPartialDependence(Isolate* isolate,
PersistentHandleVisitor* visitor));
@@ -6374,7 +6580,7 @@ class V8_EXPORT TryCatch {
* all TryCatch blocks should be stack allocated because the memory
* location itself is compared against JavaScript try/catch blocks.
*/
- V8_DEPRECATE_SOON("Use isolate version", TryCatch());
+ V8_DEPRECATED("Use isolate version", TryCatch());
/**
* Creates a new try/catch block and registers it with v8. Note that
@@ -6948,7 +7154,7 @@ class Internals {
static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
static const int kContextHeaderSize = 2 * kApiPointerSize;
- static const int kContextEmbedderDataIndex = 27;
+ static const int kContextEmbedderDataIndex = 5;
static const int kFullStringRepresentationMask = 0x07;
static const int kStringEncodingMask = 0x4;
static const int kExternalTwoByteRepresentationTag = 0x02;
@@ -6980,8 +7186,9 @@ class Internals {
static const int kNodeStateIsNearDeathValue = 4;
static const int kNodeIsIndependentShift = 3;
static const int kNodeIsPartiallyDependentShift = 4;
+ static const int kNodeIsActiveShift = 4;
- static const int kJSObjectType = 0xb6;
+ static const int kJSObjectType = 0xb5;
static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x83;
static const int kForeignType = 0x87;
@@ -7059,7 +7266,7 @@ class Internals {
V8_INLINE static void SetEmbedderData(v8::Isolate* isolate,
uint32_t slot,
void* data) {
- uint8_t *addr = reinterpret_cast<uint8_t *>(isolate) +
+ uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
kIsolateEmbedderDataOffset + slot * kApiPointerSize;
*reinterpret_cast<void**>(addr) = data;
}
@@ -7307,6 +7514,15 @@ void PersistentBase<T>::MarkPartiallyDependent() {
template <class T>
+void PersistentBase<T>::MarkActive() {
+ typedef internal::Internals I;
+ if (this->IsEmpty()) return;
+ I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), true,
+ I::kNodeIsActiveShift);
+}
+
+
+template <class T>
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
typedef internal::Internals I;
if (this->IsEmpty()) return;
@@ -7929,6 +8145,14 @@ Promise* Promise::Cast(v8::Value* value) {
}
+Proxy* Proxy::Cast(v8::Value* value) {
+#ifdef V8_ENABLE_CHECKS
+ CheckCast(value);
+#endif
+ return static_cast<Proxy*>(value);
+}
+
+
Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
@@ -8094,6 +8318,12 @@ ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
return ReturnValue<T>(&args_[kReturnValueIndex]);
}
+template <typename T>
+bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
+ typedef internal::Internals I;
+ return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(0);
+}
+
Local<Primitive> Undefined(Isolate* isolate) {
typedef internal::Object* S;
@@ -8163,7 +8393,7 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
if (change_in_bytes > 0 &&
amount - *amount_of_external_allocated_memory_at_last_global_gc >
I::kExternalAllocationLimit) {
- CollectAllGarbage("external memory allocation limit reached.");
+ ReportExternalAllocationLimitReached();
}
*amount_of_external_allocated_memory = amount;
return *amount_of_external_allocated_memory;
@@ -8353,4 +8583,4 @@ void V8::VisitHandlesForPartialDependence(Isolate* isolate,
#undef TYPE_CHECK
-#endif // V8_H_
+#endif // INCLUDE_V8_H_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment