Ignore:
Timestamp:
May 12, 2010, 9:01:56 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=39039
Provide support for separate bytecode/JIT code translations for call/construct usage
This will allow us to produce code generated specifically for use as a constructor, not for general function use.

Reviewed by Oliver Hunt.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::unlinkCallers):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::getBytecodeIndex):
(JSC::CodeBlock::getJITCode):
(JSC::CodeBlock::executablePool):
(JSC::GlobalCodeBlock::GlobalCodeBlock):
(JSC::FunctionCodeBlock::FunctionCodeBlock):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):
(JSC::Interpreter::execute):
(JSC::Interpreter::privateExecute):

  • interpreter/Interpreter.h:
  • jit/JIT.cpp:

(JSC::JIT::unlinkCallOrConstruct):
(JSC::JIT::linkConstruct):

  • jit/JIT.h:
  • jit/JITCall.cpp:

(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):

  • jit/JITOpcodes.cpp:

(JSC::JIT::privateCompileCTIMachineTrampolines):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::privateCompileCTIMachineTrampolines):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emitSlow_op_get_by_val):

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::emitSlow_op_get_by_val):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • jit/JITStubs.h:

(JSC::JITThunks::ctiVirtualConstructLink):
(JSC::JITThunks::ctiVirtualConstruct):
(JSC::):

  • jit/SpecializedThunkJIT.h:

(JSC::SpecializedThunkJIT::finalize):

  • runtime/Arguments.h:

(JSC::JSActivation::copyRegisters):

  • runtime/ArrayPrototype.cpp:

(JSC::isNumericCompareFunction):

  • runtime/Executable.cpp:

(JSC::FunctionExecutable::~FunctionExecutable):
(JSC::FunctionExecutable::compileForCall):
(JSC::FunctionExecutable::compileForConstruct):
(JSC::EvalExecutable::generateJITCode):
(JSC::ProgramExecutable::generateJITCode):
(JSC::FunctionExecutable::generateJITCodeForCall):
(JSC::FunctionExecutable::generateJITCodeForConstruct):
(JSC::FunctionExecutable::markAggregate):
(JSC::FunctionExecutable::reparseExceptionInfo):
(JSC::EvalExecutable::reparseExceptionInfo):
(JSC::FunctionExecutable::recompile):

  • runtime/Executable.h:

(JSC::ExecutableBase::ExecutableBase):
(JSC::ExecutableBase::isHostFunction):
(JSC::ExecutableBase::generatedJITCodeForCall):
(JSC::ExecutableBase::generatedJITCodeForConstruct):
(JSC::NativeExecutable::NativeExecutable):
(JSC::EvalExecutable::jitCode):
(JSC::ProgramExecutable::jitCode):
(JSC::FunctionExecutable::bytecodeForCall):
(JSC::FunctionExecutable::isGeneratedForCall):
(JSC::FunctionExecutable::generatedBytecodeForCall):
(JSC::FunctionExecutable::bytecodeForConstruct):
(JSC::FunctionExecutable::isGeneratedForConstruct):
(JSC::FunctionExecutable::generatedBytecodeForConstruct):
(JSC::FunctionExecutable::symbolTable):
(JSC::FunctionExecutable::FunctionExecutable):
(JSC::FunctionExecutable::jitCodeForCall):
(JSC::FunctionExecutable::jitCodeForConstruct):

  • runtime/JSActivation.h:

(JSC::JSActivation::JSActivationData::JSActivationData):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::~JSFunction):
(JSC::JSFunction::call):
(JSC::JSFunction::construct):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::numericCompareFunction):

File:
1 edited

Legend:

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

    r58469 r59339  
    3737    class Debugger;
    3838    class EvalCodeBlock;
     39    class FunctionCodeBlock;
    3940    class ProgramCodeBlock;
    4041    class ScopeChainNode;
     
    5152    public:
    5253        ExecutableBase(int numParameters)
    53             : m_numParameters(numParameters)
     54            : m_numParametersForCall(numParameters)
     55            , m_numParametersForConstruct(numParameters)
    5456        {
    5557        }
     
    5759        virtual ~ExecutableBase() {}
    5860
    59         bool isHostFunction() const { return m_numParameters == NUM_PARAMETERS_IS_HOST; }
     61        bool isHostFunction() const
     62        {
     63            ASSERT((m_numParametersForCall == NUM_PARAMETERS_IS_HOST) == (m_numParametersForConstruct == NUM_PARAMETERS_IS_HOST));
     64            return m_numParametersForCall == NUM_PARAMETERS_IS_HOST;
     65        }
    6066
    6167    protected:
    62         int m_numParameters;
     68        int m_numParametersForCall;
     69        int m_numParametersForConstruct;
    6370
    6471#if ENABLE(JIT)
    6572    public:
    66         JITCode& generatedJITCode()
    67         {
    68             ASSERT(m_jitCode);
    69             return m_jitCode;
    70         }
    71 
    72         ExecutablePool* getExecutablePool()
    73         {
    74             return m_jitCode.getExecutablePool();
     73        JITCode& generatedJITCodeForCall()
     74        {
     75            ASSERT(m_jitCodeForCall);
     76            return m_jitCodeForCall;
     77        }
     78
     79        JITCode& generatedJITCodeForConstruct()
     80        {
     81            ASSERT(m_jitCodeForConstruct);
     82            return m_jitCodeForConstruct;
    7583        }
    7684
    7785    protected:
    78         JITCode m_jitCode;
     86        JITCode m_jitCodeForCall;
     87        JITCode m_jitCodeForConstruct;
    7988#endif
    8089    };
     
    8695            : ExecutableBase(NUM_PARAMETERS_IS_HOST)
    8796        {
    88             m_jitCode = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCode;
     97            m_jitCodeForCall = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCodeForCall;
     98            m_jitCodeForConstruct = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCodeForCall; // FIXME: this thunk should have a construct form
    8999        }
    90100        NativeExecutable(JITCode thunk)
    91101            : ExecutableBase(NUM_PARAMETERS_IS_HOST)
    92102        {
    93             m_jitCode = thunk;
     103            m_jitCodeForCall = thunk;
     104            m_jitCodeForConstruct = thunk;
    94105        }
    95106
     
    193204        JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
    194205        {
    195             if (!m_jitCode)
     206            if (!m_jitCodeForCall)
    196207                generateJITCode(exec, scopeChainNode);
    197             return m_jitCode;
     208            return m_jitCodeForCall;
    198209        }
    199210
     
    239250        JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
    240251        {
    241             if (!m_jitCode)
     252            if (!m_jitCodeForCall)
    242253                generateJITCode(exec, scopeChainNode);
    243             return m_jitCode;
     254            return m_jitCodeForCall;
    244255        }
    245256
     
    269280        }
    270281
    271         CodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode)
     282        FunctionCodeBlock& bytecodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
    272283        {
    273284            ASSERT(scopeChainNode);
    274             if (!m_codeBlock)
    275                 compile(exec, scopeChainNode);
    276             return *m_codeBlock;
    277         }
    278 
    279         bool isGenerated() const
    280         {
    281             return m_codeBlock;
    282         }
    283 
    284         CodeBlock& generatedBytecode()
    285         {
    286             ASSERT(m_codeBlock);
    287             return *m_codeBlock;
     285            if (!m_codeBlockForCall)
     286                compileForCall(exec, scopeChainNode);
     287            return *m_codeBlockForCall;
     288        }
     289
     290        bool isGeneratedForCall() const
     291        {
     292            return m_codeBlockForCall;
     293        }
     294
     295        FunctionCodeBlock& generatedBytecodeForCall()
     296        {
     297            ASSERT(m_codeBlockForCall);
     298            return *m_codeBlockForCall;
     299        }
     300
     301        FunctionCodeBlock& bytecodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
     302        {
     303            ASSERT(scopeChainNode);
     304            if (!m_codeBlockForConstruct)
     305                compileForConstruct(exec, scopeChainNode);
     306            return *m_codeBlockForConstruct;
     307        }
     308
     309        bool isGeneratedForConstruct() const
     310        {
     311            return m_codeBlockForConstruct;
     312        }
     313
     314        FunctionCodeBlock& generatedBytecodeForConstruct()
     315        {
     316            ASSERT(m_codeBlockForConstruct);
     317            return *m_codeBlockForConstruct;
    288318        }
    289319
     
    292322        size_t variableCount() const { return m_numVariables; }
    293323        UString paramString() const;
     324        SharedSymbolTable* symbolTable() const { return m_symbolTable; }
    294325
    295326        void recompile(ExecState*);
     
    303334            , m_forceUsesArguments(forceUsesArguments)
    304335            , m_parameters(parameters)
    305             , m_codeBlock(0)
     336            , m_codeBlockForCall(0)
     337            , m_codeBlockForConstruct(0)
    306338            , m_name(name)
    307339            , m_numVariables(0)
     340            , m_symbolTable(0)
    308341        {
    309342            m_firstLine = firstLine;
     
    315348            , m_forceUsesArguments(forceUsesArguments)
    316349            , m_parameters(parameters)
    317             , m_codeBlock(0)
     350            , m_codeBlockForCall(0)
     351            , m_codeBlockForConstruct(0)
    318352            , m_name(name)
    319353            , m_numVariables(0)
     354            , m_symbolTable(0)
    320355        {
    321356            m_firstLine = firstLine;
     
    323358        }
    324359
    325         void compile(ExecState*, ScopeChainNode*);
     360        void compileForCall(ExecState*, ScopeChainNode*);
     361        void compileForConstruct(ExecState*, ScopeChainNode*);
    326362
    327363        bool m_forceUsesArguments;
    328364        RefPtr<FunctionParameters> m_parameters;
    329         CodeBlock* m_codeBlock;
     365        FunctionCodeBlock* m_codeBlockForCall;
     366        FunctionCodeBlock* m_codeBlockForConstruct;
    330367        Identifier m_name;
    331368        size_t m_numVariables;
     369        SharedSymbolTable* m_symbolTable;
    332370
    333371#if ENABLE(JIT)
    334372    public:
    335         JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
    336         {
    337             if (!m_jitCode)
    338                 generateJITCode(exec, scopeChainNode);
    339             return m_jitCode;
    340         }
    341 
    342     private:
    343         void generateJITCode(ExecState*, ScopeChainNode*);
     373        JITCode& jitCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
     374        {
     375            if (!m_jitCodeForCall)
     376                generateJITCodeForCall(exec, scopeChainNode);
     377            return m_jitCodeForCall;
     378        }
     379
     380        JITCode& jitCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
     381        {
     382            if (!m_jitCodeForConstruct)
     383                generateJITCodeForConstruct(exec, scopeChainNode);
     384            return m_jitCodeForConstruct;
     385        }
     386
     387    private:
     388        void generateJITCodeForCall(ExecState*, ScopeChainNode*);
     389        void generateJITCodeForConstruct(ExecState*, ScopeChainNode*);
    344390#endif
    345391    };
Note: See TracChangeset for help on using the changeset viewer.