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

Unified Diff: include/v8.h

Issue 77913003: Make it possible to add more than one piece of embedder data to isolates (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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/d8.cc » ('j') | src/isolate.h » ('J')
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 2f8af27263e8f9cf46cddb1992611211b35d3517..fc94f86dc8a4001e93ed708712a60ea3459c5737 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4059,17 +4059,37 @@ class V8_EXPORT Isolate {
void Dispose();
/**
- * Associate embedder-specific data with the isolate
+ * Associate embedder-specific data with the isolate. This legacy method
+ * puts the data in the 0th slot. It will be deprecated soon.
*/
V8_INLINE void SetData(void* data);
/**
- * Retrieve embedder-specific data from the isolate.
+ * Associate embedder-specific data with the isolate. |slot| has to be
+ * between 0 and GetNumberOfDataSlots() - 1.
+ */
+ V8_INLINE void SetData(uint32_t slot, void* data);
+
+ /**
+ * Retrieve embedder-specific data from the isolate. This legacy method
+ * retrieves the data from slot 0. It will be deprecated soon.
* Returns NULL if SetData has never been called.
*/
V8_INLINE void* GetData();
/**
+ * Retrieve embedder-specific data from the isolate.
+ * Returns NULL if SetData has never been called for the given |slot|.
+ */
+ V8_INLINE void* GetData(uint32_t slot);
+
+ /**
+ * Returns the maximum number of available embedder data slots. Valid slots
+ * are in the range of 0 - GetNumberOfDataSlots() - 1.
+ */
+ V8_INLINE static uint32_t GetNumberOfDataSlots();
+
+ /**
* Get statistics about the heap memory usage.
*/
void GetHeapStatistics(HeapStatistics* heap_statistics);
@@ -5454,7 +5474,7 @@ class Internals {
static const int kExternalAsciiRepresentationTag = 0x06;
static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
- static const int kIsolateRootsOffset = 3 * kApiPointerSize;
+ static const int kIsolateRootsOffset = 6 * kApiPointerSize;
static const int kUndefinedValueRootIndex = 5;
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
@@ -5478,6 +5498,8 @@ class Internals {
static const int kUndefinedOddballKind = 5;
static const int kNullOddballKind = 3;
+ static const uint32_t kNumIsolateDataSlots = 4;
+
V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
#ifdef V8_ENABLE_CHECKS
@@ -5541,15 +5563,17 @@ class Internals {
*addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
}
- V8_INLINE static void SetEmbedderData(v8::Isolate* isolate, void* data) {
Paweł Hajdan Jr. 2013/12/18 12:49:55 Shouldn't there be V8_DEPRECATED SetEmbedderData(v
- uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
- kIsolateEmbedderDataOffset;
+ V8_INLINE static void SetEmbedderData(v8::Isolate *isolate,
+ uint32_t slot,
+ void *data) {
+ uint8_t *addr = reinterpret_cast<uint8_t *>(isolate) +
+ kIsolateEmbedderDataOffset + slot * kApiPointerSize;
*reinterpret_cast<void**>(addr) = data;
}
- V8_INLINE static void* GetEmbedderData(v8::Isolate* isolate) {
+ V8_INLINE static void* GetEmbedderData(v8::Isolate* isolate, uint32_t slot) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
- kIsolateEmbedderDataOffset;
+ kIsolateEmbedderDataOffset + slot * kApiPointerSize;
return *reinterpret_cast<void**>(addr);
}
@@ -6475,13 +6499,31 @@ Handle<Boolean> False(Isolate* isolate) {
void Isolate::SetData(void* data) {
typedef internal::Internals I;
- I::SetEmbedderData(this, data);
+ I::SetEmbedderData(this, 0, data);
}
void* Isolate::GetData() {
typedef internal::Internals I;
- return I::GetEmbedderData(this);
+ return I::GetEmbedderData(this, 0);
+}
+
+
+void Isolate::SetData(uint32_t slot, void* data) {
+ typedef internal::Internals I;
+ I::SetEmbedderData(this, slot, data);
+}
+
+
+void* Isolate::GetData(uint32_t slot) {
+ typedef internal::Internals I;
+ return I::GetEmbedderData(this, slot);
+}
+
+
+uint32_t Isolate::GetNumberOfDataSlots() {
+ typedef internal::Internals I;
+ return I::kNumIsolateDataSlots;
}
« no previous file with comments | « no previous file | src/d8.cc » ('j') | src/isolate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698