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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1199 | 1201 |
| 1200 PRINTF_FORMAT(2, 3) void PrintWithTimestamp(const char* format, ...); | 1202 PRINTF_FORMAT(2, 3) void PrintWithTimestamp(const char* format, ...); |
| 1201 | 1203 |
| 1202 #ifdef USE_SIMULATOR | 1204 #ifdef USE_SIMULATOR |
| 1203 base::Mutex* simulator_i_cache_mutex() { return &simulator_i_cache_mutex_; } | 1205 base::Mutex* simulator_i_cache_mutex() { return &simulator_i_cache_mutex_; } |
| 1204 #endif | 1206 #endif |
| 1205 | 1207 |
| 1206 void set_allow_atomics_wait(bool set) { allow_atomics_wait_ = set; } | 1208 void set_allow_atomics_wait(bool set) { allow_atomics_wait_ = set; } |
| 1207 bool allow_atomics_wait() { return allow_atomics_wait_; } | 1209 bool allow_atomics_wait() { return allow_atomics_wait_; } |
| 1208 | 1210 |
| 1211 // List of native heap values allocated by the runtime as part of its | |
| 1212 // implementation | |
| 1213 // that must be freed at isolate deinit. | |
| 1214 class ManagedLifeline final { | |
|
titzer
2017/02/13 21:58:25
Can we just make this a struct and hide it in the
Mircea Trofin
2017/02/14 04:50:55
That would mean:
- changing managed_lifelines_root
| |
| 1215 public: | |
| 1216 typedef void (*Deleter)(void*); | |
| 1217 void Dispose() { deleter_(value_); } | |
| 1218 | |
| 1219 private: | |
| 1220 friend class Isolate; | |
| 1221 | |
| 1222 ManagedLifeline() { | |
| 1223 DCHECK_EQ(reinterpret_cast<void*>(this), | |
| 1224 reinterpret_cast<void*>(&value_)); | |
| 1225 } | |
| 1226 | |
| 1227 // value_ must be the first member | |
| 1228 void* value_ = nullptr; | |
| 1229 Deleter deleter_ = nullptr; | |
| 1230 ManagedLifeline* prev_ = nullptr; | |
| 1231 ManagedLifeline* next_ = nullptr; | |
| 1232 }; | |
| 1233 | |
| 1234 // Register a native value for destruction at isolate teardown. | |
| 1235 ManagedLifeline* RegisterForReleaseAtTeardown( | |
| 1236 void* value, ManagedLifeline::Deleter deleter); | |
| 1237 | |
| 1238 // Unregister a previously registered value from release at | |
| 1239 // isolate teardown, deleting the ManagedLifeline. | |
| 1240 // This transfers the responsibility of the previously managed value's | |
| 1241 // deletion to the caller. | |
| 1242 void UnregisterFromReleaseAtTeardown(ManagedLifeline*& lifeline); | |
| 1243 | |
| 1209 protected: | 1244 protected: |
| 1210 explicit Isolate(bool enable_serializer); | 1245 explicit Isolate(bool enable_serializer); |
| 1211 bool IsArrayOrObjectPrototype(Object* object); | 1246 bool IsArrayOrObjectPrototype(Object* object); |
| 1212 | 1247 |
| 1213 private: | 1248 private: |
| 1214 friend struct GlobalState; | 1249 friend struct GlobalState; |
| 1215 friend struct InitializeGlobalState; | 1250 friend struct InitializeGlobalState; |
| 1216 | 1251 |
| 1217 // These fields are accessed through the API, offsets must be kept in sync | 1252 // These fields are accessed through the API, offsets must be kept in sync |
| 1218 // with v8::internal::Internals (in include/v8.h) constants. This is also | 1253 // 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... | |
| 1480 | 1515 |
| 1481 v8::Isolate::AbortOnUncaughtExceptionCallback | 1516 v8::Isolate::AbortOnUncaughtExceptionCallback |
| 1482 abort_on_uncaught_exception_callback_; | 1517 abort_on_uncaught_exception_callback_; |
| 1483 | 1518 |
| 1484 #ifdef USE_SIMULATOR | 1519 #ifdef USE_SIMULATOR |
| 1485 base::Mutex simulator_i_cache_mutex_; | 1520 base::Mutex simulator_i_cache_mutex_; |
| 1486 #endif | 1521 #endif |
| 1487 | 1522 |
| 1488 bool allow_atomics_wait_; | 1523 bool allow_atomics_wait_; |
| 1489 | 1524 |
| 1525 ManagedLifeline managed_lifelines_root_; | |
| 1526 | |
| 1490 size_t total_regexp_code_generated_; | 1527 size_t total_regexp_code_generated_; |
| 1491 | 1528 |
| 1492 friend class ExecutionAccess; | 1529 friend class ExecutionAccess; |
| 1493 friend class HandleScopeImplementer; | 1530 friend class HandleScopeImplementer; |
| 1494 friend class HeapTester; | 1531 friend class HeapTester; |
| 1495 friend class OptimizingCompileDispatcher; | 1532 friend class OptimizingCompileDispatcher; |
| 1496 friend class SweeperThread; | 1533 friend class SweeperThread; |
| 1497 friend class ThreadManager; | 1534 friend class ThreadManager; |
| 1498 friend class Simulator; | 1535 friend class Simulator; |
| 1499 friend class StackGuard; | 1536 friend class StackGuard; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1718 | 1755 |
| 1719 EmbeddedVector<char, 128> filename_; | 1756 EmbeddedVector<char, 128> filename_; |
| 1720 FILE* file_; | 1757 FILE* file_; |
| 1721 int scope_depth_; | 1758 int scope_depth_; |
| 1722 }; | 1759 }; |
| 1723 | 1760 |
| 1724 } // namespace internal | 1761 } // namespace internal |
| 1725 } // namespace v8 | 1762 } // namespace v8 |
| 1726 | 1763 |
| 1727 #endif // V8_ISOLATE_H_ | 1764 #endif // V8_ISOLATE_H_ |
| OLD | NEW |