| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 void preGC(); | 278 void preGC(); |
| 279 void postGC(BlinkGC::GCType); | 279 void postGC(BlinkGC::GCType); |
| 280 void preSweep(); | 280 void preSweep(); |
| 281 void completeSweep(); | 281 void completeSweep(); |
| 282 void postSweep(); | 282 void postSweep(); |
| 283 // makeConsistentForMutator() drops marks from marked objects and rebuild | 283 // makeConsistentForMutator() drops marks from marked objects and rebuild |
| 284 // free lists. This is called after taking a snapshot and before resuming | 284 // free lists. This is called after taking a snapshot and before resuming |
| 285 // the executions of mutators. | 285 // the executions of mutators. |
| 286 void makeConsistentForMutator(); | 286 void makeConsistentForMutator(); |
| 287 | 287 |
| 288 void compact(); |
| 289 |
| 288 // Support for disallowing allocation. Mainly used for sanity | 290 // Support for disallowing allocation. Mainly used for sanity |
| 289 // checks asserts. | 291 // checks asserts. |
| 290 bool isAllocationAllowed() const { | 292 bool isAllocationAllowed() const { |
| 291 return !isAtSafePoint() && !m_noAllocationCount; | 293 return !isAtSafePoint() && !m_noAllocationCount; |
| 292 } | 294 } |
| 293 void enterNoAllocationScope() { m_noAllocationCount++; } | 295 void enterNoAllocationScope() { m_noAllocationCount++; } |
| 294 void leaveNoAllocationScope() { m_noAllocationCount--; } | 296 void leaveNoAllocationScope() { m_noAllocationCount--; } |
| 295 bool isGCForbidden() const { | 297 bool isGCForbidden() const { |
| 296 return m_gcForbiddenCount || isMixinInConstruction(); | 298 return m_gcForbiddenCount || isMixinInConstruction(); |
| 297 } | 299 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 315 MainThreadGCForbiddenScope() | 317 MainThreadGCForbiddenScope() |
| 316 : m_threadState(ThreadState::mainThreadState()) { | 318 : m_threadState(ThreadState::mainThreadState()) { |
| 317 m_threadState->enterGCForbiddenScope(); | 319 m_threadState->enterGCForbiddenScope(); |
| 318 } | 320 } |
| 319 ~MainThreadGCForbiddenScope() { m_threadState->leaveGCForbiddenScope(); } | 321 ~MainThreadGCForbiddenScope() { m_threadState->leaveGCForbiddenScope(); } |
| 320 | 322 |
| 321 private: | 323 private: |
| 322 ThreadState* const m_threadState; | 324 ThreadState* const m_threadState; |
| 323 }; | 325 }; |
| 324 | 326 |
| 327 class GCForbiddenScope final { |
| 328 STACK_ALLOCATED(); |
| 329 |
| 330 public: |
| 331 GCForbiddenScope(ThreadState* threadState) : m_threadState(threadState) { |
| 332 m_threadState->enterGCForbiddenScope(); |
| 333 } |
| 334 ~GCForbiddenScope() { m_threadState->leaveGCForbiddenScope(); } |
| 335 |
| 336 private: |
| 337 ThreadState* const m_threadState; |
| 338 }; |
| 339 |
| 325 void flushHeapDoesNotContainCacheIfNeeded(); | 340 void flushHeapDoesNotContainCacheIfNeeded(); |
| 326 | 341 |
| 327 // Safepoint related functionality. | 342 // Safepoint related functionality. |
| 328 // | 343 // |
| 329 // When a thread attempts to perform GC it needs to stop all other threads | 344 // When a thread attempts to perform GC it needs to stop all other threads |
| 330 // that use the heap or at least guarantee that they will not touch any | 345 // that use the heap or at least guarantee that they will not touch any |
| 331 // heap allocated object until GC is complete. | 346 // heap allocated object until GC is complete. |
| 332 // | 347 // |
| 333 // We say that a thread is at a safepoint if this thread is guaranteed to | 348 // We say that a thread is at a safepoint if this thread is guaranteed to |
| 334 // not touch any heap allocated object or any heap related functionality until | 349 // not touch any heap allocated object or any heap related functionality until |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 569 |
| 555 void resetHeapCounters(); | 570 void resetHeapCounters(); |
| 556 void increaseAllocatedObjectSize(size_t); | 571 void increaseAllocatedObjectSize(size_t); |
| 557 void decreaseAllocatedObjectSize(size_t); | 572 void decreaseAllocatedObjectSize(size_t); |
| 558 void increaseMarkedObjectSize(size_t); | 573 void increaseMarkedObjectSize(size_t); |
| 559 | 574 |
| 560 void callThreadShutdownHooks(); | 575 void callThreadShutdownHooks(); |
| 561 | 576 |
| 562 v8::Isolate* isolate() const { return m_isolate; } | 577 v8::Isolate* isolate() const { return m_isolate; } |
| 563 | 578 |
| 579 BlinkGC::StackState stackState() const { return m_stackState; } |
| 580 |
| 564 void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GCReason); | 581 void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GCReason); |
| 565 void collectGarbageForTerminatingThread(); | 582 void collectGarbageForTerminatingThread(); |
| 566 void collectAllGarbage(); | 583 void collectAllGarbage(); |
| 567 | 584 |
| 568 private: | 585 private: |
| 569 enum SnapshotType { HeapSnapshot, FreelistSnapshot }; | 586 enum SnapshotType { HeapSnapshot, FreelistSnapshot }; |
| 570 | 587 |
| 571 explicit ThreadState(BlinkGC::ThreadHeapMode); | 588 explicit ThreadState(BlinkGC::ThreadHeapMode); |
| 572 ~ThreadState(); | 589 ~ThreadState(); |
| 573 | 590 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 class ThreadStateFor<AnyThread> { | 769 class ThreadStateFor<AnyThread> { |
| 753 STATIC_ONLY(ThreadStateFor); | 770 STATIC_ONLY(ThreadStateFor); |
| 754 | 771 |
| 755 public: | 772 public: |
| 756 static ThreadState* state() { return ThreadState::current(); } | 773 static ThreadState* state() { return ThreadState::current(); } |
| 757 }; | 774 }; |
| 758 | 775 |
| 759 } // namespace blink | 776 } // namespace blink |
| 760 | 777 |
| 761 #endif // ThreadState_h | 778 #endif // ThreadState_h |
| OLD | NEW |