Changeset 46879 in webkit for trunk/JavaScriptCore/bytecode


Ignore:
Timestamp:
Aug 6, 2009, 8:05:42 PM (16 years ago)
Author:
[email protected]
Message:

2009-08-06 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Make get_by_id/put_by_id/method_check/call defer optimization using a data flag rather than a code modification.
( https://bugs.webkit.org/show_bug.cgi?id=27635 )

This improves performance of ENABLE(ASSEMBLER_WX_EXCLUSIVE) builds by 2-2.5%, reducing the overhead to about 2.5%.
(No performance impact with ASSEMBLER_WX_EXCLUSIVE disabled).

  • bytecode/CodeBlock.cpp: (JSC::printStructureStubInfo):
    • Make StructureStubInfo store the type as an integer, rather than an OpcodeID.
  • bytecode/CodeBlock.h: (JSC::): (JSC::CallLinkInfo::seenOnce): (JSC::CallLinkInfo::setSeen): (JSC::MethodCallLinkInfo::seenOnce): (JSC::MethodCallLinkInfo::setSeen):
    • Change a pointer in CallLinkInfo/MethodCallLinkInfo to use a PtrAndFlags, use a flag to track when an op has been executed once.
  • bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::deref):
    • Make StructureStubInfo store the type as an integer, rather than an OpcodeID.
  • bytecode/StructureStubInfo.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::seenOnce): (JSC::StructureStubInfo::setSeen):
    • Make StructureStubInfo store the type as an integer, rather than an OpcodeID, add a flag to track when an op has been executed once.
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitGetById): (JSC::BytecodeGenerator::emitPutById):
    • Make StructureStubInfo store the type as an integer, rather than an OpcodeID.
  • jit/JIT.cpp: (JSC::JIT::privateCompileCTIMachineTrampolines): (JSC::JIT::unlinkCall):
    • Remove the "don't lazy link" stage of calls.
  • jit/JIT.h: (JSC::JIT::compileCTIMachineTrampolines):
    • Remove the "don't lazy link" stage of calls.
  • jit/JITCall.cpp: (JSC::JIT::compileOpCallSlowCase):
    • Remove the "don't lazy link" stage of calls.
  • jit/JITStubs.cpp: (JSC::JITThunks::JITThunks): (JSC::JITThunks::tryCachePutByID): (JSC::JITThunks::tryCacheGetByID): (JSC::JITStubs::DEFINE_STUB_FUNCTION): (JSC::JITStubs::getPolymorphicAccessStructureListSlot):
    • Remove the "don't lazy link" stage of calls, and the "_second" stage of get_by_id/put_by_id/method_check.
  • jit/JITStubs.h: (JSC::JITThunks::ctiStringLengthTrampoline): (JSC::JITStubs::):
    • Remove the "don't lazy link" stage of calls, and the "_second" stage of get_by_id/put_by_id/method_check.
  • wtf/PtrAndFlags.h: (WTF::PtrAndFlags::PtrAndFlags): (WTF::PtrAndFlags::operator!): (WTF::PtrAndFlags::operator->):
    • Add ! and -> operators, add constuctor with pointer argument.
Location:
trunk/JavaScriptCore/bytecode
Files:
4 edited

Legend:

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

    r46620 r46879  
    231231static void printStructureStubInfo(const StructureStubInfo& stubInfo, unsigned instructionOffset)
    232232{
    233     switch (stubInfo.opcodeID) {
    234     case op_get_by_id_self:
     233    switch (stubInfo.accessType) {
     234    case access_get_by_id_self:
    235235        printf("  [%4d] %s: %s\n", instructionOffset, "get_by_id_self", pointerToSourceString(stubInfo.u.getByIdSelf.baseObjectStructure).UTF8String().c_str());
    236236        return;
    237     case op_get_by_id_proto:
     237    case access_get_by_id_proto:
    238238        printf("  [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_proto", pointerToSourceString(stubInfo.u.getByIdProto.baseObjectStructure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.getByIdProto.prototypeStructure).UTF8String().c_str());
    239239        return;
    240     case op_get_by_id_chain:
     240    case access_get_by_id_chain:
    241241        printf("  [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_chain", pointerToSourceString(stubInfo.u.getByIdChain.baseObjectStructure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.getByIdChain.chain).UTF8String().c_str());
    242242        return;
    243     case op_get_by_id_self_list:
     243    case access_get_by_id_self_list:
    244244        printf("  [%4d] %s: %s (%d)\n", instructionOffset, "op_get_by_id_self_list", pointerToSourceString(stubInfo.u.getByIdSelfList.structureList).UTF8String().c_str(), stubInfo.u.getByIdSelfList.listSize);
    245245        return;
    246     case op_get_by_id_proto_list:
     246    case access_get_by_id_proto_list:
    247247        printf("  [%4d] %s: %s (%d)\n", instructionOffset, "op_get_by_id_proto_list", pointerToSourceString(stubInfo.u.getByIdProtoList.structureList).UTF8String().c_str(), stubInfo.u.getByIdProtoList.listSize);
    248248        return;
    249     case op_put_by_id_transition:
     249    case access_put_by_id_transition:
    250250        printf("  [%4d] %s: %s, %s, %s\n", instructionOffset, "put_by_id_transition", pointerToSourceString(stubInfo.u.putByIdTransition.previousStructure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.putByIdTransition.structure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.putByIdTransition.chain).UTF8String().c_str());
    251251        return;
    252     case op_put_by_id_replace:
     252    case access_put_by_id_replace:
    253253        printf("  [%4d] %s: %s\n", instructionOffset, "put_by_id_replace", pointerToSourceString(stubInfo.u.putByIdReplace.baseObjectStructure).UTF8String().c_str());
    254254        return;
    255     case op_get_by_id:
     255    case access_get_by_id:
    256256        printf("  [%4d] %s\n", instructionOffset, "get_by_id");
    257257        return;
    258     case op_put_by_id:
     258    case access_put_by_id:
    259259        printf("  [%4d] %s\n", instructionOffset, "put_by_id");
    260260        return;
    261     case op_get_by_id_generic:
     261    case access_get_by_id_generic:
    262262        printf("  [%4d] %s\n", instructionOffset, "op_get_by_id_generic");
    263263        return;
    264     case op_put_by_id_generic:
     264    case access_put_by_id_generic:
    265265        printf("  [%4d] %s\n", instructionOffset, "op_put_by_id_generic");
    266266        return;
    267     case op_get_array_length:
     267    case access_get_array_length:
    268268        printf("  [%4d] %s\n", instructionOffset, "op_get_array_length");
    269269        return;
    270     case op_get_string_length:
     270    case access_get_string_length:
    271271        printf("  [%4d] %s\n", instructionOffset, "op_get_string_length");
    272272        return;
     
    13201320            structure->deref();
    13211321            // Both members must be filled at the same time
    1322             ASSERT(m_methodCallLinkInfos[i].cachedPrototypeStructure);
     1322            ASSERT(!!m_methodCallLinkInfos[i].cachedPrototypeStructure);
    13231323            m_methodCallLinkInfos[i].cachedPrototypeStructure->deref();
    13241324        }
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r46831 r46879  
    3737#include "JumpTable.h"
    3838#include "Nodes.h"
     39#include "PtrAndFlags.h"
    3940#include "RegExp.h"
    4041#include "UString.h"
     
    5455
    5556namespace JSC {
     57
     58    enum HasSeenShouldRepatch {
     59        hasSeenShouldRepatch
     60    };
    5661
    5762    class ExecState;
     
    106111        CodeLocationDataLabelPtr hotPathBegin;
    107112        CodeLocationNearCall hotPathOther;
    108         CodeBlock* ownerCodeBlock;
     113        PtrAndFlags<CodeBlock, HasSeenShouldRepatch> ownerCodeBlock;
    109114        CodeBlock* callee;
    110115        unsigned position;
     
    112117        void setUnlinked() { callee = 0; }
    113118        bool isLinked() { return callee; }
     119
     120        bool seenOnce()
     121        {
     122            return ownerCodeBlock.isFlagSet(hasSeenShouldRepatch);
     123        }
     124
     125        void setSeen()
     126        {
     127            ownerCodeBlock.setFlag(hasSeenShouldRepatch);
     128        }
    114129    };
    115130
     
    117132        MethodCallLinkInfo()
    118133            : cachedStructure(0)
    119             , cachedPrototypeStructure(0)
    120         {
     134        {
     135        }
     136
     137        bool seenOnce()
     138        {
     139            return cachedPrototypeStructure.isFlagSet(hasSeenShouldRepatch);
     140        }
     141
     142        void setSeen()
     143        {
     144            cachedPrototypeStructure.setFlag(hasSeenShouldRepatch);
    121145        }
    122146
     
    124148        CodeLocationDataLabelPtr structureLabel;
    125149        Structure* cachedStructure;
    126         Structure* cachedPrototypeStructure;
     150        PtrAndFlags<Structure, HasSeenShouldRepatch> cachedPrototypeStructure;
    127151    };
    128152
  • trunk/JavaScriptCore/bytecode/StructureStubInfo.cpp

    r46620 r46879  
    3232void StructureStubInfo::deref()
    3333{
    34     switch (opcodeID) {
    35     case op_get_by_id_self:
     34    switch (accessType) {
     35    case access_get_by_id_self:
    3636        u.getByIdSelf.baseObjectStructure->deref();
    3737        return;
    38     case op_get_by_id_proto:
     38    case access_get_by_id_proto:
    3939        u.getByIdProto.baseObjectStructure->deref();
    4040        u.getByIdProto.prototypeStructure->deref();
    4141        return;
    42     case op_get_by_id_chain:
     42    case access_get_by_id_chain:
    4343        u.getByIdChain.baseObjectStructure->deref();
    4444        u.getByIdChain.chain->deref();
    4545        return;
    46     case op_get_by_id_self_list: {
     46    case access_get_by_id_self_list: {
    4747        PolymorphicAccessStructureList* polymorphicStructures = u.getByIdSelfList.structureList;
    4848        polymorphicStructures->derefStructures(u.getByIdSelfList.listSize);
     
    5050        return;
    5151    }
    52     case op_get_by_id_proto_list: {
     52    case access_get_by_id_proto_list: {
    5353        PolymorphicAccessStructureList* polymorphicStructures = u.getByIdProtoList.structureList;
    5454        polymorphicStructures->derefStructures(u.getByIdProtoList.listSize);
     
    5656        return;
    5757    }
    58     case op_put_by_id_transition:
     58    case access_put_by_id_transition:
    5959        u.putByIdTransition.previousStructure->deref();
    6060        u.putByIdTransition.structure->deref();
    6161        u.putByIdTransition.chain->deref();
    6262        return;
    63     case op_put_by_id_replace:
     63    case access_put_by_id_replace:
    6464        u.putByIdReplace.baseObjectStructure->deref();
    6565        return;
    66     case op_get_by_id:
    67     case op_put_by_id:
    68     case op_get_by_id_generic:
    69     case op_put_by_id_generic:
    70     case op_get_array_length:
    71     case op_get_string_length:
     66    case access_get_by_id:
     67    case access_put_by_id:
     68    case access_get_by_id_generic:
     69    case access_put_by_id_generic:
     70    case access_get_array_length:
     71    case access_get_string_length:
    7272        // These instructions don't ref their Structures.
    7373        return;
  • trunk/JavaScriptCore/bytecode/StructureStubInfo.h

    r46620 r46879  
    3636namespace JSC {
    3737
     38    enum AccessType {
     39        access_get_by_id_self,
     40        access_get_by_id_proto,
     41        access_get_by_id_chain,
     42        access_get_by_id_self_list,
     43        access_get_by_id_proto_list,
     44        access_put_by_id_transition,
     45        access_put_by_id_replace,
     46        access_get_by_id,
     47        access_put_by_id,
     48        access_get_by_id_generic,
     49        access_put_by_id_generic,
     50        access_get_array_length,
     51        access_get_string_length,
     52    };
     53
    3854    struct StructureStubInfo {
    39         StructureStubInfo(OpcodeID opcodeID)
    40             : opcodeID(opcodeID)
     55        StructureStubInfo(AccessType accessType)
     56            : accessType(accessType)
     57            , seen(false)
    4158        {
    4259        }
     
    4461        void initGetByIdSelf(Structure* baseObjectStructure)
    4562        {
    46             opcodeID = op_get_by_id_self;
     63            accessType = access_get_by_id_self;
    4764
    4865            u.getByIdSelf.baseObjectStructure = baseObjectStructure;
     
    5269        void initGetByIdProto(Structure* baseObjectStructure, Structure* prototypeStructure)
    5370        {
    54             opcodeID = op_get_by_id_proto;
     71            accessType = access_get_by_id_proto;
    5572
    5673            u.getByIdProto.baseObjectStructure = baseObjectStructure;
     
    6380        void initGetByIdChain(Structure* baseObjectStructure, StructureChain* chain)
    6481        {
    65             opcodeID = op_get_by_id_chain;
     82            accessType = access_get_by_id_chain;
    6683
    6784            u.getByIdChain.baseObjectStructure = baseObjectStructure;
     
    7491        void initGetByIdSelfList(PolymorphicAccessStructureList* structureList, int listSize)
    7592        {
    76             opcodeID = op_get_by_id_self_list;
     93            accessType = access_get_by_id_self_list;
    7794
    7895            u.getByIdProtoList.structureList = structureList;
     
    8299        void initGetByIdProtoList(PolymorphicAccessStructureList* structureList, int listSize)
    83100        {
    84             opcodeID = op_get_by_id_proto_list;
     101            accessType = access_get_by_id_proto_list;
    85102
    86103            u.getByIdProtoList.structureList = structureList;
     
    92109        void initPutByIdTransition(Structure* previousStructure, Structure* structure, StructureChain* chain)
    93110        {
    94             opcodeID = op_put_by_id_transition;
     111            accessType = access_put_by_id_transition;
    95112
    96113            u.putByIdTransition.previousStructure = previousStructure;
     
    106123        void initPutByIdReplace(Structure* baseObjectStructure)
    107124        {
    108             opcodeID = op_put_by_id_replace;
     125            accessType = access_put_by_id_replace;
    109126   
    110127            u.putByIdReplace.baseObjectStructure = baseObjectStructure;
     
    114131        void deref();
    115132
    116         OpcodeID opcodeID;
     133        bool seenOnce()
     134        {
     135            return seen;
     136        }
     137
     138        void setSeen()
     139        {
     140            seen = true;
     141        }
     142
     143        int accessType : 31;
     144        int seen : 1;
     145
    117146        union {
    118147            struct {
Note: See TracChangeset for help on using the changeset viewer.