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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r155622 r155711  
    153153    if (!arguments) { // f.apply(x, arguments), with arguments unmodified.
    154154        unsigned argumentCountIncludingThis = callFrame->argumentCountIncludingThis();
    155         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + argumentCountIncludingThis + JSStack::CallFrameHeaderSize);
     155        CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - argumentCountIncludingThis - JSStack::CallFrameHeaderSize);
    156156        if (argumentCountIncludingThis > Arguments::MaxArguments + 1 || !stack->grow(newCallFrame->registers())) {
    157157            callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
     
    167167
    168168    if (arguments.isUndefinedOrNull()) {
    169         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + 1 + JSStack::CallFrameHeaderSize);
     169        CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - 1 - JSStack::CallFrameHeaderSize);
    170170        if (!stack->grow(newCallFrame->registers())) {
    171171            callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
     
    185185        Arguments* argsObject = asArguments(arguments);
    186186        unsigned argCount = argsObject->length(callFrame);
    187         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1));
     187        CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - CallFrame::offsetFor(argCount + 1));
    188188        if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
    189189            callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
     
    199199        JSArray* array = asArray(arguments);
    200200        unsigned argCount = array->length();
    201         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1));
     201        CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - CallFrame::offsetFor(argCount + 1));
    202202        if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
    203203            callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
     
    212212    JSObject* argObject = asObject(arguments);
    213213    unsigned argCount = argObject->get(callFrame, callFrame->propertyNames().length).toUInt32(callFrame);
    214     CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1));
     214    CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - CallFrame::offsetFor(argCount + 1));
    215215    if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
    216216        callFrame->vm().throwException(callFrame,  createStackOverflowError(callFrame));
     
    314314    const Register* end;
    315315
    316     it = callFrame->registers() - JSStack::CallFrameHeaderSize - callFrame->argumentCountIncludingThis();
    317     end = callFrame->registers() - JSStack::CallFrameHeaderSize;
    318     while (it < end) {
     316    it = callFrame->registers() + JSStack::CallFrameHeaderSize + callFrame->argumentCountIncludingThis();
     317    end = callFrame->registers() + JSStack::CallFrameHeaderSize;
     318    while (it > end) {
    319319        JSValue v = it->jsValue();
    320320        int registerNumber = it - callFrame->registers();
     
    326326    dataLogF("-----------------------------------------------------------------------------\n");
    327327    dataLogF("[ArgumentCount]            | %10p | %lu \n", it, (unsigned long) callFrame->argumentCount());
    328     ++it;
     328    --it;
    329329    dataLogF("[CallerFrame]              | %10p | %p \n", it, callFrame->callerFrame());
    330     ++it;
     330    --it;
    331331    dataLogF("[Callee]                   | %10p | %p \n", it, callFrame->callee());
    332     ++it;
     332    --it;
    333333    dataLogF("[ScopeChain]               | %10p | %p \n", it, callFrame->scope());
    334     ++it;
     334    --it;
    335335#if ENABLE(JIT)
    336336    AbstractPC pc = callFrame->abstractReturnPC(callFrame->vm());
     
    343343
    344344    dataLogF("[CodeBlock]                | %10p | %p \n", it, callFrame->codeBlock());
    345     ++it;
     345    --it;
    346346    dataLogF("-----------------------------------------------------------------------------\n");
    347347
    348348    int registerCount = 0;
    349349
    350     end = it + codeBlock->m_numVars;
     350    end = it - codeBlock->m_numVars;
    351351    if (it != end) {
    352352        do {
     
    355355            String name = codeBlock->nameForRegister(registerNumber);
    356356            dataLogF("[r% 3d %14s]      | %10p | %-16s 0x%lld \n", registerNumber, name.ascii().data(), it, toCString(v).data(), (long long)JSValue::encode(v));
    357             ++it;
    358             ++registerCount;
     357            --it;
     358            --registerCount;
    359359        } while (it != end);
    360360    }
Note: See TracChangeset for help on using the changeset viewer.