tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

htmlaccelNotInline.h (7980B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef mozilla_htmlaccel_htmlaccelNotInline_h
      6 #define mozilla_htmlaccel_htmlaccelNotInline_h
      7 
      8 #include "mozilla/Attributes.h"
      9 
     10 namespace mozilla::htmlaccel {
     11 // True iff the buffer contains less-than, ampersand, carriage return,
     12 // or U+0000.
     13 //
     14 // This one could probably be inline without LLVM issues when SIMD
     15 // acceleration is statically enabled, but it's probably not worth
     16 // the complexity to do that.
     17 MOZ_NEVER_INLINE bool ContainsMarkup(const char16_t* aPtr,
     18                                     const char16_t* aEnd);
     19 
     20 // HTML Serializer functions
     21 
     22 // NOTE! The SkipNonEscaped functions only skip full SIMD strides, but the
     23 // CountEscaped functions also handle the tail that doesn't fit in a SIMD
     24 // stride.
     25 
     26 /// Returns the length of the prefix that does not contain less-than,
     27 /// greater-than, ampersand, or no-break space.
     28 /// Examines the input in multiples of 16 code units and does not examine
     29 /// the tail that is left over.
     30 MOZ_NEVER_INLINE size_t SkipNonEscapedInTextNode(const char16_t* aPtr,
     31                                                 const char16_t* aEnd);
     32 
     33 /// Returns the length of the prefix that does not contain less-than,
     34 /// greater-than, ampersand, or no-break space.
     35 /// Examines the input in multiples of 16 code units and does not examine
     36 /// the tail that is left over.
     37 MOZ_NEVER_INLINE size_t SkipNonEscapedInTextNode(const char* aPtr,
     38                                                 const char* aEnd);
     39 
     40 /// Returns the length of the prefix that does not contain less-than,
     41 /// greater-than, ampersand, no-break space, or double quote.
     42 /// Examines the input in multiples of 16 code units and does not examine
     43 /// the tail that is left over.
     44 MOZ_NEVER_INLINE size_t SkipNonEscapedInAttributeValue(const char16_t* aPtr,
     45                                                       const char16_t* aEnd);
     46 
     47 /// Count occurrences of less-than, greater-than, ampersand, and no-break space.
     48 MOZ_NEVER_INLINE uint32_t CountEscapedInTextNode(const char16_t* aPtr,
     49                                                 const char16_t* aEnd);
     50 
     51 /// Count occurrences of less-than, greater-than, ampersand, and no-break space.
     52 MOZ_NEVER_INLINE uint32_t CountEscapedInTextNode(const char* aPtr,
     53                                                 const char* aEnd);
     54 
     55 /// Count occurrences of less-than, greater-than, ampersand, no-break space, and
     56 /// double quote.
     57 MOZ_NEVER_INLINE uint32_t CountEscapedInAttributeValue(const char16_t* aPtr,
     58                                                       const char16_t* aEnd);
     59 
     60 // HTML Tokenizer functions
     61 
     62 // Logically these should be MOZ_ALWAYS_INLINE_EVEN_DEBUG if LLVM was working
     63 // as expected. However, these are MOZ_NEVER_INLINE to work around
     64 // https://github.com/llvm/llvm-project/issues/160886 . This way, we get
     65 // a little bit of LICM for the SIMD constants that need to be loaded
     66 // from the constant pool instead of getting materialized by splatting
     67 // an immediate. Once the LLVM bug is fixed, these should be changed
     68 // to MOZ_ALWAYS_INLINE_EVEN_DEBUG to allow the constants to move further
     69 // up to the top of nsHtml5Tokenizer::stateLoop.
     70 
     71 /// The innerHTML / DOMParser case for the data state in the HTML parser
     72 MOZ_NEVER_INLINE int32_t AccelerateDataFastest(const char16_t* aPtr,
     73                                               const char16_t* aEnd);
     74 
     75 /// View Source case for the data state in the HTML parser
     76 MOZ_NEVER_INLINE int32_t AccelerateDataViewSource(const char16_t* aPtr,
     77                                                  const char16_t* aEnd);
     78 
     79 /// Normal network case for the data state in the HTML parser
     80 MOZ_NEVER_INLINE int32_t AccelerateDataLineCol(const char16_t* aPtr,
     81                                               const char16_t* aEnd);
     82 
     83 /// The innerHTML / DOMParser case for the RAWTEXT state in the HTML parser
     84 MOZ_NEVER_INLINE int32_t AccelerateRawtextFastest(const char16_t* aPtr,
     85                                                  const char16_t* aEnd);
     86 
     87 /// View Source case for the RAWTEXT state in the HTML parser
     88 MOZ_NEVER_INLINE int32_t AccelerateRawtextViewSource(const char16_t* aPtr,
     89                                                     const char16_t* aEnd);
     90 
     91 /// Normal network case for the RAWTEXT state in the HTML parser
     92 MOZ_NEVER_INLINE int32_t AccelerateRawtextLineCol(const char16_t* aPtr,
     93                                                  const char16_t* aEnd);
     94 
     95 /// The innerHTML / DOMParser case for the comment state in the HTML parser
     96 MOZ_NEVER_INLINE int32_t AccelerateCommentFastest(const char16_t* aPtr,
     97                                                  const char16_t* aEnd);
     98 
     99 /// View Source case for the comment state in the HTML parser
    100 MOZ_NEVER_INLINE int32_t AccelerateCommentViewSource(const char16_t* aPtr,
    101                                                     const char16_t* aEnd);
    102 
    103 /// Normal network case for the comment state in the HTML parser
    104 MOZ_NEVER_INLINE int32_t AccelerateCommentLineCol(const char16_t* aPtr,
    105                                                  const char16_t* aEnd);
    106 
    107 /// The innerHTML / DOMParser case for the attribute value single-quoted state
    108 /// in the HTML parser
    109 MOZ_NEVER_INLINE int32_t AccelerateAttributeValueSingleQuotedFastest(
    110    const char16_t* aPtr, const char16_t* aEnd);
    111 
    112 /// View Source case for the attribute value single-quoted state in the HTML
    113 /// parser
    114 MOZ_NEVER_INLINE int32_t AccelerateAttributeValueSingleQuotedViewSource(
    115    const char16_t* aPtr, const char16_t* aEnd);
    116 
    117 /// Normal network case for the attribute value single-quoted state in the HTML
    118 /// parser
    119 MOZ_NEVER_INLINE int32_t AccelerateAttributeValueSingleQuotedLineCol(
    120    const char16_t* aPtr, const char16_t* aEnd);
    121 
    122 /// The innerHTML / DOMParser case for the attribute value double-quoted state
    123 /// in the HTML parser
    124 MOZ_NEVER_INLINE int32_t AccelerateAttributeValueDoubleQuotedFastest(
    125    const char16_t* aPtr, const char16_t* aEnd);
    126 
    127 /// View Source case for the attribute value double-quoted state in the HTML
    128 /// parser
    129 MOZ_NEVER_INLINE int32_t AccelerateAttributeValueDoubleQuotedViewSource(
    130    const char16_t* aPtr, const char16_t* aEnd);
    131 
    132 /// Normal network case for the attribute value double-quoted state in the HTML
    133 /// parser
    134 MOZ_NEVER_INLINE int32_t AccelerateAttributeValueDoubleQuotedLineCol(
    135    const char16_t* aPtr, const char16_t* aEnd);
    136 
    137 /// The innerHTML / DOMParser case for the CDATA section state in the HTML
    138 /// parser
    139 MOZ_NEVER_INLINE int32_t AccelerateCdataSectionFastest(const char16_t* aPtr,
    140                                                       const char16_t* aEnd);
    141 
    142 /// View Source case for the CDATA section state in the HTML parser
    143 MOZ_NEVER_INLINE int32_t AccelerateCdataSectionViewSource(const char16_t* aPtr,
    144                                                          const char16_t* aEnd);
    145 
    146 /// Normal network case for the CDATA section state in the HTML parser
    147 MOZ_NEVER_INLINE int32_t AccelerateCdataSectionLineCol(const char16_t* aPtr,
    148                                                       const char16_t* aEnd);
    149 
    150 /// The innerHTML / DOMParser case for the plaintext state in the HTML parser
    151 MOZ_NEVER_INLINE int32_t AcceleratePlaintextFastest(const char16_t* aPtr,
    152                                                    const char16_t* aEnd);
    153 
    154 /// View Source case for the plaintext state in the HTML parser
    155 MOZ_NEVER_INLINE int32_t AcceleratePlaintextViewSource(const char16_t* aPtr,
    156                                                       const char16_t* aEnd);
    157 
    158 /// Normal network case for the plaintext state in the HTML parser
    159 MOZ_NEVER_INLINE int32_t AcceleratePlaintextLineCol(const char16_t* aPtr,
    160                                                    const char16_t* aEnd);
    161 
    162 }  // namespace mozilla::htmlaccel
    163 
    164 #endif  // mozilla_htmlaccel_htmlaccelNotInline_h