Version 2.2.16.
Remove the SetExternalStringDiposeCallback API. Changed the disposal of external string resources to call a virtual Dispose method on the resource.
Added support for more precise break points when debugging and stepping.
Memory usage improvements on all platforms.
git-svn-id: http://v8.googlecode.com/svn/trunk@4829 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/include/v8.h b/include/v8.h
index fe01e30..24b4cbe 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -134,6 +134,7 @@
class Arguments;
class Object;
+class Heap;
class Top;
}
@@ -513,6 +514,7 @@
class V8EXPORT ScriptData { // NOLINT
public:
virtual ~ScriptData() { }
+
/**
* Pre-compiles the specified script (context-independent).
*
@@ -522,6 +524,16 @@
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 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 @@
* 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() {}
};
@@ -1123,12 +1154,10 @@
/**
* Creates a new external string using the data defined in the given
* resource. When the external string is no longer live on V8's heap the
- * resource will be disposed. If a disposal callback has been set using
- * SetExternalStringDiposeCallback this callback will be called to dispose
- * the resource. Otherwise, V8 will dispose the resource using the C++ delete
- * operator. 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.
+ * 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);
@@ -1146,12 +1175,10 @@
/**
* Creates a new external string using the ascii data defined in the given
* resource. When the external string is no longer live on V8's heap the
- * resource will be disposed. If a disposal callback has been set using
- * SetExternalStringDiposeCallback this callback will be called to dispose
- * the resource. Otherwise, V8 will dispose the resource using the C++ delete
- * operator. 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.
+ * 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);
@@ -1251,10 +1278,6 @@
};
-typedef void (*ExternalStringDiposeCallback)
- (String::ExternalStringResourceBase* resource);
-
-
/**
* A JavaScript number value (ECMA-262, 4.3.20)
*/
@@ -2472,15 +2495,6 @@
static void RemoveMessageListeners(MessageCallback that);
/**
- * Set a callback to be called when an external string is no longer live on
- * V8's heap. The resource will no longer be needed by V8 and the embedder
- * can dispose of if. If this callback is not set V8 will free the resource
- * using the C++ delete operator.
- */
- static void SetExternalStringDiposeCallback(
- ExternalStringDiposeCallback that);
-
- /**
* Sets V8 flags from a string.
*/
static void SetFlagsFromString(const char* str, int length);