Ignore:
Timestamp:
Jan 8, 2009, 2:51:19 PM (16 years ago)
Author:
[email protected]
Message:

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

Reviewed by Oliver Hunt.

Fix for https://bugs.webkit.org/show_bug.cgi?id=23197
Delay creating the PCVector until an exception is thrown
Part of <rdar://problem/6469060>
Don't store exception information for a CodeBlock until first exception is thrown

  • Change the process for re-parsing/re-generating bytecode for exception information to use data from the original CodeBlock (offsets of GlobalResolve instructions) to aid in creating an identical instruction stream on re-parse, instead of padding interchangeable opcodes, which would result in different JITed code.
  • Fix bug where the wrong ScopeChainNode was used when re-parsing/regenerating from within some odd modified scope chains.
  • Lazily create the pcVector by re-JITing the regenerated CodeBlock and stealing the the pcVector from it.

Saves ~2MB on Membuster head.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): (JSC::CodeBlock::hasGlobalResolveInstructionAtBytecodeOffset): (JSC::CodeBlock::hasGlobalResolveInfoAtBytecodeOffset):
  • bytecode/CodeBlock.h: (JSC::JITCodeRef::JITCodeRef): (JSC::GlobalResolveInfo::GlobalResolveInfo): (JSC::CodeBlock::getBytecodeIndex): (JSC::CodeBlock::addGlobalResolveInstruction): (JSC::CodeBlock::addGlobalResolveInfo): (JSC::CodeBlock::addFunctionRegisterInfo): (JSC::CodeBlock::hasExceptionInfo): (JSC::CodeBlock::pcVector): (JSC::EvalCodeBlock::EvalCodeBlock): (JSC::EvalCodeBlock::baseScopeDepth):
  • bytecode/Opcode.h:
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitResolve): (JSC::BytecodeGenerator::emitGetScopedVar):
  • bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::setRegeneratingForExceptionInfo):
  • interpreter/Interpreter.cpp: (JSC::bytecodeOffsetForPC): (JSC::Interpreter::unwindCallFrame): (JSC::Interpreter::privateExecute): (JSC::Interpreter::retrieveLastCaller): (JSC::Interpreter::cti_op_instanceof): (JSC::Interpreter::cti_op_call_NotJSFunction): (JSC::Interpreter::cti_op_resolve): (JSC::Interpreter::cti_op_construct_NotJSConstruct): (JSC::Interpreter::cti_op_resolve_func): (JSC::Interpreter::cti_op_resolve_skip): (JSC::Interpreter::cti_op_resolve_global): (JSC::Interpreter::cti_op_resolve_with_base): (JSC::Interpreter::cti_op_throw): (JSC::Interpreter::cti_op_in): (JSC::Interpreter::cti_vm_throw):
  • jit/JIT.cpp: (JSC::JIT::privateCompile):
  • parser/Nodes.cpp: (JSC::EvalNode::generateBytecode): (JSC::EvalNode::bytecodeForExceptionInfoReparse): (JSC::FunctionBodyNode::bytecodeForExceptionInfoReparse):
  • parser/Nodes.h:
File:
1 edited

Legend:

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

    r39697 r39720  
    6767    struct JITCodeRef {
    6868        void* code;
     69#ifndef NDEBUG
     70        unsigned codeSize;
     71#endif
    6972        RefPtr<ExecutablePool> executablePool;
    70        
     73
    7174        JITCodeRef()
    7275            : code(0)
     76#ifndef NDEBUG
     77            , codeSize(0)
     78#endif
    7379        {
    7480        }
     
    7682        JITCodeRef(void* code, PassRefPtr<ExecutablePool> executablePool)
    7783            : code(code)
     84#ifndef NDEBUG
     85            , codeSize(0)
     86#endif
    7887            , executablePool(executablePool)
    7988        {
     
    141150
    142151    struct GlobalResolveInfo {
    143         GlobalResolveInfo()
     152        GlobalResolveInfo(unsigned bytecodeOffset)
    144153            : structure(0)
    145154            , offset(0)
     155            , bytecodeOffset(bytecodeOffset)
    146156        {
    147157        }
     
    149159        Structure* structure;
    150160        unsigned offset;
     161        unsigned bytecodeOffset;
    151162    };
    152163
     
    298309        }
    299310
    300         unsigned getBytecodeIndex(void* nativePC)
    301         {
     311        unsigned getBytecodeIndex(CallFrame* callFrame, void* nativePC)
     312        {
     313            reparseForExceptionInfoIfNecessary(callFrame);
    302314            ptrdiff_t nativePCOffset = reinterpret_cast<void**>(nativePC) - reinterpret_cast<void**>(m_jitCode.code);
    303             return binaryChop<PC, ptrdiff_t, getNativePCOffset>(m_pcVector.begin(), m_pcVector.size(), nativePCOffset)->bytecodeIndex;
     315            return binaryChop<PC, ptrdiff_t, getNativePCOffset>(m_exceptionInfo->m_pcVector.begin(), m_exceptionInfo->m_pcVector.size(), nativePCOffset)->bytecodeIndex;
    304316        }
    305317
     
    344356#if !ENABLE(JIT)
    345357        void addPropertyAccessInstruction(unsigned propertyAccessInstruction) { m_propertyAccessInstructions.append(propertyAccessInstruction); }
    346         void addGlobalResolveInstruction(unsigned globalResolveInstructions) { m_globalResolveInstructions.append(globalResolveInstructions); }
     358        void addGlobalResolveInstruction(unsigned globalResolveInstruction) { m_globalResolveInstructions.append(globalResolveInstruction); }
     359        bool hasGlobalResolveInstructionAtBytecodeOffset(unsigned bytecodeOffset);
    347360#else
    348361        size_t numberOfStructureStubInfos() const { return m_structureStubInfos.size(); }
     
    350363        StructureStubInfo& structureStubInfo(int index) { return m_structureStubInfos[index]; }
    351364
    352         void addGlobalResolveInfo() { m_globalResolveInfos.append(GlobalResolveInfo()); }
     365        void addGlobalResolveInfo(unsigned globalResolveInstruction) { m_globalResolveInfos.append(GlobalResolveInfo(globalResolveInstruction)); }
    353366        GlobalResolveInfo& globalResolveInfo(int index) { return m_globalResolveInfos[index]; }
     367        bool hasGlobalResolveInfoAtBytecodeOffset(unsigned bytecodeOffset);
    354368
    355369        size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); }
     
    358372
    359373        void addFunctionRegisterInfo(unsigned bytecodeOffset, int functionIndex) { createRareDataIfNecessary(); m_rareData->m_functionRegisterInfos.append(FunctionRegisterInfo(bytecodeOffset, functionIndex)); }
    360 
    361         Vector<PC>& pcVector() { return m_pcVector; }
    362374#endif
    363375
     
    368380        HandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
    369381
     382        bool hasExceptionInfo() const { return m_exceptionInfo; }
    370383        void clearExceptionInfo() { m_exceptionInfo.clear(); }
    371384
     
    376389        void addLineInfo(const LineInfo& lineInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_lineInfo.append(lineInfo); }
    377390        LineInfo& lastLineInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.last(); }
     391
     392#if ENABLE(JIT)
     393        Vector<PC>& pcVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_pcVector; }
     394#endif
    378395
    379396        // Constant Pool
     
    475492        Vector<CallLinkInfo> m_callLinkInfos;
    476493        Vector<CallLinkInfo*> m_linkedCallerList;
    477 
    478         Vector<PC> m_pcVector;
    479494#endif
    480495
     
    492507            Vector<LineInfo> m_lineInfo;
    493508            Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo;
     509
     510#if ENABLE(JIT)
     511            Vector<PC> m_pcVector;
     512#endif
    494513        };
    495514        OwnPtr<ExceptionInfo> m_exceptionInfo;
     
    543562    class EvalCodeBlock : public ProgramCodeBlock {
    544563    public:
    545         EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
     564        EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth)
    546565            : ProgramCodeBlock(ownerNode, EvalCode, globalObject, sourceProvider)
    547         {
    548         }
     566            , m_baseScopeDepth(baseScopeDepth)
     567        {
     568        }
     569
     570        int baseScopeDepth() const { return m_baseScopeDepth; }
     571
     572    private:
     573        int m_baseScopeDepth;
    549574    };
    550575
Note: See TracChangeset for help on using the changeset viewer.