Changeset 244286 in webkit


Ignore:
Timestamp:
Apr 15, 2019 1:39:11 PM (5 years ago)
Author:
rmorisset@apple.com
Message:

Several structures and enums in the Yarr interpreter can be shrunk
https://bugs.webkit.org/show_bug.cgi?id=196923

Reviewed by Saam Barati.

YarrOp: 88 -> 80
RegularExpression: 40 -> 32
ByteTerm: 56 -> 48
PatternTerm: 56 -> 48

  • yarr/RegularExpression.cpp:
  • yarr/YarrInterpreter.h:
  • yarr/YarrJIT.cpp:

(JSC::Yarr::YarrGenerator::YarrOp::YarrOp):

  • yarr/YarrParser.h:
  • yarr/YarrPattern.h:
Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r244285 r244286  
     12019-04-15  Robin Morisset  <rmorisset@apple.com>
     2
     3        Several structures and enums in the Yarr interpreter can be shrunk
     4        https://bugs.webkit.org/show_bug.cgi?id=196923
     5
     6        Reviewed by Saam Barati.
     7
     8        YarrOp: 88 -> 80
     9        RegularExpression: 40 -> 32
     10        ByteTerm: 56 -> 48
     11        PatternTerm: 56 -> 48
     12
     13        * yarr/RegularExpression.cpp:
     14        * yarr/YarrInterpreter.h:
     15        * yarr/YarrJIT.cpp:
     16        (JSC::Yarr::YarrGenerator::YarrOp::YarrOp):
     17        * yarr/YarrParser.h:
     18        * yarr/YarrPattern.h:
     19
    1202019-04-15  Devin Rousso  <drousso@apple.com>
    221
  • trunk/Source/JavaScriptCore/yarr/RegularExpression.cpp

    r242699 r244286  
    4444    }
    4545
    46     int lastMatchLength { -1 };
    47 
    48     unsigned m_numSubpatterns;
    49     std::unique_ptr<JSC::Yarr::BytecodePattern> m_regExpByteCode;
    50 
    5146private:
    5247    Private(const String& pattern, TextCaseSensitivity caseSensitivity, MultilineMode multilineMode, UnicodeMode unicodeMode)
     
    7974    }
    8075
     76    JSC::Yarr::ErrorCode m_constructionErrorCode { Yarr::ErrorCode::NoError };
    8177    BumpPointerAllocator m_regexAllocator;
    82     JSC::Yarr::ErrorCode m_constructionErrorCode { Yarr::ErrorCode::NoError };
     78
     79public:
     80    int lastMatchLength { -1 };
     81    unsigned m_numSubpatterns;
     82    std::unique_ptr<JSC::Yarr::BytecodePattern> m_regExpByteCode;
    8383};
    8484
  • trunk/Source/JavaScriptCore/yarr/YarrInterpreter.h

    r242699 r244286  
    4040
    4141struct ByteTerm {
    42     enum Type {
     42    union {
     43        struct {
     44            union {
     45                UChar32 patternCharacter;
     46                struct {
     47                    UChar32 lo;
     48                    UChar32 hi;
     49                } casedCharacter;
     50                CharacterClass* characterClass;
     51                unsigned subpatternId;
     52            };
     53            union {
     54                ByteDisjunction* parenthesesDisjunction;
     55                unsigned parenthesesWidth;
     56            };
     57            QuantifierType quantityType;
     58            unsigned quantityMinCount;
     59            unsigned quantityMaxCount;
     60        } atom;
     61        struct {
     62            int next;
     63            int end;
     64            bool onceThrough;
     65        } alternative;
     66        struct {
     67            bool m_bol : 1;
     68            bool m_eol : 1;
     69        } anchors;
     70        unsigned checkInputCount;
     71    };
     72    unsigned frameLocation;
     73    enum Type : uint8_t {
    4374        TypeBodyAlternativeBegin,
    4475        TypeBodyAlternativeDisjunction,
     
    73104        TypeDotStarEnclosure,
    74105    } type;
    75     union {
    76         struct {
    77             union {
    78                 UChar32 patternCharacter;
    79                 struct {
    80                     UChar32 lo;
    81                     UChar32 hi;
    82                 } casedCharacter;
    83                 CharacterClass* characterClass;
    84                 unsigned subpatternId;
    85             };
    86             union {
    87                 ByteDisjunction* parenthesesDisjunction;
    88                 unsigned parenthesesWidth;
    89             };
    90             QuantifierType quantityType;
    91             unsigned quantityMinCount;
    92             unsigned quantityMaxCount;
    93         } atom;
    94         struct {
    95             int next;
    96             int end;
    97             bool onceThrough;
    98         } alternative;
    99         struct {
    100             bool m_bol : 1;
    101             bool m_eol : 1;
    102         } anchors;
    103         unsigned checkInputCount;
    104     };
    105     unsigned frameLocation;
    106106    bool m_capture : 1;
    107107    bool m_invert : 1;
     
    378378    OptionSet<Flags> m_flags;
    379379    // Each BytecodePattern is associated with a RegExp, each RegExp is associated
    380     // with a VM.  Cache a pointer to out VM's m_regExpAllocator.
     380    // with a VM.  Cache a pointer to our VM's m_regExpAllocator.
    381381    BumpPointerAllocator* m_allocator;
    382382    ConcurrentJSLock* m_lock;
  • trunk/Source/JavaScriptCore/yarr/YarrJIT.cpp

    r243967 r244286  
    771771    }
    772772
    773     enum YarrOpCode {
     773    enum YarrOpCode : uint8_t {
    774774        // These nodes wrap body alternatives - those in the main disjunction,
    775775        // rather than subpatterns or assertions. These are chained together in
     
    817817    struct YarrOp {
    818818        explicit YarrOp(PatternTerm* term)
    819             : m_op(OpTerm)
    820             , m_term(term)
     819            : m_term(term)
     820            , m_op(OpTerm)
    821821            , m_isDeadCode(false)
    822822        {
     
    828828        {
    829829        }
    830 
    831         // The operation, as a YarrOpCode, and also a reference to the PatternTerm.
    832         YarrOpCode m_op;
    833         PatternTerm* m_term;
    834830
    835831        // For alternatives, this holds the PatternAlternative and doubly linked
     
    841837        size_t m_previousOp;
    842838        size_t m_nextOp;
     839       
     840        // The operation, as a YarrOpCode, and also a reference to the PatternTerm.
     841        PatternTerm* m_term;
     842        YarrOpCode m_op;
    843843
    844844        // Used to record a set of Jumps out of the generated code, typically
  • trunk/Source/JavaScriptCore/yarr/YarrParser.h

    r239427 r244286  
    586586     * parseCharacterClass():
    587587     *
    588      * Helper for parseTokens(); calls dirctly and indirectly (via parseCharacterClassEscape)
     588     * Helper for parseTokens(); calls directly and indirectly (via parseCharacterClassEscape)
    589589     * to an instance of CharacterClassParserDelegate, to describe the character class to the
    590590     * delegate.
  • trunk/Source/JavaScriptCore/yarr/YarrPattern.h

    r243642 r244286  
    123123};
    124124
    125 enum QuantifierType {
     125enum QuantifierType : uint8_t {
    126126    QuantifierFixedCount,
    127127    QuantifierGreedy,
     
    130130
    131131struct PatternTerm {
    132     enum Type {
     132    enum Type : uint8_t {
    133133        TypeAssertionBOL,
    134134        TypeAssertionEOL,
     
    144144    bool m_capture :1;
    145145    bool m_invert :1;
     146    QuantifierType quantityType;
     147    Checked<unsigned> quantityMinCount;
     148    Checked<unsigned> quantityMaxCount;
    146149    union {
    147150        UChar32 patternCharacter;
     
    160163        } anchors;
    161164    };
    162     QuantifierType quantityType;
    163     Checked<unsigned> quantityMinCount;
    164     Checked<unsigned> quantityMaxCount;
    165165    unsigned inputPosition;
    166166    unsigned frameLocation;
Note: See TracChangeset for help on using the changeset viewer.