| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 void preGC(); | 277 void preGC(); |
| 278 void postGC(BlinkGC::GCType); | 278 void postGC(BlinkGC::GCType); |
| 279 void preSweep(); | 279 void preSweep(); |
| 280 void completeSweep(); | 280 void completeSweep(); |
| 281 void postSweep(); | 281 void postSweep(); |
| 282 // makeConsistentForMutator() drops marks from marked objects and rebuild | 282 // makeConsistentForMutator() drops marks from marked objects and rebuild |
| 283 // free lists. This is called after taking a snapshot and before resuming | 283 // free lists. This is called after taking a snapshot and before resuming |
| 284 // the executions of mutators. | 284 // the executions of mutators. |
| 285 void makeConsistentForMutator(); | 285 void makeConsistentForMutator(); |
| 286 | 286 |
| 287 void compact(); | |
| 288 | |
| 289 // Support for disallowing allocation. Mainly used for sanity | 287 // Support for disallowing allocation. Mainly used for sanity |
| 290 // checks asserts. | 288 // checks asserts. |
| 291 bool isAllocationAllowed() const { | 289 bool isAllocationAllowed() const { |
| 292 return !isAtSafePoint() && !m_noAllocationCount; | 290 return !isAtSafePoint() && !m_noAllocationCount; |
| 293 } | 291 } |
| 294 void enterNoAllocationScope() { m_noAllocationCount++; } | 292 void enterNoAllocationScope() { m_noAllocationCount++; } |
| 295 void leaveNoAllocationScope() { m_noAllocationCount--; } | 293 void leaveNoAllocationScope() { m_noAllocationCount--; } |
| 296 bool isWrapperTracingForbidden() { return isMixinInConstruction(); } | 294 bool isWrapperTracingForbidden() { return isMixinInConstruction(); } |
| 297 bool isGCForbidden() const { | 295 bool isGCForbidden() const { |
| 298 return m_gcForbiddenCount || isMixinInConstruction(); | 296 return m_gcForbiddenCount || isMixinInConstruction(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 315 | 313 |
| 316 public: | 314 public: |
| 317 MainThreadGCForbiddenScope() | 315 MainThreadGCForbiddenScope() |
| 318 : m_threadState(ThreadState::mainThreadState()) { | 316 : m_threadState(ThreadState::mainThreadState()) { |
| 319 m_threadState->enterGCForbiddenScope(); | 317 m_threadState->enterGCForbiddenScope(); |
| 320 } | 318 } |
| 321 ~MainThreadGCForbiddenScope() { m_threadState->leaveGCForbiddenScope(); } | 319 ~MainThreadGCForbiddenScope() { m_threadState->leaveGCForbiddenScope(); } |
| 322 | 320 |
| 323 private: | 321 private: |
| 324 ThreadState* const m_threadState; | 322 ThreadState* const m_threadState; |
| 325 }; | |
| 326 | |
| 327 class GCForbiddenScope final { | |
| 328 STACK_ALLOCATED(); | |
| 329 | |
| 330 public: | |
| 331 explicit GCForbiddenScope(ThreadState* threadState) | |
| 332 : m_threadState(threadState) { | |
| 333 m_threadState->enterGCForbiddenScope(); | |
| 334 } | |
| 335 ~GCForbiddenScope() { m_threadState->leaveGCForbiddenScope(); } | |
| 336 | |
| 337 private: | |
| 338 ThreadState* const m_threadState; | |
| 339 }; | 323 }; |
| 340 | 324 |
| 341 void flushHeapDoesNotContainCacheIfNeeded(); | 325 void flushHeapDoesNotContainCacheIfNeeded(); |
| 342 | 326 |
| 343 // Safepoint related functionality. | 327 // Safepoint related functionality. |
| 344 // | 328 // |
| 345 // When a thread attempts to perform GC it needs to stop all other threads | 329 // When a thread attempts to perform GC it needs to stop all other threads |
| 346 // that use the heap or at least guarantee that they will not touch any | 330 // that use the heap or at least guarantee that they will not touch any |
| 347 // heap allocated object until GC is complete. | 331 // heap allocated object until GC is complete. |
| 348 // | 332 // |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 | 554 |
| 571 void resetHeapCounters(); | 555 void resetHeapCounters(); |
| 572 void increaseAllocatedObjectSize(size_t); | 556 void increaseAllocatedObjectSize(size_t); |
| 573 void decreaseAllocatedObjectSize(size_t); | 557 void decreaseAllocatedObjectSize(size_t); |
| 574 void increaseMarkedObjectSize(size_t); | 558 void increaseMarkedObjectSize(size_t); |
| 575 | 559 |
| 576 void callThreadShutdownHooks(); | 560 void callThreadShutdownHooks(); |
| 577 | 561 |
| 578 v8::Isolate* isolate() const { return m_isolate; } | 562 v8::Isolate* isolate() const { return m_isolate; } |
| 579 | 563 |
| 580 BlinkGC::StackState stackState() const { return m_stackState; } | |
| 581 | |
| 582 void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GCReason); | 564 void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GCReason); |
| 583 void collectGarbageForTerminatingThread(); | 565 void collectGarbageForTerminatingThread(); |
| 584 void collectAllGarbage(); | 566 void collectAllGarbage(); |
| 585 | 567 |
| 586 static const char* gcReasonString(BlinkGC::GCReason); | |
| 587 | |
| 588 private: | 568 private: |
| 589 enum SnapshotType { HeapSnapshot, FreelistSnapshot }; | 569 enum SnapshotType { HeapSnapshot, FreelistSnapshot }; |
| 590 | 570 |
| 591 explicit ThreadState(BlinkGC::ThreadHeapMode); | 571 explicit ThreadState(BlinkGC::ThreadHeapMode); |
| 592 ~ThreadState(); | 572 ~ThreadState(); |
| 593 | 573 |
| 594 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); | 574 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); |
| 595 void clearSafePointScopeMarker() { | 575 void clearSafePointScopeMarker() { |
| 596 m_safePointStackCopy.clear(); | 576 m_safePointStackCopy.clear(); |
| 597 m_safePointScopeMarker = nullptr; | 577 m_safePointScopeMarker = nullptr; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 class ThreadStateFor<AnyThread> { | 752 class ThreadStateFor<AnyThread> { |
| 773 STATIC_ONLY(ThreadStateFor); | 753 STATIC_ONLY(ThreadStateFor); |
| 774 | 754 |
| 775 public: | 755 public: |
| 776 static ThreadState* state() { return ThreadState::current(); } | 756 static ThreadState* state() { return ThreadState::current(); } |
| 777 }; | 757 }; |
| 778 | 758 |
| 779 } // namespace blink | 759 } // namespace blink |
| 780 | 760 |
| 781 #endif // ThreadState_h | 761 #endif // ThreadState_h |
| OLD | NEW |