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

Side by Side Diff: third_party/WebKit/Source/platform/heap/ThreadState.h

Issue 2531973002: Simple BlinkGC heap compaction. (Closed)
Patch Set: Clear unused pages before decommitting Created 4 years 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
OLDNEW
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
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
287 // Support for disallowing allocation. Mainly used for sanity 289 // Support for disallowing allocation. Mainly used for sanity
288 // checks asserts. 290 // checks asserts.
289 bool isAllocationAllowed() const { 291 bool isAllocationAllowed() const {
290 return !isAtSafePoint() && !m_noAllocationCount; 292 return !isAtSafePoint() && !m_noAllocationCount;
291 } 293 }
292 void enterNoAllocationScope() { m_noAllocationCount++; } 294 void enterNoAllocationScope() { m_noAllocationCount++; }
293 void leaveNoAllocationScope() { m_noAllocationCount--; } 295 void leaveNoAllocationScope() { m_noAllocationCount--; }
294 bool isWrapperTracingForbidden() { return isMixinInConstruction(); } 296 bool isWrapperTracingForbidden() { return isMixinInConstruction(); }
295 bool isGCForbidden() const { 297 bool isGCForbidden() const {
296 return m_gcForbiddenCount || isMixinInConstruction(); 298 return m_gcForbiddenCount || isMixinInConstruction();
(...skipping 18 matching lines...) Expand all
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 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 };
340
325 void flushHeapDoesNotContainCacheIfNeeded(); 341 void flushHeapDoesNotContainCacheIfNeeded();
326 342
327 // Safepoint related functionality. 343 // Safepoint related functionality.
328 // 344 //
329 // When a thread attempts to perform GC it needs to stop all other threads 345 // 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 346 // that use the heap or at least guarantee that they will not touch any
331 // heap allocated object until GC is complete. 347 // heap allocated object until GC is complete.
332 // 348 //
333 // We say that a thread is at a safepoint if this thread is guaranteed to 349 // 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 350 // not touch any heap allocated object or any heap related functionality until
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 570
555 void resetHeapCounters(); 571 void resetHeapCounters();
556 void increaseAllocatedObjectSize(size_t); 572 void increaseAllocatedObjectSize(size_t);
557 void decreaseAllocatedObjectSize(size_t); 573 void decreaseAllocatedObjectSize(size_t);
558 void increaseMarkedObjectSize(size_t); 574 void increaseMarkedObjectSize(size_t);
559 575
560 void callThreadShutdownHooks(); 576 void callThreadShutdownHooks();
561 577
562 v8::Isolate* isolate() const { return m_isolate; } 578 v8::Isolate* isolate() const { return m_isolate; }
563 579
580 BlinkGC::StackState stackState() const { return m_stackState; }
581
564 void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GCReason); 582 void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GCReason);
565 void collectGarbageForTerminatingThread(); 583 void collectGarbageForTerminatingThread();
566 void collectAllGarbage(); 584 void collectAllGarbage();
567 585
586 static const char* gcReasonString(BlinkGC::GCReason);
587
568 private: 588 private:
569 enum SnapshotType { HeapSnapshot, FreelistSnapshot }; 589 enum SnapshotType { HeapSnapshot, FreelistSnapshot };
570 590
571 explicit ThreadState(BlinkGC::ThreadHeapMode); 591 explicit ThreadState(BlinkGC::ThreadHeapMode);
572 ~ThreadState(); 592 ~ThreadState();
573 593
574 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); 594 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope();
575 void clearSafePointScopeMarker() { 595 void clearSafePointScopeMarker() {
576 m_safePointStackCopy.clear(); 596 m_safePointStackCopy.clear();
577 m_safePointScopeMarker = nullptr; 597 m_safePointScopeMarker = nullptr;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 class ThreadStateFor<AnyThread> { 772 class ThreadStateFor<AnyThread> {
753 STATIC_ONLY(ThreadStateFor); 773 STATIC_ONLY(ThreadStateFor);
754 774
755 public: 775 public:
756 static ThreadState* state() { return ThreadState::current(); } 776 static ThreadState* state() { return ThreadState::current(); }
757 }; 777 };
758 778
759 } // namespace blink 779 } // namespace blink
760 780
761 #endif // ThreadState_h 781 #endif // ThreadState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698