Advertisement
Guest User

Untitled

a guest
Mar 9th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.43 KB | None | 0 0
  1. diff --git a/Source/JavaScriptCore/heap/IncrementalSweeper.cpp b/Source/JavaScriptCore/heap/IncrementalSweeper.cpp
  2. index da15137..b3ad8c8 100644
  3. --- a/Source/JavaScriptCore/heap/IncrementalSweeper.cpp
  4. +++ b/Source/JavaScriptCore/heap/IncrementalSweeper.cpp
  5. @@ -60,6 +60,12 @@ void IncrementalSweeper::cancelTimer()
  6.      CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
  7.  }
  8.  
  9. +void IncrementalSweeper::fullSweep()
  10. +{
  11. +  while (hasWork())
  12. +      doWork();
  13. +}
  14. +
  15.  void IncrementalSweeper::doWork()
  16.  {
  17.      doSweep(WTF::monotonicallyIncreasingTime());
  18. diff --git a/Source/JavaScriptCore/heap/IncrementalSweeper.h b/Source/JavaScriptCore/heap/IncrementalSweeper.h
  19. index af826c4..199f948 100644
  20. --- a/Source/JavaScriptCore/heap/IncrementalSweeper.h
  21. +++ b/Source/JavaScriptCore/heap/IncrementalSweeper.h
  22. @@ -38,6 +38,7 @@ class IncrementalSweeper : public HeapTimer {
  23.  public:
  24.  #if USE(CF)
  25.      JS_EXPORT_PRIVATE IncrementalSweeper(Heap*, CFRunLoopRef);
  26. +    JS_EXPORT_PRIVATE void fullSweep();
  27.  #else
  28.      explicit IncrementalSweeper(VM*);
  29.  #endif
  30. @@ -52,6 +53,7 @@ private:
  31.      void doSweep(double startTime);
  32.      void scheduleTimer();
  33.      void cancelTimer();
  34. +    bool hasWork() const { return !m_blocksToSweep.isEmpty(); }
  35.      
  36.      unsigned m_currentBlockToSweepIndex;
  37.      Vector<MarkedBlock*>& m_blocksToSweep;
  38. diff --git a/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm b/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm
  39. index 17858c44e..c85dca3 100644
  40. --- a/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm
  41. +++ b/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm
  42. @@ -30,9 +30,11 @@
  43.  #import "IOSurfacePool.h"
  44.  #import "GCController.h"
  45.  #import "JSDOMWindowBase.h"
  46. +#import "JSDOMWindow.h"
  47.  #import "LayerPool.h"
  48.  #import "Logging.h"
  49.  #import "WebCoreSystemInterface.h"
  50. +#import <JavaScriptCore/IncrementalSweeper.h>
  51.  #import <mach/mach.h>
  52.  #import <mach/task_info.h>
  53.  #import <malloc/malloc.h>
  54. @@ -88,6 +90,13 @@ void MemoryPressureHandler::platformReleaseMemory(bool critical)
  55.          ReliefLogger log("Collecting JavaScript garbage");
  56.          gcController().garbageCollectNow();
  57.      }
  58. +
  59. +    // Do a full sweep of collected objects.
  60. +    {
  61. +        ReliefLogger log("Full JavaScript garbage sweep");
  62. +        JSC::JSLockHolder lock(JSDOMWindow::commonVM());
  63. +        JSDOMWindow::commonVM().heap.sweeper()->fullSweep();
  64. +    }
  65.  #endif
  66.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement