diff --git a/include/v8.h b/include/v8.h index 76e67b986c..784419ccb0 100644 --- a/include/v8.h +++ b/include/v8.h @@ -313,6 +313,7 @@ class Local { friend class String; friend class Object; friend class Context; + friend class Isolate; friend class Private; template friend class internal::CustomArguments; friend Local Undefined(Isolate* isolate); @@ -5522,8 +5523,12 @@ class V8_EXPORT FunctionTemplate : public Template { */ bool HasInstance(Local object); + V8_INLINE static FunctionTemplate* Cast(Data* data); + private: FunctionTemplate(); + + static void CheckCast(Data* that); friend class Context; friend class ObjectTemplate; }; @@ -5870,10 +5875,13 @@ class V8_EXPORT ObjectTemplate : public Template { */ void SetImmutableProto(); + V8_INLINE static ObjectTemplate* Cast(Data* data); + private: ObjectTemplate(); static Local New(internal::Isolate* isolate, Local constructor); + static void CheckCast(Data* that); friend class FunctionTemplate; }; @@ -7083,6 +7091,14 @@ class V8_EXPORT Isolate { */ V8_INLINE static uint32_t GetNumberOfDataSlots(); + /** + * Return data that was previously attached to the isolate snapshot via + * SnapshotCreator, and removes the reference to it. + * Repeated call with the same index returns an empty MaybeLocal. + */ + template + V8_INLINE MaybeLocal GetDataFromSnapshotOnce(size_t index); + /** * Get statistics about the heap memory usage. */ @@ -7725,6 +7741,7 @@ class V8_EXPORT Isolate { template friend class PersistentValueMapBase; + internal::Object** GetDataFromSnapshotOnce(size_t index); void ReportExternalAllocationLimitReached(); void CheckMemoryPressure(); }; @@ -8021,6 +8038,24 @@ class V8_EXPORT SnapshotCreator { */ size_t AddTemplate(Local