⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 121316 in webkit


Ignore:
Timestamp:
Jun 26, 2012, 8:44:05 PM (14 years ago)
Author:
ggaren@apple.com
Message:

Reduced (but did not eliminate) use of "berzerker GC"
https://bugs.webkit.org/show_bug.cgi?id=89237

Reviewed by Gavin Barraclough.

(PART 2)

../JavaScriptCore:

This part turns off "berzerker GC" and turns on incremental shrinking.

  • heap/IncrementalSweeper.cpp:

(JSC::IncrementalSweeper::doSweep): Free or shrink after sweeping to
maintain the behavior we used to get from the occasional berzerker GC,
which would run all finalizers and then free or shrink all blocks
synchronously.

  • heap/MarkedBlock.h:

(JSC::MarkedBlock::needsSweeping): Sweep zapped blocks, too. It's always
safe to sweep a zapped block (that's the point of zapping), and it's
sometimes profitable. For example, consider this case: Block A does some
allocation (transitioning Block A from Marked to FreeListed), then GC
happens (transitioning Block A to Zapped), then all objects in Block A
are free, then the incremental sweeper visits Block A. If we skipped
Zapped blocks, we'd skip Block A, even though it would be profitable to
run its destructors and free its memory.

  • runtime/GCActivityCallback.cpp:

(JSC::DefaultGCActivityCallback::doWork): Don't sweep eagerly; we'll do
this incrementally.

../WebCore:

Don't ASSERT that RootObject's destructor runs and invalidates all
RuntimeObjects before their destructors run.

We don't guarantee this behavior because some RuntimeObjects may already
be garbage by the time RootObject's destructor runs, in which case
RootObject's weak pointers will be NULL, and RootObject will not call
invalidate() on them.

It's been theoretically possible for this ASSERT to fire for a while now.
This patch makes it fire all the time.

Luckily, we only needed the behavior guarded by this ASSERT for WebKit1
in Safari on Windows (cf. https://bugs.webkit.org/show_bug.cgi?id=61317),
to handle the way WebKit1 would unload plugin DLLs. If this ever becomes
an issue again, we can fix it by (a) not unloading plugin DLLs,
(b) migrating WebKit1 to the WebKit2 JS-plugin binding model, (c) making
the Instance pointer in a RuntimeObject an indirect pointer through
RootObject, or (c) giving RuntimeObject some sort of special way to
access a zombie weak pointer.

  • bridge/runtime_object.cpp:

(JSC::Bindings::RuntimeObject::destroy): ASSERT removed. Anders said so.

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r121307 r121316  
     12012-06-26  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reduced (but did not eliminate) use of "berzerker GC"
     4        https://bugs.webkit.org/show_bug.cgi?id=89237
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        (PART 2)
     9
     10        This part turns off "berzerker GC" and turns on incremental shrinking.
     11
     12        * heap/IncrementalSweeper.cpp:
     13        (JSC::IncrementalSweeper::doSweep): Free or shrink after sweeping to
     14        maintain the behavior we used to get from the occasional berzerker GC,
     15        which would run all finalizers and then free or shrink all blocks
     16        synchronously.
     17
     18        * heap/MarkedBlock.h:
     19        (JSC::MarkedBlock::needsSweeping): Sweep zapped blocks, too. It's always
     20        safe to sweep a zapped block (that's the point of zapping), and it's
     21        sometimes profitable. For example, consider this case: Block A does some
     22        allocation (transitioning Block A from Marked to FreeListed), then GC
     23        happens (transitioning Block A to Zapped), then all objects in Block A
     24        are free, then the incremental sweeper visits Block A. If we skipped
     25        Zapped blocks, we'd skip Block A, even though it would be profitable to
     26        run its destructors and free its memory.
     27
     28        * runtime/GCActivityCallback.cpp:
     29        (JSC::DefaultGCActivityCallback::doWork): Don't sweep eagerly; we'll do
     30        this incrementally.
     31
    1322012-06-26  Filip Pizlo  <fpizlo@apple.com>
    233
  • trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp

    r121098 r121316  
    7979
    8080        block->sweep();
     81        m_globalData->heap.objectSpace().freeOrShrinkBlock(block);
    8182
    8283        CFTimeInterval elapsedTime = WTF::monotonicallyIncreasingTime() - sweepBeginTime;
  • trunk/Source/JavaScriptCore/heap/MarkedBlock.h

    r119909 r121316  
    409409    inline bool MarkedBlock::needsSweeping()
    410410    {
    411         return m_state == Marked;
     411        return m_state == Marked || m_state == Zapped;
    412412    }
    413413
  • trunk/Source/JavaScriptCore/runtime/GCActivityCallback.cpp

    r120778 r121316  
    7676    }
    7777#endif
    78     heap->collectAllGarbage();
     78    heap->collect(Heap::DoNotSweep);
    7979}
    8080   
  • trunk/Source/WebCore/ChangeLog

    r121314 r121316  
     12012-06-26  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reduced (but did not eliminate) use of "berzerker GC"
     4        https://bugs.webkit.org/show_bug.cgi?id=89237
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        (PART 2)
     9
     10        Don't ASSERT that RootObject's destructor runs and invalidates all
     11        RuntimeObjects before their destructors run.
     12
     13        We don't guarantee this behavior because some RuntimeObjects may already
     14        be garbage by the time RootObject's destructor runs, in which case
     15        RootObject's weak pointers will be NULL, and RootObject will not call
     16        invalidate() on them.
     17
     18        It's been theoretically possible for this ASSERT to fire for a while now.
     19        This patch makes it fire all the time.
     20
     21        Luckily, we only needed the behavior guarded by this ASSERT for WebKit1
     22        in Safari on Windows (cf. https://bugs.webkit.org/show_bug.cgi?id=61317),
     23        to handle the way WebKit1 would unload plugin DLLs. If this ever becomes
     24        an issue again, we can fix it by (a) not unloading plugin DLLs,
     25        (b) migrating WebKit1 to the WebKit2 JS-plugin binding model, (c) making
     26        the Instance pointer in a RuntimeObject an indirect pointer through
     27        RootObject, or (c) giving RuntimeObject some sort of special way to
     28        access a zombie weak pointer.
     29
     30        * bridge/runtime_object.cpp:
     31        (JSC::Bindings::RuntimeObject::destroy): ASSERT removed. Anders said so.
     32
    1332012-06-26  Douglas Stockwell  <dstockwell@chromium.org>
    234
  • trunk/Source/WebCore/bridge/runtime_object.cpp

    r118616 r121316  
    5252void RuntimeObject::destroy(JSCell* cell)
    5353{
    54     RuntimeObject* thisObject = static_cast<RuntimeObject*>(cell);
    55     ASSERT(!thisObject->m_instance);
    56     thisObject->RuntimeObject::~RuntimeObject();
     54    static_cast<RuntimeObject*>(cell)->RuntimeObject::~RuntimeObject();
    5755}
    5856
Note: See TracChangeset for help on using the changeset viewer.