Chromium Code Reviews| Index: src/isolate.h |
| diff --git a/src/isolate.h b/src/isolate.h |
| index c783b72f411ceb71b83cd0317362a378d2ed0985..6283e0851bb20cd80a79464ceaa4d87d03baf647 100644 |
| --- a/src/isolate.h |
| +++ b/src/isolate.h |
| @@ -531,6 +531,8 @@ class Isolate { |
| // for legacy API reasons. |
| void TearDown(); |
| + void ReleaseManagedLifelines(); |
| + |
| static void GlobalTearDown(); |
| void ClearSerializerData(); |
| @@ -1206,6 +1208,40 @@ class Isolate { |
| void set_allow_atomics_wait(bool set) { allow_atomics_wait_ = set; } |
| bool allow_atomics_wait() { return allow_atomics_wait_; } |
| + // List of native heap values allocated by the runtime as part of its |
| + // implementation |
|
bradnelson
2017/02/16 23:59:20
Reflow the text.
|
| + // that must be freed at isolate deinit. |
| + class ManagedLifeline final { |
| + public: |
| + typedef void (*Deleter)(void*); |
| + void Dispose() { deleter_(value_); } |
| + |
| + private: |
| + friend class Isolate; |
| + |
| + ManagedLifeline() { |
| + DCHECK_EQ(reinterpret_cast<void*>(this), |
| + reinterpret_cast<void*>(&value_)); |
| + } |
| + |
| + // value_ must be the first member |
| + void* value_ = nullptr; |
| + Deleter deleter_ = nullptr; |
| + ManagedLifeline* prev_ = nullptr; |
| + ManagedLifeline* next_ = nullptr; |
| + }; |
| + |
| + // Register a native value for destruction at isolate teardown. |
| + ManagedLifeline* RegisterForReleaseAtTeardown( |
| + void* value, ManagedLifeline::Deleter deleter); |
| + |
| + // Unregister a previously registered value from release at |
| + // isolate teardown, deleting the ManagedLifeline. |
| + // This transfers the responsibility of the previously managed value's |
| + // deletion to the caller. Pass by pointer, because *lifeline_ptr gets |
| + // reset to nullptr. |
| + void UnregisterFromReleaseAtTeardown(ManagedLifeline** lifeline_ptr); |
| + |
| protected: |
| explicit Isolate(bool enable_serializer); |
| bool IsArrayOrObjectPrototype(Object* object); |
| @@ -1487,6 +1523,8 @@ class Isolate { |
| bool allow_atomics_wait_; |
| + ManagedLifeline managed_lifelines_root_; |
| + |
| size_t total_regexp_code_generated_; |
| friend class ExecutionAccess; |