Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 bool Init(Deserializer* des); | 526 bool Init(Deserializer* des); |
| 527 | 527 |
| 528 // True if at least one thread Enter'ed this isolate. | 528 // True if at least one thread Enter'ed this isolate. |
| 529 bool IsInUse() { return entry_stack_ != NULL; } | 529 bool IsInUse() { return entry_stack_ != NULL; } |
| 530 | 530 |
| 531 // Destroys the non-default isolates. | 531 // Destroys the non-default isolates. |
| 532 // Sets default isolate into "has_been_disposed" state rather then destroying, | 532 // Sets default isolate into "has_been_disposed" state rather then destroying, |
| 533 // for legacy API reasons. | 533 // for legacy API reasons. |
| 534 void TearDown(); | 534 void TearDown(); |
| 535 | 535 |
| 536 void ReleaseManagedLifelines(); | |
| 537 | |
| 536 static void GlobalTearDown(); | 538 static void GlobalTearDown(); |
| 537 | 539 |
| 538 void ClearSerializerData(); | 540 void ClearSerializerData(); |
| 539 | 541 |
| 540 // Find the PerThread for this particular (isolate, thread) combination | 542 // Find the PerThread for this particular (isolate, thread) combination |
| 541 // If one does not yet exist, return null. | 543 // If one does not yet exist, return null. |
| 542 PerIsolateThreadData* FindPerThreadDataForThisThread(); | 544 PerIsolateThreadData* FindPerThreadDataForThisThread(); |
| 543 | 545 |
| 544 // Find the PerThread for given (isolate, thread) combination | 546 // Find the PerThread for given (isolate, thread) combination |
| 545 // If one does not yet exist, return null. | 547 // If one does not yet exist, return null. |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 that must be freed at isolate deinit. | |
| 1215 class ManagedLifeline final { | |
|
titzer
2017/02/21 09:30:08
Maybe a better name here? "Lifeline" feels like it
Mircea Trofin
2017/02/21 15:52:28
How about "NativeObjectLifetime{Manager|Handler}"
| |
| 1216 public: | |
| 1217 typedef void (*Deleter)(void*); | |
| 1218 void Dispose() { deleter_(value_); } | |
| 1219 | |
| 1220 private: | |
| 1221 friend class Isolate; | |
| 1222 | |
| 1223 ManagedLifeline() { | |
| 1224 DCHECK_EQ(reinterpret_cast<void*>(this), | |
| 1225 reinterpret_cast<void*>(&value_)); | |
| 1226 } | |
| 1227 | |
| 1228 // value_ must be the first member | |
| 1229 void* value_ = nullptr; | |
| 1230 Deleter deleter_ = nullptr; | |
| 1231 ManagedLifeline* prev_ = nullptr; | |
| 1232 ManagedLifeline* next_ = nullptr; | |
| 1233 }; | |
| 1234 | |
| 1235 // Register a native value for destruction at isolate teardown. | |
| 1236 ManagedLifeline* RegisterForReleaseAtTeardown( | |
| 1237 void* value, ManagedLifeline::Deleter deleter); | |
| 1238 | |
| 1239 // Unregister a previously registered value from release at | |
| 1240 // isolate teardown, deleting the ManagedLifeline. | |
| 1241 // This transfers the responsibility of the previously managed value's | |
| 1242 // deletion to the caller. Pass by pointer, because *lifeline_ptr gets | |
| 1243 // reset to nullptr. | |
| 1244 void UnregisterFromReleaseAtTeardown(ManagedLifeline** lifeline_ptr); | |
| 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 Loading... | |
| 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 Loading... | |
| 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_ |
| OLD | NEW |