Changeset 47597 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Aug 20, 2009, 2:49:07 PM (16 years ago)
Author:
[email protected]
Message:

Remove FunctionCodeBlock.
https://bugs.webkit.org/show_bug.cgi?id=28502

Reviewed by Oliver Hunt.

These only exist to allow JIT code to dereference properties off the
CodeBlock for any callee, regardless of whether it is a host function.

Instead just use the FunctionExecutable. Copy the m_parameters field
from the CodeBlock into the Executable, and use this to distinguish
between host functions, functions that have been bytecompiled, and
functions that have not.

m_parameters is moved to ExecutableBase rather than FunctionExecutable
so that (as a separate change) we can move make a separate class of
executable for host code, which is not devived from FunctionExecutable
(host code does not feature any of the properties that normal executable
do and will provide, such as source, attributes, and a parsed name).

1% win on v8 tests, 0.5% on sunspider.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::derefStructures):
(JSC::CodeBlock::refStructures):
(JSC::CodeBlock::reparseForExceptionInfoIfNecessary):
(JSC::CodeBlock::handlerForBytecodeOffset):
(JSC::CodeBlock::lineNumberForBytecodeOffset):
(JSC::CodeBlock::expressionRangeForBytecodeOffset):
(JSC::CodeBlock::getByIdExceptionInfoForBytecodeOffset):
(JSC::CodeBlock::functionRegisterForBytecodeOffset):
(JSC::CodeBlock::hasGlobalResolveInstructionAtBytecodeOffset):
(JSC::CodeBlock::hasGlobalResolveInfoAtBytecodeOffset):

  • bytecode/CodeBlock.h:

(JSC::):
(JSC::CodeBlock::source):
(JSC::CodeBlock::sourceOffset):
(JSC::CodeBlock::evalCodeCache):
(JSC::CodeBlock::createRareDataIfNecessary):

remove NativeCodeBlocks and the NativeCode code type.


  • jit/JIT.cpp:

(JSC::JIT::linkCall):

Revert to previous behaviour (as currently still commented!) that Hhost functions have a null codeblock.

  • jit/JITCall.cpp:

(JSC::JIT::compileOpCallInitializeCallFrame):
(JSC::JIT::compileOpCallSetupArgs):
(JSC::JIT::compileOpCallVarargsSetupArgs):
(JSC::JIT::compileOpConstructSetupArgs):
(JSC::JIT::compileOpCallVarargs):
(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):

Bring the 32_64 & non-32_64 JITs into line with each other, callee in regT0.

  • jit/JITOpcodes.cpp:

(JSC::JIT::privateCompileCTIMachineTrampolines):

Rewrite call trampolines to not use the CodeBlock.

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

Make call_JSFunction & call_arityCheck return the callee, don't expect to be passed the CodeBlock.

  • runtime/Executable.cpp:

(JSC::FunctionExecutable::generateBytecode):
(JSC::FunctionExecutable::recompile):
(JSC::FunctionExecutable::FunctionExecutable):

  • runtime/Executable.h:

(JSC::ExecutableBase::):
(JSC::ExecutableBase::ExecutableBase):
(JSC::FunctionExecutable::isHostFunction):

Add m_numParameters.

  • runtime/JSFunction.cpp:

(JSC::JSFunction::~JSFunction):

Only call generatedBytecode() on JSFunctions non-host FunctionExecutables.

Location:
trunk/JavaScriptCore/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Executable.cpp

    r47519 r47597  
    8686    OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(body(), globalObject->debugger(), scopeChain, &m_codeBlock->symbolTable(), m_codeBlock));
    8787    generator->generate();
     88    m_numParameters = m_codeBlock->m_numParameters;
     89    ASSERT(m_numParameters);
    8890
    8991    body()->destroyData();
     
    126128
    127129#endif
    128 
    129 bool FunctionExecutable::isHostFunction() const
    130 {
    131     return m_codeBlock && m_codeBlock->codeType() == NativeCode;
    132 }
    133130
    134131void FunctionExecutable::markAggregate(MarkStack& markStack)
     
    198195    delete m_codeBlock;
    199196    m_codeBlock = 0;
     197    m_numParameters = NUM_PARAMETERS_NOT_COMPILED;
    200198#if ENABLE(JIT)
    201199    m_jitCode = JITCode();
     
    205203#if ENABLE(JIT)
    206204FunctionExecutable::FunctionExecutable(ExecState* exec)
    207     : m_codeBlock(new NativeCodeBlock(this))
     205    : m_codeBlock(0)
    208206    , m_name(Identifier(exec, "<native thunk>"))
    209207{
    210208    m_jitCode = JITCode(JITCode::HostFunction(exec->globalData().jitStubs.ctiNativeCallThunk()));
     209    m_numParameters = NUM_PARAMETERS_IS_HOST;
    211210}
    212211#endif
  • trunk/JavaScriptCore/runtime/Executable.h

    r47582 r47597  
    4141        friend class JIT;
    4242    public:
     43        enum Mode {
     44            NoJITCode,
     45            HasJITCode,
     46            IsHost
     47        };
     48        static const int NUM_PARAMETERS_IS_HOST = 0;
     49        static const int NUM_PARAMETERS_NOT_COMPILED = -1;
     50   
    4351        virtual ~ExecutableBase() {}
    4452
    4553        ExecutableBase(const SourceCode& source)
    4654            : m_source(source)
     55            , m_numParameters(NUM_PARAMETERS_NOT_COMPILED)
    4756        {
    4857        }
     
    6372        RefPtr<ScopeNode> m_node;
    6473        SourceCode m_source;
     74        int m_numParameters;
    6575
    6676    private:
     
    220230        UString paramString() const { return body()->paramString(); }
    221231
    222         bool isHostFunction() const;
     232        bool isHostFunction() const { return m_numParameters == NUM_PARAMETERS_IS_HOST; }
    223233        bool isGenerated() const
    224234        {
  • trunk/JavaScriptCore/runtime/JSFunction.cpp

    r47412 r47597  
    9090    // are based on a check for the this pointer value for this JSFunction - which will no longer be valid once
    9191    // this memory is freed and may be reused (potentially for another, different JSFunction).
     92    if (!isHostFunction()) {
    9293#if ENABLE(JIT_OPTIMIZE_CALL)
    93     if (m_executable && m_executable->isGenerated())
    94         m_executable->generatedBytecode().unlinkCallers();
     94        if (m_executable && m_executable->isGenerated())
     95            m_executable->generatedBytecode().unlinkCallers();
    9596#endif
    96     if (!isHostFunction())
    9797        scopeChain().~ScopeChain(); // FIXME: Don't we need to do this in the interpreter too?
     98    }
    9899}
    99100
Note: See TracChangeset for help on using the changeset viewer.