summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-06-15 11:15:29 +0100
committerBen Murdoch <benm@google.com>2010-06-15 11:22:44 +0100
commit7f4d5bd8c03935e2c0cd412e561b8fc5a6a880ae (patch)
tree59a0ccf5c23a6f5890b81f4a6aa99b568c8115f2 /include
parentf7060e27768c550ace7ec48ad8c093466db52dfa (diff)
downloadandroid_external_v8-7f4d5bd8c03935e2c0cd412e561b8fc5a6a880ae.tar.gz
android_external_v8-7f4d5bd8c03935e2c0cd412e561b8fc5a6a880ae.tar.bz2
android_external_v8-7f4d5bd8c03935e2c0cd412e561b8fc5a6a880ae.zip
Update V8 to r4851 as required by WebKit r61121
Change-Id: Ib01b7c8e38d5b82b254192fc06365aa5b85780c5
Diffstat (limited to 'include')
-rw-r--r--include/v8.h126
1 files changed, 97 insertions, 29 deletions
diff --git a/include/v8.h b/include/v8.h
index 5b5dabe3..24b4cbe3 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -134,6 +134,7 @@ namespace internal {
class Arguments;
class Object;
+class Heap;
class Top;
}
@@ -513,6 +514,7 @@ class V8EXPORT Data {
class V8EXPORT ScriptData { // NOLINT
public:
virtual ~ScriptData() { }
+
/**
* Pre-compiles the specified script (context-independent).
*
@@ -522,6 +524,16 @@ class V8EXPORT ScriptData { // NOLINT
static ScriptData* PreCompile(const char* input, int length);
/**
+ * Pre-compiles the specified script (context-independent).
+ *
+ * NOTE: Pre-compilation using this method cannot happen on another thread
+ * without using Lockers.
+ *
+ * \param source Script source code.
+ */
+ static ScriptData* PreCompile(Handle<String> source);
+
+ /**
* Load previous pre-compilation data.
*
* \param data Pointer to data returned by a call to Data() of a previous
@@ -1026,12 +1038,24 @@ class V8EXPORT String : public Primitive {
class V8EXPORT ExternalStringResourceBase {
public:
virtual ~ExternalStringResourceBase() {}
+
protected:
ExternalStringResourceBase() {}
+
+ /**
+ * Internally V8 will call this Dispose method when the external string
+ * resource is no longer needed. The default implementation will use the
+ * delete operator. This method can be overridden in subclasses to
+ * control how allocated external string resources are disposed.
+ */
+ virtual void Dispose() { delete this; }
+
private:
// Disallow copying and assigning.
ExternalStringResourceBase(const ExternalStringResourceBase&);
void operator=(const ExternalStringResourceBase&);
+
+ friend class v8::internal::Heap;
};
/**
@@ -1048,10 +1072,17 @@ class V8EXPORT String : public Primitive {
* buffer.
*/
virtual ~ExternalStringResource() {}
- /** The string data from the underlying buffer.*/
+
+ /**
+ * The string data from the underlying buffer.
+ */
virtual const uint16_t* data() const = 0;
- /** The length of the string. That is, the number of two-byte characters.*/
+
+ /**
+ * The length of the string. That is, the number of two-byte characters.
+ */
virtual size_t length() const = 0;
+
protected:
ExternalStringResource() {}
};
@@ -1122,11 +1153,11 @@ class V8EXPORT String : public Primitive {
/**
* Creates a new external string using the data defined in the given
- * resource. The resource is deleted when the external string is no
- * longer live on V8's heap. The caller of this function should not
- * delete or modify the resource. Neither should the underlying buffer be
- * deallocated or modified except through the destructor of the
- * external string resource.
+ * resource. When the external string is no longer live on V8's heap the
+ * resource will be disposed by calling its Dispose method. The caller of
+ * this function should not otherwise delete or modify the resource. Neither
+ * should the underlying buffer be deallocated or modified except through the
+ * destructor of the external string resource.
*/
static Local<String> NewExternal(ExternalStringResource* resource);
@@ -1136,17 +1167,18 @@ class V8EXPORT String : public Primitive {
* will use the external string resource. The external string resource's
* character contents needs to be equivalent to this string.
* Returns true if the string has been changed to be an external string.
- * The string is not modified if the operation fails.
+ * The string is not modified if the operation fails. See NewExternal for
+ * information on the lifetime of the resource.
*/
bool MakeExternal(ExternalStringResource* resource);
/**
* Creates a new external string using the ascii data defined in the given
- * resource. The resource is deleted when the external string is no
- * longer live on V8's heap. The caller of this function should not
- * delete or modify the resource. Neither should the underlying buffer be
- * deallocated or modified except through the destructor of the
- * external string resource.
+ * resource. When the external string is no longer live on V8's heap the
+ * resource will be disposed by calling its Dispose method. The caller of
+ * this function should not otherwise delete or modify the resource. Neither
+ * should the underlying buffer be deallocated or modified except through the
+ * destructor of the external string resource.
*/
static Local<String> NewExternal(ExternalAsciiStringResource* resource);
@@ -1156,7 +1188,8 @@ class V8EXPORT String : public Primitive {
* will use the external string resource. The external string resource's
* character contents needs to be equivalent to this string.
* Returns true if the string has been changed to be an external string.
- * The string is not modified if the operation fails.
+ * The string is not modified if the operation fails. See NewExternal for
+ * information on the lifetime of the resource.
*/
bool MakeExternal(ExternalAsciiStringResource* resource);
@@ -1726,13 +1759,22 @@ typedef Handle<Value> (*NamedPropertySetter)(Local<String> property,
Local<Value> value,
const AccessorInfo& info);
-
/**
* Returns a non-empty handle if the interceptor intercepts the request.
- * The result is true if the property exists and false otherwise.
+ * The result is either boolean (true if property exists and false
+ * otherwise) or an integer encoding property attributes.
*/
+#ifdef USE_NEW_QUERY_CALLBACKS
+typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property,
+ const AccessorInfo& info);
+#else
typedef Handle<Boolean> (*NamedPropertyQuery)(Local<String> property,
const AccessorInfo& info);
+#endif
+
+typedef Handle<Value> (*NamedPropertyQueryImpl)(Local<String> property,
+ const AccessorInfo& info);
+
/**
@@ -1984,7 +2026,16 @@ class V8EXPORT FunctionTemplate : public Template {
NamedPropertyQuery query,
NamedPropertyDeleter remover,
NamedPropertyEnumerator enumerator,
- Handle<Value> data);
+ Handle<Value> data) {
+ NamedPropertyQueryImpl casted =
+ reinterpret_cast<NamedPropertyQueryImpl>(query);
+ SetNamedInstancePropertyHandlerImpl(getter,
+ setter,
+ casted,
+ remover,
+ enumerator,
+ data);
+ }
void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter,
IndexedPropertySetter setter,
IndexedPropertyQuery query,
@@ -1996,6 +2047,13 @@ class V8EXPORT FunctionTemplate : public Template {
friend class Context;
friend class ObjectTemplate;
+ private:
+ void SetNamedInstancePropertyHandlerImpl(NamedPropertyGetter getter,
+ NamedPropertySetter setter,
+ NamedPropertyQueryImpl query,
+ NamedPropertyDeleter remover,
+ NamedPropertyEnumerator enumerator,
+ Handle<Value> data);
};
@@ -2053,7 +2111,7 @@ class V8EXPORT ObjectTemplate : public Template {
*
* \param getter The callback to invoke when getting a property.
* \param setter The callback to invoke when setting a property.
- * \param query The callback to invoke to check is an object has a property.
+ * \param query The callback to invoke to check if an object has a property.
* \param deleter The callback to invoke when deleting a property.
* \param enumerator The callback to invoke to enumerate all the named
* properties of an object.
@@ -2065,7 +2123,26 @@ class V8EXPORT ObjectTemplate : public Template {
NamedPropertyQuery query = 0,
NamedPropertyDeleter deleter = 0,
NamedPropertyEnumerator enumerator = 0,
- Handle<Value> data = Handle<Value>());
+ Handle<Value> data = Handle<Value>()) {
+ NamedPropertyQueryImpl casted =
+ reinterpret_cast<NamedPropertyQueryImpl>(query);
+ SetNamedPropertyHandlerImpl(getter,
+ setter,
+ casted,
+ deleter,
+ enumerator,
+ data);
+ }
+
+ private:
+ void SetNamedPropertyHandlerImpl(NamedPropertyGetter getter,
+ NamedPropertySetter setter,
+ NamedPropertyQueryImpl query,
+ NamedPropertyDeleter deleter,
+ NamedPropertyEnumerator enumerator,
+ Handle<Value> data);
+
+ public:
/**
* Sets an indexed property handler on the object template.
@@ -2335,15 +2412,6 @@ typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags);
typedef void (*GCCallback)();
-// --- C o n t e x t G e n e r a t o r ---
-
-/**
- * Applications must provide a callback function which is called to generate
- * a context if a context was not deserialized from the snapshot.
- */
-typedef Persistent<Context> (*ContextGenerator)();
-
-
/**
* Profiler modules.
*
@@ -3177,7 +3245,7 @@ class Internals {
static const int kProxyProxyOffset = sizeof(void*);
static const int kJSObjectHeaderSize = 3 * sizeof(void*);
static const int kFullStringRepresentationMask = 0x07;
- static const int kExternalTwoByteRepresentationTag = 0x03;
+ static const int kExternalTwoByteRepresentationTag = 0x02;
// These constants are compiler dependent so their values must be
// defined within the implementation.