Ignore:
Timestamp:
Mar 29, 2012, 5:36:37 PM (13 years ago)
Author:
[email protected]
Message:

Refactor recompileAllJSFunctions() to be less expensive
https://bugs.webkit.org/show_bug.cgi?id=80330

Reviewed by Filip Pizlo.

This change is performance neutral on the JS benchmarks we track. It's mostly to improve page
load performance, which currently does at least a couple full GCs per navigation.

  • heap/Heap.cpp:

(JSC::Heap::discardAllCompiledCode): Rename recompileAllJSFunctions to discardAllCompiledCode
because the function doesn't actually recompile anything (and never did); it simply throws code
away for it to be recompiled later if we determine we should do so.
(JSC):
(JSC::Heap::collectAllGarbage):
(JSC::Heap::addFunctionExecutable): Adds a newly created FunctionExecutable to the Heap's list.
(JSC::Heap::removeFunctionExecutable): Removes the specified FunctionExecutable from the Heap's list.

  • heap/Heap.h:

(JSC):
(Heap):

  • runtime/Executable.cpp: Added next and prev fields to FunctionExecutables so that they can

be used in DoublyLinkedLists.
(JSC::FunctionExecutable::FunctionExecutable):
(JSC::FunctionExecutable::finalize): Removes the FunctionExecutable from the Heap's list.

  • runtime/Executable.h:

(FunctionExecutable):
(JSC::FunctionExecutable::create): Adds the FunctionExecutable to the Heap's list.

  • runtime/JSGlobalData.cpp: Remove recompileAllJSFunctions, as it's the Heap's job to own and manage

the list of FunctionExecutables.

  • runtime/JSGlobalData.h:

(JSGlobalData):

  • runtime/JSGlobalObject.cpp:

(JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): Use the new discardAllCompiledCode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r111877 r112624  
    766766}
    767767
     768void Heap::discardAllCompiledCode()
     769{
     770    // If JavaScript is running, it's not safe to recompile, since we'll end
     771    // up throwing away code that is live on the stack.
     772    ASSERT(!m_globalData->dynamicGlobalObject);
     773   
     774    for (FunctionExecutable* current = m_functions.head(); current; current = current->next())
     775        current->discardCode();
     776}
     777
    768778void Heap::collectAllGarbage()
    769779{
     
    771781        return;
    772782    if (!m_globalData->dynamicGlobalObject)
    773         m_globalData->recompileAllJSFunctions();
     783        discardAllCompiledCode();
    774784
    775785    collect(DoSweep);
     
    926936}
    927937
     938void Heap::addFunctionExecutable(FunctionExecutable* executable)
     939{
     940    m_functions.append(executable);
     941}
     942
     943void Heap::removeFunctionExecutable(FunctionExecutable* executable)
     944{
     945    m_functions.remove(executable);
     946}
     947
    928948} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.