Changeset 92250 in webkit


Ignore:
Timestamp:
Aug 2, 2011 5:41:11 PM (13 years ago)
Author:
oliver@apple.com
Message:

Simplify JSFunction creation for functions written in JS
https://bugs.webkit.org/show_bug.cgi?id=65422

Reviewed by Gavin Barraclough.

Remove hash lookups used to write name property and transition
function structure by caching the resultant structure and property
offset in JSGlobalObject. This doesn't impact performance, but
we can use this change to make other improvements later.

  • runtime/Executable.cpp:

(JSC::FunctionExecutable::FunctionExecutable):

  • runtime/Executable.h:

(JSC::ScriptExecutable::ScriptExecutable):
(JSC::FunctionExecutable::jsName):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::JSFunction):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::namedFunctionStructure):
(JSC::JSGlobalObject::functionNameOffset):

Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r92233 r92250  
     12011-07-30  Oliver Hunt  <oliver@apple.com>
     2
     3        Simplify JSFunction creation for functions written in JS
     4        https://bugs.webkit.org/show_bug.cgi?id=65422
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Remove hash lookups used to write name property and transition
     9        function structure by caching the resultant structure and property
     10        offset in JSGlobalObject.  This doesn't impact performance, but
     11        we can use this change to make other improvements later.
     12
     13        * runtime/Executable.cpp:
     14        (JSC::FunctionExecutable::FunctionExecutable):
     15        * runtime/Executable.h:
     16        (JSC::ScriptExecutable::ScriptExecutable):
     17        (JSC::FunctionExecutable::jsName):
     18        * runtime/JSFunction.cpp:
     19        (JSC::JSFunction::JSFunction):
     20        * runtime/JSGlobalObject.cpp:
     21        (JSC::JSGlobalObject::reset):
     22        * runtime/JSGlobalObject.h:
     23        (JSC::JSGlobalObject::namedFunctionStructure):
     24        (JSC::JSGlobalObject::functionNameOffset):
     25
    1262011-08-02  Filip Pizlo  <fpizlo@apple.com>
    227
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r91933 r92250  
    145145    m_firstLine = firstLine;
    146146    m_lastLine = lastLine;
     147    m_nameValue.set(globalData, this, jsString(&globalData, name.ustring()));
    147148}
    148149
     
    157158    m_firstLine = firstLine;
    158159    m_lastLine = lastLine;
     160    m_nameValue.set(exec->globalData(), this, jsString(&exec->globalData(), name.ustring()));
    159161}
    160162
     
    440442    ASSERT(structure()->typeInfo().overridesVisitChildren());
    441443    ScriptExecutable::visitChildren(visitor);
     444    if (m_nameValue)
     445        visitor.append(&m_nameValue);
    442446    if (m_codeBlockForCall)
    443447        m_codeBlockForCall->visitAggregate(visitor);
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r91883 r92250  
    227227#if ENABLE(CODEBLOCK_SAMPLING)
    228228            if (SamplingTool* sampler = globalData.interpreter->sampler())
    229                 sampler->notifyOfScope(*globalData, this);
     229                sampler->notifyOfScope(globalData, this);
    230230#else
    231231            UNUSED_PARAM(globalData);
     
    479479
    480480        const Identifier& name() { return m_name; }
     481        JSString* nameValue() const { return m_nameValue.get(); }
    481482        size_t parameterCount() const { return m_parameters->size(); }
    482483        unsigned capturedVariableCount() const { return m_numCapturedVariables; }
     
    510511        OwnPtr<FunctionCodeBlock> m_codeBlockForConstruct;
    511512        Identifier m_name;
     513        WriteBarrier<JSString> m_nameValue;
    512514        SharedSymbolTable* m_symbolTable;
    513515    };
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r90404 r92250  
    9191{
    9292    ASSERT(inherits(&s_info));
    93     const Identifier& name = static_cast<FunctionExecutable*>(m_executable.get())->name();
    94     putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
     93    setStructure(exec->globalData(), scopeChainNode->globalObject->namedFunctionStructure());
     94    putDirectOffset(exec->globalData(), scopeChainNode->globalObject->functionNameOffset(), executable->nameValue());
    9595}
    9696
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r92058 r92250  
    188188    m_functionPrototype.set(exec->globalData(), this, FunctionPrototype::create(exec, this, FunctionPrototype::createStructure(exec->globalData(), jsNull()))); // The real prototype will be set once ObjectPrototype is created.
    189189    m_functionStructure.set(exec->globalData(), this, JSFunction::createStructure(exec->globalData(), m_functionPrototype.get()));
     190    m_namedFunctionStructure.set(exec->globalData(), this, Structure::addPropertyTransition(exec->globalData(), m_functionStructure.get(), exec->globalData().propertyNames->name, DontDelete | ReadOnly | DontEnum, 0, m_functionNameOffset));
    190191    m_internalFunctionStructure.set(exec->globalData(), this, InternalFunction::createStructure(exec->globalData(), m_functionPrototype.get()));
    191192    JSFunction* callFunction = 0;
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r92058 r92250  
    117117        WriteBarrier<Structure> m_errorStructure;
    118118        WriteBarrier<Structure> m_functionStructure;
     119        WriteBarrier<Structure> m_namedFunctionStructure;
     120        size_t m_functionNameOffset;
    119121        WriteBarrier<Structure> m_numberObjectStructure;
    120122        WriteBarrier<Structure> m_regExpMatchesArrayStructure;
     
    230232        Structure* errorStructure() const { return m_errorStructure.get(); }
    231233        Structure* functionStructure() const { return m_functionStructure.get(); }
     234        Structure* namedFunctionStructure() const { return m_namedFunctionStructure.get(); }
     235        size_t functionNameOffset() const { return m_functionNameOffset; }
    232236        Structure* numberObjectStructure() const { return m_numberObjectStructure.get(); }
    233237        Structure* internalFunctionStructure() const { return m_internalFunctionStructure.get(); }
Note: See TracChangeset for help on using the changeset viewer.