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/interpreter/Interpreter.cpp

    r39197 r39229  
    40874087
    40884088    StructureStubInfo* stubInfo = &codeBlock->getStubInfo(returnAddress);
    4089     Instruction* vPC = codeBlock->instructions().begin() + stubInfo->bytecodeIndex;
    40904089
    40914090    // Cache hit: Specialize instruction and ref Structures.
     
    40934092    // Structure transition, cache transition info
    40944093    if (slot.type() == PutPropertySlot::NewProperty) {
    4095         vPC[0] = getOpcode(op_put_by_id_transition);
    4096         vPC[4] = structure->previousID();
    4097         vPC[5] = structure;
    40984094        StructureChain* chain = structure->cachedPrototypeChain();
    40994095        if (!chain) {
    41004096            chain = cachePrototypeChain(callFrame, structure);
    41014097            if (!chain) {
    4102                 // This happens if someone has manually inserted null into the prototype chain
    4103                 vPC[0] = getOpcode(op_put_by_id_generic);
     4098                // This happens if someone has manually inserted null into the prototype chain 
     4099                stubInfo->opcodeID = op_put_by_id_generic;
    41044100                return;
    41054101            }
    41064102        }
    4107         vPC[6] = chain;
    4108         vPC[7] = slot.cachedOffset();
    4109         codeBlock->refStructures(vPC);
     4103        stubInfo->initPutByIdTransition(structure->previousID(), structure, chain);
    41104104        JIT::compilePutByIdTransition(callFrame->scopeChain()->globalData, codeBlock, stubInfo, structure->previousID(), structure, slot.cachedOffset(), chain, returnAddress);
    41114105        return;
    41124106    }
    41134107   
    4114     vPC[0] = getOpcode(op_put_by_id_replace);
    4115     vPC[4] = structure;
    4116     vPC[5] = slot.cachedOffset();
    4117     codeBlock->refStructures(vPC);
     4108    stubInfo->initPutByIdReplace(structure);
    41184109
    41194110#if USE(CTI_REPATCH_PIC)
     
    41694160
    41704161    StructureStubInfo* stubInfo = &codeBlock->getStubInfo(returnAddress);
    4171     Instruction* vPC = codeBlock->instructions().begin() + stubInfo->bytecodeIndex;
    41724162
    41734163    // Cache hit: Specialize instruction and ref Structures.
     
    41754165    if (slot.slotBase() == baseValue) {
    41764166        // set this up, so derefStructures can do it's job.
    4177         vPC[0] = getOpcode(op_get_by_id_self);
    4178         vPC[4] = structure;
    4179         vPC[5] = slot.cachedOffset();
    4180         codeBlock->refStructures(vPC);
     4167        stubInfo->initGetByIdSelf(structure);
    41814168       
    41824169#if USE(CTI_REPATCH_PIC)
     
    42004187            asObject(baseValue)->structure()->setCachedPrototypeChain(0);
    42014188        }
    4202 
    4203         vPC[0] = getOpcode(op_get_by_id_proto);
    4204         vPC[4] = structure;
    4205         vPC[5] = slotBaseObject->structure();
    4206         vPC[6] = slot.cachedOffset();
    4207         codeBlock->refStructures(vPC);
     4189       
     4190        stubInfo->initGetByIdProto(structure, slotBaseObject->structure());
    42084191
    42094192        JIT::compileGetByIdProto(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, structure, slotBaseObject->structure(), slot.cachedOffset(), returnAddress);
     
    42134196    size_t count = countPrototypeChainEntriesAndCheckForProxies(callFrame, baseValue, slot);
    42144197    if (!count) {
    4215         vPC[0] = getOpcode(op_get_by_id_generic);
     4198        stubInfo->opcodeID = op_get_by_id_generic;
    42164199        return;
    42174200    }
     
    42224205    ASSERT(chain);
    42234206
    4224     vPC[0] = getOpcode(op_get_by_id_chain);
    4225     vPC[4] = structure;
    4226     vPC[5] = chain;
    4227     vPC[6] = count;
    4228     vPC[7] = slot.cachedOffset();
    4229     codeBlock->refStructures(vPC);
     4207    stubInfo->initGetByIdChain(structure, chain);
    42304208
    42314209    JIT::compileGetByIdChain(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, structure, chain, count, slot.cachedOffset(), returnAddress);
     
    45764554        CodeBlock* codeBlock = callFrame->codeBlock();
    45774555        StructureStubInfo* stubInfo = &codeBlock->getStubInfo(CTI_RETURN_ADDRESS);
    4578         Instruction* vPC = codeBlock->instructions().begin() + stubInfo->bytecodeIndex;
    45794556
    45804557        ASSERT(slot.slotBase()->isObject());
     
    45834560        int listIndex = 1;
    45844561
    4585         if (vPC[0].u.opcode == ARG_globalData->interpreter->getOpcode(op_get_by_id_self)) {
     4562        if (stubInfo->opcodeID == op_get_by_id_self) {
    45864563            ASSERT(!stubInfo->stubRoutine);
    4587             polymorphicStructureList = new PolymorphicAccessStructureList(vPC[5].u.operand, 0, vPC[4].u.structure);
    4588 
    4589             vPC[0] = ARG_globalData->interpreter->getOpcode(op_get_by_id_self_list);
    4590             vPC[4] = polymorphicStructureList;
    4591             vPC[5] = 2;
     4564            polymorphicStructureList = new PolymorphicAccessStructureList(0, stubInfo->u.getByIdSelf.baseObjectStructure);
     4565            stubInfo->initGetByIdSelfList(polymorphicStructureList, 2);
    45924566        } else {
    4593             polymorphicStructureList = vPC[4].u.polymorphicStructures;
    4594             listIndex = vPC[5].u.operand;
    4595 
    4596             vPC[5] = listIndex + 1;
     4567            polymorphicStructureList = stubInfo->u.getByIdSelfList.structureList;
     4568            listIndex = stubInfo->u.getByIdSelfList.listSize;
     4569            stubInfo->u.getByIdSelfList.listSize++;
    45974570        }
    45984571
     
    46074580}
    46084581
    4609 static PolymorphicAccessStructureList* getPolymorphicAccessStructureListSlot(Interpreter* interpreter, StructureStubInfo* stubInfo, Instruction* vPC, int& listIndex)
    4610 {
    4611     PolymorphicAccessStructureList* prototypeStructureList;
     4582static PolymorphicAccessStructureList* getPolymorphicAccessStructureListSlot(StructureStubInfo* stubInfo, int& listIndex)
     4583{
     4584    PolymorphicAccessStructureList* prototypeStructureList = 0;
    46124585    listIndex = 1;
    46134586
    4614     if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) {
    4615         prototypeStructureList = new PolymorphicAccessStructureList(vPC[6].u.operand, stubInfo->stubRoutine, vPC[4].u.structure, vPC[5].u.structure);
     4587    switch (stubInfo->opcodeID) {
     4588    case op_get_by_id_proto:
     4589        prototypeStructureList = new PolymorphicAccessStructureList(stubInfo->stubRoutine, stubInfo->u.getByIdProto.baseObjectStructure, stubInfo->u.getByIdProto.prototypeStructure);
    46164590        stubInfo->stubRoutine = 0;
    4617 
    4618         vPC[0] = interpreter->getOpcode(op_get_by_id_proto_list);
    4619         vPC[4] = prototypeStructureList;
    4620         vPC[5] = 2;
    4621     } else if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) {
    4622         prototypeStructureList = new PolymorphicAccessStructureList(vPC[6].u.operand, stubInfo->stubRoutine, vPC[4].u.structure, vPC[5].u.structureChain);
     4591        stubInfo->initGetByIdProtoList(prototypeStructureList, 2);
     4592        break;
     4593    case op_get_by_id_chain:
     4594        prototypeStructureList = new PolymorphicAccessStructureList(stubInfo->stubRoutine, stubInfo->u.getByIdChain.baseObjectStructure, stubInfo->u.getByIdChain.chain);
    46234595        stubInfo->stubRoutine = 0;
    4624 
    4625         vPC[0] = interpreter->getOpcode(op_get_by_id_proto_list);
    4626         vPC[4] = prototypeStructureList;
    4627         vPC[5] = 2;
    4628     } else {
    4629         ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto_list));
    4630         prototypeStructureList = vPC[4].u.polymorphicStructures;
    4631         listIndex = vPC[5].u.operand;
    4632         vPC[5] = listIndex + 1;
    4633 
    4634         ASSERT(listIndex < POLYMORPHIC_LIST_CACHE_SIZE);
     4596        stubInfo->initGetByIdProtoList(prototypeStructureList, 2);
     4597        break;
     4598    case op_get_by_id_proto_list:
     4599        prototypeStructureList = stubInfo->u.getByIdProtoList.structureList;
     4600        listIndex = stubInfo->u.getByIdProtoList.listSize;
     4601        stubInfo->u.getByIdProtoList.listSize++;
     4602        break;
     4603    default:
     4604        ASSERT_NOT_REACHED();
    46354605    }
    46364606   
     4607    ASSERT(listIndex < POLYMORPHIC_LIST_CACHE_SIZE);
    46374608    return prototypeStructureList;
    46384609}
     
    46584629    CodeBlock* codeBlock = callFrame->codeBlock();
    46594630    StructureStubInfo* stubInfo = &codeBlock->getStubInfo(CTI_RETURN_ADDRESS);
    4660     Instruction* vPC = codeBlock->instructions().begin() + stubInfo->bytecodeIndex;
    46614631
    46624632    ASSERT(slot.slotBase()->isObject());
     
    46754645
    46764646        int listIndex;
    4677         PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(ARG_globalData->interpreter, stubInfo, vPC, listIndex);
     4647        PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(stubInfo, listIndex);
    46784648
    46794649        JIT::compileGetByIdProtoList(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, slotBaseObject->structure(), slot.cachedOffset());
     
    46884658
    46894659        int listIndex;
    4690         PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(ARG_globalData->interpreter, stubInfo, vPC, listIndex);
     4660        PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(stubInfo, listIndex);
    46914661
    46924662        JIT::compileGetByIdChainList(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, chain, count, slot.cachedOffset());
     
    53585328    JSGlobalObject* globalObject = asGlobalObject(ARG_src1);
    53595329    Identifier& ident = *ARG_id2;
    5360     Instruction* vPC = ARG_instr3;
     5330    unsigned globalResolveInfoIndex = ARG_int3;
     5331    Instruction* vPC = ARG_instr4;
    53615332    ASSERT(globalObject->isGlobalObject());
    53625333
     
    53655336        JSValue* result = slot.getValue(callFrame, ident);
    53665337        if (slot.isCacheable()) {
    5367             if (vPC[4].u.structure)
    5368                 vPC[4].u.structure->deref();
     5338            GlobalResolveInfo& globalResolveInfo = callFrame->codeBlock()->globalResolveInfo(globalResolveInfoIndex);
     5339            if (globalResolveInfo.structure)
     5340                globalResolveInfo.structure->deref();
    53695341            globalObject->structure()->ref();
    5370             vPC[4] = globalObject->structure();
    5371             vPC[5] = slot.cachedOffset();
     5342            globalResolveInfo.structure = globalObject->structure();
     5343            globalResolveInfo.offset = slot.cachedOffset();
    53725344            return result;
    53735345        }
Note: See TracChangeset for help on using the changeset viewer.