Ignore:
Timestamp:
Dec 12, 2008, 12:02:09 AM (16 years ago)
Author:
[email protected]
Message:

2008-12-11 Sam Weinig <[email protected]>

Reviewed by Geoffrey Garen.

Remove dependancy on having the Instruction buffer in order to
deref Structures used for property access and global resolves.
Instead, we put references to the necessary Structures in axillary
data structures on the CodeBlock. This is not an ideal solution,
as we still pay for having the Structures in two places and we
would like to eventually just hold on to offsets into the machine
code buffer.

  • Also removes CodeBlock bloat in non-JIT by #ifdefing the JIT only data structures.
  • GNUmakefile.am:
  • JavaScriptCore.pri:
  • JavaScriptCore.scons:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • bytecode/CodeBlock.cpp: (JSC::isGlobalResolve): (JSC::isPropertyAccess): (JSC::instructionOffsetForNth): (JSC::printGlobalResolveInfo): (JSC::printStructureStubInfo): (JSC::CodeBlock::printStructures): (JSC::CodeBlock::dump): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::shrinkToFit):
  • bytecode/CodeBlock.h: (JSC::GlobalResolveInfo::GlobalResolveInfo): (JSC::getNativePC): (JSC::CodeBlock::instructions): (JSC::CodeBlock::getStubInfo): (JSC::CodeBlock::getBytecodeIndex): (JSC::CodeBlock::addPropertyAccessInstruction): (JSC::CodeBlock::addGlobalResolveInstruction): (JSC::CodeBlock::numberOfStructureStubInfos): (JSC::CodeBlock::addStructureStubInfo): (JSC::CodeBlock::structureStubInfo): (JSC::CodeBlock::addGlobalResolveInfo): (JSC::CodeBlock::globalResolveInfo): (JSC::CodeBlock::numberOfCallLinkInfos): (JSC::CodeBlock::addCallLinkInfo): (JSC::CodeBlock::callLinkInfo):
  • bytecode/Instruction.h: (JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set): (JSC::PolymorphicAccessStructureList::PolymorphicAccessStructureList):
  • bytecode/Opcode.h: (JSC::):
  • bytecode/StructureStubInfo.cpp: Copied from bytecode/CodeBlock.cpp. (JSC::StructureStubInfo::deref):
  • bytecode/StructureStubInfo.h: Copied from bytecode/CodeBlock.h. (JSC::StructureStubInfo::StructureStubInfo): (JSC::StructureStubInfo::initGetByIdSelf): (JSC::StructureStubInfo::initGetByIdProto): (JSC::StructureStubInfo::initGetByIdChain): (JSC::StructureStubInfo::initGetByIdSelfList): (JSC::StructureStubInfo::initGetByIdProtoList): (JSC::StructureStubInfo::initPutByIdTransition): (JSC::StructureStubInfo::initPutByIdReplace): (JSC::StructureStubInfo::):
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitResolve): (JSC::BytecodeGenerator::emitGetById): (JSC::BytecodeGenerator::emitPutById): (JSC::BytecodeGenerator::emitCall): (JSC::BytecodeGenerator::emitConstruct): (JSC::BytecodeGenerator::emitCatch):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::tryCTICachePutByID): (JSC::Interpreter::tryCTICacheGetByID): (JSC::Interpreter::cti_op_get_by_id_self_fail): (JSC::getPolymorphicAccessStructureListSlot): (JSC::Interpreter::cti_op_get_by_id_proto_list): (JSC::Interpreter::cti_op_resolve_global):
  • jit/JIT.cpp: (JSC::JIT::JIT): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::privateCompile):
  • jit/JITPropertyAccess.cpp: (JSC::JIT::compileGetByIdHotPath): (JSC::JIT::compilePutByIdHotPath): (JSC::JIT::compileGetByIdSlowCase): (JSC::JIT::compilePutByIdSlowCase): (JSC::JIT::privateCompileGetByIdSelfList): (JSC::JIT::privateCompileGetByIdProtoList): (JSC::JIT::privateCompileGetByIdChainList):
File:
1 edited

Legend:

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

    r39184 r39229  
    4141#include <wtf/Vector.h>
    4242
     43#if ENABLE(JIT)
     44#include "StructureStubInfo.h"
     45#endif
     46
    4347namespace JSC {
    4448
     
    5458        uint32_t target;
    5559        uint32_t scopeDepth;
     60#if ENABLE(JIT)
    5661        void* nativeCode;
     62#endif
    5763    };
    5864
     
    7379    };
    7480
    75     struct StructureStubInfo {
    76         StructureStubInfo(unsigned bytecodeIndex)
    77             : bytecodeIndex(bytecodeIndex)
    78             , stubRoutine(0)
    79             , callReturnLocation(0)
    80             , hotPathBegin(0)
    81         {
    82         }
    83    
    84         unsigned bytecodeIndex;
    85         void* stubRoutine;
    86         void* callReturnLocation;
    87         void* hotPathBegin;
    88     };
    89 
     81#if ENABLE(JIT)
    9082    struct CallLinkInfo {
    9183        CallLinkInfo()
     
    110102    };
    111103
    112 #if ENABLE(JIT)
     104    struct GlobalResolveInfo {
     105        GlobalResolveInfo()
     106            : structure(0)
     107            , offset(0)
     108        {
     109        }
     110
     111        Structure* structure;
     112        unsigned offset;
     113    };
     114
    113115    struct PC {
    114116        PC(void* nativePC, unsigned bytecodeIndex)
     
    121123        unsigned bytecodeIndex;
    122124    };
    123 #endif
    124125
    125126    // valueAtPosition helpers for the binaryChop algorithm below.
     
    135136    }
    136137
    137 #if ENABLE(JIT)
    138138    inline void* getNativePC(PC* pc)
    139139    {
    140140        return pc->nativePC;
    141141    }
    142 #endif
    143142
    144143    // Binary chop algorithm, calls valueAtPosition on pre-sorted elements in array,
     
    177176        return &array[0];
    178177    }
     178#endif
    179179
    180180    class CodeBlock {
     
    184184        ~CodeBlock();
    185185
     186        void mark();
     187        void refStructures(Instruction* vPC) const;
     188        void derefStructures(Instruction* vPC) const;
     189#if ENABLE(JIT)
     190        void unlinkCallers();
     191#endif
     192
    186193        static void dumpStatistics();
    187194
    188 #if ENABLE(JIT)
    189         void unlinkCallers();
    190 #endif
    191 
     195#if !defined(NDEBUG) || ENABLE_OPCODE_SAMPLING
     196        void dump(ExecState*) const;
     197        void printStructures(const Instruction*) const;
     198        void printStructure(const char* name, const Instruction*, int operand) const;
     199#endif
     200
     201        inline bool isKnownNotImmediate(int index)
     202        {
     203            if (index == m_thisRegister)
     204                return true;
     205
     206            if (isConstantRegisterIndex(index))
     207                return !JSImmediate::isImmediate(getConstant(index));
     208
     209            return false;
     210        }
     211
     212        ALWAYS_INLINE bool isConstantRegisterIndex(int index)
     213        {
     214            return index >= m_numVars && index < m_numVars + m_numConstants;
     215        }
     216
     217        ALWAYS_INLINE JSValue* getConstant(int index)
     218        {
     219            return m_constantRegisters[index - m_numVars].getJSValue();
     220        }
     221
     222        ALWAYS_INLINE bool isTemporaryRegisterIndex(int index)
     223        {
     224            return index >= m_numVars + m_numConstants;
     225        }
     226
     227        int expressionRangeForVPC(const Instruction*, int& divot, int& startOffset, int& endOffset);
     228        int lineNumberForVPC(const Instruction* vPC);
     229        HandlerInfo* handlerForVPC(const Instruction* vPC);
     230
     231#if ENABLE(JIT)
    192232        void addCaller(CallLinkInfo* caller)
    193233        {
     
    209249        }
    210250
    211         inline bool isKnownNotImmediate(int index)
    212         {
    213             if (index == m_thisRegister)
    214                 return true;
    215 
    216             if (isConstantRegisterIndex(index))
    217                 return !JSImmediate::isImmediate(getConstant(index));
    218 
    219             return false;
    220         }
    221 
    222         ALWAYS_INLINE bool isConstantRegisterIndex(int index)
    223         {
    224             return index >= m_numVars && index < m_numVars + m_numConstants;
    225         }
    226 
    227         ALWAYS_INLINE JSValue* getConstant(int index)
    228         {
    229             return m_constantRegisters[index - m_numVars].getJSValue();
    230         }
    231 
    232         ALWAYS_INLINE bool isTemporaryRegisterIndex(int index)
    233         {
    234             return index >= m_numVars + m_numConstants;
    235         }
    236 
    237 #if !defined(NDEBUG) || ENABLE_OPCODE_SAMPLING
    238         void dump(ExecState*) const;
    239         void printStructures(const Instruction*) const;
    240         void printStructure(const char* name, const Instruction*, int operand) const;
    241 #endif
    242         int expressionRangeForVPC(const Instruction*, int& divot, int& startOffset, int& endOffset);
    243         int lineNumberForVPC(const Instruction* vPC);
    244         HandlerInfo* handlerForVPC(const Instruction* vPC);
    245 
    246         void mark();
    247         void refStructures(Instruction* vPC) const;
    248         void derefStructures(Instruction* vPC) const;
    249 
    250251        StructureStubInfo& getStubInfo(void* returnAddress)
    251252        {
    252             return *(binaryChop<StructureStubInfo, void*, getStructureStubInfoReturnLocation>(m_propertyAccessInstructions.begin(), m_propertyAccessInstructions.size(), returnAddress));
     253            return *(binaryChop<StructureStubInfo, void*, getStructureStubInfoReturnLocation>(m_structureStubInfos.begin(), m_structureStubInfos.size(), returnAddress));
    253254        }
    254255
     
    258259        }
    259260
    260 #if ENABLE(JIT)
    261261        unsigned getBytecodeIndex(void* nativePC)
    262262        {
     
    266266
    267267        Vector<Instruction>& instructions() { return m_instructions; }
     268
    268269#if ENABLE(JIT)
    269270        void setJITCode(void* jitCode) { m_jitCode = jitCode; }
     
    292293        unsigned sourceOffset() const { return m_sourceOffset; }
    293294
    294         void addGlobalResolveInstruction(unsigned globalResolveInstructions) { m_globalResolveInstructions.append(globalResolveInstructions); }
    295 
    296         size_t numberOfPropertyAccessInstructions() const { return m_propertyAccessInstructions.size(); }
    297         void addPropertyAccessInstruction(unsigned propertyAccessInstructions) { m_propertyAccessInstructions.append(StructureStubInfo(propertyAccessInstructions)); }
    298         StructureStubInfo& propertyAccessInstruction(int index) { return m_propertyAccessInstructions[index]; }
    299 
    300         size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); }
    301         void addCallLinkInfo() { m_callLinkInfos.append(CallLinkInfo()); }
    302         CallLinkInfo& callLinkInfo(int index) { return m_callLinkInfos[index]; }
    303 
    304295        size_t numberOfJumpTargets() const { return m_jumpTargets.size(); }
    305296        void addJumpTarget(unsigned jumpTarget) { m_jumpTargets.append(jumpTarget); }
     
    317308        LineInfo& lastLineInfo() { return m_lineInfo.last(); }
    318309
    319 #if ENABLE(JIT)
     310#if !ENABLE(JIT)
     311        void addPropertyAccessInstruction(unsigned propertyAccessInstruction) { m_propertyAccessInstructions.append(propertyAccessInstruction); }
     312        void addGlobalResolveInstruction(unsigned globalResolveInstructions) { m_globalResolveInstructions.append(globalResolveInstructions); }
     313#else
     314        size_t numberOfStructureStubInfos() const { return m_structureStubInfos.size(); }
     315        void addStructureStubInfo(const StructureStubInfo& stubInfo) { m_structureStubInfos.append(stubInfo); }
     316        StructureStubInfo& structureStubInfo(int index) { return m_structureStubInfos[index]; }
     317
     318        void addGlobalResolveInfo() { m_globalResolveInfos.append(GlobalResolveInfo()); }
     319        GlobalResolveInfo& globalResolveInfo(int index) { return m_globalResolveInfos[index]; }
     320
     321        size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); }
     322        void addCallLinkInfo() { m_callLinkInfos.append(CallLinkInfo()); }
     323        CallLinkInfo& callLinkInfo(int index) { return m_callLinkInfos[index]; }
     324
    320325        Vector<PC>& pcVector() { return m_pcVector; }
    321326#endif
     
    408413        unsigned m_sourceOffset;
    409414
     415#if !ENABLE(JIT)
     416        Vector<unsigned> m_propertyAccessInstructions;
    410417        Vector<unsigned> m_globalResolveInstructions;
    411         Vector<StructureStubInfo> m_propertyAccessInstructions;
     418#else
     419        Vector<StructureStubInfo> m_structureStubInfos;
     420        Vector<GlobalResolveInfo> m_globalResolveInfos;
    412421        Vector<CallLinkInfo> m_callLinkInfos;
    413422        Vector<CallLinkInfo*> m_linkedCallerList;
     423#endif
    414424
    415425        Vector<unsigned> m_jumpTargets;
Note: See TracChangeset for help on using the changeset viewer.