Ignore:
Timestamp:
Jul 7, 2009, 2:52:07 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-07-07 Gavin Barraclough <[email protected]>

Reviewed by Sam Weinig.

Stop loading constants into the register file.

Instead, use high register values (highest bit bar the sign bit set) to indicate
constants in the instruction stream, and when we encounter such a value load it
directly from the CodeBlock.

Since constants are no longer copied into the register file, this patch renders
the 'unexpected constant' mechanism redundant, and removes it.

2% improvement, thanks to Sam Weinig.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::mark): (JSC::CodeBlock::shrinkToFit):
  • bytecode/CodeBlock.h: (JSC::CodeBlock::isTemporaryRegisterIndex): (JSC::CodeBlock::constantRegister): (JSC::CodeBlock::isConstantRegisterIndex): (JSC::CodeBlock::getConstant): (JSC::ExecState::r):
  • bytecode/Opcode.h:
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::preserveLastVar): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::addConstantValue): (JSC::BytecodeGenerator::emitEqualityOp): (JSC::BytecodeGenerator::emitLoad): (JSC::BytecodeGenerator::emitResolveBase): (JSC::BytecodeGenerator::emitResolveWithBase): (JSC::BytecodeGenerator::emitNewError):
  • bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::emitNode):
  • interpreter/CallFrame.h: (JSC::ExecState::noCaller): (JSC::ExecState::hasHostCallFrameFlag): (JSC::ExecState::addHostCallFrameFlag): (JSC::ExecState::removeHostCallFrameFlag):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::resolve): (JSC::Interpreter::resolveSkip): (JSC::Interpreter::resolveGlobal): (JSC::Interpreter::resolveBase): (JSC::Interpreter::resolveBaseAndProperty): (JSC::Interpreter::resolveBaseAndFunc): (JSC::Interpreter::dumpRegisters): (JSC::Interpreter::throwException): (JSC::Interpreter::createExceptionScope): (JSC::Interpreter::privateExecute): (JSC::Interpreter::retrieveArguments):
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass):
  • jit/JITInlineMethods.h: (JSC::JIT::emitLoadDouble): (JSC::JIT::emitLoadInt32ToDouble):
  • jit/JITOpcodes.cpp: (JSC::JIT::emit_op_new_error): (JSC::JIT::emit_op_enter): (JSC::JIT::emit_op_enter_with_activation):
  • parser/Nodes.cpp: (JSC::DeleteResolveNode::emitBytecode): (JSC::DeleteValueNode::emitBytecode): (JSC::PrefixResolveNode::emitBytecode):
  • runtime/JSActivation.cpp: (JSC::JSActivation::JSActivation):
  • wtf/Platform.h:

LayoutTests:

2009-07-07 Gavin Barraclough <[email protected]>

Reviewed by Geoff Garen.

fast/js/global-recursion-on-full-stack.html is a little finicky.

The test recurses down the JS stack to find the bottom (catching this with an exception),
then tries to call a host function (document.write), switch writes new '<script>' code,
and expects this code to be run, then expects this code to try to call 'f();' again,
which it expects to fail, and it expects to catch that exception. However it is possible
that one of the earlier stages (the call to document.write, entering the interpreter to
run the new global code) will fail, depending on exactly how much stack space was free at
the point the last call to f() failed.

Tweak the test to make it work.

  • fast/js/global-recursion-on-full-stack.html:
File:
1 edited

Legend:

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

    r45128 r45609  
    246246        RegisterID* emitLoad(RegisterID* dst, const Identifier&);
    247247        RegisterID* emitLoad(RegisterID* dst, JSValue);
    248         RegisterID* emitUnexpectedLoad(RegisterID* dst, bool);
    249         RegisterID* emitUnexpectedLoad(RegisterID* dst, double);
    250         RegisterID* emitLoadGlobalObject(RegisterID* dst, JSObject* globalObject);
    251248
    252249        RegisterID* emitUnaryOp(OpcodeID, RegisterID* dst, RegisterID* src);
     
    400397        RegisterID* addParameter(const Identifier&);
    401398       
    402         void allocateConstants(size_t);
     399        void preserveLastVar();
    403400
    404401        RegisterID& registerFor(int index)
     
    421418        unsigned addConstant(FuncExprNode*);
    422419        unsigned addConstant(const Identifier&);
    423         RegisterID* addConstant(JSValue);
    424         unsigned addUnexpectedConstant(JSValue);
     420        RegisterID* addConstantValue(JSValue);
    425421        unsigned addRegExp(RegExp*);
    426422
     
    451447        RegisterID m_argumentsRegister;
    452448        int m_activationRegisterIndex;
     449        WTF::SegmentedVector<RegisterID, 32> m_constantPoolRegisters;
    453450        WTF::SegmentedVector<RegisterID, 32> m_calleeRegisters;
    454451        WTF::SegmentedVector<RegisterID, 32> m_parameters;
     
    456453        WTF::SegmentedVector<Label, 32> m_labels;
    457454        WTF::SegmentedVector<LabelScope, 8> m_labelScopes;
    458         RefPtr<RegisterID> m_lastConstant;
     455        RefPtr<RegisterID> m_lastVar;
    459456        int m_finallyDepth;
    460457        int m_dynamicScopeDepth;
     
    467464        int m_nextGlobalIndex;
    468465        int m_nextParameterIndex;
    469         int m_nextConstantIndex;
     466        int m_firstConstantIndex;
     467        int m_nextConstantOffset;
    470468        unsigned m_globalConstantIndex;
    471469
Note: See TracChangeset for help on using the changeset viewer.