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/runtime/JSGlobalData.cpp

    r111739 r112624  
    6969using namespace WTF;
    7070
    71 namespace {
    72 
    73 using namespace JSC;
    74 
    75 class Recompiler : public MarkedBlock::VoidFunctor {
    76 public:
    77     void operator()(JSCell*);
    78 };
    79 
    80 inline void Recompiler::operator()(JSCell* cell)
    81 {
    82     if (!cell->inherits(&JSFunction::s_info))
    83         return;
    84     JSFunction* function = jsCast<JSFunction*>(cell);
    85     if (!function->executable() || function->executable()->isHostFunction())
    86         return;
    87     function->jsExecutable()->discardCode();
    88 }
    89 
    90 } // namespace
    91 
    9271namespace JSC {
    9372
     
    444423}
    445424
    446 void JSGlobalData::recompileAllJSFunctions()
    447 {
    448     // If JavaScript is running, it's not safe to recompile, since we'll end
    449     // up throwing away code that is live on the stack.
    450     ASSERT(!dynamicGlobalObject);
    451    
    452     heap.objectSpace().forEachCell<Recompiler>();
    453 }
    454 
    455425struct StackPreservingRecompiler : public MarkedBlock::VoidFunctor {
    456426    HashSet<FunctionExecutable*> currentlyExecutingFunctions;
Note: See TracChangeset for help on using the changeset viewer.