Ignore:
Timestamp:
Sep 13, 2013, 11:03:55 AM (12 years ago)
Author:
[email protected]
Message:

fourthTier: Change JSStack to grow from high to low addresses
https://bugs.webkit.org/show_bug.cgi?id=118758

Reviewed by Oliver Hunt.

Changed the JSC stack to grow down. Effectively the JSC stack frame is flipped from
what it was. See JSStack.h for the new offsets. Changed JSStack begin() and end()
to be getBaseOfStack() and getLimitOfStack(). Most of the changes are address or offset
calculation changes. Decoupled a local register ordinal (loop variable or array index)
from the offset into the callFrame using localToOperand() and the inverse operandToLocal().

  • assembler/MacroAssembler.h:

(JSC::MacroAssembler::trustedImm32ForShift):
(JSC::MacroAssembler::lshiftPtr): Added to create scaled addresses with a negative index

  • assembler/MacroAssemblerX86_64.h:

(JSC::MacroAssemblerX86_64::lshift64): Added to create scaled addresses with a negative index

  • assembler/X86Assembler.h:

(JSC::X86Assembler::shlq_i8r): Added to create scaled addresses with a negative index

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpBytecode):

  • bytecode/CodeBlock.h:

(JSC::unmodifiedArgumentsRegister):
(JSC::CodeBlock::isCaptured):

  • bytecode/CodeOrigin.h:

(JSC::CodeOrigin::stackOffset):

  • bytecode/Operands.h:

(JSC::localToOperand):
(JSC::operandIsLocal):
(JSC::operandToLocal):
(JSC::operandIsArgument):
(JSC::operandToArgument):
(JSC::argumentToOperand):

  • bytecode/VirtualRegister.h: Made InvalidVirtualRegister a positive value that fits in

31 bits since it can be placed into the 31 bit field "stackOffset" in struct InlineCallFrame.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::addVar):
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::createLazyRegisterIfNecessary):
(JSC::BytecodeGenerator::newRegister):
(JSC::BytecodeGenerator::emitNewArray):

  • bytecompiler/BytecodeGenerator.h:

(JSC::CallArguments::registerOffset):

  • bytecompiler/NodesCodegen.cpp:

(JSC::CallArguments::CallArguments):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::findArgumentPositionForLocal):
(JSC::DFG::ByteCodeParser::addCall):
(JSC::DFG::ByteCodeParser::handleCall):
(JSC::DFG::ByteCodeParser::handleInlining):
(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::compileFunction):

  • dfg/DFGOSREntry.cpp:

(JSC::DFG::prepareOSREntry):

  • dfg/DFGOSRExitCompiler32_64.cpp:

(JSC::DFG::OSRExitCompiler::compileExit):

  • dfg/DFGOSRExitCompiler64.cpp:

(JSC::DFG::OSRExitCompiler::compileExit):

  • dfg/DFGOperations.cpp:
  • dfg/DFGScoreBoard.h:

(JSC::DFG::ScoreBoard::allocate):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileGetByValOnArguments):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::callFrameSlot):
(JSC::DFG::SpeculativeJIT::argumentSlot):
(JSC::DFG::SpeculativeJIT::callFrameTagSlot):
(JSC::DFG::SpeculativeJIT::callFramePayloadSlot):
(JSC::DFG::SpeculativeJIT::argumentTagSlot):
(JSC::DFG::SpeculativeJIT::argumentPayloadSlot):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::emitCall):
(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::emitCall):
(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGValidate.cpp:

(JSC::DFG::Validate::reportValidationContext):

  • ftl/FTLLink.cpp:

(JSC::FTL::link):

  • heap/ConservativeRoots.cpp:

(JSC::ConservativeRoots::genericAddSpan):

  • interpreter/CallFrame.cpp:

(JSC::CallFrame::frameExtentInternal):

  • interpreter/CallFrame.h:

(JSC::ExecState::init):
(JSC::ExecState::argumentOffset):
(JSC::ExecState::argumentOffsetIncludingThis):
(JSC::ExecState::argIndexForRegister):

  • interpreter/Interpreter.cpp:

(JSC::loadVarargs):
(JSC::Interpreter::dumpRegisters):

  • interpreter/JSStack.cpp:

(JSC::JSStack::JSStack):
(JSC::JSStack::~JSStack):
(JSC::JSStack::growSlowCase):
(JSC::JSStack::gatherConservativeRoots):
(JSC::JSStack::releaseExcessCapacity):
(JSC::JSStack::disableErrorStackReserve):

  • interpreter/JSStack.h:

(JSC::JSStack::getBaseOfStack):
(JSC::JSStack::getLimitOfStack):
(JSC::JSStack::size):
(JSC::JSStack::end):
(JSC::JSStack::containsAddress):
(JSC::JSStack::lowAddress):
(JSC::JSStack::highAddress):
(JSC::JSStack::reservationEnd):
(JSC::JSStack::shrink):
(JSC::JSStack::grow):

  • interpreter/JSStackInlines.h:

(JSC::JSStack::getTopOfFrame):
(JSC::JSStack::pushFrame):
(JSC::JSStack::popFrame):
(JSC::JSStack::installTrapsAfterFrame):

  • interpreter/StackVisitor.cpp:

(JSC::inlinedFrameOffset):
(JSC::StackVisitor::readInlinedFrame):

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • jit/JITCall.cpp:

(JSC::JIT::compileLoadVarargs):
(JSC::JIT::compileOpCall):

  • jit/JITCall32_64.cpp:

(JSC::JIT::compileLoadVarargs):
(JSC::JIT::compileOpCall):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_create_activation):
(JSC::JIT::emit_op_get_argument_by_val):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emit_op_get_argument_by_val):

  • jit/JITStubs.cpp:

(JSC::throwExceptionFromOpCall):
(JSC::DEFINE_STUB_FUNCTION):

  • jit/ThunkGenerators.cpp:

(JSC::arityFixup):

  • llint/LLIntData.cpp:

(JSC::LLInt::Data::performAssertions):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):
(JSC::LLInt::genericCall):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/ArgList.cpp:

(JSC::ArgList::getSlice):
(JSC::MarkedArgumentBuffer::slowAppend):

  • runtime/ArgList.h:

(JSC::MarkedArgumentBuffer::MarkedArgumentBuffer):
(JSC::MarkedArgumentBuffer::slotFor):
(JSC::MarkedArgumentBuffer::mallocBase):
(JSC::ArgList::at):

  • runtime/Arguments.cpp:

(JSC::Arguments::tearOff):

  • runtime/ArrayConstructor.cpp:

(JSC::constructArrayWithSizeQuirk):

  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/JSActivation.h:

(JSC::JSActivation::registersOffset):
(JSC::JSActivation::tearOff):
(JSC::JSActivation::isValidIndex):

  • runtime/JSArray.h:

(JSC::constructArrayNegativeIndexed): New method to create an array from registers that grow down.

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::globalExec):

  • runtime/JSGlobalObject.h:

(JSC::constructArrayNegativeIndexed):

  • runtime/JSString.h:
  • runtime/Operations.h:

(JSC::jsStringFromRegisterArray):

  • runtime/SymbolTable.h:

(JSC::SharedSymbolTable::captureCount):

Location:
trunk/Source/JavaScriptCore/bytecompiler
Files:
3 edited

Legend:

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

    r155657 r155711  
    117117{
    118118    ConcurrentJITLocker locker(symbolTable().m_lock);
    119     int index = m_calleeRegisters.size();
     119    int index = localToOperand(m_calleeRegisters.size());
    120120    SymbolTableEntry newEntry(index, isConstant ? ReadOnly : 0);
    121121    SymbolTable::Map::AddResult result = symbolTable().add(locker, ident.impl(), newEntry);
     
    224224    }
    225225
    226     m_symbolTable->setCaptureStart(m_codeBlock->m_numVars);
     226    m_symbolTable->setCaptureStart(localToOperand(m_codeBlock->m_numVars));
    227227
    228228    if (functionBody->usesArguments() || codeBlock->usesEval()) { // May reify arguments object.
     
    311311    }
    312312
    313     m_symbolTable->setCaptureEnd(codeBlock->m_numVars);
     313    m_symbolTable->setCaptureEnd(localToOperand(codeBlock->m_numVars));
    314314
    315315    m_firstLazyFunction = codeBlock->m_numVars;
     
    326326            else {
    327327                emitInitLazyRegister(reg.get());
    328                 m_lazyFunctions.set(reg->index(), function);
     328                m_lazyFunctions.set(localToOperand(reg->index()), function);
    329329            }
    330330        }
     
    338338
    339339    if (shouldCaptureAllTheThings)
    340         m_symbolTable->setCaptureEnd(codeBlock->m_numVars);
     340        m_symbolTable->setCaptureEnd(localToOperand(codeBlock->m_numVars));
    341341
    342342    FunctionParameters& parameters = *functionBody->parameters();
     
    345345    // Add "this" as a parameter
    346346    int nextParameterIndex = CallFrame::thisArgumentOffset();
    347     m_thisRegister.setIndex(nextParameterIndex--);
     347    m_thisRegister.setIndex(nextParameterIndex++);
    348348    m_codeBlock->addParameter();
    349349   
    350     for (size_t i = 0; i < parameters.size(); ++i, --nextParameterIndex) {
     350    for (size_t i = 0; i < parameters.size(); ++i, ++nextParameterIndex) {
    351351        int index = nextParameterIndex;
    352352        if (capturedArguments.size() && capturedArguments[i]) {
     
    506506RegisterID* BytecodeGenerator::createLazyRegisterIfNecessary(RegisterID* reg)
    507507{
    508     if (m_lastLazyFunction <= reg->index() || reg->index() < m_firstLazyFunction)
     508    int localVariableNumber = operandToLocal(reg->index());
     509   
     510    if (m_lastLazyFunction <= localVariableNumber || localVariableNumber < m_firstLazyFunction)
    509511        return reg;
    510     emitLazyNewFunction(reg, m_lazyFunctions.get(reg->index()));
     512    emitLazyNewFunction(reg, m_lazyFunctions.get(localVariableNumber));
    511513    return reg;
    512514}
     
    514516RegisterID* BytecodeGenerator::newRegister()
    515517{
    516     m_calleeRegisters.append(m_calleeRegisters.size());
     518    m_calleeRegisters.append(localToOperand(m_calleeRegisters.size()));
    517519    m_codeBlock->m_numCalleeRegisters = max<int>(m_codeBlock->m_numCalleeRegisters, m_calleeRegisters.size());
    518520    return &m_calleeRegisters.last();
     
    14851487        argv.append(newTemporary());
    14861488        // op_new_array requires the initial values to be a sequential range of registers
    1487         ASSERT(argv.size() == 1 || argv[argv.size() - 1]->index() == argv[argv.size() - 2]->index() + 1);
     1489        ASSERT(argv.size() == 1 || argv[argv.size() - 1]->index() == argv[argv.size() - 2]->index() - 1);
    14881490        emitNode(argv.last().get(), n->value());
    14891491    }
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r155415 r155711  
    6767        RegisterID* thisRegister() { return m_argv[0].get(); }
    6868        RegisterID* argumentRegister(unsigned i) { return m_argv[i + 1].get(); }
    69         unsigned registerOffset() { return m_argv.last()->index() + CallFrame::offsetFor(argumentCountIncludingThis()); }
     69        unsigned registerOffset() { return -m_argv.last()->index() + CallFrame::offsetFor(argumentCountIncludingThis()); }
    7070        unsigned argumentCountIncludingThis() { return m_argv.size(); }
    7171        RegisterID* profileHookRegister() { return m_profileHookRegister.get(); }
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r153477 r155711  
    394394    for (int i = argumentCountIncludingThis - 1; i >= 0; --i) {
    395395        m_argv[i] = generator.newTemporary();
    396         ASSERT(static_cast<size_t>(i) == m_argv.size() - 1 || m_argv[i]->index() == m_argv[i + 1]->index() + 1);
     396        ASSERT(static_cast<size_t>(i) == m_argv.size() - 1 || m_argv[i]->index() == m_argv[i + 1]->index() - 1);
    397397    }
    398398}
Note: See TracChangeset for help on using the changeset viewer.