Changeset 155711 in webkit


Ignore:
Timestamp:
Sep 13, 2013 11:03:55 AM (11 years ago)
Author:
msaboff@apple.com
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
Files:
57 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r155705 r155711  
     12013-09-12  Michael Saboff  <msaboff@apple.com>
     2
     3        fourthTier: Change JSStack to grow from high to low addresses
     4        https://bugs.webkit.org/show_bug.cgi?id=118758
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Changed the JSC stack to grow down.  Effectively the JSC stack frame is flipped from
     9        what it was.  See JSStack.h for the new offsets.  Changed JSStack begin() and end()
     10        to be getBaseOfStack() and getLimitOfStack().  Most of the changes are address or offset
     11        calculation changes.  Decoupled a local register ordinal (loop variable or array index)
     12        from the offset into the callFrame using localToOperand() and the inverse operandToLocal().
     13
     14        * assembler/MacroAssembler.h:
     15        (JSC::MacroAssembler::trustedImm32ForShift):
     16        (JSC::MacroAssembler::lshiftPtr): Added to create scaled addresses with a negative index
     17        * assembler/MacroAssemblerX86_64.h:
     18        (JSC::MacroAssemblerX86_64::lshift64): Added to create scaled addresses with a negative index
     19        * assembler/X86Assembler.h:
     20        (JSC::X86Assembler::shlq_i8r): Added to create scaled addresses with a negative index
     21        * bytecode/CodeBlock.cpp:
     22        (JSC::CodeBlock::dumpBytecode):
     23        * bytecode/CodeBlock.h:
     24        (JSC::unmodifiedArgumentsRegister):
     25        (JSC::CodeBlock::isCaptured):
     26        * bytecode/CodeOrigin.h:
     27        (JSC::CodeOrigin::stackOffset):
     28        * bytecode/Operands.h:
     29        (JSC::localToOperand):
     30        (JSC::operandIsLocal):
     31        (JSC::operandToLocal):
     32        (JSC::operandIsArgument):
     33        (JSC::operandToArgument):
     34        (JSC::argumentToOperand):
     35        * bytecode/VirtualRegister.h: Made InvalidVirtualRegister a positive value that fits in
     36        31 bits since it can be placed into the 31 bit field "stackOffset" in struct InlineCallFrame.
     37        * bytecompiler/BytecodeGenerator.cpp:
     38        (JSC::BytecodeGenerator::addVar):
     39        (JSC::BytecodeGenerator::BytecodeGenerator):
     40        (JSC::BytecodeGenerator::createLazyRegisterIfNecessary):
     41        (JSC::BytecodeGenerator::newRegister):
     42        (JSC::BytecodeGenerator::emitNewArray):
     43        * bytecompiler/BytecodeGenerator.h:
     44        (JSC::CallArguments::registerOffset):
     45        * bytecompiler/NodesCodegen.cpp:
     46        (JSC::CallArguments::CallArguments):
     47        * dfg/DFGByteCodeParser.cpp:
     48        (JSC::DFG::ByteCodeParser::findArgumentPositionForLocal):
     49        (JSC::DFG::ByteCodeParser::addCall):
     50        (JSC::DFG::ByteCodeParser::handleCall):
     51        (JSC::DFG::ByteCodeParser::handleInlining):
     52        (JSC::DFG::ByteCodeParser::parseBlock):
     53        (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
     54        * dfg/DFGJITCompiler.cpp:
     55        (JSC::DFG::JITCompiler::compileFunction):
     56        * dfg/DFGOSREntry.cpp:
     57        (JSC::DFG::prepareOSREntry):
     58        * dfg/DFGOSRExitCompiler32_64.cpp:
     59        (JSC::DFG::OSRExitCompiler::compileExit):
     60        * dfg/DFGOSRExitCompiler64.cpp:
     61        (JSC::DFG::OSRExitCompiler::compileExit):
     62        * dfg/DFGOperations.cpp:
     63        * dfg/DFGScoreBoard.h:
     64        (JSC::DFG::ScoreBoard::allocate):
     65        * dfg/DFGSpeculativeJIT.cpp:
     66        (JSC::DFG::SpeculativeJIT::compileGetByValOnArguments):
     67        * dfg/DFGSpeculativeJIT.h:
     68        (JSC::DFG::SpeculativeJIT::callFrameSlot):
     69        (JSC::DFG::SpeculativeJIT::argumentSlot):
     70        (JSC::DFG::SpeculativeJIT::callFrameTagSlot):
     71        (JSC::DFG::SpeculativeJIT::callFramePayloadSlot):
     72        (JSC::DFG::SpeculativeJIT::argumentTagSlot):
     73        (JSC::DFG::SpeculativeJIT::argumentPayloadSlot):
     74        * dfg/DFGSpeculativeJIT32_64.cpp:
     75        (JSC::DFG::SpeculativeJIT::emitCall):
     76        (JSC::DFG::SpeculativeJIT::compile):
     77        * dfg/DFGSpeculativeJIT64.cpp:
     78        (JSC::DFG::SpeculativeJIT::emitCall):
     79        (JSC::DFG::SpeculativeJIT::compile):
     80        * dfg/DFGValidate.cpp:
     81        (JSC::DFG::Validate::reportValidationContext):
     82        * ftl/FTLLink.cpp:
     83        (JSC::FTL::link):
     84        * heap/ConservativeRoots.cpp:
     85        (JSC::ConservativeRoots::genericAddSpan):
     86        * interpreter/CallFrame.cpp:
     87        (JSC::CallFrame::frameExtentInternal):
     88        * interpreter/CallFrame.h:
     89        (JSC::ExecState::init):
     90        (JSC::ExecState::argumentOffset):
     91        (JSC::ExecState::argumentOffsetIncludingThis):
     92        (JSC::ExecState::argIndexForRegister):
     93        * interpreter/Interpreter.cpp:
     94        (JSC::loadVarargs):
     95        (JSC::Interpreter::dumpRegisters):
     96        * interpreter/JSStack.cpp:
     97        (JSC::JSStack::JSStack):
     98        (JSC::JSStack::~JSStack):
     99        (JSC::JSStack::growSlowCase):
     100        (JSC::JSStack::gatherConservativeRoots):
     101        (JSC::JSStack::releaseExcessCapacity):
     102        (JSC::JSStack::disableErrorStackReserve):
     103        * interpreter/JSStack.h:
     104        (JSC::JSStack::getBaseOfStack):
     105        (JSC::JSStack::getLimitOfStack):
     106        (JSC::JSStack::size):
     107        (JSC::JSStack::end):
     108        (JSC::JSStack::containsAddress):
     109        (JSC::JSStack::lowAddress):
     110        (JSC::JSStack::highAddress):
     111        (JSC::JSStack::reservationEnd):
     112        (JSC::JSStack::shrink):
     113        (JSC::JSStack::grow):
     114        * interpreter/JSStackInlines.h:
     115        (JSC::JSStack::getTopOfFrame):
     116        (JSC::JSStack::pushFrame):
     117        (JSC::JSStack::popFrame):
     118        (JSC::JSStack::installTrapsAfterFrame):
     119        * interpreter/StackVisitor.cpp:
     120        (JSC::inlinedFrameOffset):
     121        (JSC::StackVisitor::readInlinedFrame):
     122        * jit/JIT.cpp:
     123        (JSC::JIT::privateCompile):
     124        * jit/JITCall.cpp:
     125        (JSC::JIT::compileLoadVarargs):
     126        (JSC::JIT::compileOpCall):
     127        * jit/JITCall32_64.cpp:
     128        (JSC::JIT::compileLoadVarargs):
     129        (JSC::JIT::compileOpCall):
     130        * jit/JITOpcodes.cpp:
     131        (JSC::JIT::emit_op_create_activation):
     132        (JSC::JIT::emit_op_get_argument_by_val):
     133        * jit/JITOpcodes32_64.cpp:
     134        (JSC::JIT::emit_op_get_argument_by_val):
     135        * jit/JITStubs.cpp:
     136        (JSC::throwExceptionFromOpCall):
     137        (JSC::DEFINE_STUB_FUNCTION):
     138        * jit/ThunkGenerators.cpp:
     139        (JSC::arityFixup):
     140        * llint/LLIntData.cpp:
     141        (JSC::LLInt::Data::performAssertions):
     142        * llint/LLIntSlowPaths.cpp:
     143        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     144        (JSC::LLInt::genericCall):
     145        * llint/LowLevelInterpreter.asm:
     146        * llint/LowLevelInterpreter32_64.asm:
     147        * llint/LowLevelInterpreter64.asm:
     148        * runtime/ArgList.cpp:
     149        (JSC::ArgList::getSlice):
     150        (JSC::MarkedArgumentBuffer::slowAppend):
     151        * runtime/ArgList.h:
     152        (JSC::MarkedArgumentBuffer::MarkedArgumentBuffer):
     153        (JSC::MarkedArgumentBuffer::slotFor):
     154        (JSC::MarkedArgumentBuffer::mallocBase):
     155        (JSC::ArgList::at):
     156        * runtime/Arguments.cpp:
     157        (JSC::Arguments::tearOff):
     158        * runtime/ArrayConstructor.cpp:
     159        (JSC::constructArrayWithSizeQuirk):
     160        * runtime/CommonSlowPaths.cpp:
     161        (JSC::SLOW_PATH_DECL):
     162        * runtime/JSActivation.h:
     163        (JSC::JSActivation::registersOffset):
     164        (JSC::JSActivation::tearOff):
     165        (JSC::JSActivation::isValidIndex):
     166        * runtime/JSArray.h:
     167        (JSC::constructArrayNegativeIndexed): New method to create an array from registers that grow down.
     168        * runtime/JSGlobalObject.cpp:
     169        (JSC::JSGlobalObject::globalExec):
     170        * runtime/JSGlobalObject.h:
     171        (JSC::constructArrayNegativeIndexed):
     172        * runtime/JSString.h:
     173        * runtime/Operations.h:
     174        (JSC::jsStringFromRegisterArray):
     175        * runtime/SymbolTable.h:
     176        (JSC::SharedSymbolTable::captureCount):
     177
    11782013-09-13  Csaba Osztrogonác  <ossy@webkit.org>
    2179
  • trunk/Source/JavaScriptCore/assembler/MacroAssembler.h

    r153264 r155711  
    209209#endif
    210210
     211    // Immediate shifts only have 5 controllable bits
     212    // so we'll consider them safe for now.
     213    TrustedImm32 trustedImm32ForShift(Imm32 imm)
     214    {
     215        return TrustedImm32(imm.asTrustedImm32().m_value & 31);
     216    }
     217
    211218    // Backwards banches, these are currently all implemented using existing forwards branch mechanisms.
    212219    void branchPtr(RelationalCondition cond, RegisterID op1, TrustedImmPtr imm, Label target)
     
    630637    }
    631638   
     639    void lshiftPtr(Imm32 imm, RegisterID srcDest)
     640    {
     641        lshift64(trustedImm32ForShift(imm), srcDest);
     642    }
     643
    632644    void negPtr(RegisterID dest)
    633645    {
     
    14121424    }
    14131425   
    1414     // Immediate shifts only have 5 controllable bits
    1415     // so we'll consider them safe for now.
    1416     TrustedImm32 trustedImm32ForShift(Imm32 imm)
    1417     {
    1418         return TrustedImm32(imm.asTrustedImm32().m_value & 31);
    1419     }
    1420 
    14211426    void lshift32(Imm32 imm, RegisterID dest)
    14221427    {
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h

    r154158 r155711  
    226226    }
    227227   
     228    void lshift64(TrustedImm32 imm, RegisterID dest)
     229    {
     230        m_assembler.shlq_i8r(imm.m_value, dest);
     231    }
     232   
    228233    void neg64(RegisterID dest)
    229234    {
  • trunk/Source/JavaScriptCore/assembler/X86Assembler.h

    r154161 r155711  
    820820        }
    821821    }
     822
     823    void shlq_i8r(int imm, RegisterID dst)
     824    {
     825        if (imm == 1)
     826            m_formatter.oneByteOp64(OP_GROUP2_Ev1, GROUP2_OP_SHL, dst);
     827        else {
     828            m_formatter.oneByteOp64(OP_GROUP2_EvIb, GROUP2_OP_SHL, dst);
     829            m_formatter.immediate8(imm);
     830        }
     831    }
    822832#endif
    823833
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r155415 r155711  
    508508        out.printf(
    509509            "; %d captured var(s) (from r%d to r%d, inclusive)",
    510             symbolTable()->captureCount(), symbolTable()->captureStart(), symbolTable()->captureEnd() - 1);
     510            symbolTable()->captureCount(), symbolTable()->captureStart(), symbolTable()->captureEnd() + 1);
    511511    }
    512512    if (usesArguments()) {
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r155420 r155711  
    8787class RepatchBuffer;
    8888
    89 inline int unmodifiedArgumentsRegister(int argumentsRegister) { return argumentsRegister - 1; }
     89inline int unmodifiedArgumentsRegister(int argumentsRegister) { return argumentsRegister + 1; }
    9090
    9191static ALWAYS_INLINE int missingThisObjectMarker() { return std::numeric_limits<int>::max(); }
     
    387387            return false;
    388388
    389         return operand >= symbolTable()->captureStart()
    390         && operand < symbolTable()->captureEnd();
     389        return operand <= symbolTable()->captureStart()
     390            && operand > symbolTable()->captureEnd();
    391391    }
    392392
  • trunk/Source/JavaScriptCore/bytecode/CodeOrigin.h

    r155418 r155711  
    7777    ScriptExecutable* codeOriginOwner() const;
    7878   
    79     unsigned stackOffset() const;
     79    int stackOffset() const;
    8080   
    8181    static unsigned inlineDepthForCallFrame(InlineCallFrame*);
     
    9898    CodeOrigin caller;
    9999    BitVector capturedVars; // Indexed by the machine call frame's variable numbering.
    100     signed int stackOffset : 31;
     100    signed stackOffset : 31;
    101101    bool isCall : 1;
    102102   
     
    120120};
    121121
    122 inline unsigned CodeOrigin::stackOffset() const
     122inline int CodeOrigin::stackOffset() const
    123123{
    124124    if (!inlineCallFrame)
  • trunk/Source/JavaScriptCore/bytecode/Operands.h

    r155415 r155711  
    2929#include "CallFrame.h"
    3030#include "JSObject.h"
    31 #include "VirtualRegister.h"
    3231#include <wtf/PrintStream.h>
    3332#include <wtf/Vector.h>
     
    3534namespace JSC {
    3635
    37 inline VirtualRegister localToOperand(int local) { return (VirtualRegister)local; }
    38 inline bool operandIsLocal(int operand) { return operand >= 0; }
    39 inline int operandToLocal(int operand) { return operand; }
     36inline int localToOperand(int local) { return -local; }
     37inline bool operandIsLocal(int operand) { return operand <= 0; }
     38inline int operandToLocal(int operand) { return -operand; }
    4039
    4140// argument 0 is 'this'.
    42 inline bool operandIsArgument(int operand) { return operand < 0; }
    43 inline int operandToArgument(int operand) { return -operand + CallFrame::thisArgumentOffset(); }
    44 inline int argumentToOperand(int argument) { return -argument + CallFrame::thisArgumentOffset(); }
     41inline bool operandIsArgument(int operand) { return operand > 0; }
     42inline int operandToArgument(int operand) { return operand - CallFrame::thisArgumentOffset(); }
     43inline int argumentToOperand(int argument) { return argument + CallFrame::thisArgumentOffset(); }
    4544
    4645template<typename T> struct OperandValueTraits;
  • trunk/Source/JavaScriptCore/bytecode/VirtualRegister.h

    r155420 r155711  
    3434// Type for a virtual register number (spill location).
    3535// Using an enum to make this type-checked at compile time, to avert programmer errors.
    36 enum VirtualRegister { InvalidVirtualRegister = 0x7fffffff };
     36enum VirtualRegister { InvalidVirtualRegister = 0x3fffffff };
    3737COMPILE_ASSERT(sizeof(VirtualRegister) == sizeof(int), VirtualRegister_is_32bit);
    3838
  • 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}
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r155418 r155711  
    390390            if (!inlineCallFrame)
    391391                break;
    392             if (operand >= static_cast<int>(inlineCallFrame->stackOffset - JSStack::CallFrameHeaderSize))
     392            if (operand <= static_cast<int>(inlineCallFrame->stackOffset + JSStack::CallFrameHeaderSize))
    393393                continue;
    394394            if (operand == inlineCallFrame->stackOffset + CallFrame::thisArgumentOffset())
    395395                continue;
    396             if (operand < static_cast<int>(inlineCallFrame->stackOffset - JSStack::CallFrameHeaderSize - inlineCallFrame->arguments.size()))
     396            if (operand > static_cast<int>(inlineCallFrame->stackOffset + JSStack::CallFrameHeaderSize + inlineCallFrame->arguments.size()))
    397397                continue;
    398398            int argument = operandToArgument(operand - inlineCallFrame->stackOffset);
     
    774774            m_parameterSlots = JSStack::CallFrameHeaderSize + argCount;
    775775
    776         int registerOffset = currentInstruction[4].u.operand;
     776        int registerOffset = -currentInstruction[4].u.operand;
    777777        int dummyThisArgument = op == Call ? 0 : 1;
    778778        for (int i = 0 + dummyThisArgument; i < argCount; ++i)
     
    11591159   
    11601160    int argumentCountIncludingThis = currentInstruction[3].u.operand;
    1161     int registerOffset = currentInstruction[4].u.operand;
     1161    int registerOffset = -currentInstruction[4].u.operand;
    11621162
    11631163    int resultOperand = currentInstruction[1].u.operand;
     
    12841284    // FIXME: Don't flush constants!
    12851285   
    1286     int inlineCallFrameStart = m_inlineStackTop->remapOperand(registerOffset) - JSStack::CallFrameHeaderSize;
     1286    int inlineCallFrameStart = m_inlineStackTop->remapOperand(registerOffset) + JSStack::CallFrameHeaderSize;
    12871287   
    12881288    // Make sure that the area used by the call frame is reserved.
     
    19581958            int numOperands = currentInstruction[3].u.operand;
    19591959            ArrayAllocationProfile* profile = currentInstruction[4].u.arrayAllocationProfile;
    1960             for (int operandIdx = startOperand; operandIdx < startOperand + numOperands; ++operandIdx)
     1960            for (int operandIdx = startOperand; operandIdx > startOperand - numOperands; --operandIdx)
    19611961                addVarArgChild(get(operandIdx));
    19621962            set(currentInstruction[1].u.operand, addToGraph(Node::VarArg, NewArray, OpInfo(profile->selectIndexingType()), OpInfo(0)));
     
    22382238            OwnArrayPtr<Node*> toStringNodes = adoptArrayPtr(new Node*[numOperands]);
    22392239            for (int i = 0; i < numOperands; i++)
    2240                 toStringNodes[i] = addToGraph(ToString, get(startOperand + i));
     2240                toStringNodes[i] = addToGraph(ToString, get(startOperand - i));
    22412241
    22422242            for (int i = 0; i < numOperands; i++)
     
    33703370            byteCodeParser->m_codeBlock->ownerExecutable(),
    33713371            codeBlock->ownerExecutable());
    3372         inlineCallFrame.stackOffset = inlineCallFrameStart + JSStack::CallFrameHeaderSize;
     3372        inlineCallFrame.stackOffset = inlineCallFrameStart - JSStack::CallFrameHeaderSize;
    33733373        if (callee) {
    33743374            initializeLazyWriteBarrierForInlineCallFrameCallee(
  • trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp

    r153540 r155711  
    372372    // Plant a check that sufficient space is available in the JSStack.
    373373    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=56291
    374     addPtr(TrustedImm32(m_codeBlock->m_numCalleeRegisters * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1);
    375     Jump stackCheck = branchPtr(Below, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), GPRInfo::regT1);
     374    addPtr(TrustedImm32(-m_codeBlock->m_numCalleeRegisters * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1);
     375    Jump stackCheck = branchPtr(Above, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), GPRInfo::regT1);
    376376    // Return here after stack check.
    377377    Label fromStackCheck = label();
  • trunk/Source/JavaScriptCore/dfg/DFGOSREntry.cpp

    r155415 r155711  
    168168    //    would have otherwise just kept running albeit less quickly.
    169169   
    170     if (!vm->interpreter->stack().grow(&exec->registers()[codeBlock->m_numCalleeRegisters])) {
     170    if (!vm->interpreter->stack().grow(&exec->registers()[localToOperand(codeBlock->m_numCalleeRegisters)])) {
    171171        if (Options::verboseOSR())
    172172            dataLogF("    OSR failed because stack growth failed.\n");
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompiler32_64.cpp

    r155415 r155711  
    546546            case UnboxedBooleanInGPR: {
    547547                m_jit.load32(reinterpret_cast<char*>(scratchDataBuffer + poisonIndex(virtualRegister)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload), GPRInfo::regT0);
    548                 m_jit.store32(GPRInfo::regT0, AssemblyHelpers::payloadFor(localToOperand(virtualRegister)));
     548                m_jit.store32(GPRInfo::regT0, AssemblyHelpers::payloadFor((VirtualRegister)localToOperand(virtualRegister)));
    549549                uint32_t tag = JSValue::EmptyValueTag;
    550550                if (recovery.technique() == InGPR)
     
    554554                else
    555555                    tag = JSValue::BooleanTag;
    556                 m_jit.store32(AssemblyHelpers::TrustedImm32(tag), AssemblyHelpers::tagFor(localToOperand(virtualRegister)));
     556                m_jit.store32(AssemblyHelpers::TrustedImm32(tag), AssemblyHelpers::tagFor((VirtualRegister)localToOperand(virtualRegister)));
    557557                break;
    558558            }
     
    563563                m_jit.load32(reinterpret_cast<char*>(scratchDataBuffer + poisonIndex(virtualRegister)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload), GPRInfo::regT0);
    564564                m_jit.load32(reinterpret_cast<char*>(scratchDataBuffer + poisonIndex(virtualRegister)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag), GPRInfo::regT1);
    565                 m_jit.store32(GPRInfo::regT0, AssemblyHelpers::payloadFor(localToOperand(virtualRegister)));
    566                 m_jit.store32(GPRInfo::regT1, AssemblyHelpers::tagFor(localToOperand(virtualRegister)));
     565                m_jit.store32(GPRInfo::regT0, AssemblyHelpers::payloadFor((VirtualRegister)localToOperand(virtualRegister)));
     566                m_jit.store32(GPRInfo::regT1, AssemblyHelpers::tagFor((VirtualRegister)localToOperand(virtualRegister)));
    567567                break;
    568568               
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp

    r155415 r155711  
    532532            case InFPR:
    533533                m_jit.load64(scratchDataBuffer + poisonIndex(virtualRegister), GPRInfo::regT0);
    534                 m_jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(localToOperand(virtualRegister)));
     534                m_jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor((VirtualRegister)localToOperand(virtualRegister)));
    535535                break;
    536536               
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r155457 r155711  
    14151415    NativeCallFrameTracer tracer(vm, exec);
    14161416   
    1417     return bitwise_cast<char*>(constructArray(exec, arrayStructure, static_cast<JSValue*>(buffer), size));
     1417    return bitwise_cast<char*>(constructArrayNegativeIndexed(exec, arrayStructure, static_cast<JSValue*>(buffer), size));
    14181418}
    14191419
     
    14411441    VM& vm = exec->vm();
    14421442    NativeCallFrameTracer tracer(&vm, exec);
    1443     return bitwise_cast<char*>(constructArray(exec, arrayStructure, exec->codeBlock()->constantBuffer(start), size));
     1443    return bitwise_cast<char*>(constructArrayNegativeIndexed(exec, arrayStructure, exec->codeBlock()->constantBuffer(start), size));
    14441444}
    14451445
     
    22592259HIDE_SYMBOL(getHostCallReturnValue) "\n"
    22602260SYMBOL_STRING(getHostCallReturnValue) ":" "\n"
    2261     "mov -40(%r13), %r13\n"
     2261    "mov 40(%r13), %r13\n"
    22622262    "mov %r13, %rdi\n"
    22632263    "jmp " LOCAL_REFERENCE(getHostCallReturnValueWithExecState) "\n"
     
    22692269HIDE_SYMBOL(getHostCallReturnValue) "\n"
    22702270SYMBOL_STRING(getHostCallReturnValue) ":" "\n"
    2271     "mov -40(%edi), %edi\n"
     2271    "mov 40(%edi), %edi\n"
    22722272    "mov %edi, 4(%esp)\n"
    22732273    "jmp " LOCAL_REFERENCE(getHostCallReturnValueWithExecState) "\n"
     
    22822282".thumb_func " THUMB_FUNC_PARAM(getHostCallReturnValue) "\n"
    22832283SYMBOL_STRING(getHostCallReturnValue) ":" "\n"
    2284     "ldr r5, [r5, #-40]" "\n"
     2284    "ldr r5, [r5, #40]" "\n"
    22852285    "mov r0, r5" "\n"
    22862286    "b " LOCAL_REFERENCE(getHostCallReturnValueWithExecState) "\n"
     
    22932293INLINE_ARM_FUNCTION(getHostCallReturnValue)
    22942294SYMBOL_STRING(getHostCallReturnValue) ":" "\n"
    2295     "ldr r5, [r5, #-40]" "\n"
     2295    "ldr r5, [r5, #40]" "\n"
    22962296    "mov r0, r5" "\n"
    22972297    "b " LOCAL_REFERENCE(getHostCallReturnValueWithExecState) "\n"
     
    23042304SYMBOL_STRING(getHostCallReturnValue) ":" "\n"
    23052305    LOAD_FUNCTION_TO_T9(getHostCallReturnValueWithExecState)
    2306     "lw $s0, -40($s0)" "\n"
     2306    "lw $s0, 40($s0)" "\n"
    23072307    "move $a0, $s0" "\n"
    23082308    "b " LOCAL_REFERENCE(getHostCallReturnValueWithExecState) "\n"
     
    23142314HIDE_SYMBOL(getHostCallReturnValue) "\n"
    23152315SYMBOL_STRING(getHostCallReturnValue) ":" "\n"
    2316     "add #-40, r14" "\n"
     2316    "add #40, r14" "\n"
    23172317    "mov.l @r14, r14" "\n"
    23182318    "mov r14, r4" "\n"
  • trunk/Source/JavaScriptCore/dfg/DFGScoreBoard.h

    r155415 r155711  
    9090            ASSERT(!m_used[index]);
    9191            m_highWatermark = std::max(m_highWatermark, static_cast<unsigned>(index) + 1);
    92             return localToOperand(index);
     92            return (VirtualRegister)localToOperand(index);
    9393        }
    9494
     
    9797        m_used.append(0);
    9898        m_highWatermark = std::max(m_highWatermark, static_cast<unsigned>(next) + 1);
    99         return localToOperand(next);
     99        return (VirtualRegister)localToOperand(next);
    100100    }
    101101
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r155662 r155711  
    40334033   
    40344034    m_jit.move(propertyReg, resultReg);
    4035     m_jit.neg32(resultReg);
    40364035    m_jit.signExtend32ToPtr(resultReg, resultReg);
    40374036    m_jit.loadPtr(
     
    40434042        MacroAssembler::BaseIndex(
    40444043            scratchReg, resultReg, MacroAssembler::TimesEight,
    4045             CallFrame::thisArgumentOffset() * sizeof(Register) - sizeof(Register) +
     4044            CallFrame::thisArgumentOffset() * sizeof(Register) + sizeof(Register) +
    40464045            OBJECT_OFFSETOF(JSValue, u.asBits.tag)),
    40474046        resultTagReg);
     
    40494048        MacroAssembler::BaseIndex(
    40504049            scratchReg, resultReg, MacroAssembler::TimesEight,
    4051             CallFrame::thisArgumentOffset() * sizeof(Register) - sizeof(Register) +
     4050            CallFrame::thisArgumentOffset() * sizeof(Register) + sizeof(Register) +
    40524051            OBJECT_OFFSETOF(JSValue, u.asBits.payload)),
    40534052        resultReg);
     
    40574056        MacroAssembler::BaseIndex(
    40584057            scratchReg, resultReg, MacroAssembler::TimesEight,
    4059             CallFrame::thisArgumentOffset() * sizeof(Register) - sizeof(Register)),
     4058            CallFrame::thisArgumentOffset() * sizeof(Register) + sizeof(Register)),
    40604059        resultReg);
    40614060    jsValueResult(resultReg, node);
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r155675 r155711  
    751751    MacroAssembler::Address callFrameSlot(int slot)
    752752    {
    753         return MacroAssembler::Address(GPRInfo::callFrameRegister, (m_jit.codeBlock()->m_numCalleeRegisters + slot) * static_cast<int>(sizeof(Register)));
     753        return MacroAssembler::Address(GPRInfo::callFrameRegister, (-m_jit.codeBlock()->m_numCalleeRegisters + slot) * static_cast<int>(sizeof(Register)));
    754754    }
    755755
     
    757757    MacroAssembler::Address argumentSlot(int argument)
    758758    {
    759         return MacroAssembler::Address(GPRInfo::callFrameRegister, (m_jit.codeBlock()->m_numCalleeRegisters + argumentToOperand(argument)) * static_cast<int>(sizeof(Register)));
     759        return MacroAssembler::Address(GPRInfo::callFrameRegister, (-m_jit.codeBlock()->m_numCalleeRegisters + argumentToOperand(argument)) * static_cast<int>(sizeof(Register)));
    760760    }
    761761
    762762    MacroAssembler::Address callFrameTagSlot(int slot)
    763763    {
    764         return MacroAssembler::Address(GPRInfo::callFrameRegister, (m_jit.codeBlock()->m_numCalleeRegisters + slot) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
     764        return MacroAssembler::Address(GPRInfo::callFrameRegister, (-m_jit.codeBlock()->m_numCalleeRegisters + slot) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
    765765    }
    766766
    767767    MacroAssembler::Address callFramePayloadSlot(int slot)
    768768    {
    769         return MacroAssembler::Address(GPRInfo::callFrameRegister, (m_jit.codeBlock()->m_numCalleeRegisters + slot) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
     769        return MacroAssembler::Address(GPRInfo::callFrameRegister, (-m_jit.codeBlock()->m_numCalleeRegisters + slot) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
    770770    }
    771771
    772772    MacroAssembler::Address argumentTagSlot(int argument)
    773773    {
    774         return MacroAssembler::Address(GPRInfo::callFrameRegister, (m_jit.codeBlock()->m_numCalleeRegisters + argumentToOperand(argument)) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
     774        return MacroAssembler::Address(GPRInfo::callFrameRegister, (-m_jit.codeBlock()->m_numCalleeRegisters + argumentToOperand(argument)) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
    775775    }
    776776
    777777    MacroAssembler::Address argumentPayloadSlot(int argument)
    778778    {
    779         return MacroAssembler::Address(GPRInfo::callFrameRegister, (m_jit.codeBlock()->m_numCalleeRegisters + argumentToOperand(argument)) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
     779        return MacroAssembler::Address(GPRInfo::callFrameRegister, (-m_jit.codeBlock()->m_numCalleeRegisters + argumentToOperand(argument)) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
    780780    }
    781781
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r155662 r155711  
    740740    m_jit.beginCall(node->codeOrigin, token);
    741741   
    742     m_jit.addPtr(TrustedImm32(m_jit.codeBlock()->m_numCalleeRegisters * sizeof(Register)), GPRInfo::callFrameRegister);
     742    m_jit.addPtr(TrustedImm32(-(m_jit.codeBlock()->m_numCalleeRegisters * sizeof(Register))), GPRInfo::callFrameRegister);
    743743   
    744744    slowPath.append(m_jit.branch32(MacroAssembler::NotEqual, calleeTagGPR, TrustedImm32(JSValue::CellTag)));
     
    44254425
    44264426        int captureEnd = symbolTable->captureEnd();
    4427         for (int i = symbolTable->captureStart(); i < captureEnd; ++i) {
     4427        for (int i = symbolTable->captureStart(); i > captureEnd; --i) {
    44284428            m_jit.loadPtr(
    44294429                JITCompiler::Address(
     
    46124612        slowArgumentOutOfBounds.link(&m_jit);
    46134613
    4614         m_jit.neg32(resultPayloadGPR);
    4615        
    46164614        m_jit.load32(
    46174615            JITCompiler::BaseIndex(
     
    46884686        slowArgumentOutOfBounds.link(&m_jit);
    46894687
    4690         m_jit.neg32(resultPayloadGPR);
    4691        
    46924688        m_jit.load32(
    46934689            JITCompiler::BaseIndex(
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r155662 r155711  
    706706    m_jit.beginCall(node->codeOrigin, token);
    707707   
    708     m_jit.addPtr(TrustedImm32(m_jit.codeBlock()->m_numCalleeRegisters * sizeof(Register)), GPRInfo::callFrameRegister);
     708    m_jit.addPtr(TrustedImm32(-(m_jit.codeBlock()->m_numCalleeRegisters * sizeof(Register))), GPRInfo::callFrameRegister);
    709709   
    710710    slowPath.append(m_jit.branchPtrWithPatch(MacroAssembler::NotEqual, calleeGPR, targetToCheck, MacroAssembler::TrustedImmPtr(0)));
     
    27652765   
    27662766            m_jit.move(propertyReg, scratch2Reg);
    2767             m_jit.neg32(scratch2Reg);
    27682767            m_jit.signExtend32ToPtr(scratch2Reg, scratch2Reg);
    27692768            m_jit.loadPtr(
     
    27752774                MacroAssembler::BaseIndex(
    27762775                    scratchReg, scratch2Reg, MacroAssembler::TimesEight,
    2777                     CallFrame::thisArgumentOffset() * sizeof(Register) - sizeof(Register)));
     2776                    CallFrame::thisArgumentOffset() * sizeof(Register) + sizeof(Register)));
    27782777           
    27792778            noResult(node);
     
    43034302
    43044303        int captureEnd = symbolTable->captureEnd();
    4305         for (int i = symbolTable->captureStart(); i < captureEnd; ++i) {
     4304        for (int i = symbolTable->captureStart(); i > captureEnd; --i) {
    43064305            m_jit.load64(
    43074306                JITCompiler::Address(
     
    44544453        slowArgumentOutOfBounds.link(&m_jit);
    44554454
    4456         m_jit.neg32(resultGPR);
    44574455        m_jit.signExtend32ToPtr(resultGPR, resultGPR);
    44584456           
     
    45194517        slowArgumentOutOfBounds.link(&m_jit);
    45204518
    4521         m_jit.neg32(resultGPR);
    45224519        m_jit.signExtend32ToPtr(resultGPR, resultGPR);
    45234520       
  • trunk/Source/JavaScriptCore/dfg/DFGValidate.cpp

    r155415 r155711  
    432432    void reportValidationContext(VirtualRegister local, BasicBlock* block)
    433433    {
     434        if (!block) {
     435            dataLog("r", static_cast<int>(local), " in null Block ");
     436            return;
     437        }
     438
    434439        dataLog("r", static_cast<int>(local), " in Block ", *block);
    435440    }
  • trunk/Source/JavaScriptCore/ftl/FTLLink.cpp

    r155023 r155711  
    7676        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=56291
    7777        jit.addPtr(
    78             CCallHelpers::TrustedImm32(codeBlock->m_numCalleeRegisters * sizeof(Register)),
     78            CCallHelpers::TrustedImm32(-codeBlock->m_numCalleeRegisters * sizeof(Register)),
    7979            GPRInfo::callFrameRegister, GPRInfo::regT1);
    8080        CCallHelpers::Jump stackCheck = jit.branchPtr(
    81             CCallHelpers::Below,
     81            CCallHelpers::Above,
    8282            CCallHelpers::AbsoluteAddress(state.graph.m_vm.interpreter->stack().addressOfEnd()),
    8383            GPRInfo::regT1);
  • trunk/Source/JavaScriptCore/heap/ConservativeRoots.cpp

    r154986 r155711  
    9494void ConservativeRoots::genericAddSpan(void* begin, void* end, MarkHook& markHook)
    9595{
    96     ASSERT(begin <= end);
     96    if (begin > end) {
     97        void* swapTemp = begin;
     98        begin = end;
     99        end = swapTemp;
     100    }
     101
    97102    ASSERT((static_cast<char*>(end) - static_cast<char*>(begin)) < 0x1000000);
    98103    ASSERT(isPointerAligned(begin));
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.cpp

    r155075 r155711  
    9595    CodeBlock* codeBlock = this->codeBlock();
    9696    ASSERT(codeBlock);
    97     return registers() + codeBlock->m_numCalleeRegisters;
     97    return registers() - codeBlock->m_numCalleeRegisters;
    9898}
    9999
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r155219 r155711  
    215215        {
    216216            ASSERT(callerFrame); // Use noCaller() rather than 0 for the outer host call frame caller.
    217             ASSERT(callerFrame == noCaller() || callerFrame->removeHostCallFrameFlag()->stack()->end() >= this);
     217            ASSERT(callerFrame == noCaller() || callerFrame->removeHostCallFrameFlag()->stack()->containsAddress(this));
    218218
    219219            setCodeBlock(codeBlock);
     
    233233        size_t argumentCount() const { return argumentCountIncludingThis() - 1; }
    234234        size_t argumentCountIncludingThis() const { return this[JSStack::ArgumentCount].payload(); }
    235         static int argumentOffset(int argument) { return s_firstArgumentOffset - argument; }
    236         static int argumentOffsetIncludingThis(int argument) { return s_thisArgumentOffset - argument; }
     235        static int argumentOffset(int argument) { return (s_firstArgumentOffset + argument); }
     236        static int argumentOffsetIncludingThis(int argument) { return (s_thisArgumentOffset + argument); }
    237237
    238238        // In the following (argument() and setArgument()), the 'argument'
     
    294294    private:
    295295        static const intptr_t HostCallFrameFlag = 1;
    296         static const int s_thisArgumentOffset = -1 - JSStack::CallFrameHeaderSize;
    297         static const int s_firstArgumentOffset = s_thisArgumentOffset - 1;
     296        static const int s_thisArgumentOffset = JSStack::CallFrameHeaderSize + 1;
     297        static const int s_firstArgumentOffset = s_thisArgumentOffset + 1;
    298298
    299299#ifndef NDEBUG
     
    319319            // Hence:
    320320            //       argIndex = s_firstArgumentOffset - offset;
    321             size_t argIndex = s_firstArgumentOffset - offset;
     321            size_t argIndex = offset - s_firstArgumentOffset;
    322322            return argIndex;
    323323        }
  • 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    }
  • trunk/Source/JavaScriptCore/interpreter/JSStack.cpp

    r154986 r155711  
    5151
    5252    m_reservation = PageReservation::reserve(roundUpAllocationSize(capacity * sizeof(Register), commitSize), OSAllocator::JSVMStackPages);
    53     m_end = static_cast<Register*>(m_reservation.base());
    54     m_commitEnd = static_cast<Register*>(m_reservation.base());
     53    m_end = highAddress();
     54    m_commitEnd = highAddress();
    5555
    5656    disableErrorStackReserve();
     
    6161JSStack::~JSStack()
    6262{
    63     void* base = m_reservation.base();
    64     m_reservation.decommit(base, reinterpret_cast<intptr_t>(m_commitEnd) - reinterpret_cast<intptr_t>(base));
    65     addToCommittedByteCount(-(reinterpret_cast<intptr_t>(m_commitEnd) - reinterpret_cast<intptr_t>(base)));
     63    void* highAddress = reinterpret_cast_ptr<void*>(static_cast<char*>(m_reservation.base()) + m_reservation.size());
     64    m_reservation.decommit(reinterpret_cast_ptr<void*>(m_commitEnd), reinterpret_cast<intptr_t>(highAddress) - reinterpret_cast<intptr_t>(m_commitEnd));
     65    addToCommittedByteCount(-(reinterpret_cast<intptr_t>(highAddress) - reinterpret_cast<intptr_t>(m_commitEnd)));
    6666    m_reservation.deallocate();
    6767}
     
    7171    // If we have already committed enough memory to satisfy this request,
    7272    // just update the end pointer and return.
    73     if (newEnd <= m_commitEnd) {
     73    if (newEnd >= m_commitEnd) {
    7474        m_end = newEnd;
    7575        return true;
     
    7979    // have it is still within our budget. If not, we'll fail to grow and
    8080    // return false.
    81     long delta = roundUpAllocationSize(reinterpret_cast<char*>(newEnd) - reinterpret_cast<char*>(m_commitEnd), commitSize);
    82     if (reinterpret_cast<char*>(m_commitEnd) + delta > reinterpret_cast<char*>(m_useableEnd))
     81    long delta = roundUpAllocationSize(reinterpret_cast<char*>(m_commitEnd) - reinterpret_cast<char*>(newEnd), commitSize);
     82    if (reinterpret_cast<char*>(m_commitEnd) - delta <= reinterpret_cast<char*>(m_useableEnd))
    8383        return false;
    8484
    8585    // Otherwise, the growth is still within our budget. Go ahead and commit
    8686    // it and return true.
    87     m_reservation.commit(m_commitEnd, delta);
     87    m_reservation.commit(reinterpret_cast<char*>(m_commitEnd) - delta, delta);
    8888    addToCommittedByteCount(delta);
    89     m_commitEnd = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(m_commitEnd) + delta);
     89    m_commitEnd = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(m_commitEnd) - delta);
    9090    m_end = newEnd;
    9191    return true;
     
    9494void JSStack::gatherConservativeRoots(ConservativeRoots& conservativeRoots)
    9595{
    96     conservativeRoots.add(begin(), getTopOfStack());
     96    conservativeRoots.add(getBaseOfStack(), getTopOfStack());
    9797}
    9898
    9999void JSStack::gatherConservativeRoots(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSet& codeBlocks)
    100100{
    101     conservativeRoots.add(begin(), getTopOfStack(), jitStubRoutines, codeBlocks);
     101    conservativeRoots.add(getBaseOfStack(), getTopOfStack(), jitStubRoutines, codeBlocks);
    102102}
    103103
    104104void JSStack::releaseExcessCapacity()
    105105{
    106     ptrdiff_t delta = reinterpret_cast<uintptr_t>(m_commitEnd) - reinterpret_cast<uintptr_t>(m_reservation.base());
    107     m_reservation.decommit(m_reservation.base(), delta);
     106    ptrdiff_t delta = reinterpret_cast<uintptr_t>(highAddress()) - reinterpret_cast<uintptr_t>(m_commitEnd);
     107    m_reservation.decommit(m_commitEnd, delta);
    108108    addToCommittedByteCount(-delta);
    109     m_commitEnd = static_cast<Register*>(m_reservation.base());
     109    m_commitEnd = highAddress();
    110110}
    111111
     
    135135void JSStack::disableErrorStackReserve()
    136136{
    137     char* useableEnd = reinterpret_cast<char*>(reservationEnd()) - commitSize;
     137    char* useableEnd = reinterpret_cast<char*>(reservationEnd()) + commitSize;
    138138    m_useableEnd = reinterpret_cast_ptr<Register*>(useableEnd);
    139139
     
    143143    // enabled the reserve was not previously in use. Hence, it is safe to
    144144    // shrink back to that m_useableEnd.
    145     if (m_end > m_useableEnd) {
    146         ASSERT(m_topCallFrame->frameExtent() <= m_useableEnd);
     145    if (m_end < m_useableEnd) {
     146        ASSERT(m_topCallFrame->frameExtent() >= m_useableEnd);
    147147        shrink(m_useableEnd);
    148148    }
  • trunk/Source/JavaScriptCore/interpreter/JSStack.h

    r154986 r155711  
    5555            CallFrameHeaderSize = 6,
    5656
    57             ArgumentCount = -6,
    58             CallerFrame = -5,
    59             Callee = -4,
    60             ScopeChain = -3,
    61             ReturnPC = -2, // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
    62             CodeBlock = -1,
     57            ArgumentCount = 6,
     58            CallerFrame = 5,
     59            Callee = 4,
     60            ScopeChain = 3,
     61            ReturnPC = 2, // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
     62            CodeBlock = 1,
    6363        };
    6464
     
    7474        void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&);
    7575
    76         Register* begin() const { return static_cast<Register*>(m_reservation.base()); }
    77         Register* end() const { return m_end; }
    78         size_t size() const { return end() - begin(); }
     76        Register* getBaseOfStack() const
     77        {
     78            return highAddress() - 1;
     79        }
     80
     81        Register* getLimitOfStack() const { return m_end; }
     82        size_t size() const { return highAddress() - lowAddress(); }
    7983
    8084        bool grow(Register*);
     
    9195        Register* getStartOfFrame(CallFrame*);
    9296        Register* getTopOfStack();
     97        Register* end() const { return m_end; }
    9398
    9499        CallFrame* pushFrame(CallFrame* callerFrame, class CodeBlock*,
     
    96101
    97102        void popFrame(CallFrame*);
     103
     104        bool containsAddress(Register* address) { return (lowAddress() <= address && address <= highAddress()); }
    98105
    99106        void enableErrorStackReserve();
     
    110117
    111118    private:
     119        Register* lowAddress() const
     120        {
     121            return m_end;
     122        }
     123
     124        Register* highAddress() const
     125        {
     126            return reinterpret_cast_ptr<Register*>(static_cast<char*>(m_reservation.base()) + m_reservation.size());
     127        }
     128
    112129        Register* reservationEnd() const
    113130        {
    114             char* base = static_cast<char*>(m_reservation.base());
    115             char* reservationEnd = base + m_reservation.size();
     131            char* reservationEnd = static_cast<char*>(m_reservation.base());
    116132            return reinterpret_cast_ptr<Register*>(reservationEnd);
    117133        }
     
    143159            return;
    144160        m_end = newEnd;
    145         if (m_end == m_reservation.base() && (m_commitEnd - begin()) >= maxExcessCapacity)
     161        if (m_end == getBaseOfStack() && (m_commitEnd - getBaseOfStack()) >= maxExcessCapacity)
    146162            releaseExcessCapacity();
    147163    }
     
    149165    inline bool JSStack::grow(Register* newEnd)
    150166    {
    151         if (newEnd <= m_end)
     167        if (newEnd >= m_end)
    152168            return true;
    153169        return growSlowCase(newEnd);
  • trunk/Source/JavaScriptCore/interpreter/JSStackInlines.h

    r149980 r155711  
    3636{
    3737    if (UNLIKELY(!frame))
    38         return begin();
     38        return getBaseOfStack();
    3939    return frame->frameExtent();
    4040}
     
    6565    }
    6666
    67     Register* newCallFrameSlot = oldEnd + paddedArgsCount + JSStack::CallFrameHeaderSize;
     67    Register* newCallFrameSlot = oldEnd - paddedArgsCount - JSStack::CallFrameHeaderSize;
     68
    6869#if ENABLE(DEBUG_JSSTACK)
    69     newCallFrameSlot += JSStack::FenceSize;
     70    newCallFrameSlot -= JSStack::FenceSize;
    7071#endif
     72
    7173    Register* newEnd = newCallFrameSlot;
    7274    if (!!codeBlock)
    73         newEnd += codeBlock->m_numCalleeRegisters;
     75        newEnd -= codeBlock->m_numCalleeRegisters;
    7476
    7577    // Ensure that we have the needed stack capacity to push the new frame:
     
    121123    // are no more frames on the stack.
    122124    if (!callerFrame)
    123         shrink(begin());
     125        shrink(getBaseOfStack());
    124126
    125127    installTrapsAfterFrame(callerFrame);
     
    213215    const int sizeOfTrap = 64;
    214216    int32_t* startOfTrap = reinterpret_cast<int32_t*>(topOfFrame);
    215     int32_t* endOfTrap = startOfTrap + sizeOfTrap;
     217    int32_t* endOfTrap = startOfTrap - sizeOfTrap;
    216218    int32_t* endOfCommitedMemory = reinterpret_cast<int32_t*>(m_commitEnd);
    217219
    218220    // Make sure we're not exceeding the amount of available memory to write to:
    219     if (endOfTrap > endOfCommitedMemory)
     221    if (endOfTrap < endOfCommitedMemory)
    220222        endOfTrap = endOfCommitedMemory;
    221223
    222224    // Lay the traps:
    223225    int32_t* p = startOfTrap;
    224     while (p < endOfTrap)
    225         *p++ = 0xabadcafe; // A bad word to trigger a crash if deref'ed.
     226    while (p > endOfTrap)
     227        *p-- = 0xabadcafe; // A bad word to trigger a crash if deref'ed.
    226228}
    227229#endif // ENABLE(DEBUG_JSSTACK)
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp

    r155613 r155711  
    118118
    119119#if ENABLE(DFG_JIT)
    120 static unsigned inlinedFrameOffset(CodeOrigin* codeOrigin)
     120static int inlinedFrameOffset(CodeOrigin* codeOrigin)
    121121{
    122122    InlineCallFrame* inlineCallFrame = codeOrigin->inlineCallFrame;
    123     unsigned frameOffset = inlineCallFrame ? inlineCallFrame->stackOffset : 0;
     123    int frameOffset = inlineCallFrame ? inlineCallFrame->stackOffset : 0;
    124124    return frameOffset;
    125125}
     
    130130    ASSERT(!callFrame->hasHostCallFrameFlag());
    131131
    132     unsigned frameOffset = inlinedFrameOffset(codeOrigin);
     132    int frameOffset = inlinedFrameOffset(codeOrigin);
    133133    bool isInlined = !!frameOffset;
    134134    if (isInlined) {
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r155023 r155711  
    617617#endif
    618618
    619         addPtr(TrustedImm32(m_codeBlock->m_numCalleeRegisters * sizeof(Register)), callFrameRegister, regT1);
    620         stackCheck = branchPtr(Below, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT1);
     619        addPtr(TrustedImm32(-m_codeBlock->m_numCalleeRegisters * sizeof(Register)), callFrameRegister, regT1);
     620        stackCheck = branchPtr(Above, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT1);
    621621    }
    622622
  • trunk/Source/JavaScriptCore/jit/JITCall.cpp

    r153231 r155711  
    8989
    9090        move(regT0, regT1);
    91         add32(TrustedImm32(firstFreeRegister + JSStack::CallFrameHeaderSize), regT1);
    92         lshift32(TrustedImm32(3), regT1);
     91        neg64(regT1);
     92        add64(TrustedImm32(firstFreeRegister - JSStack::CallFrameHeaderSize), regT1);
     93        lshift64(TrustedImm32(3), regT1);
    9394        addPtr(callFrameRegister, regT1);
    9495        // regT1: newCallFrame
    9596
    96         slowCase.append(branchPtr(Below, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT1));
     97        slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT1));
    9798
    9899        // Initialize ArgumentCount.
     
    104105
    105106        // Copy arguments.
    106         neg32(regT0);
    107107        signExtend32ToPtr(regT0, regT0);
    108         end.append(branchAdd64(Zero, TrustedImm32(1), regT0));
    109         // regT0: -argumentCount
     108        end.append(branchSub64(Zero, TrustedImm32(1), regT0));
     109        // regT0: argumentCount
    110110
    111111        Label copyLoop = label();
    112112        load64(BaseIndex(callFrameRegister, regT0, TimesEight, CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register))), regT2);
    113113        store64(regT2, BaseIndex(regT1, regT0, TimesEight, CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register))));
    114         branchAdd64(NonZero, TrustedImm32(1), regT0).linkTo(copyLoop, this);
     114        branchSub64(NonZero, TrustedImm32(1), regT0).linkTo(copyLoop, this);
    115115
    116116        end.append(jump());
     
    176176    else {
    177177        int argCount = instruction[3].u.operand;
    178         int registerOffset = instruction[4].u.operand;
     178        int registerOffset = -instruction[4].u.operand;
    179179
    180180        if (opcodeID == op_call && shouldEmitProfiling()) {
  • trunk/Source/JavaScriptCore/jit/JITCall32_64.cpp

    r153231 r155711  
    158158
    159159        move(regT2, regT3);
    160         add32(TrustedImm32(firstFreeRegister + JSStack::CallFrameHeaderSize), regT3);
     160        neg32(regT3);
     161        add32(TrustedImm32(firstFreeRegister - JSStack::CallFrameHeaderSize), regT3);
    161162        lshift32(TrustedImm32(3), regT3);
    162163        addPtr(callFrameRegister, regT3);
    163164        // regT3: newCallFrame
    164165
    165         slowCase.append(branchPtr(Below, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT3));
     166        slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT3));
    166167
    167168        // Initialize ArgumentCount.
     
    174175
    175176        // Copy arguments.
    176         neg32(regT2);
    177         end.append(branchAdd32(Zero, TrustedImm32(1), regT2));
    178         // regT2: -argumentCount;
     177        end.append(branchSub32(Zero, TrustedImm32(1), regT2));
     178        // regT2: argumentCount;
    179179
    180180        Label copyLoop = label();
     
    183183        store32(regT0, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))));
    184184        store32(regT1, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))));
    185         branchAdd32(NonZero, TrustedImm32(1), regT2).linkTo(copyLoop, this);
     185        branchSub32(NonZero, TrustedImm32(1), regT2).linkTo(copyLoop, this);
    186186
    187187        end.append(jump());
     
    247247    else {
    248248        int argCount = instruction[3].u.operand;
    249         int registerOffset = instruction[4].u.operand;
     249        int registerOffset = -instruction[4].u.operand;
    250250       
    251251        if (opcodeID == op_call && shouldEmitProfiling()) {
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r155418 r155711  
    845845   
    846846    Jump activationCreated = branchTest64(NonZero, Address(callFrameRegister, sizeof(Register) * dst));
    847     JITStubCall(this, cti_op_push_activation).call(currentInstruction[1].u.operand);
    848     emitPutVirtualRegister(dst);
     847    JITStubCall(this, cti_op_push_activation).call(dst);
    849848    activationCreated.link(this);
    850849}
     
    11161115    addSlowCase(branch32(AboveOrEqual, regT1, regT2));
    11171116
    1118     neg32(regT1);
    11191117    signExtend32ToPtr(regT1, regT1);
    11201118    load64(BaseIndex(callFrameRegister, regT1, TimesEight, CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register))), regT0);
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r155418 r155711  
    12441244    addSlowCase(branch32(AboveOrEqual, regT2, regT3));
    12451245   
    1246     neg32(regT2);
    12471246    loadPtr(BaseIndex(callFrameRegister, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload) + CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register))), regT0);
    12481247    loadPtr(BaseIndex(callFrameRegister, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag) + CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register))), regT1);
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r155023 r155711  
    409409    CallFrame* callFrame = newCallFrame->callerFrame()->removeHostCallFrameFlag();
    410410    jitStackFrame.callFrame = callFrame;
     411    ASSERT(callFrame);
    411412    callFrame->vm().topCallFrame = callFrame;
    412413    if (createError)
     
    439440    CallFrame* callFrame = stackFrame.callFrame;
    440441
    441     if (UNLIKELY(!stackFrame.stack->grow(&callFrame->registers()[callFrame->codeBlock()->m_numCalleeRegisters]))) {
     442    if (UNLIKELY(!stackFrame.stack->grow(&callFrame->registers()[-callFrame->codeBlock()->m_numCalleeRegisters]))) {
    442443        ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError);
    443444        return throwExceptionFromOpCall<void*>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor);
     
    14781479    STUB_INIT_STACK_FRAME(stackFrame);
    14791480
    1480     return constructArray(stackFrame.callFrame, stackFrame.args[2].arrayAllocationProfile(), reinterpret_cast<JSValue*>(&stackFrame.callFrame->registers()[stackFrame.args[0].int32()]), stackFrame.args[1].int32());
     1481    return constructArrayNegativeIndexed(stackFrame.callFrame, stackFrame.args[2].arrayAllocationProfile(), reinterpret_cast<JSValue*>(&stackFrame.callFrame->registers()[stackFrame.args[0].int32()]), stackFrame.args[1].int32());
    14811482}
    14821483
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r154797 r155711  
    429429    jit.pop(JSInterfaceJIT::regT4);
    430430#  endif
    431     jit.addPtr(JSInterfaceJIT::TrustedImm32(-8), JSInterfaceJIT::callFrameRegister, JSInterfaceJIT::regT3);
     431    jit.neg64(JSInterfaceJIT::regT0);
     432    jit.addPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::callFrameRegister, JSInterfaceJIT::regT3);
    432433    jit.load32(JSInterfaceJIT::Address(JSInterfaceJIT::callFrameRegister, JSStack::ArgumentCount * 8), JSInterfaceJIT::regT2);
    433434    jit.add32(JSInterfaceJIT::TrustedImm32(JSStack::CallFrameHeaderSize), JSInterfaceJIT::regT2);
    434435
    435     // Move current frame regT0 number of slots
     436    // Move current frame down regT0 number of slots
    436437    JSInterfaceJIT::Label copyLoop(jit.label());
    437438    jit.load64(JSInterfaceJIT::regT3, JSInterfaceJIT::regT1);
    438439    jit.store64(JSInterfaceJIT::regT1, MacroAssembler::BaseIndex(JSInterfaceJIT::regT3, JSInterfaceJIT::regT0, JSInterfaceJIT::TimesEight));
    439     jit.subPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::regT3);
     440    jit.addPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::regT3);
    440441    jit.branchSub32(MacroAssembler::NonZero, JSInterfaceJIT::TrustedImm32(1), JSInterfaceJIT::regT2).linkTo(copyLoop, &jit);
    441442
     
    445446    JSInterfaceJIT::Label fillUndefinedLoop(jit.label());
    446447    jit.store64(JSInterfaceJIT::regT1, MacroAssembler::BaseIndex(JSInterfaceJIT::regT3, JSInterfaceJIT::regT0, JSInterfaceJIT::TimesEight));
    447     jit.subPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::regT3);
    448     jit.branchSub32(MacroAssembler::NonZero, JSInterfaceJIT::TrustedImm32(1), JSInterfaceJIT::regT2).linkTo(fillUndefinedLoop, &jit);
     448    jit.addPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::regT3);
     449    jit.branchAdd32(MacroAssembler::NonZero, JSInterfaceJIT::TrustedImm32(1), JSInterfaceJIT::regT2).linkTo(fillUndefinedLoop, &jit);
    449450
    450451    // Adjust call frame register to account for missing args
    451     jit.lshift32(JSInterfaceJIT::TrustedImm32(3), JSInterfaceJIT::regT0);
     452    jit.lshift64(JSInterfaceJIT::TrustedImm32(3), JSInterfaceJIT::regT0);
    452453    jit.addPtr(JSInterfaceJIT::regT0, JSInterfaceJIT::callFrameRegister);
    453454
     
    460461    jit.pop(JSInterfaceJIT::regT4);
    461462#  endif
    462     jit.addPtr(JSInterfaceJIT::TrustedImm32(-8), JSInterfaceJIT::callFrameRegister, JSInterfaceJIT::regT3);
     463    jit.neg32(JSInterfaceJIT::regT0);
     464    jit.addPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::callFrameRegister, JSInterfaceJIT::regT3);
    463465    jit.load32(JSInterfaceJIT::Address(JSInterfaceJIT::callFrameRegister, JSStack::ArgumentCount * 8), JSInterfaceJIT::regT2);
    464466    jit.add32(JSInterfaceJIT::TrustedImm32(JSStack::CallFrameHeaderSize), JSInterfaceJIT::regT2);
    465467
    466     // Move current frame regT0 number of slots
     468    // Move current frame down regT0 number of slots
    467469    JSInterfaceJIT::Label copyLoop(jit.label());
    468470    jit.load32(JSInterfaceJIT::regT3, JSInterfaceJIT::regT1);
     
    470472    jit.load32(MacroAssembler::Address(JSInterfaceJIT::regT3, 4), JSInterfaceJIT::regT1);
    471473    jit.store32(JSInterfaceJIT::regT1, MacroAssembler::BaseIndex(JSInterfaceJIT::regT3, JSInterfaceJIT::regT0, JSInterfaceJIT::TimesEight, 4));
    472     jit.subPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::regT3);
     474    jit.addPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::regT3);
    473475    jit.branchSub32(MacroAssembler::NonZero, JSInterfaceJIT::TrustedImm32(1), JSInterfaceJIT::regT2).linkTo(copyLoop, &jit);
    474476
     
    481483    jit.store32(JSInterfaceJIT::regT1, MacroAssembler::BaseIndex(JSInterfaceJIT::regT3, JSInterfaceJIT::regT0, JSInterfaceJIT::TimesEight, 4));
    482484
    483     jit.subPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::regT3);
    484     jit.branchSub32(MacroAssembler::NonZero, JSInterfaceJIT::TrustedImm32(1), JSInterfaceJIT::regT2).linkTo(fillUndefinedLoop, &jit);
     485    jit.addPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::regT3);
     486    jit.branchAdd32(MacroAssembler::NonZero, JSInterfaceJIT::TrustedImm32(1), JSInterfaceJIT::regT2).linkTo(fillUndefinedLoop, &jit);
    485487
    486488    // Adjust call frame register to account for missing args
  • trunk/Source/JavaScriptCore/llint/LLIntData.cpp

    r153221 r155711  
    7272    // prepared to change LowLevelInterpreter.asm as well!!
    7373    ASSERT(JSStack::CallFrameHeaderSize * 8 == 48);
    74     ASSERT(JSStack::ArgumentCount * 8 == -48);
    75     ASSERT(JSStack::CallerFrame * 8 == -40);
    76     ASSERT(JSStack::Callee * 8 == -32);
    77     ASSERT(JSStack::ScopeChain * 8 == -24);
    78     ASSERT(JSStack::ReturnPC * 8 == -16);
    79     ASSERT(JSStack::CodeBlock * 8 == -8);
    80     ASSERT(CallFrame::argumentOffsetIncludingThis(0) == -JSStack::CallFrameHeaderSize - 1);
     74    ASSERT(JSStack::ArgumentCount * 8 == 48);
     75    ASSERT(JSStack::CallerFrame * 8 == 40);
     76    ASSERT(JSStack::Callee * 8 == 32);
     77    ASSERT(JSStack::ScopeChain * 8 == 24);
     78    ASSERT(JSStack::ReturnPC * 8 == 16);
     79    ASSERT(JSStack::CodeBlock * 8 == 8);
     80    ASSERT(CallFrame::argumentOffsetIncludingThis(0) == JSStack::CallFrameHeaderSize + 1);
    8181#if CPU(BIG_ENDIAN)
    8282    ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag) == 0);
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r154935 r155711  
    246246LLINT_SLOW_PATH_DECL(trace)
    247247{
    248     dataLogF("%p / %p: executing bc#%zu, %s, scope %p\n",
     248    dataLogF("%p / %p: executing bc#%zu, %s, scope %p, pc = %p\n",
    249249            exec->codeBlock(),
    250250            exec,
    251251            static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
    252252            opcodeNames[exec->vm().interpreter->getOpcodeID(pc[0].u.opcode)],
    253             exec->scope());
     253            exec->scope(), pc);
    254254    if (exec->vm().interpreter->getOpcodeID(pc[0].u.opcode) == op_ret) {
    255255        dataLogF("Will be returning to %p\n", exec->returnPC().value());
     
    430430    dataLogF("Current end is at %p.\n", exec->vm().interpreter->stack().end());
    431431#endif
    432     ASSERT(&exec->registers()[exec->codeBlock()->m_numCalleeRegisters] > exec->vm().interpreter->stack().end());
    433     if (UNLIKELY(!vm.interpreter->stack().grow(&exec->registers()[exec->codeBlock()->m_numCalleeRegisters]))) {
     432    ASSERT(!exec->vm().interpreter->stack().containsAddress(&exec->registers()[-exec->codeBlock()->m_numCalleeRegisters]));
     433    if (UNLIKELY(!vm.interpreter->stack().grow(&exec->registers()[-exec->codeBlock()->m_numCalleeRegisters]))) {
    434434        ReturnAddressPtr returnPC = exec->returnPC();
    435435        exec = exec->callerFrame();
     
    460460{
    461461    LLINT_BEGIN();
    462     LLINT_RETURN(constructArray(exec, pc[4].u.arrayAllocationProfile, bitwise_cast<JSValue*>(&LLINT_OP(2)), pc[3].u.operand));
     462    LLINT_RETURN(constructArrayNegativeIndexed(exec, pc[4].u.arrayAllocationProfile, bitwise_cast<JSValue*>(&LLINT_OP(2)), pc[3].u.operand));
    463463}
    464464
     
    10551055    JSValue calleeAsValue = LLINT_OP_C(2).jsValue();
    10561056   
    1057     ExecState* execCallee = exec + pc[4].u.operand;
     1057    ExecState* execCallee = exec - pc[4].u.operand;
    10581058   
    10591059    execCallee->setArgumentCountIncludingThis(pc[3].u.operand);
     
    11041104    JSValue calleeAsValue = LLINT_OP(2).jsValue();
    11051105   
    1106     ExecState* execCallee = exec + pc[4].u.operand;
     1106    ExecState* execCallee = exec - pc[4].u.operand;
    11071107   
    11081108    execCallee->setArgumentCountIncludingThis(pc[3].u.operand);
     
    11441144{
    11451145    LLINT_BEGIN();
    1146     LLINT_RETURN(jsString(exec, &LLINT_OP(2), pc[3].u.operand));
     1146    LLINT_RETURN(jsStringFromRegisterArray(exec, &LLINT_OP(2), pc[3].u.operand));
    11471147}
    11481148
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r153232 r155711  
    3434const CallFrameHeaderSize = 48
    3535const CallFrameHeaderSlots = 6
    36 const ArgumentCount = -48
    37 const CallerFrame = -40
    38 const Callee = -32
    39 const ScopeChain = -24
    40 const ReturnPC = -16
    41 const CodeBlock = -8
    42 
    43 const ThisArgumentOffset = -CallFrameHeaderSize - 8
     36const ArgumentCount = 48
     37const CallerFrame = 40
     38const Callee = 32
     39const ScopeChain = 24
     40const ReturnPC = 16
     41const CodeBlock = 8
     42
     43const ThisArgumentOffset = CallFrameHeaderSize + 8
    4444
    4545# Some value representation constants.
     
    6767if JSVALUE64
    6868    # - Use a pair of registers to represent the PC: one register for the
    69     #   base of the stack, and one register for the index.
     69    #   base of the bytecodes, and one register for the index.
    7070    # - The PC base (or PB for short) should be stored in the csr. It will
    7171    #   get clobbered on calls to other JS code, but will get saved on calls
     
    351351        loadp CodeBlock::m_argumentValueProfiles + VectorBufferOffset[t1], t3
    352352        mulp sizeof ValueProfile, t0, t2 # Aaaaahhhh! Need strength reduction!
    353         negp t0
    354353        lshiftp 3, t0
    355354        addp t2, t3
    356355    .argumentProfileLoop:
    357356        if JSVALUE64
    358             loadq ThisArgumentOffset + 8 - profileArgSkip * 8[cfr, t0], t2
     357            loadq ThisArgumentOffset - 8 + profileArgSkip * 8[cfr, t0], t2
    359358            subp sizeof ValueProfile, t3
    360359            storeq t2, profileArgSkip * sizeof ValueProfile + ValueProfile::m_buckets[t3]
    361360        else
    362             loadi ThisArgumentOffset + TagOffset + 8 - profileArgSkip * 8[cfr, t0], t2
     361            loadi ThisArgumentOffset + TagOffset - 8 + profileArgSkip * 8[cfr, t0], t2
    363362            subp sizeof ValueProfile, t3
    364363            storei t2, profileArgSkip * sizeof ValueProfile + ValueProfile::m_buckets + TagOffset[t3]
    365             loadi ThisArgumentOffset + PayloadOffset + 8 - profileArgSkip * 8[cfr, t0], t2
     364            loadi ThisArgumentOffset + PayloadOffset - 8 + profileArgSkip * 8[cfr, t0], t2
    366365            storei t2, profileArgSkip * sizeof ValueProfile + ValueProfile::m_buckets + PayloadOffset[t3]
    367366        end
    368         baddpnz 8, t0, .argumentProfileLoop
     367        baddpnz -8, t0, .argumentProfileLoop
    369368    .argumentProfileDone:
    370369    end
     
    374373    loadp CodeBlock::m_vm[t1], t2
    375374    loadp VM::interpreter[t2], t2   # FIXME: Can get to the JSStack from the JITStackFrame
    376     lshifti 3, t0
    377     addp t0, cfr, t0
    378     bpaeq Interpreter::m_stack + JSStack::m_end[t2], t0, .stackHeightOK
     375    lshiftp 3, t0
     376    subp cfr, t0, t0
     377    bpbeq Interpreter::m_stack + JSStack::m_end[t2], t0, .stackHeightOK
    379378
    380379    # Stack height check failed - need to call a slow_path.
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

    r154797 r155711  
    314314    btiz t1, .continue
    315315
    316     // Move frame down "t1" slots
     316    // Move frame up "t1" slots
     317    negi t1
    317318    move cfr, t3
    318     subp 8, t3
     319    addp 8, t3
    319320    loadi PayloadOffset + ArgumentCount[cfr], t2
    320321    addi CallFrameHeaderSlots, t2
     
    324325    loadi TagOffset[t3], t0
    325326    storei t0, TagOffset[t3, t1, 8]
    326     subp 8, t3
     327    addp 8, t3
    327328    bsubinz 1, t2, .copyLoop
    328329
     
    334335    move UndefinedTag, t0
    335336    storei t0, TagOffset[t3, t1, 8]
    336     subp 8, t3
    337     bsubinz 1, t2, .fillLoop
     337    addp 8, t3
     338    baddinz 1, t2, .fillLoop
    338339
    339340    lshiftp 3, t1
     
    356357    move UndefinedTag, t0
    357358    move 0, t1
     359    negi t2
    358360.opEnterLoop:
    359     subi 1, t2
     361    addi 1, t2
    360362    storei t0, TagOffset[cfr, t2, 8]
    361363    storei t1, PayloadOffset[cfr, t2, 8]
     
    12331235    loadi ArgumentCount + PayloadOffset[cfr], t1
    12341236    biaeq t2, t1, .opGetArgumentByValSlow
    1235     negi t2
    12361237    loadi 4[PC], t3
    12371238    loadi ThisArgumentOffset + TagOffset[cfr, t2, 8], t0
     
    15751576    if VALUE_PROFILER
    15761577        loadi 16[PC], t3
     1578        negi t3
    15771579        bineq ThisArgumentOffset + TagOffset[cfr, t3, 8], CellTag, .done
    15781580        loadi ThisArgumentOffset + PayloadOffset[cfr, t3, 8], t0
     
    15921594    loadi 16[PC], t3
    15931595    lshifti 3, t3
     1596    negi t3
    15941597    addp cfr, t3  # t3 contains the new value of cfr
    15951598    loadp JSFunction::m_scope[t2], t0
     
    16221625    traceExecution()
    16231626    loadi 4[PC], t0
    1624     subi 1, t0   # Get the unmodifiedArgumentsRegister
     1627    addi 1, t0   # Get the unmodifiedArgumentsRegister
    16251628    bieq TagOffset[cfr, t0, 8], EmptyValueTag, .opTearOffArgumentsNotCreated
    16261629    callSlowPath(_llint_slow_path_tear_off_arguments)
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r154797 r155711  
    200200    btiz t1, .continue
    201201
    202     // Move frame down "t1" slots
     202    // Move frame up "t1" slots
     203    negq t1
    203204    move cfr, t3
    204     subp 8, t3
     205    addp 8, t3
    205206    loadi PayloadOffset + ArgumentCount[cfr], t2
    206207    addi CallFrameHeaderSlots, t2
     
    208209    loadq [t3], t0
    209210    storeq t0, [t3, t1, 8]
    210     subp 8, t3
     211    addp 8, t3
    211212    bsubinz 1, t2, .copyLoop
    212213
     
    216217.fillLoop:
    217218    storeq t0, [t3, t1, 8]
    218     subp 8, t3
    219     bsubinz 1, t2, .fillLoop
     219    addp 8, t3
     220    baddinz 1, t2, .fillLoop
    220221
    221222    lshiftp 3, t1
     
    239240    btiz t2, .opEnterDone
    240241    move ValueUndefined, t0
     242    negi t2
     243    sxi2q t2, t2
    241244.opEnterLoop:
    242     subi 1, t2
     245    addq 1, t2
    243246    storeq t0, [cfr, t2, 8]
    244     btinz t2, .opEnterLoop
     247    btqnz t2, .opEnterLoop
    245248.opEnterDone:
    246249    dispatch(1)
     
    10801083    loadi ArgumentCount + PayloadOffset[cfr], t1
    10811084    biaeq t2, t1, .opGetArgumentByValSlow
    1082     negi t2
    1083     sxi2q t2, t2
    10841085    loadisFromInstruction(1, t3)
    10851086    loadpFromInstruction(5, t1)
     
    14231424    if VALUE_PROFILER
    14241425        loadisFromInstruction(4, t3)
     1426        negp t3
    14251427        loadq ThisArgumentOffset[cfr, t3, 8], t0
    14261428        btqnz t0, tagMask, .done
     
    14401442    loadisFromInstruction(4, t3)
    14411443    lshifti 3, t3
     1444    negp t3
    14421445    addp cfr, t3
    14431446    loadp JSFunction::m_scope[t2], t0
     
    14681471    traceExecution()
    14691472    loadisFromInstruction(1, t0)
    1470     subi 1, t0   # Get the unmodifiedArgumentsRegister
     1473    addq 1, t0   # Get the unmodifiedArgumentsRegister
    14711474    btqz [cfr, t0, 8], .opTearOffArgumentsNotCreated
    14721475    callSlowPath(_llint_slow_path_tear_off_arguments)
  • trunk/Source/JavaScriptCore/runtime/ArgList.cpp

    r140718 r155711  
    3838    }
    3939
    40     result.m_args = m_args - startIndex;
     40    result.m_args = m_args + startIndex;
    4141    result.m_argCount =  m_argCount - startIndex;
    4242}
     
    5555{
    5656    int newCapacity = m_capacity * 4;
    57     EncodedJSValue* newBuffer = &(new EncodedJSValue[newCapacity])[newCapacity - 1];
     57    EncodedJSValue* newBuffer = new EncodedJSValue[newCapacity];
    5858    for (int i = 0; i < m_capacity; ++i)
    59         newBuffer[-i] = m_buffer[-i];
     59        newBuffer[i] = m_buffer[i];
    6060
    6161    if (EncodedJSValue* base = mallocBase())
  • trunk/Source/JavaScriptCore/runtime/ArgList.h

    r148696 r155711  
    4747        : m_size(0)
    4848        , m_capacity(inlineCapacity)
    49         , m_buffer(&m_inlineBuffer[m_capacity - 1])
     49        , m_buffer(m_inlineBuffer)
    5050        , m_markSet(0)
    5151    {
     
    105105    EncodedJSValue& slotFor(int item) const
    106106    {
    107         return m_buffer[-item];
     107        return m_buffer[item];
    108108    }
    109109       
     
    112112        if (m_capacity == static_cast<int>(inlineCapacity))
    113113            return 0;
    114         return &slotFor(m_capacity - 1);
     114        return &slotFor(0);
    115115    }
    116116       
     
    164164        if (i >= m_argCount)
    165165            return jsUndefined();
    166         return m_args[-i];
     166        return m_args[i];
    167167    }
    168168
  • trunk/Source/JavaScriptCore/runtime/Arguments.cpp

    r154422 r155711  
    313313   
    314314    m_registerArray = adoptArrayPtr(new WriteBarrier<Unknown>[m_numArguments]);
    315     m_registers = m_registerArray.get() + CallFrame::offsetFor(m_numArguments + 1);
     315    m_registers = m_registerArray.get() - CallFrame::offsetFor(1) - 1;
    316316
    317317    // If we have a captured argument that logically aliases activation storage,
     
    359359   
    360360    m_registerArray = adoptArrayPtr(new WriteBarrier<Unknown>[m_numArguments]);
    361     m_registers = m_registerArray.get() + CallFrame::offsetFor(m_numArguments + 1);
     361    m_registers = m_registerArray.get() - CallFrame::offsetFor(1) - 1;
    362362
    363363    tearOffForInlineCallFrame(
  • trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp

    r155143 r155711  
    7777{
    7878    if (!length.isNumber())
    79         return constructArray(exec, profile, globalObject, &length, 1);
     79        return constructArrayNegativeIndexed(exec, profile, globalObject, &length, 1);
    8080   
    8181    uint32_t n = length.toUInt32(exec);
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r154824 r155711  
    464464{
    465465    BEGIN();
    466     RETURN(jsString(exec, &OP(2), pc[3].u.operand));
     466    RETURN(jsStringFromRegisterArray(exec, &OP(2), pc[3].u.operand));
    467467}
    468468
  • trunk/Source/JavaScriptCore/runtime/JSActivation.h

    r155657 r155711  
    136136    inline int JSActivation::registersOffset(SharedSymbolTable* symbolTable)
    137137    {
    138         return storageOffset() - (symbolTable->captureStart() * sizeof(WriteBarrier<Unknown>));
     138        return storageOffset() + ((symbolTable->captureCount() - symbolTable->captureStart()  - 1) * sizeof(WriteBarrier<Unknown>));
    139139    }
    140140
     
    148148
    149149        int captureEnd = symbolTable()->captureEnd();
    150         for (int i = symbolTable()->captureStart(); i < captureEnd; ++i)
     150        for (int i = symbolTable()->captureStart(); i > captureEnd; --i)
    151151            dst[i].set(vm, this, src[i].get());
    152152
     
    181181    inline bool JSActivation::isValidIndex(int index) const
    182182    {
    183         if (index < symbolTable()->captureStart())
     183        if (index > symbolTable()->captureStart())
    184184            return false;
    185         if (index >= symbolTable()->captureEnd())
     185        if (index <= symbolTable()->captureEnd())
    186186            return false;
    187187        return true;
  • trunk/Source/JavaScriptCore/runtime/JSArray.h

    r154422 r155711  
    321321}
    322322
     323inline JSArray* constructArrayNegativeIndexed(ExecState* exec, Structure* arrayStructure, const JSValue* values, unsigned length)
     324{
     325    VM& vm = exec->vm();
     326    JSArray* array = JSArray::tryCreateUninitialized(vm, arrayStructure, length);
     327
     328    // FIXME: we should probably throw an out of memory error here, but
     329    // when making this change we should check that all clients of this
     330    // function will correctly handle an exception being thrown from here.
     331    RELEASE_ASSERT(array);
     332
     333    for (int i = 0; i < static_cast<int>(length); ++i)
     334        array->initializeIndex(vm, i, values[-i]);
     335    return array;
     336}
     337
    323338} // namespace JSC
    324339
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r155558 r155711  
    654654ExecState* JSGlobalObject::globalExec()
    655655{
    656     return CallFrame::create(m_globalCallFrame + JSStack::CallFrameHeaderSize);
     656    return CallFrame::create(m_globalCallFrame);
    657657}
    658658
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r155558 r155711  
    141141protected:
    142142
    143     Register m_globalCallFrame[JSStack::CallFrameHeaderSize];
     143    // Add one so we don't need to index with -1 to get current frame pointer.
     144    // An index of -1 is an error for some compilers.
     145    Register m_globalCallFrame[JSStack::CallFrameHeaderSize + 1];
    144146
    145147    WriteBarrier<JSObject> m_globalThis;
     
    605607}
    606608
     609inline JSArray* constructArrayNegativeIndexed(ExecState* exec, ArrayAllocationProfile* profile, JSGlobalObject* globalObject, const JSValue* values, unsigned length)
     610{
     611    return ArrayAllocationProfile::updateLastAllocationFor(profile, constructArrayNegativeIndexed(exec, globalObject->arrayStructureForProfileDuringAllocation(profile), values, length));
     612}
     613
     614inline JSArray* constructArrayNegativeIndexed(ExecState* exec, ArrayAllocationProfile* profile, const JSValue* values, unsigned length)
     615{
     616    return constructArrayNegativeIndexed(exec, profile, exec->lexicalGlobalObject(), values, length);
     617}
     618
    607619class DynamicGlobalObjectScope {
    608620    WTF_MAKE_NONCOPYABLE(DynamicGlobalObjectScope);
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r154253 r155711  
    313313           
    314314    private:
    315         friend JSValue jsString(ExecState*, Register*, unsigned);
     315        friend JSValue jsStringFromRegisterArray(ExecState*, Register*, unsigned);
    316316        friend JSValue jsStringFromArguments(ExecState*, JSValue);
    317317
  • trunk/Source/JavaScriptCore/runtime/Operations.h

    r154127 r155711  
    8080}
    8181
    82 ALWAYS_INLINE JSValue jsString(ExecState* exec, Register* strings, unsigned count)
     82ALWAYS_INLINE JSValue jsStringFromRegisterArray(ExecState* exec, Register* strings, unsigned count)
    8383{
    8484    VM* vm = &exec->vm();
     
    8888
    8989    for (unsigned i = 0; i < count; ++i) {
    90         JSValue v = strings[i].jsValue();
     90        JSValue v = strings[-static_cast<int>(i)].jsValue();
    9191        ropeBuilder.append(v.toString(exec));
    9292
  • trunk/Source/JavaScriptCore/runtime/SymbolTable.h

    r155262 r155711  
    465465    void setCaptureEnd(int captureEnd) { m_captureEnd = captureEnd; }
    466466
    467     int captureCount() { return m_captureEnd - m_captureStart; }
     467    int captureCount() { return -(m_captureEnd - m_captureStart); }
    468468
    469469    int parameterCount() { return m_parameterCountIncludingThis - 1; }
Note: See TracChangeset for help on using the changeset viewer.