| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/3rdparty/masm/yarr/YarrJIT.h |
| Source code | Switch to Preprocessed file |
| Line | Source | Count |
|---|---|---|
| 1 | /* | - |
| 2 | * Copyright (C) 2009 Apple Inc. All rights reserved. | - |
| 3 | * | - |
| 4 | * Redistribution and use in source and binary forms, with or without | - |
| 5 | * modification, are permitted provided that the following conditions | - |
| 6 | * are met: | - |
| 7 | * 1. Redistributions of source code must retain the above copyright | - |
| 8 | * notice, this list of conditions and the following disclaimer. | - |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright | - |
| 10 | * notice, this list of conditions and the following disclaimer in the | - |
| 11 | * documentation and/or other materials provided with the distribution. | - |
| 12 | * | - |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | - |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | - |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | - |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | - |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | - |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | - |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | - |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | - |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | - |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | - |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | - |
| 24 | */ | - |
| 25 | - | |
| 26 | #ifndef YarrJIT_h | - |
| 27 | #define YarrJIT_h | - |
| 28 | - | |
| 29 | #if ENABLE(YARR_JIT) | - |
| 30 | - | |
| 31 | #include "JSGlobalData.h" | - |
| 32 | #include "MacroAssemblerCodeRef.h" | - |
| 33 | #include "MatchResult.h" | - |
| 34 | #include "Yarr.h" | - |
| 35 | #include "YarrPattern.h" | - |
| 36 | - | |
| 37 | #if CPU(X86) && !COMPILER(MSVC) | - |
| 38 | #define YARR_CALL __attribute__ ((regparm (3))) | - |
| 39 | #else | - |
| 40 | #define YARR_CALL | - |
| 41 | #endif | - |
| 42 | - | |
| 43 | namespace JSC { | - |
| 44 | - | |
| 45 | class JSGlobalData; | - |
| 46 | class ExecutablePool; | - |
| 47 | - | |
| 48 | namespace Yarr { | - |
| 49 | - | |
| 50 | class YarrCodeBlock { | - |
| 51 | #if CPU(X86_64) | - |
| 52 | typedef MatchResult (*YarrJITCode8)(const LChar* input, unsigned start, unsigned length, int* output) YARR_CALL; | - |
| 53 | typedef MatchResult (*YarrJITCode16)(const UChar* input, unsigned start, unsigned length, int* output) YARR_CALL; | - |
| 54 | typedef MatchResult (*YarrJITCodeMatchOnly8)(const LChar* input, unsigned start, unsigned length) YARR_CALL; | - |
| 55 | typedef MatchResult (*YarrJITCodeMatchOnly16)(const UChar* input, unsigned start, unsigned length) YARR_CALL; | - |
| 56 | #else | - |
| 57 | typedef EncodedMatchResult (*YarrJITCode8)(const LChar* input, unsigned start, unsigned length, int* output) YARR_CALL; | - |
| 58 | typedef EncodedMatchResult (*YarrJITCode16)(const UChar* input, unsigned start, unsigned length, int* output) YARR_CALL; | - |
| 59 | typedef EncodedMatchResult (*YarrJITCodeMatchOnly8)(const LChar* input, unsigned start, unsigned length) YARR_CALL; | - |
| 60 | typedef EncodedMatchResult (*YarrJITCodeMatchOnly16)(const UChar* input, unsigned start, unsigned length) YARR_CALL; | - |
| 61 | #endif | - |
| 62 | - | |
| 63 | public: | - |
| 64 | YarrCodeBlock() | - |
| 65 | : m_needFallBack(false) | - |
| 66 | { | - |
| 67 | } executed 1148940 times by 153 tests: end of blockExecuted by:
| 1148940 |
| 68 | - | |
| 69 | ~YarrCodeBlock() | - |
| 70 | { | - |
| 71 | } | - |
| 72 | - | |
| 73 | void setFallBack(bool fallback) { m_needFallBack = fallback; } executed 1151494 times by 153 tests: end of blockExecuted by:
| 1151494 |
| 74 | bool isFallBack() { return m_needFallBack; } executed 1162883 times by 153 tests: return m_needFallBack;Executed by:
| 1162883 |
| 75 | - | |
| 76 | bool has8BitCode() { return m_ref8.size(); } never executed: return m_ref8.size(); | 0 |
| 77 | bool has16BitCode() { return m_ref16.size(); } executed 1173862 times by 153 tests: return m_ref16.size();Executed by:
| 1173862 |
| 78 | void set8BitCode(MacroAssemblerCodeRef ref) { m_ref8 = ref; } never executed: end of block | 0 |
| 79 | void set16BitCode(MacroAssemblerCodeRef ref) { m_ref16 = ref; } executed 1151341 times by 153 tests: end of blockExecuted by:
| 1151341 |
| 80 | - | |
| 81 | bool has8BitCodeMatchOnly() { return m_matchOnly8.size(); } never executed: return m_matchOnly8.size(); | 0 |
| 82 | bool has16BitCodeMatchOnly() { return m_matchOnly16.size(); } never executed: return m_matchOnly16.size(); | 0 |
| 83 | void set8BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) { m_matchOnly8 = matchOnly; } never executed: end of block | 0 |
| 84 | void set16BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) { m_matchOnly16 = matchOnly; } never executed: end of block | 0 |
| 85 | - | |
| 86 | MatchResult execute(const LChar* input, unsigned start, unsigned length, int* output) | - |
| 87 | { | - |
| 88 | ASSERT(has8BitCode()); | - |
| 89 | return MatchResult(reinterpret_cast<YarrJITCode8>(m_ref8.code().executableAddress())(input, start, length, output)); never executed: return MatchResult(reinterpret_cast<YarrJITCode8>(m_ref8.code().executableAddress())(input, start, length, output)); | 0 |
| 90 | } | - |
| 91 | - | |
| 92 | MatchResult execute(const UChar* input, unsigned start, unsigned length, int* output) | - |
| 93 | { | - |
| 94 | ASSERT(has16BitCode()); | - |
| 95 | return MatchResult(reinterpret_cast<YarrJITCode16>(m_ref16.code().executableAddress())(input, start, length, output)); executed 11221 times by 3 tests: return MatchResult(reinterpret_cast<YarrJITCode16>(m_ref16.code().executableAddress())(input, start, length, output));Executed by:
| 11221 |
| 96 | } | - |
| 97 | - | |
| 98 | MatchResult execute(const LChar* input, unsigned start, unsigned length) | - |
| 99 | { | - |
| 100 | ASSERT(has8BitCodeMatchOnly()); | - |
| 101 | return MatchResult(reinterpret_cast<YarrJITCodeMatchOnly8>(m_matchOnly8.code().executableAddress())(input, start, length)); never executed: return MatchResult(reinterpret_cast<YarrJITCodeMatchOnly8>(m_matchOnly8.code().executableAddress())(input, start, length)); | 0 |
| 102 | } | - |
| 103 | - | |
| 104 | MatchResult execute(const UChar* input, unsigned start, unsigned length) | - |
| 105 | { | - |
| 106 | ASSERT(has16BitCodeMatchOnly()); | - |
| 107 | return MatchResult(reinterpret_cast<YarrJITCodeMatchOnly16>(m_matchOnly16.code().executableAddress())(input, start, length)); never executed: return MatchResult(reinterpret_cast<YarrJITCodeMatchOnly16>(m_matchOnly16.code().executableAddress())(input, start, length)); | 0 |
| 108 | } | - |
| 109 | - | |
| 110 | #if ENABLE(REGEXP_TRACING) | - |
| 111 | void *getAddr() { return m_ref.code().executableAddress(); } | - |
| 112 | #endif | - |
| 113 | - | |
| 114 | void clear() | - |
| 115 | { | - |
| 116 | m_ref8 = MacroAssemblerCodeRef(); | - |
| 117 | m_ref16 = MacroAssemblerCodeRef(); | - |
| 118 | m_matchOnly8 = MacroAssemblerCodeRef(); | - |
| 119 | m_matchOnly16 = MacroAssemblerCodeRef(); | - |
| 120 | m_needFallBack = false; | - |
| 121 | } never executed: end of block | 0 |
| 122 | - | |
| 123 | private: | - |
| 124 | MacroAssemblerCodeRef m_ref8; | - |
| 125 | MacroAssemblerCodeRef m_ref16; | - |
| 126 | MacroAssemblerCodeRef m_matchOnly8; | - |
| 127 | MacroAssemblerCodeRef m_matchOnly16; | - |
| 128 | bool m_needFallBack; | - |
| 129 | }; | - |
| 130 | - | |
| 131 | enum YarrJITCompileMode { | - |
| 132 | MatchOnly, | - |
| 133 | IncludeSubpatterns | - |
| 134 | }; | - |
| 135 | void jitCompile(YarrPattern&, YarrCharSize, JSGlobalData*, YarrCodeBlock& jitObject, YarrJITCompileMode = IncludeSubpatterns); | - |
| 136 | - | |
| 137 | } } // namespace JSC::Yarr | - |
| 138 | - | |
| 139 | #endif | - |
| 140 | - | |
| 141 | #endif // YarrJIT_h | - |
| Source code | Switch to Preprocessed file |