Changeset 214838 in webkit


Ignore:
Timestamp:
Apr 3, 2017 2:07:01 PM (7 years ago)
Author:
fpizlo@apple.com
Message:

Move the Liveness<> adapters from AirLiveness.h to AirLivenessAdapter.h.

Rubber stamped by Keith Miller.

This will make it easier to write other code that uses those adapters.

(JSC::B3::Air::LivenessAdapter::LivenessAdapter): Deleted.
(JSC::B3::Air::LivenessAdapter::blockSize): Deleted.
(JSC::B3::Air::LivenessAdapter::forEachUse): Deleted.
(JSC::B3::Air::LivenessAdapter::forEachDef): Deleted.
(JSC::B3::Air::TmpLivenessAdapter::TmpLivenessAdapter): Deleted.
(JSC::B3::Air::TmpLivenessAdapter::numIndices): Deleted.
(JSC::B3::Air::TmpLivenessAdapter::acceptsBank): Deleted.
(JSC::B3::Air::TmpLivenessAdapter::acceptsRole): Deleted.
(JSC::B3::Air::TmpLivenessAdapter::valueToIndex): Deleted.
(JSC::B3::Air::TmpLivenessAdapter::indexToValue): Deleted.
(JSC::B3::Air::StackSlotLivenessAdapter::StackSlotLivenessAdapter): Deleted.
(JSC::B3::Air::StackSlotLivenessAdapter::numIndices): Deleted.
(JSC::B3::Air::StackSlotLivenessAdapter::acceptsBank): Deleted.
(JSC::B3::Air::StackSlotLivenessAdapter::acceptsRole): Deleted.
(JSC::B3::Air::StackSlotLivenessAdapter::valueToIndex): Deleted.
(JSC::B3::Air::StackSlotLivenessAdapter::indexToValue): Deleted.

  • b3/air/AirLivenessAdapter.h: Added.

(JSC::B3::Air::LivenessAdapter::LivenessAdapter):
(JSC::B3::Air::LivenessAdapter::blockSize):
(JSC::B3::Air::LivenessAdapter::forEachUse):
(JSC::B3::Air::LivenessAdapter::forEachDef):
(JSC::B3::Air::TmpLivenessAdapter::TmpLivenessAdapter):
(JSC::B3::Air::TmpLivenessAdapter::numIndices):
(JSC::B3::Air::TmpLivenessAdapter::acceptsBank):
(JSC::B3::Air::TmpLivenessAdapter::acceptsRole):
(JSC::B3::Air::TmpLivenessAdapter::valueToIndex):
(JSC::B3::Air::TmpLivenessAdapter::indexToValue):
(JSC::B3::Air::StackSlotLivenessAdapter::StackSlotLivenessAdapter):
(JSC::B3::Air::StackSlotLivenessAdapter::numIndices):
(JSC::B3::Air::StackSlotLivenessAdapter::acceptsBank):
(JSC::B3::Air::StackSlotLivenessAdapter::acceptsRole):
(JSC::B3::Air::StackSlotLivenessAdapter::valueToIndex):
(JSC::B3::Air::StackSlotLivenessAdapter::indexToValue):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r214836 r214838  
     12017-04-03  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Move the Liveness<> adapters from AirLiveness.h to AirLivenessAdapter.h.
     4
     5        Rubber stamped by Keith Miller.
     6       
     7        This will make it easier to write other code that uses those adapters.
     8
     9        * JavaScriptCore.xcodeproj/project.pbxproj:
     10        * b3/air/AirLiveness.h:
     11        (JSC::B3::Air::LivenessAdapter::LivenessAdapter): Deleted.
     12        (JSC::B3::Air::LivenessAdapter::blockSize): Deleted.
     13        (JSC::B3::Air::LivenessAdapter::forEachUse): Deleted.
     14        (JSC::B3::Air::LivenessAdapter::forEachDef): Deleted.
     15        (JSC::B3::Air::TmpLivenessAdapter::TmpLivenessAdapter): Deleted.
     16        (JSC::B3::Air::TmpLivenessAdapter::numIndices): Deleted.
     17        (JSC::B3::Air::TmpLivenessAdapter::acceptsBank): Deleted.
     18        (JSC::B3::Air::TmpLivenessAdapter::acceptsRole): Deleted.
     19        (JSC::B3::Air::TmpLivenessAdapter::valueToIndex): Deleted.
     20        (JSC::B3::Air::TmpLivenessAdapter::indexToValue): Deleted.
     21        (JSC::B3::Air::StackSlotLivenessAdapter::StackSlotLivenessAdapter): Deleted.
     22        (JSC::B3::Air::StackSlotLivenessAdapter::numIndices): Deleted.
     23        (JSC::B3::Air::StackSlotLivenessAdapter::acceptsBank): Deleted.
     24        (JSC::B3::Air::StackSlotLivenessAdapter::acceptsRole): Deleted.
     25        (JSC::B3::Air::StackSlotLivenessAdapter::valueToIndex): Deleted.
     26        (JSC::B3::Air::StackSlotLivenessAdapter::indexToValue): Deleted.
     27        * b3/air/AirLivenessAdapter.h: Added.
     28        (JSC::B3::Air::LivenessAdapter::LivenessAdapter):
     29        (JSC::B3::Air::LivenessAdapter::blockSize):
     30        (JSC::B3::Air::LivenessAdapter::forEachUse):
     31        (JSC::B3::Air::LivenessAdapter::forEachDef):
     32        (JSC::B3::Air::TmpLivenessAdapter::TmpLivenessAdapter):
     33        (JSC::B3::Air::TmpLivenessAdapter::numIndices):
     34        (JSC::B3::Air::TmpLivenessAdapter::acceptsBank):
     35        (JSC::B3::Air::TmpLivenessAdapter::acceptsRole):
     36        (JSC::B3::Air::TmpLivenessAdapter::valueToIndex):
     37        (JSC::B3::Air::TmpLivenessAdapter::indexToValue):
     38        (JSC::B3::Air::StackSlotLivenessAdapter::StackSlotLivenessAdapter):
     39        (JSC::B3::Air::StackSlotLivenessAdapter::numIndices):
     40        (JSC::B3::Air::StackSlotLivenessAdapter::acceptsBank):
     41        (JSC::B3::Air::StackSlotLivenessAdapter::acceptsRole):
     42        (JSC::B3::Air::StackSlotLivenessAdapter::valueToIndex):
     43        (JSC::B3::Air::StackSlotLivenessAdapter::indexToValue):
     44
    1452017-04-03  Filip Pizlo  <fpizlo@apple.com>
    246
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r214827 r214838  
    119119                0F15F15F14B7A73E005DE37D /* CommonSlowPaths.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */; settings = {ATTRIBUTES = (Private, ); }; };
    120120                0F1725FF1B48719A00AC3A55 /* DFGMinifiedGraph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F1725FE1B48719A00AC3A55 /* DFGMinifiedGraph.cpp */; };
     121                0F1829691E92EE54005B1EA8 /* AirLivenessAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F1829681E92EE51005B1EA8 /* AirLivenessAdapter.h */; };
    121122                0F18D3CF1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F18D3CD1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.cpp */; };
    122123                0F18D3D01B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F18D3CE1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h */; };
     
    26532654                0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonSlowPaths.h; sourceTree = "<group>"; };
    26542655                0F1725FE1B48719A00AC3A55 /* DFGMinifiedGraph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGMinifiedGraph.cpp; path = dfg/DFGMinifiedGraph.cpp; sourceTree = "<group>"; };
     2656                0F1829681E92EE51005B1EA8 /* AirLivenessAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirLivenessAdapter.h; path = b3/air/AirLivenessAdapter.h; sourceTree = "<group>"; };
    26552657                0F18D3CD1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGAdaptiveStructureWatchpoint.cpp; path = dfg/DFGAdaptiveStructureWatchpoint.cpp; sourceTree = "<group>"; };
    26562658                0F18D3CE1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAdaptiveStructureWatchpoint.h; path = dfg/DFGAdaptiveStructureWatchpoint.h; sourceTree = "<group>"; };
     
    56115613                                0FDF67D51D9DC43E001B9825 /* AirKind.h */,
    56125614                                2684D4371C00161C0081D663 /* AirLiveness.h */,
     5615                                0F1829681E92EE51005B1EA8 /* AirLivenessAdapter.h */,
    56135616                                0FE34C171C4B39AE0003A512 /* AirLogRegisterPressure.cpp */,
    56145617                                0FE34C181C4B39AE0003A512 /* AirLogRegisterPressure.h */,
     
    91119114                                7C008CE7187631B600955C24 /* Microtask.h in Headers */,
    91129115                                86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */,
     9116                                0F1829691E92EE54005B1EA8 /* AirLivenessAdapter.h in Headers */,
    91139117                                C4703CD7192844CC0013FBEA /* models.py in Headers */,
    91149118                                E3794E761B77EB97005543AE /* ModuleAnalyzer.h in Headers */,
  • trunk/Source/JavaScriptCore/b3/air/AirLiveness.h

    r214836 r214838  
    2828#if ENABLE(B3_JIT)
    2929
    30 #include "AirBasicBlock.h"
    31 #include "AirCFG.h"
    32 #include "AirCode.h"
    33 #include "AirInstInlines.h"
    34 #include "AirStackSlot.h"
    35 #include "AirTmpInlines.h"
     30#include "AirLivenessAdapter.h"
    3631#include <wtf/Liveness.h>
    3732
    3833namespace JSC { namespace B3 { namespace Air {
    39 
    40 template<typename Adapter>
    41 struct LivenessAdapter {
    42     typedef Air::CFG CFG;
    43    
    44     LivenessAdapter(Code& code)
    45         : code(code)
    46     {
    47     }
    48    
    49     unsigned blockSize(BasicBlock* block)
    50     {
    51         return block->size();
    52     }
    53    
    54     template<typename Func>
    55     void forEachUse(BasicBlock* block, size_t instBoundaryIndex, const Func& func)
    56     {
    57         if (Inst* prevInst = block->get(instBoundaryIndex - 1)) {
    58             prevInst->forEach<typename Adapter::Thing>(
    59                 [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
    60                     if (Arg::isLateUse(role)
    61                         && Adapter::acceptsBank(bank)
    62                         && Adapter::acceptsRole(role))
    63                         func(Adapter::valueToIndex(thing));
    64                 });
    65         }
    66        
    67         if (Inst* nextInst = block->get(instBoundaryIndex)) {
    68             nextInst->forEach<typename Adapter::Thing>(
    69                 [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
    70                     if (Arg::isEarlyUse(role)
    71                         && Adapter::acceptsBank(bank)
    72                         && Adapter::acceptsRole(role))
    73                         func(Adapter::valueToIndex(thing));
    74                 });
    75         }
    76     }
    77    
    78     template<typename Func>
    79     void forEachDef(BasicBlock* block, size_t instBoundaryIndex, const Func& func)
    80     {
    81         if (Inst* prevInst = block->get(instBoundaryIndex - 1)) {
    82             prevInst->forEach<typename Adapter::Thing>(
    83                 [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
    84                     if (Arg::isLateDef(role)
    85                         && Adapter::acceptsBank(bank)
    86                         && Adapter::acceptsRole(role))
    87                         func(Adapter::valueToIndex(thing));
    88                 });
    89         }
    90        
    91         if (Inst* nextInst = block->get(instBoundaryIndex)) {
    92             nextInst->forEach<typename Adapter::Thing>(
    93                 [&] (typename Adapter::Thing& thing, Arg::Role role, Bank bank, Width) {
    94                     if (Arg::isEarlyDef(role)
    95                         && Adapter::acceptsBank(bank)
    96                         && Adapter::acceptsRole(role))
    97                         func(Adapter::valueToIndex(thing));
    98                 });
    99         }
    100     }
    101 
    102     Code& code;
    103 };
    104 
    105 template<Bank adapterBank, Arg::Temperature minimumTemperature = Arg::Cold>
    106 struct TmpLivenessAdapter : LivenessAdapter<TmpLivenessAdapter<adapterBank, minimumTemperature>> {
    107     typedef LivenessAdapter<TmpLivenessAdapter<adapterBank, minimumTemperature>> Base;
    108    
    109     static constexpr const char* name = "TmpLiveness";
    110     typedef Tmp Thing;
    111 
    112     TmpLivenessAdapter(Code& code)
    113         : Base(code)
    114     {
    115     }
    116 
    117     unsigned numIndices()
    118     {
    119         unsigned numTmps = Base::code.numTmps(adapterBank);
    120         return AbsoluteTmpMapper<adapterBank>::absoluteIndex(numTmps);
    121     }
    122     static bool acceptsBank(Bank bank) { return bank == adapterBank; }
    123     static bool acceptsRole(Arg::Role role) { return Arg::temperature(role) >= minimumTemperature; }
    124     static unsigned valueToIndex(Tmp tmp) { return AbsoluteTmpMapper<adapterBank>::absoluteIndex(tmp); }
    125     static Tmp indexToValue(unsigned index) { return AbsoluteTmpMapper<adapterBank>::tmpFromAbsoluteIndex(index); }
    126 };
    127 
    128 struct StackSlotLivenessAdapter : LivenessAdapter<StackSlotLivenessAdapter> {
    129     static constexpr const char* name = "StackSlotLiveness";
    130     typedef StackSlot* Thing;
    131 
    132     StackSlotLivenessAdapter(Code& code)
    133         : LivenessAdapter(code)
    134     {
    135     }
    136 
    137     unsigned numIndices()
    138     {
    139         return code.stackSlots().size();
    140     }
    141     static bool acceptsBank(Bank) { return true; }
    142     static bool acceptsRole(Arg::Role) { return true; }
    143     static unsigned valueToIndex(StackSlot* stackSlot) { return stackSlot->index(); }
    144     StackSlot* indexToValue(unsigned index) { return code.stackSlots()[index]; }
    145 };
    14634
    14735template<typename Adapter>
Note: See TracChangeset for help on using the changeset viewer.