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

Unified Diff: include/v8.h

Issue 15001041: Externalization API for ArrayBuffer (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 7 years, 7 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 | « no previous file | src/api.cc » ('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 696892beed42ce6e5bc2acddeb359760cdf4d64d..54402c35e88d0e014b2becba54d2280b49952400 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2325,6 +2325,36 @@ class V8EXPORT Function : public Object {
static void CheckCast(Value* obj);
};
+/**
+ * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer|
+ * populates an instance of this class with a pointer to data and byte length.
+ *
+ * |ArrayBufferContents| is the owner of its data. When an instance of
+ * this class is destructed, the |Data| is freed.
+ *
+ * This API is experimental and may change significantly.
+ */
+class V8EXPORT ArrayBufferContents {
+ public:
+ ArrayBufferContents() : data_(NULL), byte_length_(0) {}
+ ~ArrayBufferContents();
+
+ void* Data() const { return data_; }
+ size_t ByteLength() const { return byte_length_; }
+
+ private:
+ ArrayBufferContents(void* data, size_t byte_length)
Sven Panne 2013/05/23 09:08:41 No callers, remove it.
+ : data_(data), byte_length_(byte_length) { }
+
+ void* data_;
+ size_t byte_length_;
+
+ friend class ArrayBuffer;
+};
+
+#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
+#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
+#endif
/**
* An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
@@ -2336,27 +2366,40 @@ class V8EXPORT ArrayBuffer : public Object {
* Data length in bytes.
*/
size_t ByteLength() const;
- /**
- * Raw pointer to the array buffer data
- */
- void* Data() const;
/**
* Create a new ArrayBuffer. Allocate |byte_length| bytes.
* Allocated memory will be owned by a created ArrayBuffer and
- * will be deallocated when it is garbage-collected.
+ * will be deallocated when it is garbage-collected,
+ * unless the object is externalized.
*/
static Local<ArrayBuffer> New(size_t byte_length);
/**
* Create a new ArrayBuffer over an existing memory block.
+ * The created array buffer is immediately in externalized state.
* The memory block will not be reclaimed when a created ArrayBuffer
* is garbage-collected.
*/
static Local<ArrayBuffer> New(void* data, size_t byte_length);
+ /**
+ * Returns true if ArrayBuffer is extrenalized, that is, does not
+ * own its memory block.
+ */
+ bool IsExternal() const;
+
+ /**
+ * Pass the ownership of this ArrayBuffer's backing store to
+ * a given ArrayBufferContents.
+ */
+ void Externalize(ArrayBufferContents* contents);
+
V8_INLINE(static ArrayBuffer* Cast(Value* obj));
+
+ static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
+
private:
ArrayBuffer();
static void CheckCast(Value* obj);
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698