Ignore:
Timestamp:
Jan 7, 2009, 5:46:14 PM (16 years ago)
Author:
[email protected]
Message:

2009-01-07 Sam Weinig <[email protected]>

Reviewed by Geoffrey Garen.

<rdar://problem/6469060> Don't store exception information for a CodeBlock until first exception is thrown

Don't initially store exception information (lineNumber/expressionRange/getByIdExcecptionInfo)
in CodeBlocks blocks. Instead, re-parse for the data on demand and cache it then.

One important change that was needed to make this work was to pad op_get_global_var with nops to
be the same length as op_resolve_global, since one could be replaced for the other on re-parsing,
and we want to keep the offsets bytecode offsets the same.

1.3MB improvement on Membuster head.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): Update op_get_global_var to account for the padding. (JSC::CodeBlock::dumpStatistics): Add more statistic dumping. (JSC::CodeBlock::CodeBlock): Initialize m_exceptionInfo. (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): Re-parses the CodeBlocks associated SourceCode and steals the ExceptionInfo from it. (JSC::CodeBlock::lineNumberForBytecodeOffset): Creates the exception info on demand. (JSC::CodeBlock::expressionRangeForBytecodeOffset): Ditto. (JSC::CodeBlock::getByIdExceptionInfoForBytecodeOffset): Ditto.
  • bytecode/CodeBlock.h: (JSC::CodeBlock::numberOfExceptionHandlers): Updated to account for m_exceptionInfo indirection. (JSC::CodeBlock::addExceptionHandler): Ditto. (JSC::CodeBlock::exceptionHandler): Ditto. (JSC::CodeBlock::clearExceptionInfo): Ditto. (JSC::CodeBlock::addExpressionInfo): Ditto. (JSC::CodeBlock::addGetByIdExceptionInfo): Ditto. (JSC::CodeBlock::numberOfLineInfos): Ditto. (JSC::CodeBlock::addLineInfo): Ditto. (JSC::CodeBlock::lastLineInfo): Ditto.
  • bytecode/Opcode.h: Change length of op_get_global_var to match op_resolve_global.
  • bytecode/SamplingTool.cpp: (JSC::SamplingTool::dump): Add comment indicating why it is okay not to pass a CallFrame.
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): Clear the exception info after generation for Function and Eval Code when not in regenerate for exception info mode. (JSC::BytecodeGenerator::BytecodeGenerator): Initialize m_regeneratingForExceptionInfo to false. (JSC::BytecodeGenerator::emitGetScopedVar): Pad op_get_global_var with 2 nops.
  • bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::setRegeneratingForExcpeptionInfo): Added.
  • interpreter/Interpreter.cpp: (JSC::Interpreter::throwException): Pass the CallFrame to exception info accessors. (JSC::Interpreter::privateExecute): Ditto. (JSC::Interpreter::retrieveLastCaller): Ditto. (JSC::Interpreter::cti_op_new_error): Ditto.
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): Pass the current bytecode offset instead of hard coding the line number, the stub will do the accessing if it gets called.
  • parser/Nodes.cpp: (JSC::ProgramNode::emitBytecode): Moved. (JSC::ProgramNode::generateBytecode): Moved. (JSC::EvalNode::create): Moved. (JSC::EvalNode::bytecodeForExceptionInfoReparse): Added. (JSC::FunctionBodyNode::generateBytecode): Rename reparse to reparseInPlace. (JSC::FunctionBodyNode::bytecodeForExceptionInfoReparse): Addded.
  • parser/Nodes.h: (JSC::ScopeNode::features): Added getter.
  • parser/Parser.cpp: (JSC::Parser::reparseInPlace): Renamed from reparse.
  • parser/Parser.h: (JSC::Parser::reparse): Added. Re-parses the passed in Node into a new Node.
  • runtime/ExceptionHelpers.cpp: (JSC::createUndefinedVariableError): Pass along CallFrame. (JSC::createInvalidParamError): Ditto. (JSC::createNotAConstructorError): Ditto. (JSC::createNotAFunctionError): Ditto. (JSC::createNotAnObjectError): Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r39670 r39697  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Cameron Zwarich <[email protected]>
    44 *
     
    264264
    265265        HandlerInfo* handlerForBytecodeOffset(unsigned bytecodeOffset);
    266         int lineNumberForBytecodeOffset(unsigned bytecodeOffset);
    267         int expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset);
    268         bool getByIdExceptionInfoForBytecodeOffset(unsigned bytecodeOffset, OpcodeID&);
     266        int lineNumberForBytecodeOffset(CallFrame*, unsigned bytecodeOffset);
     267        int expressionRangeForBytecodeOffset(CallFrame*, unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset);
     268        bool getByIdExceptionInfoForBytecodeOffset(CallFrame*, unsigned bytecodeOffset, OpcodeID&);
    269269
    270270#if ENABLE(JIT)
     
    341341        unsigned jumpTarget(int index) const { return m_jumpTargets[index]; }
    342342        unsigned lastJumpTarget() const { return m_jumpTargets.last(); }
    343 
    344         size_t numberOfExceptionHandlers() const { return m_rareData ? m_rareData->m_exceptionHandlers.size() : 0; }
    345         void addExceptionHandler(const HandlerInfo& hanler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(hanler); }
    346         HandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
    347 
    348         void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { return m_expressionInfo.append(expressionInfo); }
    349         void addGetByIdExceptionInfo(const GetByIdExceptionInfo& info) { m_getByIdExceptionInfo.append(info); }
    350 
    351         size_t numberOfLineInfos() const { return m_lineInfo.size(); }
    352         void addLineInfo(const LineInfo& lineInfo) { return m_lineInfo.append(lineInfo); }
    353         LineInfo& lastLineInfo() { return m_lineInfo.last(); }
    354343
    355344#if !ENABLE(JIT)
     
    372361        Vector<PC>& pcVector() { return m_pcVector; }
    373362#endif
     363
     364        // Exception handling support
     365
     366        size_t numberOfExceptionHandlers() const { return m_rareData ? m_rareData->m_exceptionHandlers.size() : 0; }
     367        void addExceptionHandler(const HandlerInfo& hanler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(hanler); }
     368        HandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
     369
     370        void clearExceptionInfo() { m_exceptionInfo.clear(); }
     371
     372        void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_expressionInfo.append(expressionInfo); }
     373        void addGetByIdExceptionInfo(const GetByIdExceptionInfo& info) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_getByIdExceptionInfo.append(info); }
     374
     375        size_t numberOfLineInfos() const { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.size(); }
     376        void addLineInfo(const LineInfo& lineInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_lineInfo.append(lineInfo); }
     377        LineInfo& lastLineInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.last(); }
    374378
    375379        // Constant Pool
     
    433437#endif
    434438
     439        void reparseForExceptionInfoIfNecessary(CallFrame*);
     440
    435441        void createRareDataIfNecessary()
    436442        {
     
    438444                m_rareData.set(new RareData);
    439445        }
    440 
    441446
    442447        ScopeNode* m_ownerNode;
     
    470475        Vector<CallLinkInfo> m_callLinkInfos;
    471476        Vector<CallLinkInfo*> m_linkedCallerList;
     477
     478        Vector<PC> m_pcVector;
    472479#endif
    473480
    474481        Vector<unsigned> m_jumpTargets;
    475 
    476         Vector<ExpressionRangeInfo> m_expressionInfo;
    477         Vector<LineInfo> m_lineInfo;
    478         Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo;
    479 
    480 #if ENABLE(JIT)
    481         Vector<PC> m_pcVector;
    482 #endif
    483482
    484483        // Constant Pool
     
    489488        SymbolTable m_symbolTable;
    490489
     490        struct ExceptionInfo {
     491            Vector<ExpressionRangeInfo> m_expressionInfo;
     492            Vector<LineInfo> m_lineInfo;
     493            Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo;
     494        };
     495        OwnPtr<ExceptionInfo> m_exceptionInfo;
     496
    491497        struct RareData {
    492498            Vector<HandlerInfo> m_exceptionHandlers;
     
    508514#endif
    509515        };
    510 
    511516        OwnPtr<RareData> m_rareData;
    512517    };
Note: See TracChangeset for help on using the changeset viewer.