Ignore:
Timestamp:
Dec 6, 2008, 2:01:05 PM (16 years ago)
Author:
[email protected]
Message:

2008-12-05 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

Fix for https://bugs.webkit.org/show_bug.cgi?id=22715
Encapsulate more CodeBlock members in preparation
of moving some of them to a rare data structure.

  • bytecode/CodeBlock.cpp: (JSC::locationForOffset): (JSC::printConditionalJump): (JSC::printGetByIdOp): (JSC::printPutByIdOp): (JSC::CodeBlock::printStructure): (JSC::CodeBlock::printStructures): (JSC::CodeBlock::dump): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::unlinkCallers): (JSC::CodeBlock::derefStructures): (JSC::CodeBlock::refStructures): (JSC::CodeBlock::mark): (JSC::CodeBlock::getHandlerForVPC): (JSC::CodeBlock::nativeExceptionCodeForHandlerVPC): (JSC::CodeBlock::lineNumberForVPC): (JSC::CodeBlock::expressionRangeForVPC): (JSC::CodeBlock::shrinkToFit):
  • bytecode/CodeBlock.h: (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::addCaller): (JSC::CodeBlock::removeCaller): (JSC::CodeBlock::isKnownNotImmediate): (JSC::CodeBlock::isConstantRegisterIndex): (JSC::CodeBlock::getConstant): (JSC::CodeBlock::isTemporaryRegisterIndex): (JSC::CodeBlock::getStubInfo): (JSC::CodeBlock::getCallLinkInfo): (JSC::CodeBlock::instructions): (JSC::CodeBlock::setJITCode): (JSC::CodeBlock::jitCode): (JSC::CodeBlock::ownerNode): (JSC::CodeBlock::setGlobalData): (JSC::CodeBlock::setThisRegister): (JSC::CodeBlock::thisRegister): (JSC::CodeBlock::setNeedsFullScopeChain): (JSC::CodeBlock::needsFullScopeChain): (JSC::CodeBlock::setUsesEval): (JSC::CodeBlock::usesEval): (JSC::CodeBlock::setUsesArguments): (JSC::CodeBlock::usesArguments): (JSC::CodeBlock::codeType): (JSC::CodeBlock::source): (JSC::CodeBlock::sourceOffset): (JSC::CodeBlock::addGlobalResolveInstruction): (JSC::CodeBlock::numberOfPropertyAccessInstructions): (JSC::CodeBlock::addPropertyAccessInstruction): (JSC::CodeBlock::propertyAccessInstruction): (JSC::CodeBlock::numberOfCallLinkInfos): (JSC::CodeBlock::addCallLinkInfo): (JSC::CodeBlock::callLinkInfo): (JSC::CodeBlock::numberOfJumpTargets): (JSC::CodeBlock::addJumpTarget): (JSC::CodeBlock::jumpTarget): (JSC::CodeBlock::lastJumpTarget): (JSC::CodeBlock::numberOfExceptionHandlers): (JSC::CodeBlock::addExceptionHandler): (JSC::CodeBlock::exceptionHandler): (JSC::CodeBlock::addExpressionInfo): (JSC::CodeBlock::numberOfLineInfos): (JSC::CodeBlock::addLineInfo): (JSC::CodeBlock::lastLineInfo): (JSC::CodeBlock::jitReturnAddressVPCMap): (JSC::CodeBlock::numberOfIdentifiers): (JSC::CodeBlock::addIdentifier): (JSC::CodeBlock::identifier): (JSC::CodeBlock::numberOfConstantRegisters): (JSC::CodeBlock::addConstantRegister): (JSC::CodeBlock::constantRegister): (JSC::CodeBlock::addFunction): (JSC::CodeBlock::function): (JSC::CodeBlock::addFunctionExpression): (JSC::CodeBlock::functionExpression): (JSC::CodeBlock::addUnexpectedConstant): (JSC::CodeBlock::unexpectedConstant): (JSC::CodeBlock::addRegExp): (JSC::CodeBlock::regexp): (JSC::CodeBlock::symbolTable): (JSC::CodeBlock::evalCodeCache): New inline setters/getters.

(JSC::ProgramCodeBlock::ProgramCodeBlock):
(JSC::ProgramCodeBlock::~ProgramCodeBlock):
(JSC::ProgramCodeBlock::clearGlobalObject):

  • bytecode/SamplingTool.cpp: (JSC::ScopeSampleRecord::sample): (JSC::SamplingTool::dump):
  • bytecompiler/BytecodeGenerator.cpp:
  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/Label.h:
  • interpreter/CallFrame.cpp:
  • interpreter/Interpreter.cpp:
  • jit/JIT.cpp:
  • jit/JITCall.cpp:
  • jit/JITInlineMethods.h:
  • jit/JITPropertyAccess.cpp:
  • parser/Nodes.cpp:
  • runtime/Arguments.h:
  • runtime/ExceptionHelpers.cpp:
  • runtime/JSActivation.cpp:
  • runtime/JSActivation.h:
  • runtime/JSGlobalObject.cpp: Change direct access to use new getter/setters.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r39038 r39070  
    130130void BytecodeGenerator::generate()
    131131{
    132     m_codeBlock->thisRegister = m_thisRegister.index();
     132    m_codeBlock->setThisRegister(m_thisRegister.index());
    133133
    134134    m_scopeNode->emitBytecode(*this);
     
    155155    }
    156156
    157     ++m_codeBlock->numVars;
     157    ++m_codeBlock->m_numVars;
    158158    r0 = newRegister();
    159159    return true;
     
    179179void BytecodeGenerator::allocateConstants(size_t count)
    180180{
    181     m_codeBlock->numConstants = count;
     181    m_codeBlock->m_numConstants = count;
    182182    if (!count)
    183183        return;
     
    207207{
    208208    if (m_shouldEmitDebugHooks)
    209         m_codeBlock->needsFullScopeChain = true;
     209        m_codeBlock->setNeedsFullScopeChain(true);
    210210
    211211    emitOpcode(op_enter);
    212     codeBlock->globalData = m_globalData;
     212    codeBlock->setGlobalData(m_globalData);
    213213
    214214    // FIXME: Move code that modifies the global object to Interpreter::execute.
    215215   
    216     m_codeBlock->numParameters = 1; // Allocate space for "this"
     216    m_codeBlock->m_numParameters = 1; // Allocate space for "this"
    217217
    218218    JSGlobalObject* globalObject = scopeChain.globalObject();
     
    221221   
    222222    // Shift register indexes in generated code to elide registers allocated by intermediate stack frames.
    223     m_globalVarStorageOffset = -RegisterFile::CallFrameHeaderSize - m_codeBlock->numParameters - registerFile->size();
     223    m_globalVarStorageOffset = -RegisterFile::CallFrameHeaderSize - m_codeBlock->m_numParameters - registerFile->size();
    224224
    225225    // Add previously defined symbols to bookkeeping.
     
    286286{
    287287    if (m_shouldEmitDebugHooks)
    288         m_codeBlock->needsFullScopeChain = true;
    289 
    290     codeBlock->globalData = m_globalData;
     288        m_codeBlock->setNeedsFullScopeChain(true);
     289
     290    codeBlock->setGlobalData(m_globalData);
    291291
    292292    bool usesArguments = functionBody->usesArguments();
    293     codeBlock->usesArguments = usesArguments;
     293    codeBlock->setUsesArguments(usesArguments);
    294294    if (usesArguments) {
    295295        m_argumentsRegister.setIndex(RegisterFile::OptionalCalleeArguments);
     
    297297    }
    298298
    299     if (m_codeBlock->needsFullScopeChain) {
    300         ++m_codeBlock->numVars;
     299    if (m_codeBlock->needsFullScopeChain()) {
     300        ++m_codeBlock->m_numVars;
    301301        m_activationRegisterIndex = newRegister()->index();
    302302        emitOpcode(op_enter_with_activation);
     
    328328    m_thisRegister.setIndex(m_nextParameterIndex);
    329329    ++m_nextParameterIndex;
    330     ++m_codeBlock->numParameters;
     330    ++m_codeBlock->m_numParameters;
    331331
    332332    if (functionBody->usesThis()) {
     
    357357{
    358358    if (m_shouldEmitDebugHooks)
    359         m_codeBlock->needsFullScopeChain = true;
     359        m_codeBlock->setNeedsFullScopeChain(true);
    360360
    361361    emitOpcode(op_enter);
    362     codeBlock->globalData = m_globalData;
    363     m_codeBlock->numParameters = 1; // Allocate space for "this"
     362    codeBlock->setGlobalData(m_globalData);
     363    m_codeBlock->m_numParameters = 1; // Allocate space for "this"
    364364
    365365    allocateConstants(evalNode->neededConstants());
     
    381381    // each parameter, even if the parameter doesn't make it into the symbol table.
    382382    ++m_nextParameterIndex;
    383     ++m_codeBlock->numParameters;
     383    ++m_codeBlock->m_numParameters;
    384384    return result;
    385385}
     
    427427{
    428428    m_calleeRegisters.append(m_calleeRegisters.size());
    429     m_codeBlock->numCalleeRegisters = max<int>(m_codeBlock->numCalleeRegisters, m_calleeRegisters.size());
     429    m_codeBlock->m_numCalleeRegisters = max<int>(m_codeBlock->m_numCalleeRegisters, m_calleeRegisters.size());
    430430    return &m_calleeRegisters.last();
    431431}
     
    444444RegisterID* BytecodeGenerator::highestUsedRegister()
    445445{
    446     size_t count = m_codeBlock->numCalleeRegisters;
     446    size_t count = m_codeBlock->m_numCalleeRegisters;
    447447    while (m_calleeRegisters.size() < count)
    448448        newRegister();
     
    478478    l0->setLocation(newLabelIndex);
    479479
    480     if (m_codeBlock->jumpTargets.size() != 0) {
    481         unsigned lastLabelIndex = m_codeBlock->jumpTargets.last();
     480    if (m_codeBlock->numberOfJumpTargets()) {
     481        unsigned lastLabelIndex = m_codeBlock->lastJumpTarget();
    482482        ASSERT(lastLabelIndex <= newLabelIndex);
    483483        if (newLabelIndex == lastLabelIndex) {
    484484            // Peephole optimizations have already been disabled by emitting the last label
    485             return l0;           
    486         }
    487     }
    488 
    489     m_codeBlock->jumpTargets.append(newLabelIndex);
     485            return l0;
     486        }
     487    }
     488
     489    m_codeBlock->addJumpTarget(newLabelIndex);
    490490
    491491    // This disables peephole optimizations when an instruction is a jump target
     
    671671{
    672672    // No need to explicitly unique function body nodes -- they're unique already.
    673     int index = m_codeBlock->functions.size();
    674     m_codeBlock->functions.append(n);
    675     return index;
     673    return m_codeBlock->addFunction(n);
    676674}
    677675
     
    679677{
    680678    // No need to explicitly unique function expression nodes -- they're unique already.
    681     int index = m_codeBlock->functionExpressions.size();
    682     m_codeBlock->functionExpressions.append(n);
    683     return index;
     679    return m_codeBlock->addFunctionExpression(n);
    684680}
    685681
     
    687683{
    688684    UString::Rep* rep = ident.ustring().rep();
    689     pair<IdentifierMap::iterator, bool> result = m_identifierMap.add(rep, m_codeBlock->identifiers.size());
     685    pair<IdentifierMap::iterator, bool> result = m_identifierMap.add(rep, m_codeBlock->numberOfIdentifiers());
    690686    if (result.second) // new entry
    691         m_codeBlock->identifiers.append(Identifier(m_globalData, rep));
     687        m_codeBlock->addIdentifier(Identifier(m_globalData, rep));
    692688
    693689    return result.first->second;
     
    702698        ++m_nextConstantIndex;
    703699
    704         m_codeBlock->constantRegisters.append(v);
     700        m_codeBlock->addConstantRegister(v);
    705701        return &constant;
    706702    }
     
    711707unsigned BytecodeGenerator::addUnexpectedConstant(JSValue* v)
    712708{
    713     int index = m_codeBlock->unexpectedConstants.size();
    714     m_codeBlock->unexpectedConstants.append(v);
    715     return index;
     709    return m_codeBlock->addUnexpectedConstant(v);
    716710}
    717711
    718712unsigned BytecodeGenerator::addRegExp(RegExp* r)
    719713{
    720     int index = m_codeBlock->regexps.size();
    721     m_codeBlock->regexps.append(r);
    722     return index;
     714    return m_codeBlock->addRegExp(r);
    723715}
    724716
     
    795787            && src1->isTemporary()
    796788            && m_codeBlock->isConstantRegisterIndex(src2->index())
    797             && m_codeBlock->constantRegisters[src2->index() - m_codeBlock->numVars].jsValue(m_scopeChain->globalObject()->globalExec())->isString()) {
    798             const UString& value = asString(m_codeBlock->constantRegisters[src2->index() - m_codeBlock->numVars].jsValue(m_scopeChain->globalObject()->globalExec()))->value();
     789            && m_codeBlock->constantRegister(src2->index() - m_codeBlock->m_numVars).jsValue(m_scopeChain->globalObject()->globalExec())->isString()) {
     790            const UString& value = asString(m_codeBlock->constantRegister(src2->index() - m_codeBlock->m_numVars).jsValue(m_scopeChain->globalObject()->globalExec()))->value();
    799791            if (value == "undefined") {
    800792                rewindUnaryOp();
     
    987979
    988980    if (globalObject) {
    989         m_codeBlock->globalResolveInstructions.append(instructions().size());
     981        m_codeBlock->addGlobalResolveInstruction(instructions().size());
    990982        emitOpcode(op_resolve_global);
    991983        instructions().append(dst->index());
     
    10671059RegisterID* BytecodeGenerator::emitGetById(RegisterID* dst, RegisterID* base, const Identifier& property)
    10681060{
    1069     m_codeBlock->propertyAccessInstructions.append(instructions().size());
     1061    m_codeBlock->addPropertyAccessInstruction(instructions().size());
    10701062
    10711063    emitOpcode(op_get_by_id);
     
    10821074RegisterID* BytecodeGenerator::emitPutById(RegisterID* base, const Identifier& property, RegisterID* value)
    10831075{
    1084     m_codeBlock->propertyAccessInstructions.append(instructions().size());
     1076    m_codeBlock->addPropertyAccessInstruction(instructions().size());
    10851077
    10861078    emitOpcode(op_put_by_id);
     
    12541246
    12551247    emitExpressionInfo(divot, startOffset, endOffset);
    1256     m_codeBlock->callLinkInfos.append(CallLinkInfo());
     1248    m_codeBlock->addCallLinkInfo();
    12571249
    12581250    // Emit call.
     
    12781270RegisterID* BytecodeGenerator::emitReturn(RegisterID* src)
    12791271{
    1280     if (m_codeBlock->needsFullScopeChain) {
     1272    if (m_codeBlock->needsFullScopeChain()) {
    12811273        emitOpcode(op_tear_off_activation);
    12821274        instructions().append(m_activationRegisterIndex);
    1283     } else if (m_codeBlock->usesArguments && m_codeBlock->numParameters > 1)
     1275    } else if (m_codeBlock->usesArguments() && m_codeBlock->m_numParameters > 1)
    12841276        emitOpcode(op_tear_off_arguments);
    12851277
     
    13331325
    13341326    emitExpressionInfo(divot, startOffset, endOffset);
    1335     m_codeBlock->callLinkInfos.append(CallLinkInfo());
     1327    m_codeBlock->addCallLinkInfo();
    13361328
    13371329    emitOpcode(op_construct);
     
    15521544{
    15531545    HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth, 0 };
    1554     exceptionHandlers().append(info);
     1546    m_codeBlock->addExceptionHandler(info);
    15551547    emitOpcode(op_catch);
    15561548    instructions().append(targetRegister->index());
Note: See TracChangeset for help on using the changeset viewer.