diff options
Diffstat (limited to 'src/3rdparty/masm/yarr')
-rw-r--r-- | src/3rdparty/masm/yarr/YarrJIT.cpp | 40 | ||||
-rw-r--r-- | src/3rdparty/masm/yarr/YarrJIT.h | 25 | ||||
-rw-r--r-- | src/3rdparty/masm/yarr/YarrPattern.h | 1 |
3 files changed, 50 insertions, 16 deletions
diff --git a/src/3rdparty/masm/yarr/YarrJIT.cpp b/src/3rdparty/masm/yarr/YarrJIT.cpp index dee2ade407..da65b772f7 100644 --- a/src/3rdparty/masm/yarr/YarrJIT.cpp +++ b/src/3rdparty/masm/yarr/YarrJIT.cpp @@ -33,6 +33,8 @@ #include "Yarr.h" #include "YarrCanonicalize.h" +#include <private/qv4functiontable_p.h> + #if ENABLE(YARR_JIT) using namespace WTF; @@ -3529,17 +3531,30 @@ public: m_backtrackingState.linkDataLabels(linkBuffer); + CodeRef codeRef; if (compileMode == MatchOnly) { - if (m_charSize == Char8) - codeBlock.set8BitCodeMatchOnly(FINALIZE_CODE(linkBuffer, "YarrJIT", "Match-only 8-bit regular expression")); - else - codeBlock.set16BitCodeMatchOnly(FINALIZE_CODE(linkBuffer, "YarrJIT", "Match-only 16-bit regular expression")); + if (m_charSize == Char8) { + codeRef = FINALIZE_CODE(linkBuffer, "YarrJIT", + "Match-only 8-bit regular expression"); + codeBlock.set8BitCodeMatchOnly(codeRef); + } else { + codeRef = FINALIZE_CODE(linkBuffer, "YarrJIT", + "Match-only 16-bit regular expression"); + codeBlock.set16BitCodeMatchOnly(codeRef); + } } else { - if (m_charSize == Char8) - codeBlock.set8BitCode(FINALIZE_CODE(linkBuffer, "YarrJIT", "8-bit regular expression")); - else - codeBlock.set16BitCode(FINALIZE_CODE(linkBuffer, "YarrJIT", "16-bit regular expression")); + if (m_charSize == Char8) { + codeRef = FINALIZE_CODE(linkBuffer, "YarrJIT", "8-bit regular expression"); + codeBlock.set8BitCode(codeRef); + } else { + codeRef = FINALIZE_CODE(linkBuffer, "YarrJIT", "16-bit regular expression"); + codeBlock.set16BitCode(codeRef); + } } + QV4::generateFunctionTable(nullptr, &codeRef); + + linkBuffer.makeExecutable(); + if (m_failureReason) codeBlock.setFallBackWithFailureReason(*m_failureReason); } @@ -3587,6 +3602,15 @@ private: BacktrackingState m_backtrackingState; }; +void YarrCodeBlock::replaceCodeRef(MacroAssemblerCodeRef &target, + const MacroAssemblerCodeRef &source) +{ + if (!!target && target.code().executableAddress() != source.code().executableAddress()) + QV4::destroyFunctionTable(nullptr, &target); + + target = source; +} + static void dumpCompileFailure(JITFailureReason failure) { switch (failure) { diff --git a/src/3rdparty/masm/yarr/YarrJIT.h b/src/3rdparty/masm/yarr/YarrJIT.h index 8b6b3a7577..35a0690f6e 100644 --- a/src/3rdparty/masm/yarr/YarrJIT.h +++ b/src/3rdparty/masm/yarr/YarrJIT.h @@ -82,19 +82,28 @@ class YarrCodeBlock { public: YarrCodeBlock() = default; + ~YarrCodeBlock() { clear(); } + + static void replaceCodeRef(MacroAssemblerCodeRef &target, const MacroAssemblerCodeRef &source); void setFallBackWithFailureReason(JITFailureReason failureReason) { m_failureReason = failureReason; } std::optional<JITFailureReason> failureReason() { return m_failureReason; } bool has8BitCode() { return m_ref8.size(); } bool has16BitCode() { return m_ref16.size(); } - void set8BitCode(MacroAssemblerCodeRef ref) { m_ref8 = ref; } - void set16BitCode(MacroAssemblerCodeRef ref) { m_ref16 = ref; } + void set8BitCode(MacroAssemblerCodeRef ref) { replaceCodeRef(m_ref8, ref); } + void set16BitCode(MacroAssemblerCodeRef ref) { replaceCodeRef(m_ref16, ref); } bool has8BitCodeMatchOnly() { return m_matchOnly8.size(); } bool has16BitCodeMatchOnly() { return m_matchOnly16.size(); } - void set8BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) { m_matchOnly8 = matchOnly; } - void set16BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) { m_matchOnly16 = matchOnly; } + void set8BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) + { + replaceCodeRef(m_matchOnly8, matchOnly); + } + void set16BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) + { + replaceCodeRef(m_matchOnly16, matchOnly); + } #if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS) bool usesPatternContextBuffer() { return m_usesPatternContextBuffer; } @@ -190,10 +199,10 @@ public: void clear() { - m_ref8 = MacroAssemblerCodeRef(); - m_ref16 = MacroAssemblerCodeRef(); - m_matchOnly8 = MacroAssemblerCodeRef(); - m_matchOnly16 = MacroAssemblerCodeRef(); + replaceCodeRef(m_ref8, MacroAssemblerCodeRef()); + replaceCodeRef(m_ref16, MacroAssemblerCodeRef()); + replaceCodeRef(m_matchOnly8, MacroAssemblerCodeRef()); + replaceCodeRef(m_matchOnly16, MacroAssemblerCodeRef()); m_failureReason = std::nullopt; } diff --git a/src/3rdparty/masm/yarr/YarrPattern.h b/src/3rdparty/masm/yarr/YarrPattern.h index 59decbac46..f7ddf861ba 100644 --- a/src/3rdparty/masm/yarr/YarrPattern.h +++ b/src/3rdparty/masm/yarr/YarrPattern.h @@ -31,6 +31,7 @@ #include "YarrUnicodeProperties.h" #include <wtf/CheckedArithmetic.h> #include <wtf/HashMap.h> +#include <wtf/Optional.h> #include <wtf/PrintStream.h> #include <wtf/Vector.h> #include <wtf/text/WTFString.h> |