PCRE: update to 10.36
Dropped the RTEMS patch (upstream now uses posix_madvise). Drop support for the TILE architecture (dropped by upstream). [ChangeLog][Third-Party Code] PCRE2 has been updated to version 10.36. Change-Id: Idb4467bef0ff520605b8b5d9188b9d67d8e4d0f2 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 509c25752112583e6bc997e8c9442f6b69136816) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
19fac4f9f2
commit
792caf9824
4
src/3rdparty/pcre2/AUTHORS
vendored
4
src/3rdparty/pcre2/AUTHORS
vendored
@ -2,8 +2,8 @@ THE MAIN PCRE2 LIBRARY CODE
|
|||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
Written by: Philip Hazel
|
Written by: Philip Hazel
|
||||||
Email local part: ph10
|
Email local part: Philip.Hazel
|
||||||
Email domain: cam.ac.uk
|
Email domain: gmail.com
|
||||||
|
|
||||||
University of Cambridge Computing Service,
|
University of Cambridge Computing Service,
|
||||||
Cambridge, England.
|
Cambridge, England.
|
||||||
|
4
src/3rdparty/pcre2/LICENCE
vendored
4
src/3rdparty/pcre2/LICENCE
vendored
@ -20,8 +20,8 @@ THE BASIC LIBRARY FUNCTIONS
|
|||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
Written by: Philip Hazel
|
Written by: Philip Hazel
|
||||||
Email local part: ph10
|
Email local part: Philip.Hazel
|
||||||
Email domain: cam.ac.uk
|
Email domain: gmail.com
|
||||||
|
|
||||||
University of Cambridge Computing Service,
|
University of Cambridge Computing Service,
|
||||||
Cambridge, England.
|
Cambridge, England.
|
||||||
|
@ -128,14 +128,15 @@ FILES="
|
|||||||
src/sljit/sljitNativePPC_32.c
|
src/sljit/sljitNativePPC_32.c
|
||||||
src/sljit/sljitNativePPC_64.c
|
src/sljit/sljitNativePPC_64.c
|
||||||
src/sljit/sljitNativePPC_common.c
|
src/sljit/sljitNativePPC_common.c
|
||||||
|
src/sljit/sljitNativeS390X.c
|
||||||
src/sljit/sljitNativeSPARC_32.c
|
src/sljit/sljitNativeSPARC_32.c
|
||||||
src/sljit/sljitNativeSPARC_common.c
|
src/sljit/sljitNativeSPARC_common.c
|
||||||
src/sljit/sljitNativeTILEGX_64.c
|
|
||||||
src/sljit/sljitNativeTILEGX-encoder.c
|
|
||||||
src/sljit/sljitNativeX86_32.c
|
src/sljit/sljitNativeX86_32.c
|
||||||
src/sljit/sljitNativeX86_64.c
|
src/sljit/sljitNativeX86_64.c
|
||||||
src/sljit/sljitNativeX86_common.c
|
src/sljit/sljitNativeX86_common.c
|
||||||
|
src/sljit/sljitProtExecAllocator.c
|
||||||
src/sljit/sljitUtils.c
|
src/sljit/sljitUtils.c
|
||||||
|
src/sljit/sljitWXExecAllocator.c
|
||||||
"
|
"
|
||||||
|
|
||||||
for i in $FILES; do
|
for i in $FILES; do
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
From ac10063196685fe6124055feb1275e13a78f562e Mon Sep 17 00:00:00 2001
|
|
||||||
From: Mikhail Svetkin <mikhail.svetkin@qt.io>
|
|
||||||
Date: Tue, 20 Mar 2018 14:03:54 +0100
|
|
||||||
Subject: [PATCH] rtems: Fix pcre2 build (madvise undefined)
|
|
||||||
|
|
||||||
RTEMS does not have madvise. We can use only posix_madvise
|
|
||||||
|
|
||||||
Change-Id: Ia18b7cd2d7f9db84331f7e2350d060b9e85b30c8
|
|
||||||
---
|
|
||||||
src/3rdparty/pcre2/src/sljit/sljitUtils.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/3rdparty/pcre2/src/sljit/sljitUtils.c b/src/3rdparty/pcre2/src/sljit/sljitUtils.c
|
|
||||||
index 5c2a838932..2ead044b1b 100644
|
|
||||||
--- a/src/3rdparty/pcre2/src/sljit/sljitUtils.c
|
|
||||||
+++ b/src/3rdparty/pcre2/src/sljit/sljitUtils.c
|
|
||||||
@@ -315,7 +315,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_u8 *SLJIT_FUNC sljit_stack_resize(struct sljit_st
|
|
||||||
aligned_new_start = (sljit_uw)new_start & ~sljit_page_align;
|
|
||||||
aligned_old_start = ((sljit_uw)stack->start) & ~sljit_page_align;
|
|
||||||
/* If madvise is available, we release the unnecessary space. */
|
|
||||||
-#if defined(MADV_DONTNEED)
|
|
||||||
+#if defined(MADV_DONTNEED) && !defined(__rtems__)
|
|
||||||
if (aligned_new_start > aligned_old_start)
|
|
||||||
madvise((void*)aligned_old_start, aligned_new_start - aligned_old_start, MADV_DONTNEED);
|
|
||||||
#elif defined(POSIX_MADV_DONTNEED)
|
|
||||||
--
|
|
||||||
2.21.0
|
|
||||||
|
|
11
src/3rdparty/pcre2/qt_attribution.json
vendored
11
src/3rdparty/pcre2/qt_attribution.json
vendored
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
"Description": "The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.",
|
"Description": "The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.",
|
||||||
"Homepage": "http://www.pcre.org/",
|
"Homepage": "http://www.pcre.org/",
|
||||||
"Version": "10.35",
|
"Version": "10.36",
|
||||||
"DownloadLocation": "https://ftp.pcre.org/pub/pcre/pcre2-10.35.tar.bz2",
|
"DownloadLocation": "https://ftp.pcre.org/pub/pcre/pcre2-10.36.tar.bz2",
|
||||||
"License": "BSD 3-clause \"New\" or \"Revised\" License",
|
"License": "BSD 3-clause \"New\" or \"Revised\" License",
|
||||||
"LicenseId": "BSD-3-Clause",
|
"LicenseId": "BSD-3-Clause",
|
||||||
"LicenseFile": "LICENCE",
|
"LicenseFile": "LICENCE",
|
||||||
@ -24,12 +24,11 @@ Copyright (c) 2010-2020 Zoltan Herczeg"
|
|||||||
"Path": "src/sljit",
|
"Path": "src/sljit",
|
||||||
"Description": "The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.",
|
"Description": "The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.",
|
||||||
"Homepage": "http://www.pcre.org/",
|
"Homepage": "http://www.pcre.org/",
|
||||||
"Version": "10.35",
|
"Version": "10.36",
|
||||||
"DownloadLocation": "https://ftp.pcre.org/pub/pcre/pcre2-10.35.tar.bz2",
|
"DownloadLocation": "https://ftp.pcre.org/pub/pcre/pcre2-10.36.tar.bz2",
|
||||||
"License": "BSD 2-clause \"Simplified\" License",
|
"License": "BSD 2-clause \"Simplified\" License",
|
||||||
"LicenseId": "BSD-2-Clause",
|
"LicenseId": "BSD-2-Clause",
|
||||||
"LicenseFile": "LICENCE-SLJIT",
|
"LicenseFile": "LICENCE-SLJIT",
|
||||||
"Copyright": "Copyright (c) 2009-2020 Zoltan Herczeg
|
"Copyright": "Copyright (c) 2009-2020 Zoltan Herczeg"
|
||||||
Copyright 2013-2013 Tilera Corporation(jiwang@tilera.com)"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
4
src/3rdparty/pcre2/src/pcre2.h
vendored
4
src/3rdparty/pcre2/src/pcre2.h
vendored
@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
/* The current PCRE version information. */
|
/* The current PCRE version information. */
|
||||||
|
|
||||||
#define PCRE2_MAJOR 10
|
#define PCRE2_MAJOR 10
|
||||||
#define PCRE2_MINOR 35
|
#define PCRE2_MINOR 36
|
||||||
#define PCRE2_PRERELEASE
|
#define PCRE2_PRERELEASE
|
||||||
#define PCRE2_DATE 2020-05-09
|
#define PCRE2_DATE 2020-12-04
|
||||||
|
|
||||||
/* When an application links to a PCRE DLL in Windows, the symbols that are
|
/* When an application links to a PCRE DLL in Windows, the symbols that are
|
||||||
imported have to be identified as such. When building PCRE2, the appropriate
|
imported have to be identified as such. When building PCRE2, the appropriate
|
||||||
|
3
src/3rdparty/pcre2/src/pcre2_compile.c
vendored
3
src/3rdparty/pcre2/src/pcre2_compile.c
vendored
@ -2344,7 +2344,7 @@ if (ptr > *nameptr + MAX_NAME_SIZE)
|
|||||||
*errorcodeptr = ERR48;
|
*errorcodeptr = ERR48;
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
*namelenptr = ptr - *nameptr;
|
*namelenptr = (uint32_t)(ptr - *nameptr);
|
||||||
|
|
||||||
/* Subpattern names must not be empty, and their terminator is checked here.
|
/* Subpattern names must not be empty, and their terminator is checked here.
|
||||||
(What follows a verb or alpha assertion name is checked separately.) */
|
(What follows a verb or alpha assertion name is checked separately.) */
|
||||||
@ -4331,6 +4331,7 @@ while (ptr < ptrend)
|
|||||||
{
|
{
|
||||||
if (++ptr >= ptrend || !IS_DIGIT(*ptr)) goto BAD_VERSION_CONDITION;
|
if (++ptr >= ptrend || !IS_DIGIT(*ptr)) goto BAD_VERSION_CONDITION;
|
||||||
minor = (*ptr++ - CHAR_0) * 10;
|
minor = (*ptr++ - CHAR_0) * 10;
|
||||||
|
if (ptr >= ptrend) goto BAD_VERSION_CONDITION;
|
||||||
if (IS_DIGIT(*ptr)) minor += *ptr++ - CHAR_0;
|
if (IS_DIGIT(*ptr)) minor += *ptr++ - CHAR_0;
|
||||||
if (ptr >= ptrend || *ptr != CHAR_RIGHT_PARENTHESIS)
|
if (ptr >= ptrend || *ptr != CHAR_RIGHT_PARENTHESIS)
|
||||||
goto BAD_VERSION_CONDITION;
|
goto BAD_VERSION_CONDITION;
|
||||||
|
168
src/3rdparty/pcre2/src/pcre2_jit_compile.c
vendored
168
src/3rdparty/pcre2/src/pcre2_jit_compile.c
vendored
@ -1466,9 +1466,9 @@ do
|
|||||||
default:
|
default:
|
||||||
accelerated_start = NULL;
|
accelerated_start = NULL;
|
||||||
fast_forward_allowed = FALSE;
|
fast_forward_allowed = FALSE;
|
||||||
break;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case OP_ONCE:
|
case OP_ONCE:
|
||||||
case OP_BRA:
|
case OP_BRA:
|
||||||
@ -1834,57 +1834,57 @@ while (cc < ccend)
|
|||||||
case OP_BRAZERO:
|
case OP_BRAZERO:
|
||||||
case OP_BRAMINZERO:
|
case OP_BRAMINZERO:
|
||||||
case OP_BRAPOSZERO:
|
case OP_BRAPOSZERO:
|
||||||
repeat_check = FALSE;
|
|
||||||
size = 1;
|
size = 1;
|
||||||
|
repeat_check = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CASE_ITERATOR_PRIVATE_DATA_1
|
CASE_ITERATOR_PRIVATE_DATA_1
|
||||||
space = 1;
|
|
||||||
size = -2;
|
size = -2;
|
||||||
|
space = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CASE_ITERATOR_PRIVATE_DATA_2A
|
CASE_ITERATOR_PRIVATE_DATA_2A
|
||||||
space = 2;
|
|
||||||
size = -2;
|
size = -2;
|
||||||
|
space = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CASE_ITERATOR_PRIVATE_DATA_2B
|
CASE_ITERATOR_PRIVATE_DATA_2B
|
||||||
space = 2;
|
|
||||||
size = -(2 + IMM2_SIZE);
|
size = -(2 + IMM2_SIZE);
|
||||||
|
space = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CASE_ITERATOR_TYPE_PRIVATE_DATA_1
|
CASE_ITERATOR_TYPE_PRIVATE_DATA_1
|
||||||
space = 1;
|
|
||||||
size = 1;
|
size = 1;
|
||||||
|
space = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
|
CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
|
||||||
|
size = 1;
|
||||||
if (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI)
|
if (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI)
|
||||||
space = 2;
|
space = 2;
|
||||||
size = 1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_TYPEUPTO:
|
case OP_TYPEUPTO:
|
||||||
|
size = 1 + IMM2_SIZE;
|
||||||
if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)
|
if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)
|
||||||
space = 2;
|
space = 2;
|
||||||
size = 1 + IMM2_SIZE;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_TYPEMINUPTO:
|
case OP_TYPEMINUPTO:
|
||||||
space = 2;
|
|
||||||
size = 1 + IMM2_SIZE;
|
size = 1 + IMM2_SIZE;
|
||||||
|
space = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_CLASS:
|
case OP_CLASS:
|
||||||
case OP_NCLASS:
|
case OP_NCLASS:
|
||||||
space = get_class_iterator_size(cc + size);
|
|
||||||
size = 1 + 32 / sizeof(PCRE2_UCHAR);
|
size = 1 + 32 / sizeof(PCRE2_UCHAR);
|
||||||
|
space = get_class_iterator_size(cc + size);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8
|
#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8
|
||||||
case OP_XCLASS:
|
case OP_XCLASS:
|
||||||
space = get_class_iterator_size(cc + size);
|
|
||||||
size = GET(cc, 1);
|
size = GET(cc, 1);
|
||||||
|
space = get_class_iterator_size(cc + size);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4578,7 +4578,14 @@ if (common->nltype != NLTYPE_ANY)
|
|||||||
/* All newlines are ascii, just skip intermediate octets. */
|
/* All newlines are ascii, just skip intermediate octets. */
|
||||||
jump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
jump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
||||||
loop = LABEL();
|
loop = LABEL();
|
||||||
|
if (sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_SUPP | SLJIT_MEM_POST, TMP2, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)) == SLJIT_SUCCESS)
|
||||||
|
sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_POST, TMP2, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
|
||||||
|
else
|
||||||
|
{
|
||||||
OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
|
OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
|
||||||
|
OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
|
||||||
|
}
|
||||||
|
|
||||||
OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc0);
|
OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc0);
|
||||||
CMPTO(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0x80, loop);
|
CMPTO(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0x80, loop);
|
||||||
OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
|
OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
|
||||||
@ -6161,9 +6168,9 @@ static SLJIT_INLINE void fast_forward_newline(compiler_common *common)
|
|||||||
{
|
{
|
||||||
DEFINE_COMPILER;
|
DEFINE_COMPILER;
|
||||||
struct sljit_label *loop;
|
struct sljit_label *loop;
|
||||||
struct sljit_jump *lastchar;
|
struct sljit_jump *lastchar = NULL;
|
||||||
struct sljit_jump *firstchar;
|
struct sljit_jump *firstchar;
|
||||||
struct sljit_jump *quit;
|
struct sljit_jump *quit = NULL;
|
||||||
struct sljit_jump *foundcr = NULL;
|
struct sljit_jump *foundcr = NULL;
|
||||||
struct sljit_jump *notfoundnl;
|
struct sljit_jump *notfoundnl;
|
||||||
jump_list *newline = NULL;
|
jump_list *newline = NULL;
|
||||||
@ -6176,6 +6183,36 @@ if (common->match_end_ptr != 0)
|
|||||||
|
|
||||||
if (common->nltype == NLTYPE_FIXED && common->newline > 255)
|
if (common->nltype == NLTYPE_FIXED && common->newline > 255)
|
||||||
{
|
{
|
||||||
|
#ifdef JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD
|
||||||
|
if (JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD && common->mode == PCRE2_JIT_COMPLETE)
|
||||||
|
{
|
||||||
|
if (HAS_VIRTUAL_REGISTERS)
|
||||||
|
{
|
||||||
|
OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
|
||||||
|
OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
|
||||||
|
OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, str));
|
||||||
|
OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin));
|
||||||
|
}
|
||||||
|
firstchar = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0);
|
||||||
|
|
||||||
|
OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
|
||||||
|
OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_UNUSED, 0, STR_PTR, 0, TMP1, 0);
|
||||||
|
OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_NOT_EQUAL);
|
||||||
|
#if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32
|
||||||
|
OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT);
|
||||||
|
#endif
|
||||||
|
OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
|
||||||
|
|
||||||
|
fast_forward_char_pair_simd(common, 1, common->newline & 0xff, common->newline & 0xff, 0, (common->newline >> 8) & 0xff, (common->newline >> 8) & 0xff);
|
||||||
|
OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD */
|
||||||
|
{
|
||||||
lastchar = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
lastchar = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
||||||
if (HAS_VIRTUAL_REGISTERS)
|
if (HAS_VIRTUAL_REGISTERS)
|
||||||
{
|
{
|
||||||
@ -6207,8 +6244,10 @@ if (common->nltype == NLTYPE_FIXED && common->newline > 255)
|
|||||||
CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, loop);
|
CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, loop);
|
||||||
|
|
||||||
JUMPHERE(quit);
|
JUMPHERE(quit);
|
||||||
JUMPHERE(firstchar);
|
|
||||||
JUMPHERE(lastchar);
|
JUMPHERE(lastchar);
|
||||||
|
}
|
||||||
|
|
||||||
|
JUMPHERE(firstchar);
|
||||||
|
|
||||||
if (common->match_end_ptr != 0)
|
if (common->match_end_ptr != 0)
|
||||||
OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
|
OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
|
||||||
@ -6225,22 +6264,59 @@ else
|
|||||||
|
|
||||||
/* Example: match /^/ to \r\n from offset 1. */
|
/* Example: match /^/ to \r\n from offset 1. */
|
||||||
firstchar = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0);
|
firstchar = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0);
|
||||||
move_back(common, NULL, FALSE);
|
|
||||||
|
if (common->nltype == NLTYPE_ANY)
|
||||||
|
move_back(common, NULL, FALSE);
|
||||||
|
else
|
||||||
|
OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
|
||||||
|
|
||||||
loop = LABEL();
|
loop = LABEL();
|
||||||
common->ff_newline_shortcut = loop;
|
common->ff_newline_shortcut = loop;
|
||||||
|
|
||||||
read_char(common, common->nlmin, common->nlmax, NULL, READ_CHAR_NEWLINE);
|
#ifdef JIT_HAS_FAST_FORWARD_CHAR_SIMD
|
||||||
lastchar = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
if (JIT_HAS_FAST_FORWARD_CHAR_SIMD && (common->nltype == NLTYPE_FIXED || common->nltype == NLTYPE_ANYCRLF))
|
||||||
if (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF)
|
{
|
||||||
|
if (common->nltype == NLTYPE_ANYCRLF)
|
||||||
|
{
|
||||||
|
fast_forward_char_simd(common, CHAR_CR, CHAR_LF, 0);
|
||||||
|
if (common->mode != PCRE2_JIT_COMPLETE)
|
||||||
|
lastchar = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
||||||
|
|
||||||
|
OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
|
||||||
|
OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
|
||||||
|
quit = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fast_forward_char_simd(common, common->newline, common->newline, 0);
|
||||||
|
|
||||||
|
OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
|
||||||
|
if (common->mode != PCRE2_JIT_COMPLETE)
|
||||||
|
{
|
||||||
|
OP2(SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_UNUSED, 0, STR_PTR, 0, STR_END, 0);
|
||||||
|
CMOV(SLJIT_GREATER, STR_PTR, STR_END, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* JIT_HAS_FAST_FORWARD_CHAR_SIMD */
|
||||||
|
{
|
||||||
|
read_char(common, common->nlmin, common->nlmax, NULL, READ_CHAR_NEWLINE);
|
||||||
|
lastchar = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
||||||
|
if (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF)
|
||||||
foundcr = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);
|
foundcr = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);
|
||||||
check_newlinechar(common, common->nltype, &newline, FALSE);
|
check_newlinechar(common, common->nltype, &newline, FALSE);
|
||||||
set_jumps(newline, loop);
|
set_jumps(newline, loop);
|
||||||
|
}
|
||||||
|
|
||||||
if (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF)
|
if (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF)
|
||||||
|
{
|
||||||
|
if (quit == NULL)
|
||||||
{
|
{
|
||||||
quit = JUMP(SLJIT_JUMP);
|
quit = JUMP(SLJIT_JUMP);
|
||||||
JUMPHERE(foundcr);
|
JUMPHERE(foundcr);
|
||||||
|
}
|
||||||
|
|
||||||
notfoundnl = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
notfoundnl = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
||||||
OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
|
OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
|
||||||
OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_NL);
|
OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_NL);
|
||||||
@ -6252,7 +6328,9 @@ if (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF)
|
|||||||
JUMPHERE(notfoundnl);
|
JUMPHERE(notfoundnl);
|
||||||
JUMPHERE(quit);
|
JUMPHERE(quit);
|
||||||
}
|
}
|
||||||
JUMPHERE(lastchar);
|
|
||||||
|
if (lastchar)
|
||||||
|
JUMPHERE(lastchar);
|
||||||
JUMPHERE(firstchar);
|
JUMPHERE(firstchar);
|
||||||
|
|
||||||
if (common->match_end_ptr != 0)
|
if (common->match_end_ptr != 0)
|
||||||
@ -6493,9 +6571,11 @@ if (common->invalid_utf)
|
|||||||
|
|
||||||
if (common->mode != PCRE2_JIT_COMPLETE)
|
if (common->mode != PCRE2_JIT_COMPLETE)
|
||||||
{
|
{
|
||||||
|
OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);
|
||||||
OP1(SLJIT_MOV, TMP2, 0, STR_PTR, 0);
|
OP1(SLJIT_MOV, TMP2, 0, STR_PTR, 0);
|
||||||
move_back(common, NULL, TRUE);
|
move_back(common, NULL, TRUE);
|
||||||
check_start_used_ptr(common);
|
check_start_used_ptr(common);
|
||||||
|
OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
|
||||||
OP1(SLJIT_MOV, STR_PTR, 0, TMP2, 0);
|
OP1(SLJIT_MOV, STR_PTR, 0, TMP2, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7594,25 +7674,20 @@ if (needstype || needsscript)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cc = ccbegin;
|
cc = ccbegin;
|
||||||
}
|
|
||||||
|
|
||||||
if (needschar)
|
|
||||||
OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
|
|
||||||
|
|
||||||
if (needstype)
|
if (needstype)
|
||||||
{
|
{
|
||||||
|
/* TMP2 has already been shifted by 2 */
|
||||||
if (!needschar)
|
if (!needschar)
|
||||||
{
|
{
|
||||||
OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 3);
|
OP2(SLJIT_ADD, TMP1, 0, TMP2, 0, TMP2, 0);
|
||||||
OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);
|
|
||||||
OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
|
OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
|
||||||
|
|
||||||
OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
|
OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 2);
|
OP2(SLJIT_ADD, TMP1, 0, TMP2, 0, TMP2, 0);
|
||||||
OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);
|
|
||||||
OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
|
OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
|
||||||
|
|
||||||
OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
|
OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
|
||||||
@ -7620,6 +7695,31 @@ if (needstype || needsscript)
|
|||||||
typereg = RETURN_ADDR;
|
typereg = RETURN_ADDR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (needschar)
|
||||||
|
OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
|
||||||
|
}
|
||||||
|
else if (needstype)
|
||||||
|
{
|
||||||
|
OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 3);
|
||||||
|
OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);
|
||||||
|
|
||||||
|
if (!needschar)
|
||||||
|
{
|
||||||
|
OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
|
||||||
|
|
||||||
|
OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
|
||||||
|
|
||||||
|
OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
|
||||||
|
OP1(SLJIT_MOV_U8, RETURN_ADDR, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
|
||||||
|
typereg = RETURN_ADDR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (needschar)
|
||||||
|
OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
|
||||||
}
|
}
|
||||||
#endif /* SUPPORT_UNICODE */
|
#endif /* SUPPORT_UNICODE */
|
||||||
|
|
||||||
@ -13581,7 +13681,7 @@ if (common->has_then)
|
|||||||
set_then_offsets(common, common->start, NULL);
|
set_then_offsets(common, common->start, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
compiler = sljit_create_compiler(allocator_data);
|
compiler = sljit_create_compiler(allocator_data, NULL);
|
||||||
if (!compiler)
|
if (!compiler)
|
||||||
{
|
{
|
||||||
SLJIT_FREE(common->optimized_cbracket, allocator_data);
|
SLJIT_FREE(common->optimized_cbracket, allocator_data);
|
||||||
@ -13983,7 +14083,7 @@ else
|
|||||||
{
|
{
|
||||||
/* This case is highly unlikely since we just recently
|
/* This case is highly unlikely since we just recently
|
||||||
freed a lot of memory. Not impossible though. */
|
freed a lot of memory. Not impossible though. */
|
||||||
sljit_free_code(executable_func);
|
sljit_free_code(executable_func, NULL);
|
||||||
PRIV(jit_free_rodata)(common->read_only_data_head, allocator_data);
|
PRIV(jit_free_rodata)(common->read_only_data_head, allocator_data);
|
||||||
return PCRE2_ERROR_NOMEMORY;
|
return PCRE2_ERROR_NOMEMORY;
|
||||||
}
|
}
|
||||||
@ -14097,13 +14197,13 @@ if (executable_allocator_is_working == 0)
|
|||||||
/* Checks whether the executable allocator is working. This check
|
/* Checks whether the executable allocator is working. This check
|
||||||
might run multiple times in multi-threaded environments, but the
|
might run multiple times in multi-threaded environments, but the
|
||||||
result should not be affected by it. */
|
result should not be affected by it. */
|
||||||
void *ptr = SLJIT_MALLOC_EXEC(32);
|
void *ptr = SLJIT_MALLOC_EXEC(32, NULL);
|
||||||
|
|
||||||
executable_allocator_is_working = -1;
|
executable_allocator_is_working = -1;
|
||||||
|
|
||||||
if (ptr != NULL)
|
if (ptr != NULL)
|
||||||
{
|
{
|
||||||
SLJIT_FREE_EXEC(((sljit_u8*)(ptr)) + SLJIT_EXEC_OFFSET(ptr));
|
SLJIT_FREE_EXEC(((sljit_u8*)(ptr)) + SLJIT_EXEC_OFFSET(ptr), NULL);
|
||||||
executable_allocator_is_working = 1;
|
executable_allocator_is_working = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
src/3rdparty/pcre2/src/pcre2_jit_misc.c
vendored
2
src/3rdparty/pcre2/src/pcre2_jit_misc.c
vendored
@ -89,7 +89,7 @@ int i;
|
|||||||
for (i = 0; i < JIT_NUMBER_OF_COMPILE_MODES; i++)
|
for (i = 0; i < JIT_NUMBER_OF_COMPILE_MODES; i++)
|
||||||
{
|
{
|
||||||
if (functions->executable_funcs[i] != NULL)
|
if (functions->executable_funcs[i] != NULL)
|
||||||
sljit_free_code(functions->executable_funcs[i]);
|
sljit_free_code(functions->executable_funcs[i], NULL);
|
||||||
PRIV(jit_free_rodata)(functions->read_only_data_heads[i], allocator_data);
|
PRIV(jit_free_rodata)(functions->read_only_data_heads[i], allocator_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
src/3rdparty/pcre2/src/pcre2_jit_neon_inc.h
vendored
4
src/3rdparty/pcre2/src/pcre2_jit_neon_inc.h
vendored
@ -87,6 +87,10 @@ static sljit_u8* SLJIT_FUNC FF_FUN(sljit_u8 *str_end, sljit_u8 *str_ptr, sljit_u
|
|||||||
{
|
{
|
||||||
quad_word qw;
|
quad_word qw;
|
||||||
int_char ic;
|
int_char ic;
|
||||||
|
|
||||||
|
SLJIT_UNUSED_ARG(offs1);
|
||||||
|
SLJIT_UNUSED_ARG(offs2);
|
||||||
|
|
||||||
ic.x = chars;
|
ic.x = chars;
|
||||||
|
|
||||||
#if defined(FFCS)
|
#if defined(FFCS)
|
||||||
|
10
src/3rdparty/pcre2/src/pcre2_match.c
vendored
10
src/3rdparty/pcre2/src/pcre2_match.c
vendored
@ -6115,8 +6115,8 @@ BOOL has_req_cu = FALSE;
|
|||||||
BOOL startline;
|
BOOL startline;
|
||||||
|
|
||||||
#if PCRE2_CODE_UNIT_WIDTH == 8
|
#if PCRE2_CODE_UNIT_WIDTH == 8
|
||||||
BOOL memchr_not_found_first_cu = FALSE;
|
BOOL memchr_not_found_first_cu;
|
||||||
BOOL memchr_not_found_first_cu2 = FALSE;
|
BOOL memchr_not_found_first_cu2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PCRE2_UCHAR first_cu = 0;
|
PCRE2_UCHAR first_cu = 0;
|
||||||
@ -6709,6 +6709,11 @@ FRAGMENT_RESTART:
|
|||||||
start_partial = match_partial = NULL;
|
start_partial = match_partial = NULL;
|
||||||
mb->hitend = FALSE;
|
mb->hitend = FALSE;
|
||||||
|
|
||||||
|
#if PCRE2_CODE_UNIT_WIDTH == 8
|
||||||
|
memchr_not_found_first_cu = FALSE;
|
||||||
|
memchr_not_found_first_cu2 = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
PCRE2_SPTR new_start_match;
|
PCRE2_SPTR new_start_match;
|
||||||
@ -7187,6 +7192,7 @@ if (utf && end_subject != true_end_subject &&
|
|||||||
starting code units in 8-bit and 16-bit modes. */
|
starting code units in 8-bit and 16-bit modes. */
|
||||||
|
|
||||||
start_match = end_subject + 1;
|
start_match = end_subject + 1;
|
||||||
|
|
||||||
#if PCRE2_CODE_UNIT_WIDTH != 32
|
#if PCRE2_CODE_UNIT_WIDTH != 32
|
||||||
while (start_match < true_end_subject && NOT_FIRSTCU(*start_match))
|
while (start_match < true_end_subject && NOT_FIRSTCU(*start_match))
|
||||||
start_match++;
|
start_match++;
|
||||||
|
46
src/3rdparty/pcre2/src/sljit/sljitConfig.h
vendored
46
src/3rdparty/pcre2/src/sljit/sljitConfig.h
vendored
@ -24,19 +24,19 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SLJIT_CONFIG_H_
|
#ifndef SLJIT_CONFIG_H_
|
||||||
#define _SLJIT_CONFIG_H_
|
#define SLJIT_CONFIG_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/*
|
||||||
/* Custom defines */
|
This file contains the basic configuration options for the SLJIT compiler
|
||||||
/* --------------------------------------------------------------------- */
|
and their default values. These options can be overridden in the
|
||||||
|
sljitConfigPre.h header file when SLJIT_HAVE_CONFIG_PRE is set to a
|
||||||
/* Put your custom defines here. This empty section will never change
|
non-zero value.
|
||||||
which helps maintaining patches (with diff / patch utilities). */
|
*/
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/* Architecture */
|
/* Architecture */
|
||||||
@ -54,7 +54,7 @@ extern "C" {
|
|||||||
/* #define SLJIT_CONFIG_MIPS_32 1 */
|
/* #define SLJIT_CONFIG_MIPS_32 1 */
|
||||||
/* #define SLJIT_CONFIG_MIPS_64 1 */
|
/* #define SLJIT_CONFIG_MIPS_64 1 */
|
||||||
/* #define SLJIT_CONFIG_SPARC_32 1 */
|
/* #define SLJIT_CONFIG_SPARC_32 1 */
|
||||||
/* #define SLJIT_CONFIG_TILEGX 1 */
|
/* #define SLJIT_CONFIG_S390X 1 */
|
||||||
|
|
||||||
/* #define SLJIT_CONFIG_AUTO 1 */
|
/* #define SLJIT_CONFIG_AUTO 1 */
|
||||||
/* #define SLJIT_CONFIG_UNSUPPORTED 1 */
|
/* #define SLJIT_CONFIG_UNSUPPORTED 1 */
|
||||||
@ -63,12 +63,6 @@ extern "C" {
|
|||||||
/* Utilities */
|
/* Utilities */
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Useful for thread-safe compiling of global functions. */
|
|
||||||
#ifndef SLJIT_UTIL_GLOBAL_LOCK
|
|
||||||
/* Enabled by default */
|
|
||||||
#define SLJIT_UTIL_GLOBAL_LOCK 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Implements a stack like data structure (by using mmap / VirtualAlloc */
|
/* Implements a stack like data structure (by using mmap / VirtualAlloc */
|
||||||
/* or a custom allocator). */
|
/* or a custom allocator). */
|
||||||
#ifndef SLJIT_UTIL_STACK
|
#ifndef SLJIT_UTIL_STACK
|
||||||
@ -108,15 +102,31 @@ extern "C" {
|
|||||||
|
|
||||||
/* When SLJIT_PROT_EXECUTABLE_ALLOCATOR is enabled SLJIT uses
|
/* When SLJIT_PROT_EXECUTABLE_ALLOCATOR is enabled SLJIT uses
|
||||||
an allocator which does not set writable and executable
|
an allocator which does not set writable and executable
|
||||||
permission flags at the same time. The trade-of is increased
|
permission flags at the same time.
|
||||||
memory consumption and disabled dynamic code modifications. */
|
Instead, it creates a shared memory segment (usually backed by a file)
|
||||||
|
and maps it twice, with different permissions, depending on the use
|
||||||
|
case.
|
||||||
|
The trade-off is increased use of virtual memory, incompatibility with
|
||||||
|
fork(), and some possible additional security risks by the use of
|
||||||
|
publicly accessible files for the generated code. */
|
||||||
#ifndef SLJIT_PROT_EXECUTABLE_ALLOCATOR
|
#ifndef SLJIT_PROT_EXECUTABLE_ALLOCATOR
|
||||||
/* Disabled by default. */
|
/* Disabled by default. */
|
||||||
#define SLJIT_PROT_EXECUTABLE_ALLOCATOR 0
|
#define SLJIT_PROT_EXECUTABLE_ALLOCATOR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* When SLJIT_WX_EXECUTABLE_ALLOCATOR is enabled SLJIT uses an
|
||||||
|
allocator which does not set writable and executable permission
|
||||||
|
flags at the same time.
|
||||||
|
Instead, it creates a new independent map on each invocation and
|
||||||
|
switches permissions at the underlying pages as needed.
|
||||||
|
The trade-off is increased memory use and degraded performance. */
|
||||||
|
#ifndef SLJIT_WX_EXECUTABLE_ALLOCATOR
|
||||||
|
/* Disabled by default. */
|
||||||
|
#define SLJIT_WX_EXECUTABLE_ALLOCATOR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* !SLJIT_EXECUTABLE_ALLOCATOR */
|
||||||
|
|
||||||
/* Force cdecl calling convention even if a better calling
|
/* Force cdecl calling convention even if a better calling
|
||||||
convention (e.g. fastcall) is supported by the C compiler.
|
convention (e.g. fastcall) is supported by the C compiler.
|
||||||
If this option is disabled (this is the default), functions
|
If this option is disabled (this is the default), functions
|
||||||
@ -159,4 +169,4 @@ extern "C" {
|
|||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* SLJIT_CONFIG_H_ */
|
||||||
|
145
src/3rdparty/pcre2/src/sljit/sljitConfigInternal.h
vendored
145
src/3rdparty/pcre2/src/sljit/sljitConfigInternal.h
vendored
@ -24,8 +24,8 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SLJIT_CONFIG_INTERNAL_H_
|
#ifndef SLJIT_CONFIG_INTERNAL_H_
|
||||||
#define _SLJIT_CONFIG_INTERNAL_H_
|
#define SLJIT_CONFIG_INTERNAL_H_
|
||||||
|
|
||||||
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
|
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
|
||||||
|| (defined SLJIT_DEBUG && SLJIT_DEBUG && (!defined(SLJIT_ASSERT) || !defined(SLJIT_UNREACHABLE)))
|
|| (defined SLJIT_DEBUG && SLJIT_DEBUG && (!defined(SLJIT_ASSERT) || !defined(SLJIT_UNREACHABLE)))
|
||||||
@ -81,30 +81,13 @@ extern "C" {
|
|||||||
|
|
||||||
Other macros:
|
Other macros:
|
||||||
SLJIT_FUNC : calling convention attribute for both calling JIT from C and C calling back from JIT
|
SLJIT_FUNC : calling convention attribute for both calling JIT from C and C calling back from JIT
|
||||||
SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (compiler independent helper)
|
SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (platform independent helper)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************/
|
/*****************/
|
||||||
/* Sanity check. */
|
/* Sanity check. */
|
||||||
/*****************/
|
/*****************/
|
||||||
|
|
||||||
#if !((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
|
|
||||||
|| (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
|
|
||||||
|| (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
|
|
||||||
|| (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
|
|
||||||
|| (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
|
|
||||||
|| (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
|
|
||||||
|| (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
|
|
||||||
|| (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
|
|
||||||
|| (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
|
|
||||||
|| (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
|
|
||||||
|| (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
|
|
||||||
|| (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
|
|
||||||
|| (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
|
|
||||||
|| (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED))
|
|
||||||
#error "An architecture must be selected"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
|
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
|
||||||
+ (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
|
+ (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
|
||||||
+ (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
|
+ (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
|
||||||
@ -113,15 +96,36 @@ extern "C" {
|
|||||||
+ (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
|
+ (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
|
||||||
+ (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
|
+ (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
|
||||||
+ (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
|
+ (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
|
||||||
+ (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
|
|
||||||
+ (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
|
+ (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
|
||||||
+ (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
|
+ (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
|
||||||
+ (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
|
+ (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
|
||||||
|
+ (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) \
|
||||||
+ (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
|
+ (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
|
||||||
+ (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
|
+ (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
|
||||||
#error "Multiple architectures are selected"
|
#error "Multiple architectures are selected"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
|
||||||
|
&& !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
|
||||||
|
&& !(defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
|
||||||
|
&& !(defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
|
||||||
|
&& !(defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
|
||||||
|
&& !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
|
||||||
|
&& !(defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
|
||||||
|
&& !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
|
||||||
|
&& !(defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
|
||||||
|
&& !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
|
||||||
|
&& !(defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
|
||||||
|
&& !(defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X) \
|
||||||
|
&& !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) \
|
||||||
|
&& !(defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
|
||||||
|
#if defined SLJIT_CONFIG_AUTO && !SLJIT_CONFIG_AUTO
|
||||||
|
#error "An architecture must be selected"
|
||||||
|
#else /* SLJIT_CONFIG_AUTO */
|
||||||
|
#define SLJIT_CONFIG_AUTO 1
|
||||||
|
#endif /* !SLJIT_CONFIG_AUTO */
|
||||||
|
#endif /* !SLJIT_CONFIG */
|
||||||
|
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
/* Automatic CPU detection (requires compiler support). */
|
/* Automatic CPU detection (requires compiler support). */
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
@ -154,8 +158,6 @@ extern "C" {
|
|||||||
#define SLJIT_CONFIG_MIPS_64 1
|
#define SLJIT_CONFIG_MIPS_64 1
|
||||||
#elif defined(__sparc__) || defined(__sparc)
|
#elif defined(__sparc__) || defined(__sparc)
|
||||||
#define SLJIT_CONFIG_SPARC_32 1
|
#define SLJIT_CONFIG_SPARC_32 1
|
||||||
#elif defined(__tilegx__)
|
|
||||||
#define SLJIT_CONFIG_TILEGX 1
|
|
||||||
#else
|
#else
|
||||||
/* Unsupported architecture */
|
/* Unsupported architecture */
|
||||||
#define SLJIT_CONFIG_UNSUPPORTED 1
|
#define SLJIT_CONFIG_UNSUPPORTED 1
|
||||||
@ -210,18 +212,16 @@ extern "C" {
|
|||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
|
|
||||||
#ifdef SLJIT_CONFIG_X86
|
#ifdef SLJIT_CONFIG_X86
|
||||||
#if defined(__CET__)
|
|
||||||
|
#if defined(__CET__) && !(defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET)
|
||||||
#define SLJIT_CONFIG_X86_CET 1
|
#define SLJIT_CONFIG_X86_CET 1
|
||||||
#endif
|
#endif
|
||||||
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET)
|
|
||||||
#if defined(__GNUC__)
|
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) && defined(__GNUC__)
|
||||||
#if !defined (__SHSTK__)
|
|
||||||
#error "-mshstk is needed to compile with -fcf-protection"
|
|
||||||
#endif
|
|
||||||
#include <x86intrin.h>
|
#include <x86intrin.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#endif
|
#endif /* SLJIT_CONFIG_X86 */
|
||||||
|
|
||||||
/**********************************/
|
/**********************************/
|
||||||
/* External function definitions. */
|
/* External function definitions. */
|
||||||
@ -411,7 +411,7 @@ typedef long int sljit_sw;
|
|||||||
&& !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
|
&& !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
|
||||||
&& !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
|
&& !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
|
||||||
&& !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
|
&& !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
|
||||||
&& !(defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
|
&& !(defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
|
||||||
#define SLJIT_32BIT_ARCHITECTURE 1
|
#define SLJIT_32BIT_ARCHITECTURE 1
|
||||||
#define SLJIT_WORD_SHIFT 2
|
#define SLJIT_WORD_SHIFT 2
|
||||||
typedef unsigned int sljit_uw;
|
typedef unsigned int sljit_uw;
|
||||||
@ -453,10 +453,14 @@ typedef double sljit_f64;
|
|||||||
#if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
|
#if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
|
||||||
#define SLJIT_W(w) (w##l)
|
#define SLJIT_W(w) (w##l)
|
||||||
#elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
|
#elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
|
||||||
|
#ifdef _WIN64
|
||||||
#define SLJIT_W(w) (w##ll)
|
#define SLJIT_W(w) (w##ll)
|
||||||
#else
|
#else /* !windows */
|
||||||
|
#define SLJIT_W(w) (w##l)
|
||||||
|
#endif /* windows */
|
||||||
|
#else /* 32 bit */
|
||||||
#define SLJIT_W(w) (w)
|
#define SLJIT_W(w) (w)
|
||||||
#endif
|
#endif /* unknown */
|
||||||
|
|
||||||
#endif /* !SLJIT_W */
|
#endif /* !SLJIT_W */
|
||||||
|
|
||||||
@ -504,7 +508,8 @@ typedef double sljit_f64;
|
|||||||
|
|
||||||
#endif /* !SLJIT_MIPS_REV */
|
#endif /* !SLJIT_MIPS_REV */
|
||||||
|
|
||||||
#elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
|
#elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
|
||||||
|
|| (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
|
||||||
|
|
||||||
#define SLJIT_BIG_ENDIAN 1
|
#define SLJIT_BIG_ENDIAN 1
|
||||||
|
|
||||||
@ -531,7 +536,8 @@ typedef double sljit_f64;
|
|||||||
|| (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
|
|| (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
|
||||||
|| (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
|
|| (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
|
||||||
|| (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
|
|| (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
|
||||||
|| (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
|
|| (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
|
||||||
|
|| (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
|
||||||
#define SLJIT_UNALIGNED 1
|
#define SLJIT_UNALIGNED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -549,17 +555,19 @@ typedef double sljit_f64;
|
|||||||
|
|
||||||
#ifndef SLJIT_FUNC
|
#ifndef SLJIT_FUNC
|
||||||
|
|
||||||
#if (defined SLJIT_USE_CDECL_CALLING_CONVENTION && SLJIT_USE_CDECL_CALLING_CONVENTION)
|
#if (defined SLJIT_USE_CDECL_CALLING_CONVENTION && SLJIT_USE_CDECL_CALLING_CONVENTION) \
|
||||||
|
|| !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
|
||||||
|
|
||||||
/* Force cdecl. */
|
|
||||||
#define SLJIT_FUNC
|
#define SLJIT_FUNC
|
||||||
|
|
||||||
#elif (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
|
#elif defined(__GNUC__) && !defined(__APPLE__)
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__APPLE__)
|
|
||||||
|
|
||||||
|
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||||
#define SLJIT_FUNC __attribute__ ((fastcall))
|
#define SLJIT_FUNC __attribute__ ((fastcall))
|
||||||
#define SLJIT_X86_32_FASTCALL 1
|
#define SLJIT_X86_32_FASTCALL 1
|
||||||
|
#else
|
||||||
|
#define SLJIT_FUNC
|
||||||
|
#endif /* gcc >= 3.4 */
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
|
|
||||||
@ -573,16 +581,10 @@ typedef double sljit_f64;
|
|||||||
|
|
||||||
#else /* Unknown compiler. */
|
#else /* Unknown compiler. */
|
||||||
|
|
||||||
/* The cdecl attribute is the default. */
|
/* The cdecl calling convention is usually the x86 default. */
|
||||||
#define SLJIT_FUNC
|
#define SLJIT_FUNC
|
||||||
|
|
||||||
#endif
|
#endif /* SLJIT_USE_CDECL_CALLING_CONVENTION */
|
||||||
|
|
||||||
#else /* Non x86-32 architectures. */
|
|
||||||
|
|
||||||
#define SLJIT_FUNC
|
|
||||||
|
|
||||||
#endif /* SLJIT_CONFIG_X86_32 */
|
|
||||||
|
|
||||||
#endif /* !SLJIT_FUNC */
|
#endif /* !SLJIT_FUNC */
|
||||||
|
|
||||||
@ -613,8 +615,16 @@ determine the next executed instruction after return. */
|
|||||||
SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
|
SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
|
||||||
#define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size)
|
#define SLJIT_BUILTIN_MALLOC_EXEC(size, exec_allocator_data) sljit_malloc_exec(size)
|
||||||
#define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
|
#define SLJIT_BUILTIN_FREE_EXEC(ptr, exec_allocator_data) sljit_free_exec(ptr)
|
||||||
|
|
||||||
|
#ifndef SLJIT_MALLOC_EXEC
|
||||||
|
#define SLJIT_MALLOC_EXEC(size, exec_allocator_data) SLJIT_BUILTIN_MALLOC_EXEC((size), (exec_allocator_data))
|
||||||
|
#endif /* SLJIT_MALLOC_EXEC */
|
||||||
|
|
||||||
|
#ifndef SLJIT_FREE_EXEC
|
||||||
|
#define SLJIT_FREE_EXEC(ptr, exec_allocator_data) SLJIT_BUILTIN_FREE_EXEC((ptr), (exec_allocator_data))
|
||||||
|
#endif /* SLJIT_FREE_EXEC */
|
||||||
|
|
||||||
#if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
|
#if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
|
||||||
SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void* ptr);
|
SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void* ptr);
|
||||||
@ -623,7 +633,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void* ptr);
|
|||||||
#define SLJIT_EXEC_OFFSET(ptr) 0
|
#define SLJIT_EXEC_OFFSET(ptr) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* SLJIT_EXECUTABLE_ALLOCATOR */
|
||||||
|
|
||||||
/**********************************************/
|
/**********************************************/
|
||||||
/* Registers and locals offset determination. */
|
/* Registers and locals offset determination. */
|
||||||
@ -699,11 +709,32 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void* ptr);
|
|||||||
#define SLJIT_LOCALS_OFFSET_BASE ((16 + 1 + 6 + 2 + 1) * sizeof(sljit_sw))
|
#define SLJIT_LOCALS_OFFSET_BASE ((16 + 1 + 6 + 2 + 1) * sizeof(sljit_sw))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
|
#elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
|
||||||
|
|
||||||
#define SLJIT_NUMBER_OF_REGISTERS 10
|
/*
|
||||||
#define SLJIT_NUMBER_OF_SAVED_REGISTERS 5
|
* https://refspecs.linuxbase.org/ELF/zSeries/lzsabi0_zSeries.html#STACKFRAME
|
||||||
#define SLJIT_LOCALS_OFFSET_BASE 0
|
*
|
||||||
|
* 160
|
||||||
|
* .. FR6
|
||||||
|
* .. FR4
|
||||||
|
* .. FR2
|
||||||
|
* 128 FR0
|
||||||
|
* 120 R15 (used for SP)
|
||||||
|
* 112 R14
|
||||||
|
* 104 R13
|
||||||
|
* 96 R12
|
||||||
|
* ..
|
||||||
|
* 48 R6
|
||||||
|
* ..
|
||||||
|
* 16 R2
|
||||||
|
* 8 RESERVED
|
||||||
|
* 0 SP
|
||||||
|
*/
|
||||||
|
#define SLJIT_S390X_DEFAULT_STACK_FRAME_SIZE 160
|
||||||
|
|
||||||
|
#define SLJIT_NUMBER_OF_REGISTERS 12
|
||||||
|
#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
|
||||||
|
#define SLJIT_LOCALS_OFFSET_BASE SLJIT_S390X_DEFAULT_STACK_FRAME_SIZE
|
||||||
|
|
||||||
#elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
|
#elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
|
||||||
|
|
||||||
@ -791,4 +822,4 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void* ptr);
|
|||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* SLJIT_CONFIG_INTERNAL_H_ */
|
||||||
|
@ -72,9 +72,8 @@
|
|||||||
alloc_chunk / free_chunk :
|
alloc_chunk / free_chunk :
|
||||||
* allocate executable system memory chunks
|
* allocate executable system memory chunks
|
||||||
* the size is always divisible by CHUNK_SIZE
|
* the size is always divisible by CHUNK_SIZE
|
||||||
allocator_grab_lock / allocator_release_lock :
|
SLJIT_ALLOCATOR_LOCK / SLJIT_ALLOCATOR_UNLOCK :
|
||||||
* make the allocator thread safe
|
* provided as part of sljitUtils
|
||||||
* can be empty if the OS (or the application) does not support threading
|
|
||||||
* only the allocator requires this lock, sljit is fully thread safe
|
* only the allocator requires this lock, sljit is fully thread safe
|
||||||
as it only uses local variables
|
as it only uses local variables
|
||||||
*/
|
*/
|
||||||
@ -95,6 +94,7 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
#ifdef MAP_ANON
|
||||||
/* Configures TARGET_OS_OSX when appropriate */
|
/* Configures TARGET_OS_OSX when appropriate */
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
|
|
||||||
@ -104,17 +104,23 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size)
|
|||||||
|
|
||||||
#ifdef MAP_JIT
|
#ifdef MAP_JIT
|
||||||
|
|
||||||
|
/*
|
||||||
|
On macOS systems, returns MAP_JIT if it is defined _and_ we're running on a
|
||||||
|
version where it's OK to have more than one JIT block.
|
||||||
|
On non-macOS systems, returns MAP_JIT if it is defined.
|
||||||
|
*/
|
||||||
static SLJIT_INLINE int get_map_jit_flag()
|
static SLJIT_INLINE int get_map_jit_flag()
|
||||||
{
|
{
|
||||||
/* On macOS systems, returns MAP_JIT if it is defined _and_ we're running on a version
|
|
||||||
of macOS where it's OK to have more than one JIT block.
|
|
||||||
On non-macOS systems, returns MAP_JIT if it is defined. */
|
|
||||||
#if TARGET_OS_OSX
|
#if TARGET_OS_OSX
|
||||||
|
sljit_sw page_size = get_page_alignment() + 1;
|
||||||
|
void *ptr;
|
||||||
static int map_jit_flag = -1;
|
static int map_jit_flag = -1;
|
||||||
|
|
||||||
/* The following code is thread safe because multiple initialization
|
/*
|
||||||
|
The following code is thread safe because multiple initialization
|
||||||
sets map_jit_flag to the same value and the code has no side-effects.
|
sets map_jit_flag to the same value and the code has no side-effects.
|
||||||
Changing the kernel version witout system restart is (very) unlikely. */
|
Changing the kernel version witout system restart is (very) unlikely.
|
||||||
|
*/
|
||||||
if (map_jit_flag == -1) {
|
if (map_jit_flag == -1) {
|
||||||
struct utsname name;
|
struct utsname name;
|
||||||
|
|
||||||
@ -123,15 +129,9 @@ static SLJIT_INLINE int get_map_jit_flag()
|
|||||||
|
|
||||||
/* Kernel version for 10.14.0 (Mojave) */
|
/* Kernel version for 10.14.0 (Mojave) */
|
||||||
if (atoi(name.release) >= 18) {
|
if (atoi(name.release) >= 18) {
|
||||||
/* Only use MAP_JIT if a hardened runtime is used, because MAP_JIT is incompatible with fork(). */
|
/* Only use MAP_JIT if a hardened runtime is used */
|
||||||
|
|
||||||
/* mirroring page size detection from sljit_allocate_stack */
|
ptr = mmap(NULL, page_size, PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||||
long page_size = sysconf(_SC_PAGESIZE);
|
|
||||||
/* Should never happen */
|
|
||||||
if (page_size < 0)
|
|
||||||
page_size = 4096;
|
|
||||||
|
|
||||||
void *ptr = mmap(NULL, page_size, PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
|
|
||||||
|
|
||||||
if (ptr == MAP_FAILED) {
|
if (ptr == MAP_FAILED) {
|
||||||
map_jit_flag = MAP_JIT;
|
map_jit_flag = MAP_JIT;
|
||||||
@ -148,7 +148,7 @@ static SLJIT_INLINE int get_map_jit_flag()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MAP_JIT */
|
#endif /* MAP_JIT */
|
||||||
|
#endif /* MAP_ANON */
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ */
|
||||||
|
|
||||||
static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
|
static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
|
||||||
@ -166,10 +166,9 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
|
|||||||
|
|
||||||
retval = mmap(NULL, size, prot, flags, -1, 0);
|
retval = mmap(NULL, size, prot, flags, -1, 0);
|
||||||
#else /* !MAP_ANON */
|
#else /* !MAP_ANON */
|
||||||
if (dev_zero < 0) {
|
if (SLJIT_UNLIKELY((dev_zero < 0) && open_dev_zero()))
|
||||||
if (open_dev_zero())
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
retval = mmap(NULL, size, prot, MAP_PRIVATE, dev_zero, 0);
|
retval = mmap(NULL, size, prot, MAP_PRIVATE, dev_zero, 0);
|
||||||
#endif /* MAP_ANON */
|
#endif /* MAP_ANON */
|
||||||
|
|
||||||
@ -253,7 +252,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
|
|||||||
struct free_block *free_block;
|
struct free_block *free_block;
|
||||||
sljit_uw chunk_size;
|
sljit_uw chunk_size;
|
||||||
|
|
||||||
allocator_grab_lock();
|
SLJIT_ALLOCATOR_LOCK();
|
||||||
if (size < (64 - sizeof(struct block_header)))
|
if (size < (64 - sizeof(struct block_header)))
|
||||||
size = (64 - sizeof(struct block_header));
|
size = (64 - sizeof(struct block_header));
|
||||||
size = ALIGN_SIZE(size);
|
size = ALIGN_SIZE(size);
|
||||||
@ -277,7 +276,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
|
|||||||
}
|
}
|
||||||
allocated_size += size;
|
allocated_size += size;
|
||||||
header->size = size;
|
header->size = size;
|
||||||
allocator_release_lock();
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
return MEM_START(header);
|
return MEM_START(header);
|
||||||
}
|
}
|
||||||
free_block = free_block->next;
|
free_block = free_block->next;
|
||||||
@ -286,7 +285,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
|
|||||||
chunk_size = (size + sizeof(struct block_header) + CHUNK_SIZE - 1) & CHUNK_MASK;
|
chunk_size = (size + sizeof(struct block_header) + CHUNK_SIZE - 1) & CHUNK_MASK;
|
||||||
header = (struct block_header*)alloc_chunk(chunk_size);
|
header = (struct block_header*)alloc_chunk(chunk_size);
|
||||||
if (!header) {
|
if (!header) {
|
||||||
allocator_release_lock();
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +312,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
|
|||||||
}
|
}
|
||||||
next_header->size = 1;
|
next_header->size = 1;
|
||||||
next_header->prev_size = chunk_size;
|
next_header->prev_size = chunk_size;
|
||||||
allocator_release_lock();
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
return MEM_START(header);
|
return MEM_START(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +321,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
|
|||||||
struct block_header *header;
|
struct block_header *header;
|
||||||
struct free_block* free_block;
|
struct free_block* free_block;
|
||||||
|
|
||||||
allocator_grab_lock();
|
SLJIT_ALLOCATOR_LOCK();
|
||||||
header = AS_BLOCK_HEADER(ptr, -(sljit_sw)sizeof(struct block_header));
|
header = AS_BLOCK_HEADER(ptr, -(sljit_sw)sizeof(struct block_header));
|
||||||
allocated_size -= header->size;
|
allocated_size -= header->size;
|
||||||
|
|
||||||
@ -359,7 +358,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allocator_release_lock();
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void)
|
||||||
@ -367,7 +366,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void)
|
|||||||
struct free_block* free_block;
|
struct free_block* free_block;
|
||||||
struct free_block* next_free_block;
|
struct free_block* next_free_block;
|
||||||
|
|
||||||
allocator_grab_lock();
|
SLJIT_ALLOCATOR_LOCK();
|
||||||
|
|
||||||
free_block = free_blocks;
|
free_block = free_blocks;
|
||||||
while (free_block) {
|
while (free_block) {
|
||||||
@ -382,5 +381,5 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks));
|
SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks));
|
||||||
allocator_release_lock();
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
}
|
}
|
||||||
|
59
src/3rdparty/pcre2/src/sljit/sljitLir.c
vendored
59
src/3rdparty/pcre2/src/sljit/sljitLir.c
vendored
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
/* For SLJIT_CACHE_FLUSH, which can expand to FlushInstructionCache. */
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
@ -223,14 +222,6 @@
|
|||||||
# define FCSR_FCC 33
|
# define FCSR_FCC 33
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
|
|
||||||
# define IS_JAL 0x04
|
|
||||||
# define IS_COND 0x08
|
|
||||||
|
|
||||||
# define PATCH_B 0x10
|
|
||||||
# define PATCH_J 0x20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
|
#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
|
||||||
# define IS_MOVABLE 0x04
|
# define IS_MOVABLE 0x04
|
||||||
# define IS_COND 0x08
|
# define IS_COND 0x08
|
||||||
@ -274,6 +265,8 @@
|
|||||||
|
|
||||||
#if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
|
#if (defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR)
|
||||||
#include "sljitProtExecAllocator.c"
|
#include "sljitProtExecAllocator.c"
|
||||||
|
#elif (defined SLJIT_WX_EXECUTABLE_ALLOCATOR && SLJIT_WX_EXECUTABLE_ALLOCATOR)
|
||||||
|
#include "sljitWXExecAllocator.c"
|
||||||
#else
|
#else
|
||||||
#include "sljitExecAllocator.c"
|
#include "sljitExecAllocator.c"
|
||||||
#endif
|
#endif
|
||||||
@ -286,6 +279,10 @@
|
|||||||
#define SLJIT_ADD_EXEC_OFFSET(ptr, exec_offset) ((sljit_u8 *)(ptr))
|
#define SLJIT_ADD_EXEC_OFFSET(ptr, exec_offset) ((sljit_u8 *)(ptr))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SLJIT_UPDATE_WX_FLAGS
|
||||||
|
#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Argument checking features. */
|
/* Argument checking features. */
|
||||||
|
|
||||||
#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
|
#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
|
||||||
@ -366,7 +363,7 @@ static sljit_s32 compiler_initialized = 0;
|
|||||||
static void init_compiler(void);
|
static void init_compiler(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data)
|
SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data, void *exec_allocator_data)
|
||||||
{
|
{
|
||||||
struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler), allocator_data);
|
struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler), allocator_data);
|
||||||
if (!compiler)
|
if (!compiler)
|
||||||
@ -393,6 +390,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allo
|
|||||||
compiler->error = SLJIT_SUCCESS;
|
compiler->error = SLJIT_SUCCESS;
|
||||||
|
|
||||||
compiler->allocator_data = allocator_data;
|
compiler->allocator_data = allocator_data;
|
||||||
|
compiler->exec_allocator_data = exec_allocator_data;
|
||||||
compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, allocator_data);
|
compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, allocator_data);
|
||||||
compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, allocator_data);
|
compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, allocator_data);
|
||||||
|
|
||||||
@ -485,22 +483,28 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_compiler_memory_error(struct sljit_compi
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
|
#if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code, void *exec_allocator_data)
|
||||||
{
|
{
|
||||||
|
SLJIT_UNUSED_ARG(exec_allocator_data);
|
||||||
|
|
||||||
/* Remove thumb mode flag. */
|
/* Remove thumb mode flag. */
|
||||||
SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1));
|
SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1), exec_allocator_data);
|
||||||
}
|
}
|
||||||
#elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
|
#elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code, void *exec_allocator_data)
|
||||||
{
|
{
|
||||||
|
SLJIT_UNUSED_ARG(exec_allocator_data);
|
||||||
|
|
||||||
/* Resolve indirection. */
|
/* Resolve indirection. */
|
||||||
code = (void*)(*(sljit_uw*)code);
|
code = (void*)(*(sljit_uw*)code);
|
||||||
SLJIT_FREE_EXEC(code);
|
SLJIT_FREE_EXEC(code, exec_allocator_data);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code, void *exec_allocator_data)
|
||||||
{
|
{
|
||||||
SLJIT_FREE_EXEC(code);
|
SLJIT_UNUSED_ARG(exec_allocator_data);
|
||||||
|
|
||||||
|
SLJIT_FREE_EXEC(code, exec_allocator_data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -627,7 +631,10 @@ static SLJIT_INLINE sljit_s32 get_arg_count(sljit_s32 arg_types)
|
|||||||
return arg_count;
|
return arg_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
|
|
||||||
|
/* Only used in RISC architectures where the instruction size is constant */
|
||||||
|
#if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
|
||||||
|
&& !(defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
|
||||||
|
|
||||||
static SLJIT_INLINE sljit_uw compute_next_addr(struct sljit_label *label, struct sljit_jump *jump,
|
static SLJIT_INLINE sljit_uw compute_next_addr(struct sljit_label *label, struct sljit_jump *jump,
|
||||||
struct sljit_const *const_, struct sljit_put_label *put_label)
|
struct sljit_const *const_, struct sljit_put_label *put_label)
|
||||||
@ -649,7 +656,7 @@ static SLJIT_INLINE sljit_uw compute_next_addr(struct sljit_label *label, struct
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !SLJIT_CONFIG_X86 */
|
#endif /* !SLJIT_CONFIG_X86 && !SLJIT_CONFIG_S390X */
|
||||||
|
|
||||||
static SLJIT_INLINE void set_emit_enter(struct sljit_compiler *compiler,
|
static SLJIT_INLINE void set_emit_enter(struct sljit_compiler *compiler,
|
||||||
sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
|
sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
|
||||||
@ -1378,6 +1385,8 @@ static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op_custom(struct sljit_co
|
|||||||
#elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
|
#elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
|
||||||
CHECK_ARGUMENT((size == 2 && (((sljit_sw)instruction) & 0x1) == 0)
|
CHECK_ARGUMENT((size == 2 && (((sljit_sw)instruction) & 0x1) == 0)
|
||||||
|| (size == 4 && (((sljit_sw)instruction) & 0x3) == 0));
|
|| (size == 4 && (((sljit_sw)instruction) & 0x3) == 0));
|
||||||
|
#elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
|
||||||
|
CHECK_ARGUMENT(size == 2 || size == 4 || size == 6);
|
||||||
#else
|
#else
|
||||||
CHECK_ARGUMENT(size == 4 && (((sljit_sw)instruction) & 0x3) == 0);
|
CHECK_ARGUMENT(size == 4 && (((sljit_sw)instruction) & 0x3) == 0);
|
||||||
#endif
|
#endif
|
||||||
@ -2034,7 +2043,7 @@ static SLJIT_INLINE sljit_s32 emit_mov_before_return(struct sljit_compiler *comp
|
|||||||
#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
|
#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) \
|
||||||
|| (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC) \
|
|| (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC) \
|
||||||
|| (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
|
|| (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
|
||||||
|| ((defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS) && !(defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1))
|
|| ((defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS) && !(defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1 && SLJIT_MIPS_REV < 6))
|
||||||
|
|
||||||
static SLJIT_INLINE sljit_s32 sljit_emit_cmov_generic(struct sljit_compiler *compiler, sljit_s32 type,
|
static SLJIT_INLINE sljit_s32 sljit_emit_cmov_generic(struct sljit_compiler *compiler, sljit_s32 type,
|
||||||
sljit_s32 dst_reg,
|
sljit_s32 dst_reg,
|
||||||
@ -2111,8 +2120,8 @@ static SLJIT_INLINE sljit_s32 sljit_emit_cmov_generic(struct sljit_compiler *com
|
|||||||
# include "sljitNativeMIPS_common.c"
|
# include "sljitNativeMIPS_common.c"
|
||||||
#elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
|
#elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
|
||||||
# include "sljitNativeSPARC_common.c"
|
# include "sljitNativeSPARC_common.c"
|
||||||
#elif (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
|
#elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
|
||||||
# include "sljitNativeTILEGX_64.c"
|
# include "sljitNativeS390X.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
|
#if !(defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
|
||||||
@ -2143,7 +2152,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SLJIT_UNLIKELY((src1 & SLJIT_IMM) && !(src2 & SLJIT_IMM))) {
|
if (SLJIT_UNLIKELY((src1 & SLJIT_IMM) && !(src2 & SLJIT_IMM))) {
|
||||||
/* Immediate is prefered as second argument by most architectures. */
|
/* Immediate is preferred as second argument by most architectures. */
|
||||||
switch (condition) {
|
switch (condition) {
|
||||||
case SLJIT_LESS:
|
case SLJIT_LESS:
|
||||||
condition = SLJIT_GREATER;
|
condition = SLJIT_GREATER;
|
||||||
@ -2292,9 +2301,10 @@ SLJIT_API_FUNC_ATTRIBUTE const char* sljit_get_platform_name(void)
|
|||||||
return "unsupported";
|
return "unsupported";
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data)
|
SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data, void *exec_allocator_data)
|
||||||
{
|
{
|
||||||
SLJIT_UNUSED_ARG(allocator_data);
|
SLJIT_UNUSED_ARG(allocator_data);
|
||||||
|
SLJIT_UNUSED_ARG(exec_allocator_data);
|
||||||
SLJIT_UNREACHABLE();
|
SLJIT_UNREACHABLE();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2342,9 +2352,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code, void *exec_allocator_data)
|
||||||
{
|
{
|
||||||
SLJIT_UNUSED_ARG(code);
|
SLJIT_UNUSED_ARG(code);
|
||||||
|
SLJIT_UNUSED_ARG(exec_allocator_data);
|
||||||
SLJIT_UNREACHABLE();
|
SLJIT_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
42
src/3rdparty/pcre2/src/sljit/sljitLir.h
vendored
42
src/3rdparty/pcre2/src/sljit/sljitLir.h
vendored
@ -24,8 +24,8 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SLJIT_LIR_H_
|
#ifndef SLJIT_LIR_H_
|
||||||
#define _SLJIT_LIR_H_
|
#define SLJIT_LIR_H_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
@ -70,9 +70,11 @@
|
|||||||
- pass --smc-check=all argument to valgrind, since JIT is a "self-modifying code"
|
- pass --smc-check=all argument to valgrind, since JIT is a "self-modifying code"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !(defined SLJIT_NO_DEFAULT_CONFIG && SLJIT_NO_DEFAULT_CONFIG)
|
#if (defined SLJIT_HAVE_CONFIG_PRE && SLJIT_HAVE_CONFIG_PRE)
|
||||||
|
#include "sljitConfigPre.h"
|
||||||
|
#endif /* SLJIT_HAVE_CONFIG_PRE */
|
||||||
|
|
||||||
#include "sljitConfig.h"
|
#include "sljitConfig.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The following header file defines useful macros for fine tuning
|
/* The following header file defines useful macros for fine tuning
|
||||||
sljit based code generators. They are listed in the beginning
|
sljit based code generators. They are listed in the beginning
|
||||||
@ -80,6 +82,10 @@ of sljitConfigInternal.h */
|
|||||||
|
|
||||||
#include "sljitConfigInternal.h"
|
#include "sljitConfigInternal.h"
|
||||||
|
|
||||||
|
#if (defined SLJIT_HAVE_CONFIG_POST && SLJIT_HAVE_CONFIG_POST)
|
||||||
|
#include "sljitConfigPost.h"
|
||||||
|
#endif /* SLJIT_HAVE_CONFIG_POST */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -385,6 +391,7 @@ struct sljit_compiler {
|
|||||||
struct sljit_put_label *last_put_label;
|
struct sljit_put_label *last_put_label;
|
||||||
|
|
||||||
void *allocator_data;
|
void *allocator_data;
|
||||||
|
void *exec_allocator_data;
|
||||||
struct sljit_memory_fragment *buf;
|
struct sljit_memory_fragment *buf;
|
||||||
struct sljit_memory_fragment *abuf;
|
struct sljit_memory_fragment *abuf;
|
||||||
|
|
||||||
@ -451,9 +458,9 @@ struct sljit_compiler {
|
|||||||
sljit_sw cache_argw;
|
sljit_sw cache_argw;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
|
#if (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
|
||||||
sljit_s32 cache_arg;
|
/* Need to allocate register save area to make calls. */
|
||||||
sljit_sw cache_argw;
|
sljit_s32 have_save_area;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
|
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
|
||||||
@ -485,10 +492,12 @@ struct sljit_compiler {
|
|||||||
custom memory managers. This pointer is passed to SLJIT_MALLOC
|
custom memory managers. This pointer is passed to SLJIT_MALLOC
|
||||||
and SLJIT_FREE macros. Most allocators (including the default
|
and SLJIT_FREE macros. Most allocators (including the default
|
||||||
one) ignores this value, and it is recommended to pass NULL
|
one) ignores this value, and it is recommended to pass NULL
|
||||||
as a dummy value for allocator_data.
|
as a dummy value for allocator_data. The exec_allocator_data
|
||||||
|
has the same purpose but this one is passed to SLJIT_MALLOC_EXEC /
|
||||||
|
SLJIT_MALLOC_FREE functions.
|
||||||
|
|
||||||
Returns NULL if failed. */
|
Returns NULL if failed. */
|
||||||
SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data);
|
SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data, void *exec_allocator_data);
|
||||||
|
|
||||||
/* Frees everything except the compiled machine code. */
|
/* Frees everything except the compiled machine code. */
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler);
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler);
|
||||||
@ -535,7 +544,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
|
|
||||||
/* Free executable code. */
|
/* Free executable code. */
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code);
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code, void *exec_allocator_data);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
When the protected executable allocator is used the JIT code is mapped
|
When the protected executable allocator is used the JIT code is mapped
|
||||||
@ -699,7 +708,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IMPORATNT NOTE: memory access MUST be naturally aligned except
|
IMPORTANT NOTE: memory access MUST be naturally aligned unless
|
||||||
SLJIT_UNALIGNED macro is defined and its value is 1.
|
SLJIT_UNALIGNED macro is defined and its value is 1.
|
||||||
|
|
||||||
length | alignment
|
length | alignment
|
||||||
@ -741,6 +750,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *
|
|||||||
mips: [reg+imm], -65536 <= imm <= 65535
|
mips: [reg+imm], -65536 <= imm <= 65535
|
||||||
sparc: [reg+imm], -4096 <= imm <= 4095
|
sparc: [reg+imm], -4096 <= imm <= 4095
|
||||||
[reg+reg] is supported
|
[reg+reg] is supported
|
||||||
|
s390x: [reg+imm], -2^19 <= imm < 2^19
|
||||||
|
[reg+reg] is supported
|
||||||
|
Write-back is not supported
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Macros for specifying operand types. */
|
/* Macros for specifying operand types. */
|
||||||
@ -1405,12 +1417,6 @@ SLJIT_API_FUNC_ATTRIBUTE const char* sljit_get_platform_name(void);
|
|||||||
/* Portable helper function to get an offset of a member. */
|
/* Portable helper function to get an offset of a member. */
|
||||||
#define SLJIT_OFFSETOF(base, member) ((sljit_sw)(&((base*)0x10)->member) - 0x10)
|
#define SLJIT_OFFSETOF(base, member) ((sljit_sw)(&((base*)0x10)->member) - 0x10)
|
||||||
|
|
||||||
#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
|
|
||||||
/* This global lock is useful to compile common functions. */
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_grab_lock(void);
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_release_lock(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
|
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
|
||||||
|
|
||||||
/* The sljit_stack structure and its manipulation functions provides
|
/* The sljit_stack structure and its manipulation functions provides
|
||||||
@ -1538,4 +1544,4 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_current_flags(struct sljit_compiler *com
|
|||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _SLJIT_LIR_H_ */
|
#endif /* SLJIT_LIR_H_ */
|
||||||
|
86
src/3rdparty/pcre2/src/sljit/sljitNativeARM_32.c
vendored
86
src/3rdparty/pcre2/src/sljit/sljitNativeARM_32.c
vendored
@ -467,18 +467,28 @@ static SLJIT_INLINE void inline_set_jump_addr(sljit_uw jump_ptr, sljit_sw execut
|
|||||||
sljit_s32 bl = (mov_pc & 0x0000f000) != RD(TMP_PC);
|
sljit_s32 bl = (mov_pc & 0x0000f000) != RD(TMP_PC);
|
||||||
sljit_sw diff = (sljit_sw)(((sljit_sw)new_addr - (sljit_sw)(inst + 2) - executable_offset) >> 2);
|
sljit_sw diff = (sljit_sw)(((sljit_sw)new_addr - (sljit_sw)(inst + 2) - executable_offset) >> 2);
|
||||||
|
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
if (diff <= 0x7fffff && diff >= -0x800000) {
|
if (diff <= 0x7fffff && diff >= -0x800000) {
|
||||||
/* Turn to branch. */
|
/* Turn to branch. */
|
||||||
if (!bl) {
|
if (!bl) {
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 1, 0);
|
||||||
|
}
|
||||||
inst[0] = (mov_pc & COND_MASK) | (B - CONDITIONAL) | (diff & 0xffffff);
|
inst[0] = (mov_pc & COND_MASK) | (B - CONDITIONAL) | (diff & 0xffffff);
|
||||||
if (flush_cache) {
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 1, 1);
|
||||||
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 0);
|
||||||
|
}
|
||||||
inst[0] = (mov_pc & COND_MASK) | (BL - CONDITIONAL) | (diff & 0xffffff);
|
inst[0] = (mov_pc & COND_MASK) | (BL - CONDITIONAL) | (diff & 0xffffff);
|
||||||
inst[1] = NOP;
|
inst[1] = NOP;
|
||||||
if (flush_cache) {
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 1);
|
||||||
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
||||||
}
|
}
|
||||||
@ -491,28 +501,52 @@ static SLJIT_INLINE void inline_set_jump_addr(sljit_uw jump_ptr, sljit_sw execut
|
|||||||
ptr = inst + 1;
|
ptr = inst + 1;
|
||||||
|
|
||||||
if (*inst != mov_pc) {
|
if (*inst != mov_pc) {
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + (!bl ? 1 : 2), 0);
|
||||||
|
}
|
||||||
inst[0] = mov_pc;
|
inst[0] = mov_pc;
|
||||||
if (!bl) {
|
if (!bl) {
|
||||||
if (flush_cache) {
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 1, 1);
|
||||||
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inst[1] = BLX | RM(TMP_REG1);
|
inst[1] = BLX | RM(TMP_REG1);
|
||||||
if (flush_cache) {
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 1);
|
||||||
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(ptr, ptr + 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
*ptr = new_addr;
|
*ptr = new_addr;
|
||||||
|
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(ptr, ptr + 1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
sljit_uw *inst = (sljit_uw*)jump_ptr;
|
sljit_uw *inst = (sljit_uw*)jump_ptr;
|
||||||
|
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
SLJIT_ASSERT((inst[0] & 0xfff00000) == MOVW && (inst[1] & 0xfff00000) == MOVT);
|
SLJIT_ASSERT((inst[0] & 0xfff00000) == MOVW && (inst[1] & 0xfff00000) == MOVT);
|
||||||
|
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
inst[0] = MOVW | (inst[0] & 0xf000) | ((new_addr << 4) & 0xf0000) | (new_addr & 0xfff);
|
inst[0] = MOVW | (inst[0] & 0xf000) | ((new_addr << 4) & 0xf0000) | (new_addr & 0xfff);
|
||||||
inst[1] = MOVT | (inst[1] & 0xf000) | ((new_addr >> 12) & 0xf0000) | ((new_addr >> 16) & 0xfff);
|
inst[1] = MOVT | (inst[1] & 0xf000) | ((new_addr >> 12) & 0xf0000) | ((new_addr >> 16) & 0xfff);
|
||||||
|
|
||||||
if (flush_cache) {
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 1);
|
||||||
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
||||||
}
|
}
|
||||||
@ -529,10 +563,18 @@ static SLJIT_INLINE void inline_set_const(sljit_uw addr, sljit_sw executable_off
|
|||||||
sljit_uw ldr_literal = ptr[1];
|
sljit_uw ldr_literal = ptr[1];
|
||||||
sljit_uw src2;
|
sljit_uw src2;
|
||||||
|
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
src2 = get_imm(new_constant);
|
src2 = get_imm(new_constant);
|
||||||
if (src2) {
|
if (src2) {
|
||||||
*inst = 0xe3a00000 | (ldr_literal & 0xf000) | src2;
|
|
||||||
if (flush_cache) {
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
*inst = 0xe3a00000 | (ldr_literal & 0xf000) | src2;
|
||||||
|
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 1, 1);
|
||||||
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
||||||
}
|
}
|
||||||
@ -541,8 +583,14 @@ static SLJIT_INLINE void inline_set_const(sljit_uw addr, sljit_sw executable_off
|
|||||||
|
|
||||||
src2 = get_imm(~new_constant);
|
src2 = get_imm(~new_constant);
|
||||||
if (src2) {
|
if (src2) {
|
||||||
*inst = 0xe3e00000 | (ldr_literal & 0xf000) | src2;
|
|
||||||
if (flush_cache) {
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
*inst = 0xe3e00000 | (ldr_literal & 0xf000) | src2;
|
||||||
|
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 1, 1);
|
||||||
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
||||||
}
|
}
|
||||||
@ -555,19 +603,44 @@ static SLJIT_INLINE void inline_set_const(sljit_uw addr, sljit_sw executable_off
|
|||||||
ptr = inst + 1;
|
ptr = inst + 1;
|
||||||
|
|
||||||
if (*inst != ldr_literal) {
|
if (*inst != ldr_literal) {
|
||||||
*inst = ldr_literal;
|
|
||||||
if (flush_cache) {
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
*inst = ldr_literal;
|
||||||
|
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 1, 1);
|
||||||
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
SLJIT_CACHE_FLUSH(inst, inst + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(ptr, ptr + 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
*ptr = new_constant;
|
*ptr = new_constant;
|
||||||
|
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(ptr, ptr + 1, 1);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
sljit_uw *inst = (sljit_uw*)addr;
|
sljit_uw *inst = (sljit_uw*)addr;
|
||||||
|
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
SLJIT_ASSERT((inst[0] & 0xfff00000) == MOVW && (inst[1] & 0xfff00000) == MOVT);
|
SLJIT_ASSERT((inst[0] & 0xfff00000) == MOVW && (inst[1] & 0xfff00000) == MOVT);
|
||||||
|
|
||||||
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
inst[0] = MOVW | (inst[0] & 0xf000) | ((new_constant << 4) & 0xf0000) | (new_constant & 0xfff);
|
inst[0] = MOVW | (inst[0] & 0xf000) | ((new_constant << 4) & 0xf0000) | (new_constant & 0xfff);
|
||||||
inst[1] = MOVT | (inst[1] & 0xf000) | ((new_constant >> 12) & 0xf0000) | ((new_constant >> 16) & 0xfff);
|
inst[1] = MOVT | (inst[1] & 0xf000) | ((new_constant >> 12) & 0xf0000) | ((new_constant >> 16) & 0xfff);
|
||||||
|
|
||||||
if (flush_cache) {
|
if (flush_cache) {
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 1);
|
||||||
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
||||||
}
|
}
|
||||||
@ -612,7 +685,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
#else
|
#else
|
||||||
size = compiler->size;
|
size = compiler->size;
|
||||||
#endif
|
#endif
|
||||||
code = (sljit_uw*)SLJIT_MALLOC_EXEC(size * sizeof(sljit_uw));
|
code = (sljit_uw*)SLJIT_MALLOC_EXEC(size * sizeof(sljit_uw), compiler->exec_allocator_data);
|
||||||
PTR_FAIL_WITH_EXEC_IF(code);
|
PTR_FAIL_WITH_EXEC_IF(code);
|
||||||
buf = compiler->buf;
|
buf = compiler->buf;
|
||||||
|
|
||||||
@ -653,7 +726,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (SLJIT_UNLIKELY(resolve_const_pool_index(compiler, &first_patch, cpool_current_index, cpool_start_address, buf_ptr))) {
|
if (SLJIT_UNLIKELY(resolve_const_pool_index(compiler, &first_patch, cpool_current_index, cpool_start_address, buf_ptr))) {
|
||||||
SLJIT_FREE_EXEC(code);
|
SLJIT_FREE_EXEC(code, compiler->exec_allocator_data);
|
||||||
compiler->error = SLJIT_ERR_ALLOC_FAILED;
|
compiler->error = SLJIT_ERR_ALLOC_FAILED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -756,7 +829,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
cpool_current_index = 0;
|
cpool_current_index = 0;
|
||||||
while (buf_ptr < buf_end) {
|
while (buf_ptr < buf_end) {
|
||||||
if (SLJIT_UNLIKELY(resolve_const_pool_index(compiler, &first_patch, cpool_current_index, cpool_start_address, buf_ptr))) {
|
if (SLJIT_UNLIKELY(resolve_const_pool_index(compiler, &first_patch, cpool_current_index, cpool_start_address, buf_ptr))) {
|
||||||
SLJIT_FREE_EXEC(code);
|
SLJIT_FREE_EXEC(code, compiler->exec_allocator_data);
|
||||||
compiler->error = SLJIT_ERR_ALLOC_FAILED;
|
compiler->error = SLJIT_ERR_ALLOC_FAILED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -856,6 +929,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
code_ptr = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
code_ptr = (sljit_uw *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
||||||
|
|
||||||
SLJIT_CACHE_FLUSH(code, code_ptr);
|
SLJIT_CACHE_FLUSH(code, code_ptr);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(code, code_ptr, 1);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
src/3rdparty/pcre2/src/sljit/sljitNativeARM_64.c
vendored
32
src/3rdparty/pcre2/src/sljit/sljitNativeARM_64.c
vendored
@ -151,16 +151,6 @@ static SLJIT_INLINE sljit_s32 emit_imm64_const(struct sljit_compiler *compiler,
|
|||||||
return push_inst(compiler, MOVK | RD(dst) | ((imm >> 48) << 5) | (3 << 21));
|
return push_inst(compiler, MOVK | RD(dst) | ((imm >> 48) << 5) | (3 << 21));
|
||||||
}
|
}
|
||||||
|
|
||||||
static SLJIT_INLINE void modify_imm64_const(sljit_ins* inst, sljit_uw new_imm)
|
|
||||||
{
|
|
||||||
sljit_s32 dst = inst[0] & 0x1f;
|
|
||||||
SLJIT_ASSERT((inst[0] & 0xffe00000) == MOVZ && (inst[1] & 0xffe00000) == (MOVK | (1 << 21)));
|
|
||||||
inst[0] = MOVZ | dst | ((new_imm & 0xffff) << 5);
|
|
||||||
inst[1] = MOVK | dst | (((new_imm >> 16) & 0xffff) << 5) | (1 << 21);
|
|
||||||
inst[2] = MOVK | dst | (((new_imm >> 32) & 0xffff) << 5) | (2 << 21);
|
|
||||||
inst[3] = MOVK | dst | ((new_imm >> 48) << 5) | (3 << 21);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SLJIT_INLINE sljit_sw detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code, sljit_sw executable_offset)
|
static SLJIT_INLINE sljit_sw detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_sw diff;
|
sljit_sw diff;
|
||||||
@ -253,7 +243,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
CHECK_PTR(check_sljit_generate_code(compiler));
|
CHECK_PTR(check_sljit_generate_code(compiler));
|
||||||
reverse_buf(compiler);
|
reverse_buf(compiler);
|
||||||
|
|
||||||
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
|
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins), compiler->exec_allocator_data);
|
||||||
PTR_FAIL_WITH_EXEC_IF(code);
|
PTR_FAIL_WITH_EXEC_IF(code);
|
||||||
buf = compiler->buf;
|
buf = compiler->buf;
|
||||||
|
|
||||||
@ -380,6 +370,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
code_ptr = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
code_ptr = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
||||||
|
|
||||||
SLJIT_CACHE_FLUSH(code, code_ptr);
|
SLJIT_CACHE_FLUSH(code, code_ptr);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(code, code_ptr, 1);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2034,15 +2025,24 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct slj
|
|||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins* inst = (sljit_ins*)addr;
|
sljit_ins* inst = (sljit_ins*)addr;
|
||||||
modify_imm64_const(inst, new_target);
|
sljit_s32 dst;
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 4, 0);
|
||||||
|
|
||||||
|
dst = inst[0] & 0x1f;
|
||||||
|
SLJIT_ASSERT((inst[0] & 0xffe00000) == MOVZ && (inst[1] & 0xffe00000) == (MOVK | (1 << 21)));
|
||||||
|
inst[0] = MOVZ | dst | ((new_target & 0xffff) << 5);
|
||||||
|
inst[1] = MOVK | dst | (((new_target >> 16) & 0xffff) << 5) | (1 << 21);
|
||||||
|
inst[2] = MOVK | dst | (((new_target >> 32) & 0xffff) << 5) | (2 << 21);
|
||||||
|
inst[3] = MOVK | dst | ((new_target >> 48) << 5) | (3 << 21);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 4, 1);
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 4);
|
SLJIT_CACHE_FLUSH(inst, inst + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins* inst = (sljit_ins*)addr;
|
sljit_set_jump_addr(addr, new_constant, executable_offset);
|
||||||
modify_imm64_const(inst, new_constant);
|
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 4);
|
|
||||||
}
|
}
|
||||||
|
@ -377,7 +377,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
CHECK_PTR(check_sljit_generate_code(compiler));
|
CHECK_PTR(check_sljit_generate_code(compiler));
|
||||||
reverse_buf(compiler);
|
reverse_buf(compiler);
|
||||||
|
|
||||||
code = (sljit_u16*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_u16));
|
code = (sljit_u16*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_u16), compiler->exec_allocator_data);
|
||||||
PTR_FAIL_WITH_EXEC_IF(code);
|
PTR_FAIL_WITH_EXEC_IF(code);
|
||||||
buf = compiler->buf;
|
buf = compiler->buf;
|
||||||
|
|
||||||
@ -463,6 +463,8 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
code_ptr = (sljit_u16 *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
code_ptr = (sljit_u16 *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
||||||
|
|
||||||
SLJIT_CACHE_FLUSH(code, code_ptr);
|
SLJIT_CACHE_FLUSH(code, code_ptr);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(code, code_ptr, 1);
|
||||||
|
|
||||||
/* Set thumb mode flag. */
|
/* Set thumb mode flag. */
|
||||||
return (void*)((sljit_uw)code | 0x1);
|
return (void*)((sljit_uw)code | 0x1);
|
||||||
}
|
}
|
||||||
@ -608,7 +610,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s
|
|||||||
Although some clever things could be done here, "NOT IMM" does not worth the efforts. */
|
Although some clever things could be done here, "NOT IMM" does not worth the efforts. */
|
||||||
break;
|
break;
|
||||||
case SLJIT_ADD:
|
case SLJIT_ADD:
|
||||||
nimm = -imm;
|
nimm = -(sljit_sw)imm;
|
||||||
if (IS_2_LO_REGS(reg, dst)) {
|
if (IS_2_LO_REGS(reg, dst)) {
|
||||||
if (imm <= 0x7)
|
if (imm <= 0x7)
|
||||||
return push_inst16(compiler, ADDSI3 | IMM3(imm) | RD3(dst) | RN3(reg));
|
return push_inst16(compiler, ADDSI3 | IMM3(imm) | RD3(dst) | RN3(reg));
|
||||||
@ -630,7 +632,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s
|
|||||||
nimm = get_imm(imm);
|
nimm = get_imm(imm);
|
||||||
if (nimm != INVALID_IMM)
|
if (nimm != INVALID_IMM)
|
||||||
return push_inst32(compiler, ADD_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | nimm);
|
return push_inst32(compiler, ADD_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | nimm);
|
||||||
nimm = get_imm(-imm);
|
nimm = get_imm(-(sljit_sw)imm);
|
||||||
if (nimm != INVALID_IMM)
|
if (nimm != INVALID_IMM)
|
||||||
return push_inst32(compiler, SUB_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | nimm);
|
return push_inst32(compiler, SUB_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | nimm);
|
||||||
break;
|
break;
|
||||||
@ -655,11 +657,11 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s
|
|||||||
nimm = get_imm(imm);
|
nimm = get_imm(imm);
|
||||||
if (nimm != INVALID_IMM)
|
if (nimm != INVALID_IMM)
|
||||||
return push_inst32(compiler, CMPI_W | RN4(reg) | nimm);
|
return push_inst32(compiler, CMPI_W | RN4(reg) | nimm);
|
||||||
nimm = get_imm(-imm);
|
nimm = get_imm(-(sljit_sw)imm);
|
||||||
if (nimm != INVALID_IMM)
|
if (nimm != INVALID_IMM)
|
||||||
return push_inst32(compiler, CMNI_W | RN4(reg) | nimm);
|
return push_inst32(compiler, CMNI_W | RN4(reg) | nimm);
|
||||||
}
|
}
|
||||||
nimm = -imm;
|
nimm = -(sljit_sw)imm;
|
||||||
if (IS_2_LO_REGS(reg, dst)) {
|
if (IS_2_LO_REGS(reg, dst)) {
|
||||||
if (imm <= 0x7)
|
if (imm <= 0x7)
|
||||||
return push_inst16(compiler, SUBSI3 | IMM3(imm) | RD3(dst) | RN3(reg));
|
return push_inst16(compiler, SUBSI3 | IMM3(imm) | RD3(dst) | RN3(reg));
|
||||||
@ -681,7 +683,7 @@ static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, s
|
|||||||
nimm = get_imm(imm);
|
nimm = get_imm(imm);
|
||||||
if (nimm != INVALID_IMM)
|
if (nimm != INVALID_IMM)
|
||||||
return push_inst32(compiler, SUB_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | nimm);
|
return push_inst32(compiler, SUB_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | nimm);
|
||||||
nimm = get_imm(-imm);
|
nimm = get_imm(-(sljit_sw)imm);
|
||||||
if (nimm != INVALID_IMM)
|
if (nimm != INVALID_IMM)
|
||||||
return push_inst32(compiler, ADD_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | nimm);
|
return push_inst32(compiler, ADD_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | nimm);
|
||||||
break;
|
break;
|
||||||
@ -2366,15 +2368,16 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct slj
|
|||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_u16 *inst = (sljit_u16*)addr;
|
sljit_u16 *inst = (sljit_u16*)addr;
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 4, 0);
|
||||||
modify_imm32_const(inst, new_target);
|
modify_imm32_const(inst, new_target);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 4, 1);
|
||||||
inst = (sljit_u16 *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_u16 *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 4);
|
SLJIT_CACHE_FLUSH(inst, inst + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_u16 *inst = (sljit_u16*)addr;
|
sljit_set_jump_addr(addr, new_constant, executable_offset);
|
||||||
modify_imm32_const(inst, new_constant);
|
|
||||||
inst = (sljit_u16 *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 4);
|
|
||||||
}
|
}
|
||||||
|
@ -425,23 +425,20 @@ static SLJIT_INLINE sljit_s32 emit_const(struct sljit_compiler *compiler, sljit_
|
|||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins *)addr;
|
sljit_ins *inst = (sljit_ins *)addr;
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 0);
|
||||||
SLJIT_ASSERT((inst[0] & 0xffe00000) == LUI && (inst[1] & 0xfc000000) == ORI);
|
SLJIT_ASSERT((inst[0] & 0xffe00000) == LUI && (inst[1] & 0xfc000000) == ORI);
|
||||||
inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 16) & 0xffff);
|
inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 16) & 0xffff);
|
||||||
inst[1] = (inst[1] & 0xffff0000) | (new_target & 0xffff);
|
inst[1] = (inst[1] & 0xffff0000) | (new_target & 0xffff);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 1);
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins *)addr;
|
sljit_set_jump_addr(addr, new_constant, executable_offset);
|
||||||
|
|
||||||
SLJIT_ASSERT((inst[0] & 0xffe00000) == LUI && (inst[1] & 0xfc000000) == ORI);
|
|
||||||
inst[0] = (inst[0] & 0xffff0000) | ((new_constant >> 16) & 0xffff);
|
|
||||||
inst[1] = (inst[1] & 0xffff0000) | (new_constant & 0xffff);
|
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static sljit_s32 call_with_args(struct sljit_compiler *compiler, sljit_s32 arg_types, sljit_ins *ins_ptr)
|
static sljit_s32 call_with_args(struct sljit_compiler *compiler, sljit_s32 arg_types, sljit_ins *ins_ptr)
|
||||||
|
@ -525,25 +525,21 @@ static SLJIT_INLINE sljit_s32 emit_const(struct sljit_compiler *compiler, sljit_
|
|||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins *)addr;
|
sljit_ins *inst = (sljit_ins *)addr;
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 6, 0);
|
||||||
inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 48) & 0xffff);
|
inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 48) & 0xffff);
|
||||||
inst[1] = (inst[1] & 0xffff0000) | ((new_target >> 32) & 0xffff);
|
inst[1] = (inst[1] & 0xffff0000) | ((new_target >> 32) & 0xffff);
|
||||||
inst[3] = (inst[3] & 0xffff0000) | ((new_target >> 16) & 0xffff);
|
inst[3] = (inst[3] & 0xffff0000) | ((new_target >> 16) & 0xffff);
|
||||||
inst[5] = (inst[5] & 0xffff0000) | (new_target & 0xffff);
|
inst[5] = (inst[5] & 0xffff0000) | (new_target & 0xffff);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 6, 1);
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 6);
|
SLJIT_CACHE_FLUSH(inst, inst + 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins *)addr;
|
sljit_set_jump_addr(addr, new_constant, executable_offset);
|
||||||
|
|
||||||
inst[0] = (inst[0] & 0xffff0000) | ((new_constant >> 48) & 0xffff);
|
|
||||||
inst[1] = (inst[1] & 0xffff0000) | ((new_constant >> 32) & 0xffff);
|
|
||||||
inst[3] = (inst[3] & 0xffff0000) | ((new_constant >> 16) & 0xffff);
|
|
||||||
inst[5] = (inst[5] & 0xffff0000) | (new_constant & 0xffff);
|
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static sljit_s32 call_with_args(struct sljit_compiler *compiler, sljit_s32 arg_types, sljit_ins *ins_ptr)
|
static sljit_s32 call_with_args(struct sljit_compiler *compiler, sljit_s32 arg_types, sljit_ins *ins_ptr)
|
||||||
|
@ -290,9 +290,9 @@ static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 4] = {
|
|||||||
Useful for reordering instructions in the delay slot. */
|
Useful for reordering instructions in the delay slot. */
|
||||||
static sljit_s32 push_inst(struct sljit_compiler *compiler, sljit_ins ins, sljit_s32 delay_slot)
|
static sljit_s32 push_inst(struct sljit_compiler *compiler, sljit_ins ins, sljit_s32 delay_slot)
|
||||||
{
|
{
|
||||||
|
sljit_ins *ptr = (sljit_ins*)ensure_buf(compiler, sizeof(sljit_ins));
|
||||||
SLJIT_ASSERT(delay_slot == MOVABLE_INS || delay_slot >= UNMOVABLE_INS
|
SLJIT_ASSERT(delay_slot == MOVABLE_INS || delay_slot >= UNMOVABLE_INS
|
||||||
|| delay_slot == ((ins >> 11) & 0x1f) || delay_slot == ((ins >> 16) & 0x1f));
|
|| delay_slot == ((ins >> 11) & 0x1f) || delay_slot == ((ins >> 16) & 0x1f));
|
||||||
sljit_ins *ptr = (sljit_ins*)ensure_buf(compiler, sizeof(sljit_ins));
|
|
||||||
FAIL_IF(!ptr);
|
FAIL_IF(!ptr);
|
||||||
*ptr = ins;
|
*ptr = ins;
|
||||||
compiler->size++;
|
compiler->size++;
|
||||||
@ -520,7 +520,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
CHECK_PTR(check_sljit_generate_code(compiler));
|
CHECK_PTR(check_sljit_generate_code(compiler));
|
||||||
reverse_buf(compiler);
|
reverse_buf(compiler);
|
||||||
|
|
||||||
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
|
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins), compiler->exec_allocator_data);
|
||||||
PTR_FAIL_WITH_EXEC_IF(code);
|
PTR_FAIL_WITH_EXEC_IF(code);
|
||||||
buf = compiler->buf;
|
buf = compiler->buf;
|
||||||
|
|
||||||
@ -667,6 +667,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
/* GCC workaround for invalid code generation with -O2. */
|
/* GCC workaround for invalid code generation with -O2. */
|
||||||
sljit_cache_flush(code, code_ptr);
|
sljit_cache_flush(code, code_ptr);
|
||||||
#endif
|
#endif
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(code, code_ptr, 1);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,7 +680,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
|
|||||||
#ifdef SLJIT_IS_FPU_AVAILABLE
|
#ifdef SLJIT_IS_FPU_AVAILABLE
|
||||||
return SLJIT_IS_FPU_AVAILABLE;
|
return SLJIT_IS_FPU_AVAILABLE;
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
asm ("cfc1 %0, $0" : "=r"(fir));
|
__asm__ ("cfc1 %0, $0" : "=r"(fir));
|
||||||
return (fir >> 22) & 0x1;
|
return (fir >> 22) & 0x1;
|
||||||
#else
|
#else
|
||||||
#error "FIR check is not implemented for this architecture"
|
#error "FIR check is not implemented for this architecture"
|
||||||
@ -2185,14 +2186,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil
|
|||||||
sljit_s32 dst_reg,
|
sljit_s32 dst_reg,
|
||||||
sljit_s32 src, sljit_sw srcw)
|
sljit_s32 src, sljit_sw srcw)
|
||||||
{
|
{
|
||||||
#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1)
|
#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1 && SLJIT_MIPS_REV < 6)
|
||||||
sljit_ins ins;
|
sljit_ins ins;
|
||||||
#endif /* SLJIT_MIPS_REV >= 1 */
|
#endif /* SLJIT_MIPS_REV >= 1 && SLJIT_MIPS_REV < 6 */
|
||||||
|
|
||||||
CHECK_ERROR();
|
CHECK_ERROR();
|
||||||
CHECK(check_sljit_emit_cmov(compiler, type, dst_reg, src, srcw));
|
CHECK(check_sljit_emit_cmov(compiler, type, dst_reg, src, srcw));
|
||||||
|
|
||||||
#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1)
|
#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1 && SLJIT_MIPS_REV < 6)
|
||||||
|
|
||||||
if (SLJIT_UNLIKELY(src & SLJIT_IMM)) {
|
if (SLJIT_UNLIKELY(src & SLJIT_IMM)) {
|
||||||
#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
|
#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
|
||||||
@ -2249,7 +2250,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil
|
|||||||
|
|
||||||
return push_inst(compiler, ins | S(src) | D(dst_reg), DR(dst_reg));
|
return push_inst(compiler, ins | S(src) | D(dst_reg), DR(dst_reg));
|
||||||
|
|
||||||
#else /* SLJIT_MIPS_REV < 1 */
|
#else /* SLJIT_MIPS_REV < 1 || SLJIT_MIPS_REV >= 6 */
|
||||||
return sljit_emit_cmov_generic(compiler, type, dst_reg, src, srcw);
|
return sljit_emit_cmov_generic(compiler, type, dst_reg, src, srcw);
|
||||||
#endif /* SLJIT_MIPS_REV >= 1 */
|
#endif /* SLJIT_MIPS_REV >= 1 */
|
||||||
}
|
}
|
||||||
|
11
src/3rdparty/pcre2/src/sljit/sljitNativePPC_32.c
vendored
11
src/3rdparty/pcre2/src/sljit/sljitNativePPC_32.c
vendored
@ -258,21 +258,18 @@ static SLJIT_INLINE sljit_s32 emit_const(struct sljit_compiler *compiler, sljit_
|
|||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins *)addr;
|
sljit_ins *inst = (sljit_ins *)addr;
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 0);
|
||||||
SLJIT_ASSERT((inst[0] & 0xfc1f0000) == ADDIS && (inst[1] & 0xfc000000) == ORI);
|
SLJIT_ASSERT((inst[0] & 0xfc1f0000) == ADDIS && (inst[1] & 0xfc000000) == ORI);
|
||||||
inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 16) & 0xffff);
|
inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 16) & 0xffff);
|
||||||
inst[1] = (inst[1] & 0xffff0000) | (new_target & 0xffff);
|
inst[1] = (inst[1] & 0xffff0000) | (new_target & 0xffff);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 1);
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins *)addr;
|
sljit_set_jump_addr(addr, new_constant, executable_offset);
|
||||||
|
|
||||||
SLJIT_ASSERT((inst[0] & 0xfc1f0000) == ADDIS && (inst[1] & 0xfc000000) == ORI);
|
|
||||||
inst[0] = (inst[0] & 0xffff0000) | ((new_constant >> 16) & 0xffff);
|
|
||||||
inst[1] = (inst[1] & 0xffff0000) | (new_constant & 0xffff);
|
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
|
||||||
}
|
}
|
||||||
|
12
src/3rdparty/pcre2/src/sljit/sljitNativePPC_64.c
vendored
12
src/3rdparty/pcre2/src/sljit/sljitNativePPC_64.c
vendored
@ -477,23 +477,19 @@ static SLJIT_INLINE sljit_s32 emit_const(struct sljit_compiler *compiler, sljit_
|
|||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins*)addr;
|
sljit_ins *inst = (sljit_ins*)addr;
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 5, 0);
|
||||||
inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 48) & 0xffff);
|
inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 48) & 0xffff);
|
||||||
inst[1] = (inst[1] & 0xffff0000) | ((new_target >> 32) & 0xffff);
|
inst[1] = (inst[1] & 0xffff0000) | ((new_target >> 32) & 0xffff);
|
||||||
inst[3] = (inst[3] & 0xffff0000) | ((new_target >> 16) & 0xffff);
|
inst[3] = (inst[3] & 0xffff0000) | ((new_target >> 16) & 0xffff);
|
||||||
inst[4] = (inst[4] & 0xffff0000) | (new_target & 0xffff);
|
inst[4] = (inst[4] & 0xffff0000) | (new_target & 0xffff);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 5, 1);
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 5);
|
SLJIT_CACHE_FLUSH(inst, inst + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins*)addr;
|
sljit_set_jump_addr(addr, new_constant, executable_offset);
|
||||||
|
|
||||||
inst[0] = (inst[0] & 0xffff0000) | ((new_constant >> 48) & 0xffff);
|
|
||||||
inst[1] = (inst[1] & 0xffff0000) | ((new_constant >> 32) & 0xffff);
|
|
||||||
inst[3] = (inst[3] & 0xffff0000) | ((new_constant >> 16) & 0xffff);
|
|
||||||
inst[4] = (inst[4] & 0xffff0000) | (new_constant & 0xffff);
|
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 5);
|
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
compiler->size += (sizeof(struct sljit_function_context) / sizeof(sljit_ins));
|
compiler->size += (sizeof(struct sljit_function_context) / sizeof(sljit_ins));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
|
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins), compiler->exec_allocator_data);
|
||||||
PTR_FAIL_WITH_EXEC_IF(code);
|
PTR_FAIL_WITH_EXEC_IF(code);
|
||||||
buf = compiler->buf;
|
buf = compiler->buf;
|
||||||
|
|
||||||
@ -607,6 +607,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
code_ptr = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
code_ptr = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
||||||
|
|
||||||
SLJIT_CACHE_FLUSH(code, code_ptr);
|
SLJIT_CACHE_FLUSH(code, code_ptr);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(code, code_ptr, 1);
|
||||||
|
|
||||||
#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
|
#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
|
||||||
return code_ptr;
|
return code_ptr;
|
||||||
|
2812
src/3rdparty/pcre2/src/sljit/sljitNativeS390X.c
vendored
Normal file
2812
src/3rdparty/pcre2/src/sljit/sljitNativeS390X.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -266,21 +266,18 @@ static SLJIT_INLINE sljit_s32 emit_const(struct sljit_compiler *compiler, sljit_
|
|||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins *)addr;
|
sljit_ins *inst = (sljit_ins *)addr;
|
||||||
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 0);
|
||||||
SLJIT_ASSERT(((inst[0] & 0xc1c00000) == 0x01000000) && ((inst[1] & 0xc1f82000) == 0x80102000));
|
SLJIT_ASSERT(((inst[0] & 0xc1c00000) == 0x01000000) && ((inst[1] & 0xc1f82000) == 0x80102000));
|
||||||
inst[0] = (inst[0] & 0xffc00000) | ((new_target >> 10) & 0x3fffff);
|
inst[0] = (inst[0] & 0xffc00000) | ((new_target >> 10) & 0x3fffff);
|
||||||
inst[1] = (inst[1] & 0xfffffc00) | (new_target & 0x3ff);
|
inst[1] = (inst[1] & 0xfffffc00) | (new_target & 0x3ff);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(inst, inst + 2, 1);
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
sljit_ins *inst = (sljit_ins *)addr;
|
sljit_set_jump_addr(addr, new_constant, executable_offset);
|
||||||
|
|
||||||
SLJIT_ASSERT(((inst[0] & 0xc1c00000) == 0x01000000) && ((inst[1] & 0xc1f82000) == 0x80102000));
|
|
||||||
inst[0] = (inst[0] & 0xffc00000) | ((new_constant >> 10) & 0x3fffff);
|
|
||||||
inst[1] = (inst[1] & 0xfffffc00) | (new_constant & 0x3ff);
|
|
||||||
inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset);
|
|
||||||
SLJIT_CACHE_FLUSH(inst, inst + 2);
|
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
CHECK_PTR(check_sljit_generate_code(compiler));
|
CHECK_PTR(check_sljit_generate_code(compiler));
|
||||||
reverse_buf(compiler);
|
reverse_buf(compiler);
|
||||||
|
|
||||||
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
|
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins), compiler->exec_allocator_data);
|
||||||
PTR_FAIL_WITH_EXEC_IF(code);
|
PTR_FAIL_WITH_EXEC_IF(code);
|
||||||
buf = compiler->buf;
|
buf = compiler->buf;
|
||||||
|
|
||||||
@ -437,6 +437,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
code_ptr = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
code_ptr = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset);
|
||||||
|
|
||||||
SLJIT_CACHE_FLUSH(code, code_ptr);
|
SLJIT_CACHE_FLUSH(code, code_ptr);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(code, code_ptr, 1);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10159
src/3rdparty/pcre2/src/sljit/sljitNativeTILEGX-encoder.c
vendored
10159
src/3rdparty/pcre2/src/sljit/sljitNativeTILEGX-encoder.c
vendored
File diff suppressed because it is too large
Load Diff
2563
src/3rdparty/pcre2/src/sljit/sljitNativeTILEGX_64.c
vendored
2563
src/3rdparty/pcre2/src/sljit/sljitNativeTILEGX_64.c
vendored
File diff suppressed because it is too large
Load Diff
@ -506,7 +506,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
reverse_buf(compiler);
|
reverse_buf(compiler);
|
||||||
|
|
||||||
/* Second code generation pass. */
|
/* Second code generation pass. */
|
||||||
code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size);
|
code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size, compiler->exec_allocator_data);
|
||||||
PTR_FAIL_WITH_EXEC_IF(code);
|
PTR_FAIL_WITH_EXEC_IF(code);
|
||||||
buf = compiler->buf;
|
buf = compiler->buf;
|
||||||
|
|
||||||
@ -557,7 +557,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
SLJIT_ASSERT(put_label->label);
|
SLJIT_ASSERT(put_label->label);
|
||||||
put_label->addr = (sljit_uw)code_ptr;
|
put_label->addr = (sljit_uw)code_ptr;
|
||||||
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
||||||
code_ptr = generate_put_label_code(put_label, code_ptr, (sljit_uw)(SLJIT_ADD_EXEC_OFFSET(code, executable_offset) + put_label->label->size));
|
code_ptr = generate_put_label_code(put_label, code_ptr, (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code, executable_offset) + put_label->label->size);
|
||||||
#endif
|
#endif
|
||||||
put_label = put_label->next;
|
put_label = put_label->next;
|
||||||
break;
|
break;
|
||||||
@ -629,7 +629,11 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
|
|||||||
compiler->error = SLJIT_ERR_COMPILED;
|
compiler->error = SLJIT_ERR_COMPILED;
|
||||||
compiler->executable_offset = executable_offset;
|
compiler->executable_offset = executable_offset;
|
||||||
compiler->executable_size = code_ptr - code;
|
compiler->executable_size = code_ptr - code;
|
||||||
return (void*)(code + executable_offset);
|
|
||||||
|
code = (sljit_u8*)SLJIT_ADD_EXEC_OFFSET(code, executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS(code, (sljit_u8*)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset), 1);
|
||||||
|
return (void*)code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
|
SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
|
||||||
@ -725,15 +729,16 @@ static SLJIT_INLINE sljit_s32 emit_endbranch(struct sljit_compiler *compiler)
|
|||||||
#else
|
#else
|
||||||
*inst = 0xfa;
|
*inst = 0xfa;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else /* !SLJIT_CONFIG_X86_CET */
|
||||||
SLJIT_UNUSED_ARG(compiler);
|
SLJIT_UNUSED_ARG(compiler);
|
||||||
#endif
|
#endif /* SLJIT_CONFIG_X86_CET */
|
||||||
return SLJIT_SUCCESS;
|
return SLJIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) && defined (__SHSTK__)
|
||||||
|
|
||||||
static SLJIT_INLINE sljit_s32 emit_rdssp(struct sljit_compiler *compiler, sljit_s32 reg)
|
static SLJIT_INLINE sljit_s32 emit_rdssp(struct sljit_compiler *compiler, sljit_s32 reg)
|
||||||
{
|
{
|
||||||
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET)
|
|
||||||
sljit_u8 *inst;
|
sljit_u8 *inst;
|
||||||
sljit_s32 size;
|
sljit_s32 size;
|
||||||
|
|
||||||
@ -753,16 +758,11 @@ static SLJIT_INLINE sljit_s32 emit_rdssp(struct sljit_compiler *compiler, sljit_
|
|||||||
*inst++ = 0x0f;
|
*inst++ = 0x0f;
|
||||||
*inst++ = 0x1e;
|
*inst++ = 0x1e;
|
||||||
*inst = (0x3 << 6) | (0x1 << 3) | (reg_map[reg] & 0x7);
|
*inst = (0x3 << 6) | (0x1 << 3) | (reg_map[reg] & 0x7);
|
||||||
#else
|
|
||||||
SLJIT_UNUSED_ARG(compiler);
|
|
||||||
SLJIT_UNUSED_ARG(reg);
|
|
||||||
#endif
|
|
||||||
return SLJIT_SUCCESS;
|
return SLJIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SLJIT_INLINE sljit_s32 emit_incssp(struct sljit_compiler *compiler, sljit_s32 reg)
|
static SLJIT_INLINE sljit_s32 emit_incssp(struct sljit_compiler *compiler, sljit_s32 reg)
|
||||||
{
|
{
|
||||||
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET)
|
|
||||||
sljit_u8 *inst;
|
sljit_u8 *inst;
|
||||||
sljit_s32 size;
|
sljit_s32 size;
|
||||||
|
|
||||||
@ -782,29 +782,28 @@ static SLJIT_INLINE sljit_s32 emit_incssp(struct sljit_compiler *compiler, sljit
|
|||||||
*inst++ = 0x0f;
|
*inst++ = 0x0f;
|
||||||
*inst++ = 0xae;
|
*inst++ = 0xae;
|
||||||
*inst = (0x3 << 6) | (0x5 << 3) | (reg_map[reg] & 0x7);
|
*inst = (0x3 << 6) | (0x5 << 3) | (reg_map[reg] & 0x7);
|
||||||
#else
|
|
||||||
SLJIT_UNUSED_ARG(compiler);
|
|
||||||
SLJIT_UNUSED_ARG(reg);
|
|
||||||
#endif
|
|
||||||
return SLJIT_SUCCESS;
|
return SLJIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* SLJIT_CONFIG_X86_CET && __SHSTK__ */
|
||||||
|
|
||||||
static SLJIT_INLINE sljit_s32 cpu_has_shadow_stack(void)
|
static SLJIT_INLINE sljit_s32 cpu_has_shadow_stack(void)
|
||||||
{
|
{
|
||||||
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET)
|
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) && defined (__SHSTK__)
|
||||||
return _get_ssp() != 0;
|
return _get_ssp() != 0;
|
||||||
#else
|
#else /* !SLJIT_CONFIG_X86_CET || !__SHSTK__ */
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* SLJIT_CONFIG_X86_CET && __SHSTK__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
static SLJIT_INLINE sljit_s32 adjust_shadow_stack(struct sljit_compiler *compiler,
|
static SLJIT_INLINE sljit_s32 adjust_shadow_stack(struct sljit_compiler *compiler,
|
||||||
sljit_s32 src, sljit_sw srcw, sljit_s32 base, sljit_sw disp)
|
sljit_s32 src, sljit_sw srcw, sljit_s32 base, sljit_sw disp)
|
||||||
{
|
{
|
||||||
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET)
|
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) && defined (__SHSTK__)
|
||||||
sljit_u8 *inst;
|
sljit_u8 *inst, *jz_after_cmp_inst;
|
||||||
|
sljit_uw size_jz_after_cmp_inst;
|
||||||
|
|
||||||
sljit_s32 size_before_rdssp_inst = compiler->size;
|
sljit_uw size_before_rdssp_inst = compiler->size;
|
||||||
|
|
||||||
/* Generate "RDSSP TMP_REG1". */
|
/* Generate "RDSSP TMP_REG1". */
|
||||||
FAIL_IF(emit_rdssp(compiler, TMP_REG1));
|
FAIL_IF(emit_rdssp(compiler, TMP_REG1));
|
||||||
@ -839,8 +838,8 @@ static SLJIT_INLINE sljit_s32 adjust_shadow_stack(struct sljit_compiler *compile
|
|||||||
FAIL_IF(!inst);
|
FAIL_IF(!inst);
|
||||||
INC_SIZE(2);
|
INC_SIZE(2);
|
||||||
*inst++ = get_jump_code(SLJIT_EQUAL) - 0x10;
|
*inst++ = get_jump_code(SLJIT_EQUAL) - 0x10;
|
||||||
sljit_uw size_jz_after_cmp_inst = compiler->size;
|
size_jz_after_cmp_inst = compiler->size;
|
||||||
sljit_u8 *jz_after_cmp_inst = inst;
|
jz_after_cmp_inst = inst;
|
||||||
|
|
||||||
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
||||||
/* REX_W is not necessary. */
|
/* REX_W is not necessary. */
|
||||||
@ -860,13 +859,13 @@ static SLJIT_INLINE sljit_s32 adjust_shadow_stack(struct sljit_compiler *compile
|
|||||||
*inst = size_before_rdssp_inst - compiler->size;
|
*inst = size_before_rdssp_inst - compiler->size;
|
||||||
|
|
||||||
*jz_after_cmp_inst = compiler->size - size_jz_after_cmp_inst;
|
*jz_after_cmp_inst = compiler->size - size_jz_after_cmp_inst;
|
||||||
#else /* SLJIT_CONFIG_X86_CET */
|
#else /* !SLJIT_CONFIG_X86_CET || !__SHSTK__ */
|
||||||
SLJIT_UNUSED_ARG(compiler);
|
SLJIT_UNUSED_ARG(compiler);
|
||||||
SLJIT_UNUSED_ARG(src);
|
SLJIT_UNUSED_ARG(src);
|
||||||
SLJIT_UNUSED_ARG(srcw);
|
SLJIT_UNUSED_ARG(srcw);
|
||||||
SLJIT_UNUSED_ARG(base);
|
SLJIT_UNUSED_ARG(base);
|
||||||
SLJIT_UNUSED_ARG(disp);
|
SLJIT_UNUSED_ARG(disp);
|
||||||
#endif /* SLJIT_CONFIG_X86_CET */
|
#endif /* SLJIT_CONFIG_X86_CET && __SHSTK__ */
|
||||||
return SLJIT_SUCCESS;
|
return SLJIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3123,15 +3122,21 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct slj
|
|||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
SLJIT_UNUSED_ARG(executable_offset);
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS((void*)addr, (void*)(addr + sizeof(sljit_uw)), 0);
|
||||||
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
|
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
|
||||||
sljit_unaligned_store_sw((void*)addr, new_target - (addr + 4) - (sljit_uw)executable_offset);
|
sljit_unaligned_store_sw((void*)addr, new_target - (addr + 4) - (sljit_uw)executable_offset);
|
||||||
#else
|
#else
|
||||||
sljit_unaligned_store_sw((void*)addr, (sljit_sw) new_target);
|
sljit_unaligned_store_sw((void*)addr, (sljit_sw) new_target);
|
||||||
#endif
|
#endif
|
||||||
|
SLJIT_UPDATE_WX_FLAGS((void*)addr, (void*)(addr + sizeof(sljit_uw)), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant, sljit_sw executable_offset)
|
||||||
{
|
{
|
||||||
SLJIT_UNUSED_ARG(executable_offset);
|
SLJIT_UNUSED_ARG(executable_offset);
|
||||||
|
|
||||||
|
SLJIT_UPDATE_WX_FLAGS((void*)addr, (void*)(addr + sizeof(sljit_sw)), 0);
|
||||||
sljit_unaligned_store_sw((void*)addr, new_constant);
|
sljit_unaligned_store_sw((void*)addr, new_constant);
|
||||||
|
SLJIT_UPDATE_WX_FLAGS((void*)addr, (void*)(addr + sizeof(sljit_sw)), 1);
|
||||||
}
|
}
|
||||||
|
474
src/3rdparty/pcre2/src/sljit/sljitProtExecAllocator.c
vendored
Normal file
474
src/3rdparty/pcre2/src/sljit/sljitProtExecAllocator.c
vendored
Normal file
@ -0,0 +1,474 @@
|
|||||||
|
/*
|
||||||
|
* Stack-less Just-In-Time compiler
|
||||||
|
*
|
||||||
|
* Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file contains a simple executable memory allocator
|
||||||
|
|
||||||
|
It is assumed, that executable code blocks are usually medium (or sometimes
|
||||||
|
large) memory blocks, and the allocator is not too frequently called (less
|
||||||
|
optimized than other allocators). Thus, using it as a generic allocator is
|
||||||
|
not suggested.
|
||||||
|
|
||||||
|
How does it work:
|
||||||
|
Memory is allocated in continuous memory areas called chunks by alloc_chunk()
|
||||||
|
Chunk format:
|
||||||
|
[ block ][ block ] ... [ block ][ block terminator ]
|
||||||
|
|
||||||
|
All blocks and the block terminator is started with block_header. The block
|
||||||
|
header contains the size of the previous and the next block. These sizes
|
||||||
|
can also contain special values.
|
||||||
|
Block size:
|
||||||
|
0 - The block is a free_block, with a different size member.
|
||||||
|
1 - The block is a block terminator.
|
||||||
|
n - The block is used at the moment, and the value contains its size.
|
||||||
|
Previous block size:
|
||||||
|
0 - This is the first block of the memory chunk.
|
||||||
|
n - The size of the previous block.
|
||||||
|
|
||||||
|
Using these size values we can go forward or backward on the block chain.
|
||||||
|
The unused blocks are stored in a chain list pointed by free_blocks. This
|
||||||
|
list is useful if we need to find a suitable memory area when the allocator
|
||||||
|
is called.
|
||||||
|
|
||||||
|
When a block is freed, the new free block is connected to its adjacent free
|
||||||
|
blocks if possible.
|
||||||
|
|
||||||
|
[ free block ][ used block ][ free block ]
|
||||||
|
and "used block" is freed, the three blocks are connected together:
|
||||||
|
[ one big free block ]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* System (OS) functions */
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* 64 KByte. */
|
||||||
|
#define CHUNK_SIZE 0x10000
|
||||||
|
|
||||||
|
struct chunk_header {
|
||||||
|
void *executable;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
alloc_chunk / free_chunk :
|
||||||
|
* allocate executable system memory chunks
|
||||||
|
* the size is always divisible by CHUNK_SIZE
|
||||||
|
SLJIT_ALLOCATOR_LOCK / SLJIT_ALLOCATOR_UNLOCK :
|
||||||
|
* provided as part of sljitUtils
|
||||||
|
* only the allocator requires this lock, sljit is fully thread safe
|
||||||
|
as it only uses local variables
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __NetBSD__
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef O_NOATIME
|
||||||
|
#define O_NOATIME 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* this is a linux extension available since kernel 3.11 */
|
||||||
|
#ifndef O_TMPFILE
|
||||||
|
#define O_TMPFILE 020200000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
char *secure_getenv(const char *name);
|
||||||
|
int mkostemp(char *template, int flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static SLJIT_INLINE int create_tempfile(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
char tmp_name[256];
|
||||||
|
size_t tmp_name_len = 0;
|
||||||
|
char *dir;
|
||||||
|
struct stat st;
|
||||||
|
#if defined(SLJIT_SINGLE_THREADED) && SLJIT_SINGLE_THREADED
|
||||||
|
mode_t mode;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_MEMFD_CREATE
|
||||||
|
/* this is a GNU extension, make sure to use -D_GNU_SOURCE */
|
||||||
|
fd = memfd_create("sljit", MFD_CLOEXEC);
|
||||||
|
if (fd != -1) {
|
||||||
|
fchmod(fd, 0);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dir = secure_getenv("TMPDIR");
|
||||||
|
|
||||||
|
if (dir) {
|
||||||
|
tmp_name_len = strlen(dir);
|
||||||
|
if (tmp_name_len > 0 && tmp_name_len < sizeof(tmp_name)) {
|
||||||
|
if ((stat(dir, &st) == 0) && S_ISDIR(st.st_mode))
|
||||||
|
strcpy(tmp_name, dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef P_tmpdir
|
||||||
|
if (!tmp_name_len) {
|
||||||
|
tmp_name_len = strlen(P_tmpdir);
|
||||||
|
if (tmp_name_len > 0 && tmp_name_len < sizeof(tmp_name))
|
||||||
|
strcpy(tmp_name, P_tmpdir);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (!tmp_name_len) {
|
||||||
|
strcpy(tmp_name, "/tmp");
|
||||||
|
tmp_name_len = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
SLJIT_ASSERT(tmp_name_len > 0 && tmp_name_len < sizeof(tmp_name));
|
||||||
|
|
||||||
|
if (tmp_name[tmp_name_len - 1] == '/')
|
||||||
|
tmp_name[--tmp_name_len] = '\0';
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
/*
|
||||||
|
* the previous trimming might had left an empty string if TMPDIR="/"
|
||||||
|
* so work around the problem below
|
||||||
|
*/
|
||||||
|
fd = open(tmp_name_len ? tmp_name : "/",
|
||||||
|
O_TMPFILE | O_EXCL | O_RDWR | O_NOATIME | O_CLOEXEC, 0);
|
||||||
|
if (fd != -1)
|
||||||
|
return fd;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (tmp_name_len + 7 >= sizeof(tmp_name))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
strcpy(tmp_name + tmp_name_len, "/XXXXXX");
|
||||||
|
#if defined(SLJIT_SINGLE_THREADED) && SLJIT_SINGLE_THREADED
|
||||||
|
mode = umask(0777);
|
||||||
|
#endif
|
||||||
|
fd = mkostemp(tmp_name, O_CLOEXEC | O_NOATIME);
|
||||||
|
#if defined(SLJIT_SINGLE_THREADED) && SLJIT_SINGLE_THREADED
|
||||||
|
umask(mode);
|
||||||
|
#else
|
||||||
|
fchmod(fd, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fd == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (unlink(tmp_name)) {
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SLJIT_INLINE struct chunk_header* alloc_chunk(sljit_uw size)
|
||||||
|
{
|
||||||
|
struct chunk_header *retval;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = create_tempfile();
|
||||||
|
if (fd == -1)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (ftruncate(fd, size)) {
|
||||||
|
close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
retval = (struct chunk_header *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
|
||||||
|
if (retval == MAP_FAILED) {
|
||||||
|
close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
retval->executable = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0);
|
||||||
|
|
||||||
|
if (retval->executable == MAP_FAILED) {
|
||||||
|
munmap((void *)retval, size);
|
||||||
|
close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* MAP_REMAPDUP is a NetBSD extension available sinde 8.0, make sure to
|
||||||
|
* adjust your feature macros (ex: -D_NETBSD_SOURCE) as needed
|
||||||
|
*/
|
||||||
|
static SLJIT_INLINE struct chunk_header* alloc_chunk(sljit_uw size)
|
||||||
|
{
|
||||||
|
struct chunk_header *retval;
|
||||||
|
|
||||||
|
retval = (struct chunk_header *)mmap(NULL, size,
|
||||||
|
PROT_READ | PROT_WRITE | PROT_MPROTECT(PROT_EXEC),
|
||||||
|
MAP_ANON | MAP_SHARED, -1, 0);
|
||||||
|
|
||||||
|
if (retval == MAP_FAILED)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
retval->executable = mremap(retval, size, NULL, size, MAP_REMAPDUP);
|
||||||
|
if (retval->executable == MAP_FAILED) {
|
||||||
|
munmap((void *)retval, size);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mprotect(retval->executable, size, PROT_READ | PROT_EXEC) == -1) {
|
||||||
|
munmap(retval->executable, size);
|
||||||
|
munmap((void *)retval, size);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
#endif /* NetBSD */
|
||||||
|
|
||||||
|
static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size)
|
||||||
|
{
|
||||||
|
struct chunk_header *header = ((struct chunk_header *)chunk) - 1;
|
||||||
|
|
||||||
|
munmap(header->executable, size);
|
||||||
|
munmap((void *)header, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* Common functions */
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#define CHUNK_MASK (~(CHUNK_SIZE - 1))
|
||||||
|
|
||||||
|
struct block_header {
|
||||||
|
sljit_uw size;
|
||||||
|
sljit_uw prev_size;
|
||||||
|
sljit_sw executable_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct free_block {
|
||||||
|
struct block_header header;
|
||||||
|
struct free_block *next;
|
||||||
|
struct free_block *prev;
|
||||||
|
sljit_uw size;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define AS_BLOCK_HEADER(base, offset) \
|
||||||
|
((struct block_header*)(((sljit_u8*)base) + offset))
|
||||||
|
#define AS_FREE_BLOCK(base, offset) \
|
||||||
|
((struct free_block*)(((sljit_u8*)base) + offset))
|
||||||
|
#define MEM_START(base) ((void*)((base) + 1))
|
||||||
|
#define ALIGN_SIZE(size) (((size) + sizeof(struct block_header) + 7) & ~7)
|
||||||
|
|
||||||
|
static struct free_block* free_blocks;
|
||||||
|
static sljit_uw allocated_size;
|
||||||
|
static sljit_uw total_size;
|
||||||
|
|
||||||
|
static SLJIT_INLINE void sljit_insert_free_block(struct free_block *free_block, sljit_uw size)
|
||||||
|
{
|
||||||
|
free_block->header.size = 0;
|
||||||
|
free_block->size = size;
|
||||||
|
|
||||||
|
free_block->next = free_blocks;
|
||||||
|
free_block->prev = NULL;
|
||||||
|
if (free_blocks)
|
||||||
|
free_blocks->prev = free_block;
|
||||||
|
free_blocks = free_block;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SLJIT_INLINE void sljit_remove_free_block(struct free_block *free_block)
|
||||||
|
{
|
||||||
|
if (free_block->next)
|
||||||
|
free_block->next->prev = free_block->prev;
|
||||||
|
|
||||||
|
if (free_block->prev)
|
||||||
|
free_block->prev->next = free_block->next;
|
||||||
|
else {
|
||||||
|
SLJIT_ASSERT(free_blocks == free_block);
|
||||||
|
free_blocks = free_block->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
|
||||||
|
{
|
||||||
|
struct chunk_header *chunk_header;
|
||||||
|
struct block_header *header;
|
||||||
|
struct block_header *next_header;
|
||||||
|
struct free_block *free_block;
|
||||||
|
sljit_uw chunk_size;
|
||||||
|
sljit_sw executable_offset;
|
||||||
|
|
||||||
|
SLJIT_ALLOCATOR_LOCK();
|
||||||
|
if (size < (64 - sizeof(struct block_header)))
|
||||||
|
size = (64 - sizeof(struct block_header));
|
||||||
|
size = ALIGN_SIZE(size);
|
||||||
|
|
||||||
|
free_block = free_blocks;
|
||||||
|
while (free_block) {
|
||||||
|
if (free_block->size >= size) {
|
||||||
|
chunk_size = free_block->size;
|
||||||
|
if (chunk_size > size + 64) {
|
||||||
|
/* We just cut a block from the end of the free block. */
|
||||||
|
chunk_size -= size;
|
||||||
|
free_block->size = chunk_size;
|
||||||
|
header = AS_BLOCK_HEADER(free_block, chunk_size);
|
||||||
|
header->prev_size = chunk_size;
|
||||||
|
header->executable_offset = free_block->header.executable_offset;
|
||||||
|
AS_BLOCK_HEADER(header, size)->prev_size = size;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sljit_remove_free_block(free_block);
|
||||||
|
header = (struct block_header*)free_block;
|
||||||
|
size = chunk_size;
|
||||||
|
}
|
||||||
|
allocated_size += size;
|
||||||
|
header->size = size;
|
||||||
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
|
return MEM_START(header);
|
||||||
|
}
|
||||||
|
free_block = free_block->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
chunk_size = sizeof(struct chunk_header) + sizeof(struct block_header);
|
||||||
|
chunk_size = (chunk_size + size + CHUNK_SIZE - 1) & CHUNK_MASK;
|
||||||
|
|
||||||
|
chunk_header = alloc_chunk(chunk_size);
|
||||||
|
if (!chunk_header) {
|
||||||
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
executable_offset = (sljit_sw)((sljit_u8*)chunk_header->executable - (sljit_u8*)chunk_header);
|
||||||
|
|
||||||
|
chunk_size -= sizeof(struct chunk_header) + sizeof(struct block_header);
|
||||||
|
total_size += chunk_size;
|
||||||
|
|
||||||
|
header = (struct block_header *)(chunk_header + 1);
|
||||||
|
|
||||||
|
header->prev_size = 0;
|
||||||
|
header->executable_offset = executable_offset;
|
||||||
|
if (chunk_size > size + 64) {
|
||||||
|
/* Cut the allocated space into a free and a used block. */
|
||||||
|
allocated_size += size;
|
||||||
|
header->size = size;
|
||||||
|
chunk_size -= size;
|
||||||
|
|
||||||
|
free_block = AS_FREE_BLOCK(header, size);
|
||||||
|
free_block->header.prev_size = size;
|
||||||
|
free_block->header.executable_offset = executable_offset;
|
||||||
|
sljit_insert_free_block(free_block, chunk_size);
|
||||||
|
next_header = AS_BLOCK_HEADER(free_block, chunk_size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* All space belongs to this allocation. */
|
||||||
|
allocated_size += chunk_size;
|
||||||
|
header->size = chunk_size;
|
||||||
|
next_header = AS_BLOCK_HEADER(header, chunk_size);
|
||||||
|
}
|
||||||
|
next_header->size = 1;
|
||||||
|
next_header->prev_size = chunk_size;
|
||||||
|
next_header->executable_offset = executable_offset;
|
||||||
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
|
return MEM_START(header);
|
||||||
|
}
|
||||||
|
|
||||||
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
|
||||||
|
{
|
||||||
|
struct block_header *header;
|
||||||
|
struct free_block* free_block;
|
||||||
|
|
||||||
|
SLJIT_ALLOCATOR_LOCK();
|
||||||
|
header = AS_BLOCK_HEADER(ptr, -(sljit_sw)sizeof(struct block_header));
|
||||||
|
header = AS_BLOCK_HEADER(header, -header->executable_offset);
|
||||||
|
allocated_size -= header->size;
|
||||||
|
|
||||||
|
/* Connecting free blocks together if possible. */
|
||||||
|
|
||||||
|
/* If header->prev_size == 0, free_block will equal to header.
|
||||||
|
In this case, free_block->header.size will be > 0. */
|
||||||
|
free_block = AS_FREE_BLOCK(header, -(sljit_sw)header->prev_size);
|
||||||
|
if (SLJIT_UNLIKELY(!free_block->header.size)) {
|
||||||
|
free_block->size += header->size;
|
||||||
|
header = AS_BLOCK_HEADER(free_block, free_block->size);
|
||||||
|
header->prev_size = free_block->size;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
free_block = (struct free_block*)header;
|
||||||
|
sljit_insert_free_block(free_block, header->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
header = AS_BLOCK_HEADER(free_block, free_block->size);
|
||||||
|
if (SLJIT_UNLIKELY(!header->size)) {
|
||||||
|
free_block->size += ((struct free_block*)header)->size;
|
||||||
|
sljit_remove_free_block((struct free_block*)header);
|
||||||
|
header = AS_BLOCK_HEADER(free_block, free_block->size);
|
||||||
|
header->prev_size = free_block->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The whole chunk is free. */
|
||||||
|
if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) {
|
||||||
|
/* If this block is freed, we still have (allocated_size / 2) free space. */
|
||||||
|
if (total_size - free_block->size > (allocated_size * 3 / 2)) {
|
||||||
|
total_size -= free_block->size;
|
||||||
|
sljit_remove_free_block(free_block);
|
||||||
|
free_chunk(free_block, free_block->size +
|
||||||
|
sizeof(struct chunk_header) +
|
||||||
|
sizeof(struct block_header));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
|
}
|
||||||
|
|
||||||
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void)
|
||||||
|
{
|
||||||
|
struct free_block* free_block;
|
||||||
|
struct free_block* next_free_block;
|
||||||
|
|
||||||
|
SLJIT_ALLOCATOR_LOCK();
|
||||||
|
|
||||||
|
free_block = free_blocks;
|
||||||
|
while (free_block) {
|
||||||
|
next_free_block = free_block->next;
|
||||||
|
if (!free_block->header.prev_size &&
|
||||||
|
AS_BLOCK_HEADER(free_block, free_block->size)->size == 1) {
|
||||||
|
total_size -= free_block->size;
|
||||||
|
sljit_remove_free_block(free_block);
|
||||||
|
free_chunk(free_block, free_block->size +
|
||||||
|
sizeof(struct chunk_header) +
|
||||||
|
sizeof(struct block_header));
|
||||||
|
}
|
||||||
|
free_block = next_free_block;
|
||||||
|
}
|
||||||
|
|
||||||
|
SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks));
|
||||||
|
SLJIT_ALLOCATOR_UNLOCK();
|
||||||
|
}
|
||||||
|
|
||||||
|
SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void* ptr)
|
||||||
|
{
|
||||||
|
return ((struct block_header *)(ptr))[-1].executable_offset;
|
||||||
|
}
|
257
src/3rdparty/pcre2/src/sljit/sljitUtils.c
vendored
257
src/3rdparty/pcre2/src/sljit/sljitUtils.c
vendored
@ -28,131 +28,50 @@
|
|||||||
/* Locks */
|
/* Locks */
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR) || (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
|
/* Executable Allocator */
|
||||||
|
|
||||||
|
#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR) \
|
||||||
|
&& !(defined SLJIT_WX_EXECUTABLE_ALLOCATOR && SLJIT_WX_EXECUTABLE_ALLOCATOR)
|
||||||
#if (defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
|
#if (defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
|
||||||
|
#define SLJIT_ALLOCATOR_LOCK()
|
||||||
#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
|
#define SLJIT_ALLOCATOR_UNLOCK()
|
||||||
|
#elif !(defined _WIN32)
|
||||||
static SLJIT_INLINE void allocator_grab_lock(void)
|
|
||||||
{
|
|
||||||
/* Always successful. */
|
|
||||||
}
|
|
||||||
|
|
||||||
static SLJIT_INLINE void allocator_release_lock(void)
|
|
||||||
{
|
|
||||||
/* Always successful. */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SLJIT_EXECUTABLE_ALLOCATOR */
|
|
||||||
|
|
||||||
#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
|
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_grab_lock(void)
|
|
||||||
{
|
|
||||||
/* Always successful. */
|
|
||||||
}
|
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_release_lock(void)
|
|
||||||
{
|
|
||||||
/* Always successful. */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SLJIT_UTIL_GLOBAL_LOCK */
|
|
||||||
|
|
||||||
#elif defined(_WIN32) /* SLJIT_SINGLE_THREADED */
|
|
||||||
|
|
||||||
#include "windows.h"
|
|
||||||
|
|
||||||
#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
|
|
||||||
|
|
||||||
static HANDLE allocator_mutex = 0;
|
|
||||||
|
|
||||||
static SLJIT_INLINE void allocator_grab_lock(void)
|
|
||||||
{
|
|
||||||
/* No idea what to do if an error occures. Static mutexes should never fail... */
|
|
||||||
if (!allocator_mutex)
|
|
||||||
allocator_mutex = CreateMutex(NULL, TRUE, NULL);
|
|
||||||
else
|
|
||||||
WaitForSingleObject(allocator_mutex, INFINITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SLJIT_INLINE void allocator_release_lock(void)
|
|
||||||
{
|
|
||||||
ReleaseMutex(allocator_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SLJIT_EXECUTABLE_ALLOCATOR */
|
|
||||||
|
|
||||||
#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
|
|
||||||
|
|
||||||
static HANDLE global_mutex = 0;
|
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_grab_lock(void)
|
|
||||||
{
|
|
||||||
/* No idea what to do if an error occures. Static mutexes should never fail... */
|
|
||||||
if (!global_mutex)
|
|
||||||
global_mutex = CreateMutex(NULL, TRUE, NULL);
|
|
||||||
else
|
|
||||||
WaitForSingleObject(global_mutex, INFINITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_release_lock(void)
|
|
||||||
{
|
|
||||||
ReleaseMutex(global_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SLJIT_UTIL_GLOBAL_LOCK */
|
|
||||||
|
|
||||||
#else /* _WIN32 */
|
|
||||||
|
|
||||||
#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
|
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
static pthread_mutex_t allocator_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t allocator_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
#define SLJIT_ALLOCATOR_LOCK() pthread_mutex_lock(&allocator_lock)
|
||||||
|
#define SLJIT_ALLOCATOR_UNLOCK() pthread_mutex_unlock(&allocator_lock)
|
||||||
|
#else /* windows */
|
||||||
|
static HANDLE allocator_lock;
|
||||||
|
|
||||||
static SLJIT_INLINE void allocator_grab_lock(void)
|
static SLJIT_INLINE void allocator_grab_lock(void)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&allocator_mutex);
|
HANDLE lock;
|
||||||
|
if (SLJIT_UNLIKELY(!allocator_lock)) {
|
||||||
|
lock = CreateMutex(NULL, FALSE, NULL);
|
||||||
|
if (InterlockedCompareExchangePointer(&allocator_lock, lock, NULL))
|
||||||
|
CloseHandle(lock);
|
||||||
|
}
|
||||||
|
WaitForSingleObject(allocator_lock, INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SLJIT_INLINE void allocator_release_lock(void)
|
#define SLJIT_ALLOCATOR_LOCK() allocator_grab_lock()
|
||||||
{
|
#define SLJIT_ALLOCATOR_UNLOCK() ReleaseMutex(allocator_lock)
|
||||||
pthread_mutex_unlock(&allocator_mutex);
|
#endif /* thread implementation */
|
||||||
}
|
#endif /* SLJIT_EXECUTABLE_ALLOCATOR && !SLJIT_WX_EXECUTABLE_ALLOCATOR */
|
||||||
|
|
||||||
#endif /* SLJIT_EXECUTABLE_ALLOCATOR */
|
|
||||||
|
|
||||||
#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
static pthread_mutex_t global_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_grab_lock(void)
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&global_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_release_lock(void)
|
|
||||||
{
|
|
||||||
pthread_mutex_unlock(&global_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SLJIT_UTIL_GLOBAL_LOCK */
|
|
||||||
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
/* Stack */
|
/* Stack */
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) || (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
|
#if ((defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) \
|
||||||
|
&& !(defined SLJIT_UTIL_SIMPLE_STACK_ALLOCATION && SLJIT_UTIL_SIMPLE_STACK_ALLOCATION)) \
|
||||||
|
|| ((defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR) \
|
||||||
|
&& !((defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR) \
|
||||||
|
|| (defined SLJIT_WX_EXECUTABLE_ALLOCATOR && SLJIT_WX_EXECUTABLE_ALLOCATOR)))
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
#include "windows.h"
|
|
||||||
#else /* !_WIN32 */
|
|
||||||
/* Provides mmap function. */
|
/* Provides mmap function. */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@ -163,56 +82,84 @@ SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_release_lock(void)
|
|||||||
#endif /* MAP_ANONYMOUS */
|
#endif /* MAP_ANONYMOUS */
|
||||||
#endif /* !MAP_ANON */
|
#endif /* !MAP_ANON */
|
||||||
|
|
||||||
#ifndef MADV_DONTNEED
|
|
||||||
#ifdef POSIX_MADV_DONTNEED
|
|
||||||
#define MADV_DONTNEED POSIX_MADV_DONTNEED
|
|
||||||
#endif /* POSIX_MADV_DONTNEED */
|
|
||||||
#endif /* !MADV_DONTNEED */
|
|
||||||
|
|
||||||
/* For detecting the page size. */
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#ifndef MAP_ANON
|
#ifndef MAP_ANON
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
/* Some old systems does not have MAP_ANON. */
|
#ifdef O_CLOEXEC
|
||||||
static sljit_s32 dev_zero = -1;
|
#define SLJIT_CLOEXEC O_CLOEXEC
|
||||||
|
#else /* !O_CLOEXEC */
|
||||||
|
#define SLJIT_CLOEXEC 0
|
||||||
|
#endif /* O_CLOEXEC */
|
||||||
|
|
||||||
|
/* Some old systems do not have MAP_ANON. */
|
||||||
|
static int dev_zero = -1;
|
||||||
|
|
||||||
#if (defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
|
#if (defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
|
||||||
|
|
||||||
static SLJIT_INLINE sljit_s32 open_dev_zero(void)
|
static SLJIT_INLINE int open_dev_zero(void)
|
||||||
{
|
{
|
||||||
dev_zero = open("/dev/zero", O_RDWR);
|
dev_zero = open("/dev/zero", O_RDWR | SLJIT_CLOEXEC);
|
||||||
|
|
||||||
return dev_zero < 0;
|
return dev_zero < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* SLJIT_SINGLE_THREADED */
|
#else /* !SLJIT_SINGLE_THREADED */
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
static pthread_mutex_t dev_zero_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t dev_zero_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
static SLJIT_INLINE sljit_s32 open_dev_zero(void)
|
static SLJIT_INLINE int open_dev_zero(void)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&dev_zero_mutex);
|
pthread_mutex_lock(&dev_zero_mutex);
|
||||||
/* The dev_zero might be initialized by another thread during the waiting. */
|
if (SLJIT_UNLIKELY(dev_zero < 0))
|
||||||
if (dev_zero < 0) {
|
dev_zero = open("/dev/zero", O_RDWR | SLJIT_CLOEXEC);
|
||||||
dev_zero = open("/dev/zero", O_RDWR);
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&dev_zero_mutex);
|
pthread_mutex_unlock(&dev_zero_mutex);
|
||||||
return dev_zero < 0;
|
return dev_zero < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SLJIT_SINGLE_THREADED */
|
#endif /* SLJIT_SINGLE_THREADED */
|
||||||
|
#undef SLJIT_CLOEXEC
|
||||||
#endif /* !MAP_ANON */
|
#endif /* !MAP_ANON */
|
||||||
|
#endif /* !_WIN32 */
|
||||||
|
#endif /* open_dev_zero */
|
||||||
|
|
||||||
|
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) \
|
||||||
|
|| (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
static SLJIT_INLINE sljit_sw get_page_alignment(void) {
|
||||||
|
SYSTEM_INFO si;
|
||||||
|
static sljit_sw sljit_page_align;
|
||||||
|
if (!sljit_page_align) {
|
||||||
|
GetSystemInfo(&si);
|
||||||
|
sljit_page_align = si.dwPageSize - 1;
|
||||||
|
}
|
||||||
|
return sljit_page_align;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
static SLJIT_INLINE sljit_sw get_page_alignment(void) {
|
||||||
|
static sljit_sw sljit_page_align;
|
||||||
|
if (!sljit_page_align) {
|
||||||
|
sljit_page_align = sysconf(_SC_PAGESIZE);
|
||||||
|
/* Should never happen. */
|
||||||
|
if (sljit_page_align < 0)
|
||||||
|
sljit_page_align = 4096;
|
||||||
|
sljit_page_align--;
|
||||||
|
}
|
||||||
|
return sljit_page_align;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#endif /* SLJIT_UTIL_STACK || SLJIT_EXECUTABLE_ALLOCATOR */
|
#endif /* get_page_alignment() */
|
||||||
|
|
||||||
#endif /* SLJIT_EXECUTABLE_ALLOCATOR || SLJIT_UTIL_GLOBAL_LOCK */
|
|
||||||
|
|
||||||
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
|
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
|
||||||
|
|
||||||
@ -264,16 +211,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_u8 *SLJIT_FUNC sljit_stack_resize(struct sljit_st
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
SLJIT_INLINE static sljit_sw get_page_alignment(void) {
|
|
||||||
SYSTEM_INFO si;
|
|
||||||
static sljit_sw sljit_page_align;
|
|
||||||
if (!sljit_page_align) {
|
|
||||||
GetSystemInfo(&si);
|
|
||||||
sljit_page_align = si.dwPageSize - 1;
|
|
||||||
}
|
|
||||||
return sljit_page_align;
|
|
||||||
}
|
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_free_stack(struct sljit_stack *stack, void *allocator_data)
|
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_free_stack(struct sljit_stack *stack, void *allocator_data)
|
||||||
{
|
{
|
||||||
SLJIT_UNUSED_ARG(allocator_data);
|
SLJIT_UNUSED_ARG(allocator_data);
|
||||||
@ -281,19 +218,7 @@ SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_free_stack(struct sljit_stack *st
|
|||||||
SLJIT_FREE(stack, allocator_data);
|
SLJIT_FREE(stack, allocator_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* ! defined _WIN32 */
|
#else /* !_WIN32 */
|
||||||
|
|
||||||
SLJIT_INLINE static sljit_sw get_page_alignment(void) {
|
|
||||||
static sljit_sw sljit_page_align;
|
|
||||||
if (!sljit_page_align) {
|
|
||||||
sljit_page_align = sysconf(_SC_PAGESIZE);
|
|
||||||
/* Should never happen. */
|
|
||||||
if (sljit_page_align < 0)
|
|
||||||
sljit_page_align = 4096;
|
|
||||||
sljit_page_align--;
|
|
||||||
}
|
|
||||||
return sljit_page_align;
|
|
||||||
}
|
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_free_stack(struct sljit_stack *stack, void *allocator_data)
|
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_free_stack(struct sljit_stack *stack, void *allocator_data)
|
||||||
{
|
{
|
||||||
@ -302,7 +227,7 @@ SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_free_stack(struct sljit_stack *st
|
|||||||
SLJIT_FREE(stack, allocator_data);
|
SLJIT_FREE(stack, allocator_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* defined _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_FUNC sljit_allocate_stack(sljit_uw start_size, sljit_uw max_size, void *allocator_data)
|
SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_FUNC sljit_allocate_stack(sljit_uw start_size, sljit_uw max_size, void *allocator_data)
|
||||||
{
|
{
|
||||||
@ -342,12 +267,10 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_FUNC sljit_allocate_stack(slj
|
|||||||
#ifdef MAP_ANON
|
#ifdef MAP_ANON
|
||||||
ptr = mmap(NULL, max_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
ptr = mmap(NULL, max_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||||
#else /* !MAP_ANON */
|
#else /* !MAP_ANON */
|
||||||
if (dev_zero < 0) {
|
if (SLJIT_UNLIKELY((dev_zero < 0) && open_dev_zero())) {
|
||||||
if (open_dev_zero() != 0) {
|
|
||||||
SLJIT_FREE(stack, allocator_data);
|
SLJIT_FREE(stack, allocator_data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ptr = mmap(NULL, max_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, dev_zero, 0);
|
ptr = mmap(NULL, max_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, dev_zero, 0);
|
||||||
#endif /* MAP_ANON */
|
#endif /* MAP_ANON */
|
||||||
if (ptr == MAP_FAILED) {
|
if (ptr == MAP_FAILED) {
|
||||||
@ -365,7 +288,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_FUNC sljit_allocate_stack(slj
|
|||||||
|
|
||||||
SLJIT_API_FUNC_ATTRIBUTE sljit_u8 *SLJIT_FUNC sljit_stack_resize(struct sljit_stack *stack, sljit_u8 *new_start)
|
SLJIT_API_FUNC_ATTRIBUTE sljit_u8 *SLJIT_FUNC sljit_stack_resize(struct sljit_stack *stack, sljit_u8 *new_start)
|
||||||
{
|
{
|
||||||
#if defined _WIN32 || defined(MADV_DONTNEED)
|
#if defined _WIN32 || defined(POSIX_MADV_DONTNEED)
|
||||||
sljit_uw aligned_old_start;
|
sljit_uw aligned_old_start;
|
||||||
sljit_uw aligned_new_start;
|
sljit_uw aligned_new_start;
|
||||||
sljit_sw page_align;
|
sljit_sw page_align;
|
||||||
@ -389,15 +312,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_u8 *SLJIT_FUNC sljit_stack_resize(struct sljit_st
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(MADV_DONTNEED)
|
#elif defined(POSIX_MADV_DONTNEED)
|
||||||
if (stack->start < new_start) {
|
if (stack->start < new_start) {
|
||||||
page_align = get_page_alignment();
|
page_align = get_page_alignment();
|
||||||
|
|
||||||
aligned_new_start = (sljit_uw)new_start & ~page_align;
|
aligned_new_start = (sljit_uw)new_start & ~page_align;
|
||||||
aligned_old_start = ((sljit_uw)stack->start) & ~page_align;
|
aligned_old_start = ((sljit_uw)stack->start) & ~page_align;
|
||||||
/* If madvise is available, we release the unnecessary space. */
|
|
||||||
if (aligned_new_start > aligned_old_start)
|
if (aligned_new_start > aligned_old_start) {
|
||||||
madvise((void*)aligned_old_start, aligned_new_start - aligned_old_start, MADV_DONTNEED);
|
posix_madvise((void*)aligned_old_start, aligned_new_start - aligned_old_start, POSIX_MADV_DONTNEED);
|
||||||
|
#ifdef MADV_FREE
|
||||||
|
madvise((void*)aligned_old_start, aligned_new_start - aligned_old_start, MADV_FREE);
|
||||||
|
#endif /* MADV_FREE */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
225
src/3rdparty/pcre2/src/sljit/sljitWXExecAllocator.c
vendored
Normal file
225
src/3rdparty/pcre2/src/sljit/sljitWXExecAllocator.c
vendored
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
/*
|
||||||
|
* Stack-less Just-In-Time compiler
|
||||||
|
*
|
||||||
|
* Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file contains a simple W^X executable memory allocator for POSIX
|
||||||
|
like systems and Windows
|
||||||
|
|
||||||
|
In *NIX, MAP_ANON is required (that is considered a feature) so make
|
||||||
|
sure to set the right availability macros for your system or the code
|
||||||
|
will fail to build.
|
||||||
|
|
||||||
|
If your system doesn't support mapping of anonymous pages (ex: IRIX) it
|
||||||
|
is also likely that it doesn't need this allocator and should be using
|
||||||
|
the standard one instead.
|
||||||
|
|
||||||
|
It allocates a separate map for each code block and may waste a lot of
|
||||||
|
memory, because whatever was requested, will be rounded up to the page
|
||||||
|
size (minimum 4KB, but could be even bigger).
|
||||||
|
|
||||||
|
It changes the page permissions (RW <-> RX) as needed and therefore, if you
|
||||||
|
will be updating the code after it has been generated, need to make sure to
|
||||||
|
block any concurrent execution, or could result in a SIGBUS, that could
|
||||||
|
even manifest itself at a different address than the one that was being
|
||||||
|
modified.
|
||||||
|
|
||||||
|
Only use if you are unable to use the regular allocator because of security
|
||||||
|
restrictions and adding exceptions to your application or the system are
|
||||||
|
not possible.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) \
|
||||||
|
sljit_update_wx_flags((from), (to), (enable_exec))
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#ifdef __NetBSD__
|
||||||
|
#if defined(PROT_MPROTECT)
|
||||||
|
#define check_se_protected(ptr, size) (0)
|
||||||
|
#define SLJIT_PROT_WX PROT_MPROTECT(PROT_EXEC)
|
||||||
|
#else /* !PROT_MPROTECT */
|
||||||
|
#ifdef _NETBSD_SOURCE
|
||||||
|
#include <sys/param.h>
|
||||||
|
#else /* !_NETBSD_SOURCE */
|
||||||
|
typedef unsigned int u_int;
|
||||||
|
#define devmajor_t sljit_s32
|
||||||
|
#endif /* _NETBSD_SOURCE */
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define check_se_protected(ptr, size) netbsd_se_protected()
|
||||||
|
|
||||||
|
static SLJIT_INLINE int netbsd_se_protected(void)
|
||||||
|
{
|
||||||
|
int mib[3];
|
||||||
|
int paxflags;
|
||||||
|
size_t len = sizeof(paxflags);
|
||||||
|
|
||||||
|
mib[0] = CTL_PROC;
|
||||||
|
mib[1] = getpid();
|
||||||
|
mib[2] = PROC_PID_PAXFLAGS;
|
||||||
|
|
||||||
|
if (SLJIT_UNLIKELY(sysctl(mib, 3, &paxflags, &len, NULL, 0) < 0))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return (paxflags & CTL_PROC_PAXFLAGS_MPROTECT) ? -1 : 0;
|
||||||
|
}
|
||||||
|
#endif /* PROT_MPROTECT */
|
||||||
|
#else /* POSIX */
|
||||||
|
#define check_se_protected(ptr, size) generic_se_protected(ptr, size)
|
||||||
|
|
||||||
|
static SLJIT_INLINE int generic_se_protected(void *ptr, sljit_uw size)
|
||||||
|
{
|
||||||
|
if (SLJIT_LIKELY(!mprotect(ptr, size, PROT_EXEC)))
|
||||||
|
return mprotect(ptr, size, PROT_READ | PROT_WRITE);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif /* NetBSD */
|
||||||
|
|
||||||
|
#if defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED
|
||||||
|
#define SLJIT_SE_LOCK()
|
||||||
|
#define SLJIT_SE_UNLOCK()
|
||||||
|
#else /* !SLJIT_SINGLE_THREADED */
|
||||||
|
#include <pthread.h>
|
||||||
|
#define SLJIT_SE_LOCK() pthread_mutex_lock(&se_lock)
|
||||||
|
#define SLJIT_SE_UNLOCK() pthread_mutex_unlock(&se_lock)
|
||||||
|
#endif /* SLJIT_SINGLE_THREADED */
|
||||||
|
|
||||||
|
#ifndef SLJIT_PROT_WX
|
||||||
|
#define SLJIT_PROT_WX 0
|
||||||
|
#endif /* !SLJIT_PROT_WX */
|
||||||
|
|
||||||
|
SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
|
||||||
|
{
|
||||||
|
#if !(defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
|
||||||
|
static pthread_mutex_t se_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
#endif
|
||||||
|
static int se_protected = !SLJIT_PROT_WX;
|
||||||
|
sljit_uw* ptr;
|
||||||
|
|
||||||
|
if (SLJIT_UNLIKELY(se_protected < 0))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
size += sizeof(sljit_uw);
|
||||||
|
ptr = (sljit_uw*)mmap(NULL, size, PROT_READ | PROT_WRITE | SLJIT_PROT_WX,
|
||||||
|
MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||||
|
|
||||||
|
if (ptr == MAP_FAILED)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (SLJIT_UNLIKELY(se_protected > 0)) {
|
||||||
|
SLJIT_SE_LOCK();
|
||||||
|
se_protected = check_se_protected(ptr, size);
|
||||||
|
SLJIT_SE_UNLOCK();
|
||||||
|
if (SLJIT_UNLIKELY(se_protected < 0)) {
|
||||||
|
munmap((void *)ptr, size);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*ptr++ = size;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef SLJIT_PROT_WX
|
||||||
|
#undef SLJIT_SE_UNLOCK
|
||||||
|
#undef SLJIT_SE_LOCK
|
||||||
|
|
||||||
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
|
||||||
|
{
|
||||||
|
sljit_uw *start_ptr = ((sljit_uw*)ptr) - 1;
|
||||||
|
munmap((void*)start_ptr, *start_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sljit_update_wx_flags(void *from, void *to, sljit_s32 enable_exec)
|
||||||
|
{
|
||||||
|
sljit_uw page_mask = (sljit_uw)get_page_alignment();
|
||||||
|
sljit_uw start = (sljit_uw)from;
|
||||||
|
sljit_uw end = (sljit_uw)to;
|
||||||
|
int prot = PROT_READ | (enable_exec ? PROT_EXEC : PROT_WRITE);
|
||||||
|
|
||||||
|
SLJIT_ASSERT(start < end);
|
||||||
|
|
||||||
|
start &= ~page_mask;
|
||||||
|
end = (end + page_mask) & ~page_mask;
|
||||||
|
|
||||||
|
mprotect((void*)start, end - start, prot);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* windows */
|
||||||
|
|
||||||
|
SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
|
||||||
|
{
|
||||||
|
sljit_uw *ptr;
|
||||||
|
|
||||||
|
size += sizeof(sljit_uw);
|
||||||
|
ptr = (sljit_uw*)VirtualAlloc(NULL, size,
|
||||||
|
MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||||
|
|
||||||
|
if (!ptr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
*ptr++ = size;
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
|
||||||
|
{
|
||||||
|
sljit_uw start = (sljit_uw)ptr - sizeof(sljit_uw);
|
||||||
|
#if defined(SLJIT_DEBUG) && SLJIT_DEBUG
|
||||||
|
sljit_uw page_mask = (sljit_uw)get_page_alignment();
|
||||||
|
|
||||||
|
SLJIT_ASSERT(!(start & page_mask));
|
||||||
|
#endif
|
||||||
|
VirtualFree((void*)start, 0, MEM_RELEASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sljit_update_wx_flags(void *from, void *to, sljit_s32 enable_exec)
|
||||||
|
{
|
||||||
|
DWORD oldprot;
|
||||||
|
sljit_uw page_mask = (sljit_uw)get_page_alignment();
|
||||||
|
sljit_uw start = (sljit_uw)from;
|
||||||
|
sljit_uw end = (sljit_uw)to;
|
||||||
|
DWORD prot = enable_exec ? PAGE_EXECUTE : PAGE_READWRITE;
|
||||||
|
|
||||||
|
SLJIT_ASSERT(start < end);
|
||||||
|
|
||||||
|
start &= ~page_mask;
|
||||||
|
end = (end + page_mask) & ~page_mask;
|
||||||
|
|
||||||
|
VirtualProtect((void*)start, end - start, prot, &oldprot);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !windows */
|
||||||
|
|
||||||
|
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void)
|
||||||
|
{
|
||||||
|
/* This allocator does not keep unused memory for future allocations. */
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user