Ignore:
Timestamp:
Feb 26, 2012, 6:07:34 PM (13 years ago)
Author:
[email protected]
Message:

Getting the instruction stream for a code block should not require two loads
https://bugs.webkit.org/show_bug.cgi?id=79608

Reviewed by Sam Weinig.

Introduced the RefCountedArray class, which contains a single inline pointer
to a ref-counted non-resizeable vector backing store. This satisfies the
requirements of CodeBlock, which desires the ability to share instruction
streams with other CodeBlocks. It also reduces the number of loads required
for getting the instruction stream by one.

This patch also gets rid of the bytecode discarding logic, since we don't
use it anymore and it's unlikely to ever work right with DFG or LLInt. And
I didn't feel like porting dead code to use RefCountedArray.

  • GNUmakefile.list.am:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/CodeBlock.cpp:

(JSC::instructionOffsetForNth):
(JSC::CodeBlock::dump):
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::finalizeUnconditionally):
(JSC::CodeBlock::handlerForBytecodeOffset):
(JSC::CodeBlock::lineNumberForBytecodeOffset):
(JSC::CodeBlock::expressionRangeForBytecodeOffset):
(JSC::CodeBlock::shrinkToFit):

  • bytecode/CodeBlock.h:

(CodeBlock):
(JSC::CodeBlock::numberOfInstructions):
(JSC::CodeBlock::instructions):
(JSC::CodeBlock::instructionCount):
(JSC::CodeBlock::valueProfileForBytecodeOffset):
(JSC):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::Label::setLocation):
(JSC):
(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::newLabel):

  • bytecompiler/BytecodeGenerator.h:

(JSC):
(BytecodeGenerator):
(JSC::BytecodeGenerator::instructions):

  • bytecompiler/Label.h:

(JSC::Label::Label):
(Label):

  • dfg/DFGByteCodeCache.h:

(JSC::DFG::ByteCodeCache::~ByteCodeCache):
(JSC::DFG::ByteCodeCache::get):

  • jit/JITExceptions.cpp:

(JSC::genericThrow):

  • llint/LowLevelInterpreter32_64.asm:
  • runtime/Executable.cpp:

(JSC::EvalExecutable::compileInternal):
(JSC::ProgramExecutable::compileInternal):
(JSC::FunctionExecutable::codeBlockWithBytecodeFor):
(JSC::FunctionExecutable::produceCodeBlockFor):

  • wtf/RefCountedArray.h: Added.

(WTF):
(RefCountedArray):
(WTF::RefCountedArray::RefCountedArray):
(WTF::RefCountedArray::operator=):
(WTF::RefCountedArray::~RefCountedArray):
(WTF::RefCountedArray::size):
(WTF::RefCountedArray::data):
(WTF::RefCountedArray::begin):
(WTF::RefCountedArray::end):
(WTF::RefCountedArray::at):
(WTF::RefCountedArray::operator[]):
(Header):
(WTF::RefCountedArray::Header::size):
(WTF::RefCountedArray::Header::payload):
(WTF::RefCountedArray::Header::fromPayload):

  • wtf/Platform.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r108444 r108943  
    211211    JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
    212212   
    213     if (!!m_evalCodeBlock && m_evalCodeBlock->canProduceCopyWithBytecode()) {
    214         BytecodeDestructionBlocker blocker(m_evalCodeBlock.get());
     213    if (!!m_evalCodeBlock) {
    215214        OwnPtr<EvalCodeBlock> newCodeBlock = adoptPtr(new EvalCodeBlock(CodeBlock::CopyParsedBlock, *m_evalCodeBlock));
    216215        newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_evalCodeBlock.release()));
     
    347346    JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
    348347   
    349     if (!!m_programCodeBlock && m_programCodeBlock->canProduceCopyWithBytecode()) {
    350         BytecodeDestructionBlocker blocker(m_programCodeBlock.get());
     348    if (!!m_programCodeBlock) {
    351349        OwnPtr<ProgramCodeBlock> newCodeBlock = adoptPtr(new ProgramCodeBlock(CodeBlock::CopyParsedBlock, *m_programCodeBlock));
    352350        newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_programCodeBlock.release()));
     
    495493FunctionCodeBlock* FunctionExecutable::codeBlockWithBytecodeFor(CodeSpecializationKind kind)
    496494{
    497     FunctionCodeBlock* codeBlock = baselineCodeBlockFor(kind);
    498     if (codeBlock->canProduceCopyWithBytecode())
    499         return codeBlock;
    500     return 0;
     495    return baselineCodeBlockFor(kind);
    501496}
    502497
    503498PassOwnPtr<FunctionCodeBlock> FunctionExecutable::produceCodeBlockFor(ScopeChainNode* scopeChainNode, CompilationKind compilationKind, CodeSpecializationKind specializationKind, JSObject*& exception)
    504499{
    505     if (!!codeBlockFor(specializationKind) && codeBlockFor(specializationKind)->canProduceCopyWithBytecode()) {
    506         BytecodeDestructionBlocker blocker(codeBlockFor(specializationKind).get());
     500    if (!!codeBlockFor(specializationKind))
    507501        return adoptPtr(new FunctionCodeBlock(CodeBlock::CopyParsedBlock, *codeBlockFor(specializationKind)));
    508     }
    509502   
    510503    exception = 0;
Note: See TracChangeset for help on using the changeset viewer.