Ignore:
Timestamp:
Aug 30, 2012, 3:50:00 PM (13 years ago)
Author:
[email protected]
Message:

Use one object instead of two for closures, eliminating ScopeChainNode
https://bugs.webkit.org/show_bug.cgi?id=95501

Reviewed by Filip Pizlo.

../JavaScriptCore:

This patch removes ScopeChainNode, and moves all the data and related
functions that used to be in ScopeChainNode into JSScope.

Most of this patch is mechanical changes to use a JSScope* where we used
to use a ScopeChainNode*. I've only specifically commented about items
that were non-mechanical.

  • runtime/Completion.cpp:

(JSC::evaluate):

  • runtime/Completion.h: Don't require an explicit scope chain argument

when evaluating code. Clients never wanted anything other than the
global scope, and other arbitrary scopes probably wouldn't work
correctly, anyway.

  • runtime/JSScope.cpp:
  • runtime/JSScope.h:

(JSC::JSScope::JSScope): JSScope now requires the data we used to pass to
ScopeChainNode, so it can link itself into the scope chain correctly.

  • runtime/JSWithScope.h:

(JSC::JSWithScope::create):
(JSC::JSWithScope::JSWithScope): JSWithScope gets an extra constructor
for specifically supplying your own scope chain. The DOM needs this
interface for setting up the scope chain for certain event handlers.
Other clients always just push the JSWithScope to the head of the current
scope chain.

../WebCore:

Mechanical changes to update for JSC interface changes.

../WebKit/mac:

Mechanical change to update for JSC interface change.

../WebKit/qt:

Mechanical change to update for JSC interface change.

  • Api/qwebelement.cpp:

(QWebElement::evaluateJavaScript):

../WebKit2:

Mechanical changes to update for JSC interface change.

File:
1 edited

Legend:

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

    r127191 r127202  
    159159}
    160160
    161 JSObject* EvalExecutable::compileOptimized(ExecState* exec, ScopeChainNode* scopeChainNode, unsigned bytecodeIndex)
     161JSObject* EvalExecutable::compileOptimized(ExecState* exec, JSScope* scope, unsigned bytecodeIndex)
    162162{
    163163    ASSERT(exec->globalData().dynamicGlobalObject);
     
    165165    JSObject* error = 0;
    166166    if (m_evalCodeBlock->getJITType() != JITCode::topTierJIT())
    167         error = compileInternal(exec, scopeChainNode, JITCode::nextTierJIT(m_evalCodeBlock->getJITType()), bytecodeIndex);
     167        error = compileInternal(exec, scope, JITCode::nextTierJIT(m_evalCodeBlock->getJITType()), bytecodeIndex);
    168168    ASSERT(!!m_evalCodeBlock);
    169169    return error;
     
    192192}
    193193
    194 JSObject* EvalExecutable::compileInternal(ExecState* exec, ScopeChainNode* scopeChainNode, JITCode::JITType jitType, unsigned bytecodeIndex)
     194JSObject* EvalExecutable::compileInternal(ExecState* exec, JSScope* scope, JITCode::JITType jitType, unsigned bytecodeIndex)
    195195{
    196196    SamplingRegion samplingRegion(samplingDescription(jitType));
     
    218218        recordParse(evalNode->features(), evalNode->hasCapturedVariables(), evalNode->lineNo(), evalNode->lastLine());
    219219       
    220         JSGlobalObject* globalObject = scopeChainNode->globalObject.get();
     220        JSGlobalObject* globalObject = scope->globalObject();
    221221       
    222222        OwnPtr<CodeBlock> previousCodeBlock = m_evalCodeBlock.release();
    223223        ASSERT((jitType == JITCode::bottomTierJIT()) == !previousCodeBlock);
    224         m_evalCodeBlock = adoptPtr(new EvalCodeBlock(this, globalObject, source().provider(), scopeChainNode->localDepth(), previousCodeBlock.release()));
    225         OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(evalNode.get(), scopeChainNode, m_evalCodeBlock->symbolTable(), m_evalCodeBlock.get(), !!m_evalCodeBlock->alternative() ? OptimizingCompilation : FirstCompilation)));
     224        m_evalCodeBlock = adoptPtr(new EvalCodeBlock(this, globalObject, source().provider(), scope->localDepth(), previousCodeBlock.release()));
     225        OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(evalNode.get(), scope, m_evalCodeBlock->symbolTable(), m_evalCodeBlock.get(), !!m_evalCodeBlock->alternative() ? OptimizingCompilation : FirstCompilation)));
    226226        if ((exception = generator->generate())) {
    227227            m_evalCodeBlock = static_pointer_cast<EvalCodeBlock>(m_evalCodeBlock->releaseAlternative());
     
    301301}
    302302
    303 JSObject* ProgramExecutable::compileOptimized(ExecState* exec, ScopeChainNode* scopeChainNode, unsigned bytecodeIndex)
     303JSObject* ProgramExecutable::compileOptimized(ExecState* exec, JSScope* scope, unsigned bytecodeIndex)
    304304{
    305305    ASSERT(exec->globalData().dynamicGlobalObject);
     
    307307    JSObject* error = 0;
    308308    if (m_programCodeBlock->getJITType() != JITCode::topTierJIT())
    309         error = compileInternal(exec, scopeChainNode, JITCode::nextTierJIT(m_programCodeBlock->getJITType()), bytecodeIndex);
     309        error = compileInternal(exec, scope, JITCode::nextTierJIT(m_programCodeBlock->getJITType()), bytecodeIndex);
    310310    ASSERT(!!m_programCodeBlock);
    311311    return error;
     
    319319#endif
    320320
    321 JSObject* ProgramExecutable::compileInternal(ExecState* exec, ScopeChainNode* scopeChainNode, JITCode::JITType jitType, unsigned bytecodeIndex)
     321JSObject* ProgramExecutable::compileInternal(ExecState* exec, JSScope* scope, JITCode::JITType jitType, unsigned bytecodeIndex)
    322322{
    323323    SamplingRegion samplingRegion(samplingDescription(jitType));
     
    343343        recordParse(programNode->features(), programNode->hasCapturedVariables(), programNode->lineNo(), programNode->lastLine());
    344344
    345         JSGlobalObject* globalObject = scopeChainNode->globalObject.get();
     345        JSGlobalObject* globalObject = scope->globalObject();
    346346   
    347347        OwnPtr<CodeBlock> previousCodeBlock = m_programCodeBlock.release();
    348348        ASSERT((jitType == JITCode::bottomTierJIT()) == !previousCodeBlock);
    349349        m_programCodeBlock = adoptPtr(new ProgramCodeBlock(this, GlobalCode, globalObject, source().provider(), previousCodeBlock.release()));
    350         OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(programNode.get(), scopeChainNode, globalObject->symbolTable(), m_programCodeBlock.get(), !!m_programCodeBlock->alternative() ? OptimizingCompilation : FirstCompilation)));
     350        OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(programNode.get(), scope, globalObject->symbolTable(), m_programCodeBlock.get(), !!m_programCodeBlock->alternative() ? OptimizingCompilation : FirstCompilation)));
    351351        if ((exception = generator->generate())) {
    352352            m_programCodeBlock = static_pointer_cast<ProgramCodeBlock>(m_programCodeBlock->releaseAlternative());
     
    432432}
    433433
    434 JSObject* FunctionExecutable::compileOptimizedForCall(ExecState* exec, ScopeChainNode* scopeChainNode, unsigned bytecodeIndex)
     434JSObject* FunctionExecutable::compileOptimizedForCall(ExecState* exec, JSScope* scope, unsigned bytecodeIndex)
    435435{
    436436    ASSERT(exec->globalData().dynamicGlobalObject);
     
    438438    JSObject* error = 0;
    439439    if (m_codeBlockForCall->getJITType() != JITCode::topTierJIT())
    440         error = compileForCallInternal(exec, scopeChainNode, JITCode::nextTierJIT(m_codeBlockForCall->getJITType()), bytecodeIndex);
     440        error = compileForCallInternal(exec, scope, JITCode::nextTierJIT(m_codeBlockForCall->getJITType()), bytecodeIndex);
    441441    ASSERT(!!m_codeBlockForCall);
    442442    return error;
    443443}
    444444
    445 JSObject* FunctionExecutable::compileOptimizedForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode, unsigned bytecodeIndex)
     445JSObject* FunctionExecutable::compileOptimizedForConstruct(ExecState* exec, JSScope* scope, unsigned bytecodeIndex)
    446446{
    447447    ASSERT(exec->globalData().dynamicGlobalObject);
     
    449449    JSObject* error = 0;
    450450    if (m_codeBlockForConstruct->getJITType() != JITCode::topTierJIT())
    451         error = compileForConstructInternal(exec, scopeChainNode, JITCode::nextTierJIT(m_codeBlockForConstruct->getJITType()), bytecodeIndex);
     451        error = compileForConstructInternal(exec, scope, JITCode::nextTierJIT(m_codeBlockForConstruct->getJITType()), bytecodeIndex);
    452452    ASSERT(!!m_codeBlockForConstruct);
    453453    return error;
     
    471471}
    472472
    473 PassOwnPtr<FunctionCodeBlock> FunctionExecutable::produceCodeBlockFor(ScopeChainNode* scopeChainNode, CompilationKind compilationKind, CodeSpecializationKind specializationKind, JSObject*& exception)
     473PassOwnPtr<FunctionCodeBlock> FunctionExecutable::produceCodeBlockFor(JSScope* scope, CompilationKind compilationKind, CodeSpecializationKind specializationKind, JSObject*& exception)
    474474{
    475475    if (!!codeBlockFor(specializationKind))
     
    477477   
    478478    exception = 0;
    479     JSGlobalData* globalData = scopeChainNode->globalData;
    480     JSGlobalObject* globalObject = scopeChainNode->globalObject.get();
     479    JSGlobalData* globalData = scope->globalData();
     480    JSGlobalObject* globalObject = scope->globalObject();
    481481    RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(globalData, globalObject, m_source, m_parameters.get(), isStrictMode() ? JSParseStrict : JSParseNormal, FunctionBodyNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, 0, 0, &exception);
    482482
     
    493493    ASSERT((compilationKind == FirstCompilation) == !codeBlockFor(specializationKind));
    494494    result = adoptPtr(new FunctionCodeBlock(this, FunctionCode, globalObject, source().provider(), source().startOffset(), specializationKind == CodeForConstruct));
    495     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scopeChainNode, result->symbolTable(), result.get(), compilationKind)));
     495    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scope, result->symbolTable(), result.get(), compilationKind)));
    496496    exception = generator->generate();
    497497    body->destroyData();
     
    503503}
    504504
    505 JSObject* FunctionExecutable::compileForCallInternal(ExecState* exec, ScopeChainNode* scopeChainNode, JITCode::JITType jitType, unsigned bytecodeIndex)
     505JSObject* FunctionExecutable::compileForCallInternal(ExecState* exec, JSScope* scope, JITCode::JITType jitType, unsigned bytecodeIndex)
    506506{
    507507    SamplingRegion samplingRegion(samplingDescription(jitType));
     
    515515    ASSERT((jitType == JITCode::bottomTierJIT()) == !m_codeBlockForCall);
    516516    JSObject* exception;
    517     OwnPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scopeChainNode, !!m_codeBlockForCall ? OptimizingCompilation : FirstCompilation, CodeForCall, exception);
     517    OwnPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scope, !!m_codeBlockForCall ? OptimizingCompilation : FirstCompilation, CodeForCall, exception);
    518518    if (!newCodeBlock)
    519519        return exception;
     
    546546}
    547547
    548 JSObject* FunctionExecutable::compileForConstructInternal(ExecState* exec, ScopeChainNode* scopeChainNode, JITCode::JITType jitType, unsigned bytecodeIndex)
     548JSObject* FunctionExecutable::compileForConstructInternal(ExecState* exec, JSScope* scope, JITCode::JITType jitType, unsigned bytecodeIndex)
    549549{
    550550    SamplingRegion samplingRegion(samplingDescription(jitType));
     
    558558    ASSERT((jitType == JITCode::bottomTierJIT()) == !m_codeBlockForConstruct);
    559559    JSObject* exception;
    560     OwnPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scopeChainNode, !!m_codeBlockForConstruct ? OptimizingCompilation : FirstCompilation, CodeForConstruct, exception);
     560    OwnPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scope, !!m_codeBlockForConstruct ? OptimizingCompilation : FirstCompilation, CodeForConstruct, exception);
    561561    if (!newCodeBlock)
    562562        return exception;
Note: See TracChangeset for help on using the changeset viewer.