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/bytecode/CodeBlock.cpp

    r44844 r45609  
    364364    }
    365365
    366     if (m_rareData && !m_rareData->m_unexpectedConstants.isEmpty()) {
    367         printf("\nUnexpected Constants:\n");
    368         size_t i = 0;
    369         do {
    370             printf("  k%u = %s\n", static_cast<unsigned>(i), valueToSourceString(exec, m_rareData->m_unexpectedConstants[i]).ascii());
    371             ++i;
    372         } while (i < m_rareData->m_unexpectedConstants.size());
    373     }
    374    
    375366    if (m_rareData && !m_rareData->m_regexps.isEmpty()) {
    376367        printf("\nm_regexps:\n");
     
    507498            break;
    508499        }
    509         case op_unexpected_load: {
    510             int r0 = (++it)->u.operand;
    511             int k0 = (++it)->u.operand;
    512             printf("[%4d] unexpected_load\t %s, %s\n", location, registerName(r0).c_str(), constantName(exec, k0, unexpectedConstant(k0)).c_str());
    513             break;
    514         }
    515500        case op_new_object: {
    516501            int r0 = (++it)->u.operand;
     
    10851070            int errorType = (++it)->u.operand;
    10861071            int k0 = (++it)->u.operand;
    1087             printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(r0).c_str(), errorType, constantName(exec, k0, unexpectedConstant(k0)).c_str());
     1072            printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(r0).c_str(), errorType, constantName(exec, k0, getConstant(k0)).c_str());
    10881073            break;
    10891074        }
     
    11431128    macro(regexps) \
    11441129    macro(functions) \
    1145     macro(unexpectedConstants) \
    11461130    macro(exceptionHandlers) \
    11471131    macro(immediateSwitchJumpTables) \
     
    12681252CodeBlock::CodeBlock(ScopeNode* ownerNode)
    12691253    : m_numCalleeRegisters(0)
    1270     , m_numConstants(0)
    12711254    , m_numVars(0)
    12721255    , m_numParameters(0)
     
    12911274CodeBlock::CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
    12921275    : m_numCalleeRegisters(0)
    1293     , m_numConstants(0)
    12941276    , m_numVars(0)
    12951277    , m_numParameters(0)
     
    14561438            m_rareData->m_functions[i]->body()->mark();
    14571439
    1458         for (size_t i = 0; i < m_rareData->m_unexpectedConstants.size(); ++i) {
    1459             if (!m_rareData->m_unexpectedConstants[i].marked())
    1460                 m_rareData->m_unexpectedConstants[i].mark();
    1461         }
    14621440        m_rareData->m_evalCodeCache.mark();
    14631441    }
     
    17581736        m_rareData->m_exceptionHandlers.shrinkToFit();
    17591737        m_rareData->m_functions.shrinkToFit();
    1760         m_rareData->m_unexpectedConstants.shrinkToFit();
    17611738        m_rareData->m_regexps.shrinkToFit();
    17621739        m_rareData->m_immediateSwitchJumpTables.shrinkToFit();
Note: See TracChangeset for help on using the changeset viewer.