Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: include/v8.h

Issue 151163005: A64: Synchronize with r16356. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ChangeLog ('k') | include/v8-profiler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 3252602bcf19d8fabba52e0c7fbbd274615f7ff2..5cba8d3f88124fd38db09e720008e851d6f9f2a3 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -43,7 +43,7 @@
// We reserve the V8_* prefix for macros defined in V8 public API and
// assume there are no name conflicts with the embedder's code.
-#ifdef _WIN32
+#ifdef V8_OS_WIN
// Setup for Windows DLL export/import. When building the V8 DLL the
// BUILDING_V8_SHARED needs to be defined. When building a program which uses
@@ -56,59 +56,33 @@
#endif
#ifdef BUILDING_V8_SHARED
-#define V8_EXPORT __declspec(dllexport)
+# define V8_EXPORT __declspec(dllexport)
#elif USING_V8_SHARED
-#define V8_EXPORT __declspec(dllimport)
+# define V8_EXPORT __declspec(dllimport)
#else
-#define V8_EXPORT
+# define V8_EXPORT
#endif // BUILDING_V8_SHARED
-#else // _WIN32
+#else // V8_OS_WIN
// Setup for Linux shared library export.
-#if defined(__GNUC__) && ((__GNUC__ >= 4) || \
- (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED)
-#ifdef BUILDING_V8_SHARED
-#define V8_EXPORT __attribute__ ((visibility("default")))
-#else
-#define V8_EXPORT
-#endif
-#else
-#define V8_EXPORT
-#endif
-
-#endif // _WIN32
-
-#if defined(__GNUC__) && !defined(DEBUG)
-#define V8_INLINE(declarator) inline __attribute__((always_inline)) declarator
-#elif defined(_MSC_VER) && !defined(DEBUG)
-#define V8_INLINE(declarator) __forceinline declarator
+#if V8_HAS_ATTRIBUTE_VISIBILITY && defined(V8_SHARED)
+# ifdef BUILDING_V8_SHARED
+# define V8_EXPORT __attribute__ ((visibility("default")))
+# else
+# define V8_EXPORT
+# endif
#else
-#define V8_INLINE(declarator) inline declarator
+# define V8_EXPORT
#endif
-#if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS
-#define V8_DEPRECATED(declarator) declarator __attribute__ ((deprecated))
-#elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS
-#define V8_DEPRECATED(declarator) __declspec(deprecated) declarator
-#else
-#define V8_DEPRECATED(declarator) declarator
-#endif
-
-#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
- #define V8_UNLIKELY(condition) __builtin_expect((condition), 0)
- #define V8_LIKELY(condition) __builtin_expect((condition), 1)
-#else
- #define V8_UNLIKELY(condition) (condition)
- #define V8_LIKELY(condition) (condition)
-#endif
+#endif // V8_OS_WIN
/**
* The v8 JavaScript engine.
*/
namespace v8 {
-class AccessorInfo;
class AccessorSignature;
class Array;
class Boolean;
@@ -145,11 +119,11 @@ class Utils;
class Value;
template <class T> class Handle;
template <class T> class Local;
+template <class T> class Eternal;
template <class T> class Persistent;
class FunctionTemplate;
class ObjectTemplate;
class Data;
-class AccessorInfo;
template<typename T> class PropertyCallbackInfo;
class StackTrace;
class StackFrame;
@@ -303,7 +277,7 @@ template <class T> class Handle {
* to which they refer are identical.
* The handles' references are not checked.
*/
- template <class S> V8_INLINE(bool operator==(const Handle<S> that) const) {
+ template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const) {
internal::Object** a = reinterpret_cast<internal::Object**>(**this);
internal::Object** b = reinterpret_cast<internal::Object**>(*that);
if (a == 0) return b == 0;
@@ -328,9 +302,16 @@ template <class T> class Handle {
* the objects to which they refer are different.
* The handles' references are not checked.
*/
- template <class S> V8_INLINE(bool operator!=(Handle<S> that) const) {
+ template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const) {
+ return !operator==(that);
+ }
+
+#ifndef V8_USE_UNSAFE_HANDLES
+ template <class S> V8_INLINE(
+ bool operator!=(const Persistent<S>& that) const) {
return !operator==(that);
}
+#endif
template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) {
#ifdef V8_ENABLE_CHECKS
@@ -368,11 +349,9 @@ template <class T> class Handle {
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;
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);
@@ -388,11 +367,6 @@ template <class T> class Handle {
};
-// A value which will never be returned by Local::Eternalize
-// Useful for static initialization
-const int kUninitializedEternalIndex = -1;
-
-
/**
* A light-weight stack-allocated object handle. All operations
* that return objects from within v8 return them in local handles. They
@@ -438,11 +412,6 @@ template <class T> class Local : public Handle<T> {
return Local<S>::Cast(*this);
}
- // Keep this Local alive for the lifetime of the Isolate.
- // It remains retrievable via the returned index,
- V8_INLINE(int Eternalize(Isolate* isolate));
- V8_INLINE(static Local<T> GetEternal(Isolate* isolate, int index));
-
/**
* Create a local handle for the content of another handle.
* The referee is kept alive by the local handle even when
@@ -463,14 +432,13 @@ template <class T> class Local : public Handle<T> {
private:
friend class Utils;
+ template<class F> friend class Eternal;
template<class F> friend class Persistent;
template<class F> friend class Handle;
- friend class Arguments;
template<class F> friend class FunctionCallbackInfo;
template<class F> friend class PropertyCallbackInfo;
friend class String;
friend class Object;
- friend class AccessorInfo;
friend class Context;
template<class F> friend class internal::CustomArguments;
friend class HandleScope;
@@ -478,6 +446,28 @@ template <class T> class Local : public Handle<T> {
V8_INLINE(static Local<T> New(Isolate* isolate, T* that));
};
+
+// Eternal handles are set-once handles that live for the life of the isolate.
+template <class T> class Eternal {
+ public:
+ V8_INLINE(Eternal()) : index_(kInitialValue) { }
+ template<class S>
+ V8_INLINE(Eternal(Isolate* isolate, Local<S> handle))
+ : index_(kInitialValue) {
+ Set(isolate, handle);
+ }
+ // Can only be safely called if already set.
+ V8_INLINE(Local<T> Get(Isolate* isolate));
+ V8_INLINE(bool IsEmpty()) { return index_ != kInitialValue; }
+ template<class S>
+ V8_INLINE(void Set(Isolate* isolate, Local<S> handle));
+
+ private:
+ static const int kInitialValue = -1;
+ int index_;
+};
+
+
/**
* An object reference that is independent of any handle scope. Where
* a Local handle only lives as long as the HandleScope in which it was
@@ -618,13 +608,22 @@ template <class T> class Persistent // NOLINT
return *a == *b;
}
- template <class S> V8_INLINE(bool operator==(const Handle<S> that) const) {
+ template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const) {
internal::Object** a = reinterpret_cast<internal::Object**>(**this);
internal::Object** b = reinterpret_cast<internal::Object**>(*that);
if (a == 0) return b == 0;
if (b == 0) return false;
return *a == *b;
}
+
+ template <class S> V8_INLINE(
+ bool operator!=(const Persistent<S>& that) const) {
+ return !operator==(that);
+ }
+
+ template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const) {
+ return !operator==(that);
+ }
#endif
V8_INLINE(void Dispose());
@@ -2030,16 +2029,11 @@ enum ExternalArrayType {
* setting|getting a particular property. See Object and ObjectTemplate's
* method SetAccessor.
*/
-typedef Handle<Value> (*AccessorGetter)(Local<String> property,
- const AccessorInfo& info);
typedef void (*AccessorGetterCallback)(
Local<String> property,
const PropertyCallbackInfo<Value>& info);
-typedef void (*AccessorSetter)(Local<String> property,
- Local<Value> value,
- const AccessorInfo& info);
typedef void (*AccessorSetterCallback)(
Local<String> property,
Local<Value> value,
@@ -2113,12 +2107,6 @@ class V8_EXPORT Object : public Value {
bool Delete(uint32_t index);
- 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,
@@ -2977,6 +2965,14 @@ class V8_EXPORT Template : public Data {
void Set(Handle<String> name, Handle<Data> value,
PropertyAttribute attributes = None);
V8_INLINE(void Set(const char* name, Handle<Data> value));
+
+ void SetAccessorProperty(
+ Local<String> name,
+ Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
+ Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
+ PropertyAttribute attribute = None,
+ AccessControl settings = DEFAULT);
+
private:
Template();
@@ -3059,15 +3055,6 @@ class FunctionCallbackInfo {
};
-class V8_EXPORT Arguments : public FunctionCallbackInfo<Value> {
- private:
- friend class internal::FunctionCallbackArguments;
- V8_INLINE(Arguments(internal::Object** implicit_args,
- internal::Object** values,
- int length,
- bool is_construct_call));
-};
-
/**
* The information passed to a property callback about the context
* of the property access.
@@ -3100,23 +3087,12 @@ class PropertyCallbackInfo {
};
-class V8_EXPORT AccessorInfo : public PropertyCallbackInfo<Value> {
- private:
- friend class internal::PropertyCallbackArguments;
- V8_INLINE(AccessorInfo(internal::Object** args))
- : PropertyCallbackInfo<Value>(args) { }
-};
-
-
-typedef Handle<Value> (*InvocationCallback)(const Arguments& args);
typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
/**
* NamedProperty[Getter|Setter] are used as interceptors on object.
* See ObjectTemplate::SetNamedPropertyHandler.
*/
-typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property,
- const AccessorInfo& info);
typedef void (*NamedPropertyGetterCallback)(
Local<String> property,
const PropertyCallbackInfo<Value>& info);
@@ -3126,9 +3102,6 @@ typedef void (*NamedPropertyGetterCallback)(
* Returns the value if the setter intercepts the request.
* Otherwise, returns an empty handle.
*/
-typedef Handle<Value> (*NamedPropertySetter)(Local<String> property,
- Local<Value> value,
- const AccessorInfo& info);
typedef void (*NamedPropertySetterCallback)(
Local<String> property,
Local<Value> value,
@@ -3140,8 +3113,6 @@ typedef void (*NamedPropertySetterCallback)(
* The result is an integer encoding property attributes (like v8::None,
* v8::DontEnum, etc.)
*/
-typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property,
- const AccessorInfo& info);
typedef void (*NamedPropertyQueryCallback)(
Local<String> property,
const PropertyCallbackInfo<Integer>& info);
@@ -3152,8 +3123,6 @@ typedef void (*NamedPropertyQueryCallback)(
* The return value is true if the property could be deleted and false
* otherwise.
*/
-typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property,
- const AccessorInfo& info);
typedef void (*NamedPropertyDeleterCallback)(
Local<String> property,
const PropertyCallbackInfo<Boolean>& info);
@@ -3163,7 +3132,6 @@ typedef void (*NamedPropertyDeleterCallback)(
* Returns an array containing the names of the properties the named
* property getter intercepts.
*/
-typedef Handle<Array> (*NamedPropertyEnumerator)(const AccessorInfo& info);
typedef void (*NamedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
@@ -3172,8 +3140,6 @@ typedef void (*NamedPropertyEnumeratorCallback)(
* Returns the value of the property if the getter intercepts the
* request. Otherwise, returns an empty handle.
*/
-typedef Handle<Value> (*IndexedPropertyGetter)(uint32_t index,
- const AccessorInfo& info);
typedef void (*IndexedPropertyGetterCallback)(
uint32_t index,
const PropertyCallbackInfo<Value>& info);
@@ -3183,9 +3149,6 @@ typedef void (*IndexedPropertyGetterCallback)(
* Returns the value if the setter intercepts the request.
* Otherwise, returns an empty handle.
*/
-typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index,
- Local<Value> value,
- const AccessorInfo& info);
typedef void (*IndexedPropertySetterCallback)(
uint32_t index,
Local<Value> value,
@@ -3196,8 +3159,6 @@ typedef void (*IndexedPropertySetterCallback)(
* Returns a non-empty handle if the interceptor intercepts the request.
* The result is an integer encoding property attributes.
*/
-typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index,
- const AccessorInfo& info);
typedef void (*IndexedPropertyQueryCallback)(
uint32_t index,
const PropertyCallbackInfo<Integer>& info);
@@ -3208,8 +3169,6 @@ typedef void (*IndexedPropertyQueryCallback)(
* The return value is true if the property could be deleted and false
* otherwise.
*/
-typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index,
- const AccessorInfo& info);
typedef void (*IndexedPropertyDeleterCallback)(
uint32_t index,
const PropertyCallbackInfo<Boolean>& info);
@@ -3219,7 +3178,6 @@ typedef void (*IndexedPropertyDeleterCallback)(
* Returns an array containing the indices of the properties the
* indexed property getter intercepts.
*/
-typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info);
typedef void (*IndexedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
@@ -3351,11 +3309,6 @@ typedef bool (*IndexedSecurityCallback)(Local<Object> host,
class V8_EXPORT FunctionTemplate : public Template {
public:
/** Creates a function template.*/
- V8_DEPRECATED(static Local<FunctionTemplate> New(
- InvocationCallback callback,
- Handle<Value> data = Handle<Value>(),
- Handle<Signature> signature = Handle<Signature>(),
- int length = 0));
static Local<FunctionTemplate> New(
FunctionCallback callback = 0,
Handle<Value> data = Handle<Value>(),
@@ -3370,8 +3323,6 @@ class V8_EXPORT FunctionTemplate : public Template {
* callback is called whenever the function created from this
* FunctionTemplate is called.
*/
- V8_DEPRECATED(void SetCallHandler(InvocationCallback callback,
- Handle<Value> data = Handle<Value>()));
void SetCallHandler(FunctionCallback callback,
Handle<Value> data = Handle<Value>());
@@ -3418,6 +3369,12 @@ class V8_EXPORT FunctionTemplate : public Template {
void ReadOnlyPrototype();
/**
+ * Removes the prototype property from functions created from this
+ * FunctionTemplate.
+ */
+ void RemovePrototype();
+
+ /**
* Returns true if the given object is an instance of this function
* template.
*/
@@ -3425,9 +3382,6 @@ class V8_EXPORT 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;
};
@@ -3476,14 +3430,6 @@ class V8_EXPORT ObjectTemplate : public Template {
* defined by FunctionTemplate::HasInstance()), an implicit TypeError is
* thrown and no callback is invoked.
*/
- 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,
@@ -3518,13 +3464,6 @@ class V8_EXPORT ObjectTemplate : public Template {
* \param data A piece of data that will be passed to the callbacks
* whenever they are invoked.
*/
- 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,
@@ -3549,13 +3488,6 @@ class V8_EXPORT ObjectTemplate : public Template {
* \param data A piece of data that will be passed to the callbacks
* whenever they are invoked.
*/
- 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,
@@ -3570,9 +3502,6 @@ class V8_EXPORT ObjectTemplate : public Template {
* behave like normal JavaScript objects that cannot be called as a
* function.
*/
- V8_DEPRECATED(void SetCallAsFunctionHandler(
- InvocationCallback callback,
- Handle<Value> data = Handle<Value>()));
void SetCallAsFunctionHandler(FunctionCallback callback,
Handle<Value> data = Handle<Value>());
@@ -4797,12 +4726,14 @@ class V8_EXPORT V8 {
void* data,
RevivableCallback weak_reference_callback);
static void ClearWeak(internal::Object** global_handle);
- static int Eternalize(internal::Isolate* isolate,
- internal::Object** handle);
- static internal::Object** GetEternal(internal::Isolate* isolate, int index);
+ static void Eternalize(Isolate* isolate,
+ Value* handle,
+ int* index);
+ static Local<Value> GetEternal(Isolate* isolate, int index);
template <class T> friend class Handle;
template <class T> friend class Local;
+ template <class T> friend class Eternal;
template <class T> friend class Persistent;
friend class Context;
};
@@ -5664,17 +5595,16 @@ Local<T> Local<T>::New(Isolate* isolate, T* that) {
template<class T>
-int Local<T>::Eternalize(Isolate* isolate) {
- return V8::Eternalize(reinterpret_cast<internal::Isolate*>(isolate),
- reinterpret_cast<internal::Object**>(this->val_));
+template<class S>
+void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
+ TYPE_CHECK(T, S);
+ V8::Eternalize(isolate, Value::Cast(*handle), &this->index_);
}
template<class T>
-Local<T> Local<T>::GetEternal(Isolate* isolate, int index) {
- internal::Object** handle =
- V8::GetEternal(reinterpret_cast<internal::Isolate*>(isolate), index);
- return Local<T>(T::Cast(reinterpret_cast<Value*>(handle)));
+Local<T> Eternal<T>::Get(Isolate* isolate) {
+ return Local<T>::Cast(V8::GetEternal(isolate, index_));
}
@@ -5993,13 +5923,6 @@ FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args,
is_construct_call_(is_construct_call) { }
-Arguments::Arguments(internal::Object** args,
- internal::Object** values,
- int length,
- bool is_construct_call)
- : FunctionCallbackInfo<Value>(args, values, length, is_construct_call) { }
-
-
template<typename T>
Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
if (i < 0 || length_ <= i) return Local<Value>(*Undefined());
« no previous file with comments | « ChangeLog ('k') | include/v8-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698