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

Side by Side Diff: src/isolate.h

Issue 2676513008: [wasm] Managed<T> ensures T's lifetime does not leak past Isolate's (Closed)
Patch Set: Comments Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « BUILD.gn ('k') | src/isolate.cc » ('j') | src/isolate.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_ISOLATE_H_ 5 #ifndef V8_ISOLATE_H_
6 #define V8_ISOLATE_H_ 6 #define V8_ISOLATE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 10
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 bool Init(Deserializer* des); 524 bool Init(Deserializer* des);
525 525
526 // True if at least one thread Enter'ed this isolate. 526 // True if at least one thread Enter'ed this isolate.
527 bool IsInUse() { return entry_stack_ != NULL; } 527 bool IsInUse() { return entry_stack_ != NULL; }
528 528
529 // Destroys the non-default isolates. 529 // Destroys the non-default isolates.
530 // Sets default isolate into "has_been_disposed" state rather then destroying, 530 // Sets default isolate into "has_been_disposed" state rather then destroying,
531 // for legacy API reasons. 531 // for legacy API reasons.
532 void TearDown(); 532 void TearDown();
533 533
534 void ReleaseManagedLifelines();
535
534 static void GlobalTearDown(); 536 static void GlobalTearDown();
535 537
536 void ClearSerializerData(); 538 void ClearSerializerData();
537 539
538 // Find the PerThread for this particular (isolate, thread) combination 540 // Find the PerThread for this particular (isolate, thread) combination
539 // If one does not yet exist, return null. 541 // If one does not yet exist, return null.
540 PerIsolateThreadData* FindPerThreadDataForThisThread(); 542 PerIsolateThreadData* FindPerThreadDataForThisThread();
541 543
542 // Find the PerThread for given (isolate, thread) combination 544 // Find the PerThread for given (isolate, thread) combination
543 // If one does not yet exist, return null. 545 // If one does not yet exist, return null.
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 1203
1202 PRINTF_FORMAT(2, 3) void PrintWithTimestamp(const char* format, ...); 1204 PRINTF_FORMAT(2, 3) void PrintWithTimestamp(const char* format, ...);
1203 1205
1204 #ifdef USE_SIMULATOR 1206 #ifdef USE_SIMULATOR
1205 base::Mutex* simulator_i_cache_mutex() { return &simulator_i_cache_mutex_; } 1207 base::Mutex* simulator_i_cache_mutex() { return &simulator_i_cache_mutex_; }
1206 #endif 1208 #endif
1207 1209
1208 void set_allow_atomics_wait(bool set) { allow_atomics_wait_ = set; } 1210 void set_allow_atomics_wait(bool set) { allow_atomics_wait_ = set; }
1209 bool allow_atomics_wait() { return allow_atomics_wait_; } 1211 bool allow_atomics_wait() { return allow_atomics_wait_; }
1210 1212
1213 // List of native heap values allocated by the runtime as part of its
1214 // implementation
1215 // that must be freed at isolate deinit.
1216 class ManagedLifeline final {
1217 public:
1218 typedef void (*Deleter)(void*);
1219 void Dispose() { deleter_(value_); }
1220
1221 private:
1222 friend class Isolate;
1223
1224 ManagedLifeline() {
1225 DCHECK_EQ(reinterpret_cast<void*>(this),
1226 reinterpret_cast<void*>(&value_));
1227 }
1228
1229 // value_ must be the first member
1230 void* value_ = nullptr;
1231 Deleter deleter_ = nullptr;
1232 ManagedLifeline* prev_ = nullptr;
1233 ManagedLifeline* next_ = nullptr;
1234 };
1235
1236 // Register a native value for destruction at isolate teardown.
1237 ManagedLifeline* RegisterForReleaseAtTeardown(
1238 void* value, ManagedLifeline::Deleter deleter);
1239
1240 // Unregister a previously registered value from release at
1241 // isolate teardown, deleting the ManagedLifeline.
1242 // This transfers the responsibility of the previously managed value's
1243 // deletion to the caller.
1244 void UnregisterFromReleaseAtTeardown(ManagedLifeline*& lifeline);
1245
1211 protected: 1246 protected:
1212 explicit Isolate(bool enable_serializer); 1247 explicit Isolate(bool enable_serializer);
1213 bool IsArrayOrObjectPrototype(Object* object); 1248 bool IsArrayOrObjectPrototype(Object* object);
1214 1249
1215 private: 1250 private:
1216 friend struct GlobalState; 1251 friend struct GlobalState;
1217 friend struct InitializeGlobalState; 1252 friend struct InitializeGlobalState;
1218 1253
1219 // These fields are accessed through the API, offsets must be kept in sync 1254 // These fields are accessed through the API, offsets must be kept in sync
1220 // with v8::internal::Internals (in include/v8.h) constants. This is also 1255 // with v8::internal::Internals (in include/v8.h) constants. This is also
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 1517
1483 v8::Isolate::AbortOnUncaughtExceptionCallback 1518 v8::Isolate::AbortOnUncaughtExceptionCallback
1484 abort_on_uncaught_exception_callback_; 1519 abort_on_uncaught_exception_callback_;
1485 1520
1486 #ifdef USE_SIMULATOR 1521 #ifdef USE_SIMULATOR
1487 base::Mutex simulator_i_cache_mutex_; 1522 base::Mutex simulator_i_cache_mutex_;
1488 #endif 1523 #endif
1489 1524
1490 bool allow_atomics_wait_; 1525 bool allow_atomics_wait_;
1491 1526
1527 ManagedLifeline managed_lifelines_root_;
1528
1492 size_t total_regexp_code_generated_; 1529 size_t total_regexp_code_generated_;
1493 1530
1494 friend class ExecutionAccess; 1531 friend class ExecutionAccess;
1495 friend class HandleScopeImplementer; 1532 friend class HandleScopeImplementer;
1496 friend class HeapTester; 1533 friend class HeapTester;
1497 friend class OptimizingCompileDispatcher; 1534 friend class OptimizingCompileDispatcher;
1498 friend class SweeperThread; 1535 friend class SweeperThread;
1499 friend class ThreadManager; 1536 friend class ThreadManager;
1500 friend class Simulator; 1537 friend class Simulator;
1501 friend class StackGuard; 1538 friend class StackGuard;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 1757
1721 EmbeddedVector<char, 128> filename_; 1758 EmbeddedVector<char, 128> filename_;
1722 FILE* file_; 1759 FILE* file_;
1723 int scope_depth_; 1760 int scope_depth_;
1724 }; 1761 };
1725 1762
1726 } // namespace internal 1763 } // namespace internal
1727 } // namespace v8 1764 } // namespace v8
1728 1765
1729 #endif // V8_ISOLATE_H_ 1766 #endif // V8_ISOLATE_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/isolate.cc » ('j') | src/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698