Changeset 46618 in webkit for trunk/JavaScriptCore/bytecode


Ignore:
Timestamp:
Jul 30, 2009, 7:20:11 PM (16 years ago)
Author:
[email protected]
Message:

2009-07-23 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

    r46598 r46618  
    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;
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r46598 r46618  
    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
     
    121136        }
    122137
     138        bool seenOnce()
     139        {
     140            return cachedPrototypeStructure.isFlagSet(hasSeenShouldRepatch);
     141        }
     142
     143        void setSeen()
     144        {
     145            cachedPrototypeStructure.setFlag(hasSeenShouldRepatch);
     146        }
     147
    123148        CodeLocationCall callReturnLocation;
    124149        CodeLocationDataLabelPtr structureLabel;
    125150        Structure* cachedStructure;
    126         Structure* cachedPrototypeStructure;
     151        PtrAndFlags<Structure, HasSeenShouldRepatch> cachedPrototypeStructure;
    127152    };
    128153
  • trunk/JavaScriptCore/bytecode/StructureStubInfo.cpp

    r39229 r46618  
    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

    r44711 r46618  
    3434#include "Structure.h"
    3535
     36
    3637namespace JSC {
    3738
     39    static const int access_get_by_id_self = 0;
     40    static const int access_get_by_id_proto = 1;
     41    static const int access_get_by_id_chain = 2;
     42    static const int access_get_by_id_self_list = 3;
     43    static const int access_get_by_id_proto_list = 4;
     44    static const int access_put_by_id_transition = 5;
     45    static const int access_put_by_id_replace = 6;
     46    static const int access_get_by_id = 7;
     47    static const int access_put_by_id = 8;
     48    static const int access_get_by_id_generic = 9;
     49    static const int access_put_by_id_generic = 10;
     50    static const int access_get_array_length = 11;
     51    static const int access_get_string_length = 12;
     52
    3853    struct StructureStubInfo {
    39         StructureStubInfo(OpcodeID opcodeID)
    40             : opcodeID(opcodeID)
     54        StructureStubInfo(int accessType)
     55            : accessType(accessType)
     56            , seen(false)
    4157        {
    4258        }
     
    4460        void initGetByIdSelf(Structure* baseObjectStructure)
    4561        {
    46             opcodeID = op_get_by_id_self;
     62            accessType = access_get_by_id_self;
    4763
    4864            u.getByIdSelf.baseObjectStructure = baseObjectStructure;
     
    5268        void initGetByIdProto(Structure* baseObjectStructure, Structure* prototypeStructure)
    5369        {
    54             opcodeID = op_get_by_id_proto;
     70            accessType = access_get_by_id_proto;
    5571
    5672            u.getByIdProto.baseObjectStructure = baseObjectStructure;
     
    6379        void initGetByIdChain(Structure* baseObjectStructure, StructureChain* chain)
    6480        {
    65             opcodeID = op_get_by_id_chain;
     81            accessType = access_get_by_id_chain;
    6682
    6783            u.getByIdChain.baseObjectStructure = baseObjectStructure;
     
    7490        void initGetByIdSelfList(PolymorphicAccessStructureList* structureList, int listSize)
    7591        {
    76             opcodeID = op_get_by_id_self_list;
     92            accessType = access_get_by_id_self_list;
    7793
    7894            u.getByIdProtoList.structureList = structureList;
     
    8298        void initGetByIdProtoList(PolymorphicAccessStructureList* structureList, int listSize)
    8399        {
    84             opcodeID = op_get_by_id_proto_list;
     100            accessType = access_get_by_id_proto_list;
    85101
    86102            u.getByIdProtoList.structureList = structureList;
     
    92108        void initPutByIdTransition(Structure* previousStructure, Structure* structure, StructureChain* chain)
    93109        {
    94             opcodeID = op_put_by_id_transition;
     110            accessType = access_put_by_id_transition;
    95111
    96112            u.putByIdTransition.previousStructure = previousStructure;
     
    106122        void initPutByIdReplace(Structure* baseObjectStructure)
    107123        {
    108             opcodeID = op_put_by_id_replace;
     124            accessType = access_put_by_id_replace;
    109125   
    110126            u.putByIdReplace.baseObjectStructure = baseObjectStructure;
     
    114130        void deref();
    115131
    116         OpcodeID opcodeID;
     132        bool seenOnce()
     133        {
     134            return seen;
     135        }
     136
     137        void setSeen()
     138        {
     139            seen = true;
     140        }
     141
     142        int accessType : 31;
     143        int seen : 1;
     144
    117145        union {
    118146            struct {
Note: See TracChangeset for help on using the changeset viewer.