Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Import sljit 0.91 (svn r257).

The changes since the last import are:

r257: Add missing ADJUST_LOCAL_OFFSET for ARM64.
r256: Move incorrectly placed array definitions.
r255: More work on testing environment.
r254: Refactor test default output.
r253: Pass entry adress in r12 on PPC-LE.
r252: Optimize calls on MIPS-64.
r251: Several minor fixes.
r250: Add missing SLJIT_IS_FPU_AVAILABLE checks and reorder U and S flags.
r249: Optimize jumps on ARM-64.
r248: Optimize jumps on PowerPC.
r247: MIPS64 support is mostly finished.
r246: MIPS arithmetic.
r245: Start working on MIPS64.
r244: Uniform names for TILE-Gx.
r243: Uniform the names of ARM compilers.
r242: Change ll to l on x86 and rename some instructions on ARM-64.
r241: Improved memory access in PPC and reordering the parameter type flags.
r240: Prepare for more registers on ARM-Thumb2 and renaming TMP_REGISTER to TMP_REG1 on x86.
r239: Prepare for more registers on ARMv5.
r238: Prepare for more registers on TILE-Gx.
r237: Prepare for more registers on MIPS and SPARC.
r236: Prepare for more registers on PPC.
r235: Prepare for more registers on x86.
r234: Most tests are pass on ARM-64 now.
r233: Around 25 test cases are now pass on ARM-64.
r232: More progress on ARM-64 and Thumb2 refactoring.
r231: Some progress an ARM-64 and ARM-T2 refactoring.
r230: Thumb2 code refactoring.
r229: Start working on ARM-64.
r228: Little endian PowerPC systems are supported now by the JIT compiler.
r227: TileGX architecture is now supported. Patch made by Jiong Wang.
r226: Cache flush for android. Patch by  Giuseppe D'Angelo.
r225: Add support for forcibly freeing unused executable memory. Inspired by Carsten Klein.
r224: Few typo fixes.
r223: Reorder madvise and posix_madvise.
r222: The missing sljit_get_float_register_index function is added.
r221: Remove an invalid shift on ARM.
r220: JIT compiler now supports 32 bit Macs thanks to Lawrence Velazquez.
r219: Better code size statistics.
r218: Improvements for x86 and LIR dump.
r217: ICC and SunPro C fixes
r216: A new file for tracking internal changes are added.
r215: Less GNU dependnet Makefile and Intel style assemby for x86-64 systems.
r214: Switch from stdcall to cdecl in x86-32.
r213: Upstreaming minor fixes. Thanks for Daniel Richard G.
r212: Documentation update and a fix for a locking issue.
r211: Renaming temporaries to scratches to match the new name of the register. Does not affect compatibility.
r210: Improving assertions.
r209: Port sljit to SunPro C compiler. Patch by Daniel Richard G.
r208: SLJIT_TEMPORARY_REGx registers are renamed to SLJIT_SCRATCH_REGx.
r207: Removing unused checks.
r206: Optimizations for arm.
r205: Some optimizations on powerpc, mips and sparc.
r204: Rename sljit_emit_cond_value to sljit_emit_op_flags.
r203: Small x86 optimization.
r202: Finish cond_value with AND and INT_OP.
r201: More x86 fixes and improvements.
r200: Rename buf and code to inst.
r199: Replacing constants with instruction names in x86. Greatly improves maintainability.
r198: Only xmm0-xmm5 is volatile on Win64, so xmm6 must be saved.
r197: PowerPC shift right always modifies the carry flag. We may need to restore it.
r196: Rename SLJIT_F* functions to SLJIT_*D
r195: SLJIT_INT_OP works in the same way as SLJIT_SINGLE_OP: the input register arguments must be generated by the output of another instruction with SLJIT_INT_OP flag
r194: Renaming sljit_w to sljit_sw, sljit_i to sljit_si, sljit_h to sljit_sh, and sljit_b to sljit_sb.
r193: ARM single precision support.
r192: Single precision support added for ppc, mips and sparc.
r191: Add single precision support. Only works on x86 now.
r190: Relace C types with sljit types. No functionality change.
r189: Change 0 to NULL for mmap.
r188: Support environments where MAP_ANON is not available.
r187: Adding type descriptors for pointers and doubles (preparing for x32 ABIs and single precision support).
  • Loading branch information...
commit 10443852d3dac03e6493725101707400befee76e 1 parent 42a5aab
alnsn authored
Showing with 25,840 additions and 4,317 deletions.
  1. +53 −0 sys/external/bsd/sljit/dist/API_CHANGES
  2. +8 −0 sys/external/bsd/sljit/dist/INTERNAL_CHANGES
  3. +26 −23 sys/external/bsd/sljit/dist/Makefile
  4. +10 −7 sys/external/bsd/sljit/dist/README
  5. +77 −77 sys/external/bsd/sljit/dist/regex_src/regexJIT.c
  6. +43 −8 sys/external/bsd/sljit/dist/regex_src/regexMain.c
  7. +11 −1 sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h
  8. +104 −36 sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h
  9. +43 −8 sys/external/bsd/sljit/dist/sljit_src/sljitExecAllocator.c
  10. +393 −270 sys/external/bsd/sljit/dist/sljit_src/sljitLir.c
  11. +382 −252 sys/external/bsd/sljit/dist/sljit_src/sljitLir.h
  12. +2,524 −0 sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_32.c
  13. +1,902 −0 sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c
  14. +2,007 −0 sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_T2_32.c
  15. +48 −85 sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_32.c
  16. +469 −0 sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_64.c
  17. +475 −279 sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_common.c
  18. +15 −10 sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_32.c
  19. +19 −20 sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_64.c
  20. +648 −396 sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c
  21. +6 −5 sys/external/bsd/sljit/dist/sljit_src/sljitNativeSPARC_32.c
  22. +263 −190 sys/external/bsd/sljit/dist/sljit_src/sljitNativeSPARC_common.c
  23. +10,159 −0 sys/external/bsd/sljit/dist/sljit_src/sljitNativeTILEGX-encoder.c
  24. +2,580 −0 sys/external/bsd/sljit/dist/sljit_src/sljitNativeTILEGX_64.c
  25. +189 −154 sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_32.c
  26. +279 −258 sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_64.c
  27. +1,274 −1,074 sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c
  28. +59 −9 sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c
  29. +7 −7 sys/external/bsd/sljit/dist/test_src/sljitMain.c
  30. +1,767 −1,148 sys/external/bsd/sljit/dist/test_src/sljitTest.c
View
53 sys/external/bsd/sljit/dist/API_CHANGES
@@ -0,0 +1,53 @@
+This file is the short summary of the API changes:
+
+05.03.2014 - Backward compatible
+ The sljit_set_target now supports those jumps, which
+ does not created with SLJIT_REWRITABLE_JUMP flag.
+ Reason: sljit_emit_ijump does not support conditional
+ jumps.
+
+03.03.2014 - Non-backward compatible
+ SLJIT_MOV_UI cannot be combined with SLJIT_INT_OP.
+ Reason: SLJIT_INT_OP flag is not recommended to use
+ directly, and SLJIT_IMOV has no sign bit.
+
+29.01.2014 - Backward compatible
+ Bits assigned to SLJIT_MEM and SLJIT_IMM flags are changed.
+ Reason: the most common cases are fits into one byte now,
+ and more registers can be supported in the future.
+
+08.11.2012 - Non-backward compatible
+ SLJIT_TEMPORARY_REGx registers are renamed to SLJIT_SCRATCH_REGx.
+
+07.11.2012 - Non-backward compatible
+ sljit_emit_cond_value is renamed to sljit_emit_op_flags. An
+ extra source argument is added which will be used in the future.
+
+05.11.2012 - Backward compatible
+ sljit_emit_cond_value now supports SLJIT_AND and SLJIT_INT_OP
+ flags, which makes this function complete.
+
+01.11.2012 - Non-backward compatible
+ SLJIT_F* opcodes are renamed to SLJIT_*D to show that
+ they are double precision operators. Furthermore
+ SLJIT_*S single precision opcodes are added.
+
+01.11.2012 - Non-backward compatible
+ Register arguments of operations with SLJIT_INT_OP flag
+ must be computed by another operation with SLJIT_INT_OP flag.
+ The same way as SLJIT_SINGLE_OP flag works with floating point
+ numbers. See the description of SLJIT_INT_OP.
+
+01.11.2012 - Backward compatible
+ All operations whose support the SLJIT_INT_OP flag, have an
+ alternate name now, which includes the SLJIT_INT_OP. These
+ names starting with I.
+
+31.10.2012 - Non-backward compatible
+ Renaming sljit_w to sljit_sw, sljit_i to sljit_si, sljit_h
+ to sljit_sh, and sljit_b to sljit_sb. Reason: their sign
+ bit is part of the type now.
+
+20.10.2012 - Non-backward compatible
+ Renaming SLJIT_C_FLOAT_NAN to SLJIT_C_FLOAT_UNORDERED.
+ Reason: all architectures call these unordered comparions.
View
8 sys/external/bsd/sljit/dist/INTERNAL_CHANGES
@@ -0,0 +1,8 @@
+This file is the short summary of the internal changes:
+
+18.11.2012
+ Switching from stdcall to cdecl on x86-32. Fastcall is still the default
+ on GCC and MSVC. Now Intel C compilers are supported.
+
+20.10.2012
+ Supporting Sparc-32 CPUs.
View
49 sys/external/bsd/sljit/dist/Makefile
@@ -1,17 +1,22 @@
+ifndef CROSS_COMPILER
# default compier
CC = gcc
+else
+CC = $(CROSS_COMPILER)
+endif
-# Cross compiler for ARM
-#CC = arm-linux-gcc
+ifndef EXTRA_CPPFLAGS
+EXTRA_CPPFLAGS=
+endif
-# Cross compiler for PPC
-#CC = powerpc-linux-gnu-gcc
+ifndef EXTRA_LDFLAGS
+EXTRA_LDFLAGS=
+endif
-# Cross compiler for PPC-64
-#CC = powerpc64-unknown-linux-gnu-gcc
-
-CFLAGS = -O2 -Wall -DSLJIT_CONFIG_AUTO=1
-LDFLAGS=
+CPPFLAGS = $(EXTRA_CPPFLAGS) -DSLJIT_CONFIG_AUTO=1 -Isljit_src
+CFLAGS = -O2 -Wall
+REGEX_CFLAGS = -fshort-wchar
+LDFLAGS = $(EXTRA_LDFLAGS)
TARGET = sljit_test regex_test
@@ -20,17 +25,15 @@ SRCDIR = sljit_src
TESTDIR = test_src
REGEXDIR = regex_src
-CFLAGS += -Isljit_src
-REGEX_CFLAGS = -fshort-wchar
-
SLJIT_HEADERS = $(SRCDIR)/sljitLir.h $(SRCDIR)/sljitConfig.h $(SRCDIR)/sljitConfigInternal.h
SLJIT_LIR_FILES = $(SRCDIR)/sljitLir.c $(SRCDIR)/sljitExecAllocator.c $(SRCDIR)/sljitUtils.c \
- $(SRCDIR)/sljitNativeX86_common.c $(SRCDIR)/sljitNativeX86_32.c $(SRCDIR)/sljitNativeX86_64.c \
- $(SRCDIR)/sljitNativeARM_v5.c $(SRCDIR)/sljitNativeARM_Thumb2.c \
+ $(SRCDIR)/sljitNativeARM_32.c $(SRCDIR)/sljitNativeARM_T2_32.c $(SRCDIR)/sljitNativeARM_64.c \
+ $(SRCDIR)/sljitNativeMIPS_common.c $(SRCDIR)/sljitNativeMIPS_32.c $(SRCDIR)/sljitNativeMIPS_64.c \
$(SRCDIR)/sljitNativePPC_common.c $(SRCDIR)/sljitNativePPC_32.c $(SRCDIR)/sljitNativePPC_64.c \
- $(SRCDIR)/sljitNativeMIPS_common.c $(SRCDIR)/sljitNativeMIPS_32.c \
- $(SRCDIR)/sljitNativeSPARC_common.c $(SRCDIR)/sljitNativeSPARC_32.c
+ $(SRCDIR)/sljitNativeSPARC_common.c $(SRCDIR)/sljitNativeSPARC_32.c \
+ $(SRCDIR)/sljitNativeTILEGX_64.c \
+ $(SRCDIR)/sljitNativeX86_common.c $(SRCDIR)/sljitNativeX86_32.c $(SRCDIR)/sljitNativeX86_64.c
all: $(BINDIR) $(TARGET)
@@ -38,25 +41,25 @@ $(BINDIR) :
mkdir $(BINDIR)
$(BINDIR)/sljitLir.o : $(BINDIR) $(SLJIT_LIR_FILES) $(SLJIT_HEADERS)
- $(CC) $(CFLAGS) -c -o $@ $(SRCDIR)/sljitLir.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SRCDIR)/sljitLir.c
$(BINDIR)/sljitMain.o : $(TESTDIR)/sljitMain.c $(BINDIR) $(SLJIT_HEADERS)
- $(CC) $(CFLAGS) -c -o $@ $(TESTDIR)/sljitMain.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(TESTDIR)/sljitMain.c
$(BINDIR)/sljitTest.o : $(TESTDIR)/sljitTest.c $(BINDIR) $(SLJIT_HEADERS)
- $(CC) $(CFLAGS) -c -o $@ $(TESTDIR)/sljitTest.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(TESTDIR)/sljitTest.c
$(BINDIR)/regexMain.o : $(REGEXDIR)/regexMain.c $(BINDIR) $(SLJIT_HEADERS)
- $(CC) $(CFLAGS) $(REGEX_CFLAGS) -c -o $@ $(REGEXDIR)/regexMain.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(REGEX_CFLAGS) -c -o $@ $(REGEXDIR)/regexMain.c
$(BINDIR)/regexJIT.o : $(REGEXDIR)/regexJIT.c $(BINDIR) $(SLJIT_HEADERS) $(REGEXDIR)/regexJIT.h
- $(CC) $(CFLAGS) $(REGEX_CFLAGS) -c -o $@ $(REGEXDIR)/regexJIT.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(REGEX_CFLAGS) -c -o $@ $(REGEXDIR)/regexJIT.c
clean:
rm -f $(BINDIR)/*.o $(BINDIR)/sljit_test $(BINDIR)/regex_test
sljit_test: $(BINDIR)/sljitMain.o $(BINDIR)/sljitTest.o $(BINDIR)/sljitLir.o
- $(CC) $(LDFLAGS) $(BINDIR)/sljitMain.o $(BINDIR)/sljitTest.o $(BINDIR)/sljitLir.o -o $(BINDIR)/$@ -lm -lpthread
+ $(CC) $(CFLAGS) $(LDFLAGS) $(BINDIR)/sljitMain.o $(BINDIR)/sljitTest.o $(BINDIR)/sljitLir.o -o $(BINDIR)/$@ -lm -lpthread
regex_test: $(BINDIR)/regexMain.o $(BINDIR)/regexJIT.o $(BINDIR)/sljitLir.o
- $(CC) $(LDFLAGS) $(BINDIR)/regexMain.o $(BINDIR)/regexJIT.o $(BINDIR)/sljitLir.o -o $(BINDIR)/$@ -lm -lpthread
+ $(CC) $(CFLAGS) $(LDFLAGS) $(BINDIR)/regexMain.o $(BINDIR)/regexJIT.o $(BINDIR)/sljitLir.o -o $(BINDIR)/$@ -lm -lpthread
View
17 sys/external/bsd/sljit/dist/README
@@ -2,18 +2,19 @@
SLJIT - Stack Less JIT Compiler
Purpose:
- A simple machine independent JIT, which suitable for interpreters and
- other dynamic tools. See sljitLir.h for more information.
+ A simple, machine independent JIT compiler, which suitable for
+ translating interpreted byte code to machine code. The sljitLir.h
+ describes the LIR (low-level intermediate representation) of SLJIT.
Compatible:
Any C (C++) compiler. At least I hope so.
Using sljit:
- Copy sljitLir.c sljitLir.h sljitConfig.h sljitExecAllocator.c and sljitNative*.c
- files into your project. Add sljitLir.c into your project. The other files are
- included by sljitLir.c (when required). Define the machine by SLJIT_CONFIG_*
- selector. See sljitConfig.h for all possible values. For C++ compilers, rename
- sljitLir.c to sljitLir.cpp.
+ Copy the content of sljit_src directory into your project source directory.
+ Add sljitLir.c source file to your build environment. All other files are
+ included by sljitLir.c (if required). Define the machine by SLJIT_CONFIG_*
+ selector. See sljitConfig.h for all possible values. For C++ compilers,
+ rename sljitLir.c to sljitLir.cpp.
More info:
http://sljit.sourceforge.net/
@@ -24,3 +25,5 @@ Contact:
Special thanks:
Alexander Nasonov
Daniel Richard G.
+ Giuseppe D'Angelo
+ Jiong Wang (TileGX support)
View
154 sys/external/bsd/sljit/dist/regex_src/regexJIT.c
@@ -53,13 +53,13 @@ struct regex_machine
/* flags. */
int flags;
/* Number of state descriptors for one term. */
- sljit_w no_states;
+ sljit_sw no_states;
/* Total size. */
- sljit_w size;
+ sljit_sw size;
union {
void *init_match;
- sljit_w (SLJIT_CALL *call_init)(void *next, void* match);
+ sljit_sw (SLJIT_CALL *call_init)(void *next, void* match);
} u;
#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
struct sljit_function_context context;
@@ -74,19 +74,19 @@ struct regex_machine
struct regex_match
{
/* Current and next state array. */
- sljit_w *current;
- sljit_w *next;
+ sljit_sw *current;
+ sljit_sw *next;
/* Starting. */
- sljit_w head;
+ sljit_sw head;
/* String character index (ever increasing). */
- sljit_w index;
+ sljit_sw index;
/* Best match found so far (members in priority order). */
- sljit_w best_begin;
- sljit_w best_end;
- sljit_w best_id;
+ sljit_sw best_begin;
+ sljit_sw best_end;
+ sljit_sw best_id;
/* Bool flags (encoded as word). */
- sljit_w fast_quit;
- sljit_w fast_forward;
+ sljit_sw fast_quit;
+ sljit_sw fast_forward;
/* Machine. */
struct regex_machine *machine;
@@ -96,7 +96,7 @@ struct regex_match
} u;
/* Variable sized array to contain the state arrays. */
- sljit_w states[1];
+ sljit_sw states[1];
};
/* State vector
@@ -117,11 +117,11 @@ struct regex_match
/* String fragment length. */
#define R_LENGTH SLJIT_SAVED_EREG2
/* 'struct regex_match*' */
-#define R_REGEX_MATCH SLJIT_TEMPORARY_REG1
+#define R_REGEX_MATCH SLJIT_SCRATCH_REG1
/* Current character. */
-#define R_CURR_CHAR SLJIT_TEMPORARY_REG2
+#define R_CURR_CHAR SLJIT_SCRATCH_REG2
/* Temporary register. */
-#define R_TEMP SLJIT_TEMPORARY_REG3
+#define R_TEMP SLJIT_SCRATCH_REG3
/* Caches the regex_match->best_begin. */
#define R_BEST_BEGIN SLJIT_TEMPORARY_EREG1
/* Current character index. */
@@ -379,13 +379,13 @@ struct compiler_common {
/* REGEX_ flags. */
int flags;
/* Encoded size of the dfa representation. */
- sljit_w dfa_size;
+ sljit_sw dfa_size;
/* Number of terms. */
- sljit_w terms_size;
+ sljit_sw terms_size;
/* Number of state descriptors for one term (same as machine->no_states). */
- sljit_w no_states;
+ sljit_sw no_states;
/* Number of type_rng_(char|left)-s in the longest character range. */
- sljit_w longest_range_size;
+ sljit_sw longest_range_size;
/* DFA linear representation (size: dfa_size). */
struct stack_item *dfa_transitions;
@@ -555,7 +555,7 @@ static int iterate(struct stack *stack, int min, int max)
return len;
}
-static int parse_iterator(const regex_char_t *regex_string, int length, struct stack *stack, sljit_w *dfa_size, int begin)
+static int parse_iterator(const regex_char_t *regex_string, int length, struct stack *stack, sljit_sw *dfa_size, int begin)
{
/* We only know that *regex_string == { . */
int val1, val2;
@@ -1281,8 +1281,8 @@ static int trace_transitions(int from, struct compiler_common *compiler_common)
/* Code generator */
/* --------------------------------------------------------------------- */
-#define TERM_OFFSET_OF(index, offs) (((index) * no_states + (offs)) * sizeof(sljit_w))
-#define TERM_REL_OFFSET_OF(base, offs) ((base) + ((offs) * sizeof(sljit_w)))
+#define TERM_OFFSET_OF(index, offs) (((index) * no_states + (offs)) * sizeof(sljit_sw))
+#define TERM_REL_OFFSET_OF(base, offs) ((base) + ((offs) * sizeof(sljit_sw)))
#define EMIT_OP1(type, arg1, arg2, arg3, arg4) \
CHECK(sljit_emit_op1(compiler, type, arg1, arg2, arg3, arg4))
@@ -1314,9 +1314,9 @@ static int compile_uncond_tran(struct compiler_common *compiler_common, int reg)
struct stack *stack = &compiler_common->stack;
struct stack_item *search_states = compiler_common->search_states;
int flags = compiler_common->flags;
- sljit_w no_states = compiler_common->no_states;
+ sljit_sw no_states = compiler_common->no_states;
sljit_uw head = 0;
- sljit_w offset, value;
+ sljit_sw offset, value;
if (reg != R_CURR_STATE || !(compiler_common->flags & REGEX_FAKE_MATCH_BEGIN)) {
CHECK(trace_transitions(0, compiler_common));
@@ -1366,15 +1366,15 @@ static int compile_uncond_tran(struct compiler_common *compiler_common, int reg)
return REGEX_NO_ERROR;
}
-static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w curr_index)
+static int compile_cond_tran(struct compiler_common *compiler_common, sljit_sw curr_index)
{
struct sljit_compiler *compiler = compiler_common->compiler;
struct stack *stack = &compiler_common->stack;
struct stack_item *search_states = compiler_common->search_states;
- sljit_w offset;
+ sljit_sw offset;
int flags;
- sljit_w no_states;
- sljit_w value;
+ sljit_sw no_states;
+ sljit_sw value;
struct sljit_jump *jump1;
struct sljit_jump *jump2;
struct sljit_jump *jump3;
@@ -1402,8 +1402,8 @@ static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w cu
if (!(flags & REGEX_ID_CHECK)) {
if (!(flags & REGEX_MATCH_BEGIN)) {
/* Check whether item is inserted. */
- EMIT_CMP(jump1, SLJIT_C_NOT_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_w), SLJIT_IMM, -1);
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_w), R_NEXT_HEAD, 0);
+ EMIT_CMP(jump1, SLJIT_C_NOT_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_sw), SLJIT_IMM, -1);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_sw), R_NEXT_HEAD, 0);
if (offset > 0) {
EMIT_OP1(SLJIT_MOV, R_NEXT_HEAD, 0, SLJIT_IMM, offset);
}
@@ -1413,19 +1413,19 @@ static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w cu
EMIT_LABEL(label1);
sljit_set_label(jump1, label1);
- EMIT_CMP(jump1, SLJIT_C_LESS_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_w), R_TEMP, 0);
+ EMIT_CMP(jump1, SLJIT_C_LESS_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_sw), R_TEMP, 0);
EMIT_LABEL(label1);
sljit_set_label(jump2, label1);
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_w), R_TEMP, 0);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_sw), R_TEMP, 0);
EMIT_LABEL(label1);
sljit_set_label(jump1, label1);
}
else {
/* Check whether item is inserted. */
- EMIT_CMP(jump1, SLJIT_C_NOT_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_w), SLJIT_IMM, -1);
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_w), R_NEXT_HEAD, 0);
+ EMIT_CMP(jump1, SLJIT_C_NOT_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_sw), SLJIT_IMM, -1);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_sw), R_NEXT_HEAD, 0);
if (offset > 0) {
EMIT_OP1(SLJIT_MOV, R_NEXT_HEAD, 0, SLJIT_IMM, offset);
}
@@ -1438,8 +1438,8 @@ static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w cu
EMIT_OP1(SLJIT_MOV, R_TEMP, 0, SLJIT_MEM1(R_CURR_STATE), TERM_OFFSET_OF(curr_index, 2));
/* Check whether item is inserted. */
- EMIT_CMP(jump1, SLJIT_C_NOT_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_w), SLJIT_IMM, -1);
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_w), R_NEXT_HEAD, 0);
+ EMIT_CMP(jump1, SLJIT_C_NOT_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_sw), SLJIT_IMM, -1);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_sw), R_NEXT_HEAD, 0);
if (offset > 0) {
EMIT_OP1(SLJIT_MOV, R_NEXT_HEAD, 0, SLJIT_IMM, offset);
}
@@ -1449,7 +1449,7 @@ static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w cu
EMIT_LABEL(label1);
sljit_set_label(jump1, label1);
- EMIT_OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_w), R_TEMP, 0);
+ EMIT_OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_sw), R_TEMP, 0);
EMIT_JUMP(jump1, SLJIT_C_LESS);
EMIT_JUMP(jump3, SLJIT_C_GREATER);
@@ -1463,7 +1463,7 @@ static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w cu
sljit_set_label(jump4, label1);
}
- EMIT_OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_MEM1(R_NEXT_STATE), offset + 3 * sizeof(sljit_w), R_TEMP, 0);
+ EMIT_OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_MEM1(R_NEXT_STATE), offset + 3 * sizeof(sljit_sw), R_TEMP, 0);
EMIT_JUMP(jump4, SLJIT_C_GREATER_EQUAL);
EMIT_JUMP(jump5, SLJIT_JUMP);
@@ -1471,7 +1471,7 @@ static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w cu
EMIT_LABEL(label1);
sljit_set_label(jump3, label1);
sljit_set_label(jump2, label1);
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_w), R_TEMP, 0);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_sw), R_TEMP, 0);
EMIT_OP1(SLJIT_MOV, R_TEMP, 0, SLJIT_MEM1(R_CURR_STATE), TERM_OFFSET_OF(curr_index, 3));
if (search_states[value].value > 0) {
@@ -1484,7 +1484,7 @@ static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w cu
EMIT_LABEL(label1);
sljit_set_label(jump5, label1);
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + 3 * sizeof(sljit_w), R_TEMP, 0);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + 3 * sizeof(sljit_sw), R_TEMP, 0);
/* Exit. */
EMIT_LABEL(label1);
@@ -1503,8 +1503,8 @@ static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w cu
}
/* Check whether item is inserted. */
- EMIT_CMP(jump1, SLJIT_C_NOT_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_w), SLJIT_IMM, -1);
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_w), R_NEXT_HEAD, 0);
+ EMIT_CMP(jump1, SLJIT_C_NOT_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_sw), SLJIT_IMM, -1);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + sizeof(sljit_sw), R_NEXT_HEAD, 0);
if (offset > 0) {
EMIT_OP1(SLJIT_MOV, R_NEXT_HEAD, 0, SLJIT_IMM, offset);
}
@@ -1514,11 +1514,11 @@ static int compile_cond_tran(struct compiler_common *compiler_common, sljit_w cu
EMIT_LABEL(label1);
sljit_set_label(jump1, label1);
- EMIT_CMP(jump1, SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_w), R_TEMP, 0);
+ EMIT_CMP(jump1, SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_sw), R_TEMP, 0);
EMIT_LABEL(label1);
sljit_set_label(jump2, label1);
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_w), R_TEMP, 0);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_NEXT_STATE), offset + 2 * sizeof(sljit_sw), R_TEMP, 0);
EMIT_LABEL(label1);
sljit_set_label(jump1, label1);
@@ -1593,11 +1593,11 @@ static int compile_end_check(struct compiler_common *compiler_common, struct slj
sljit_set_label(jump, leave_label);
EMIT_OP2(SLJIT_ADD, R_TEMP, 0, R_TEMP, 0, R_CURR_STATE, 0);
- EMIT_OP1(SLJIT_MOV, R_BEST_BEGIN, 0, SLJIT_MEM1(R_TEMP), sizeof(sljit_w));
- EMIT_CMP(clear_states_jump, !(compiler_common->flags & REGEX_MATCH_NON_GREEDY) ? SLJIT_C_GREATER : SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(R_TEMP), 2 * sizeof(sljit_w), R_CURR_CHAR, 0);
+ EMIT_OP1(SLJIT_MOV, R_BEST_BEGIN, 0, SLJIT_MEM1(R_TEMP), sizeof(sljit_sw));
+ EMIT_CMP(clear_states_jump, !(compiler_common->flags & REGEX_MATCH_NON_GREEDY) ? SLJIT_C_GREATER : SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(R_TEMP), 2 * sizeof(sljit_sw), R_CURR_CHAR, 0);
/* Case 1: keep this case. */
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_TEMP), sizeof(sljit_w), R_NEXT_HEAD, 0);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_TEMP), sizeof(sljit_sw), R_NEXT_HEAD, 0);
EMIT_OP2(SLJIT_SUB, R_NEXT_HEAD, 0, R_TEMP, 0, R_CURR_STATE, 0);
EMIT_OP1(SLJIT_MOV, R_TEMP, 0, R_BEST_BEGIN, 0);
@@ -1608,7 +1608,7 @@ static int compile_end_check(struct compiler_common *compiler_common, struct slj
EMIT_LABEL(label);
sljit_set_label(clear_states_jump, label);
- EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_TEMP), sizeof(sljit_w), SLJIT_IMM, -1);
+ EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_TEMP), sizeof(sljit_sw), SLJIT_IMM, -1);
EMIT_OP1(SLJIT_MOV, R_TEMP, 0, R_BEST_BEGIN, 0);
EMIT_JUMP(jump, SLJIT_JUMP);
@@ -1689,14 +1689,14 @@ static int compile_leave_fast_forward(struct compiler_common *compiler_common, s
return REGEX_NO_ERROR;
}
-static int compile_newline_check(struct compiler_common *compiler_common, sljit_w ind)
+static int compile_newline_check(struct compiler_common *compiler_common, sljit_sw ind)
{
struct sljit_compiler *compiler = compiler_common->compiler;
struct sljit_jump *jump1;
struct sljit_jump *jump2;
struct sljit_label *label;
- sljit_w no_states;
- sljit_w offset;
+ sljit_sw no_states;
+ sljit_sw offset;
/* Check whether a new-line character is found. */
EMIT_CMP(jump1, SLJIT_C_EQUAL, R_CURR_CHAR, 0, SLJIT_IMM, '\n');
@@ -1728,15 +1728,15 @@ static SLJIT_INLINE void range_set_label(struct sljit_jump **range_jump_list, st
}
}
-static sljit_w compile_range_check(struct compiler_common *compiler_common, sljit_w ind)
+static sljit_sw compile_range_check(struct compiler_common *compiler_common, sljit_sw ind)
{
struct sljit_compiler *compiler = compiler_common->compiler;
struct stack_item *dfa_transitions = compiler_common->dfa_transitions;
struct sljit_jump **range_jump_list = compiler_common->range_jump_list;
int invert = dfa_transitions[ind].value;
struct sljit_label *label;
- sljit_w no_states;
- sljit_w offset;
+ sljit_sw no_states;
+ sljit_sw offset;
int init_range = 1, prev_value = 0;
ind++;
@@ -1799,7 +1799,7 @@ static sljit_w compile_range_check(struct compiler_common *compiler_common, slji
/* Main compiler */
/* --------------------------------------------------------------------- */
-#define TERM_OFFSET_OF(ind, offs) (((ind) * compiler_common.no_states + (offs)) * sizeof(sljit_w))
+#define TERM_OFFSET_OF(ind, offs) (((ind) * compiler_common.no_states + (offs)) * sizeof(sljit_sw))
#define EMIT_OP1(type, arg1, arg2, arg3, arg4) \
CHECK(sljit_emit_op1(compiler_common.compiler, type, arg1, arg2, arg3, arg4))
@@ -1833,7 +1833,7 @@ static sljit_w compile_range_check(struct compiler_common *compiler_common, slji
struct regex_machine* regex_compile(const regex_char_t *regex_string, int length, int re_flags, int *error)
{
struct compiler_common compiler_common;
- sljit_w ind;
+ sljit_sw ind;
int error_code, done, suggest_fast_forward;
/* ID of an empty match (-1 if not reachable). */
int empty_match_id;
@@ -2263,7 +2263,7 @@ struct regex_machine* regex_compile(const regex_char_t *regex_string, int length
compiler_common.machine->continue_match = sljit_generate_code(compiler_common.compiler);
#ifndef SLJIT_INDIRECT_CALL
- compiler_common.machine->u.init_match = (void*)(sljit_w)sljit_get_label_addr(label);
+ compiler_common.machine->u.init_match = (void*)(sljit_sw)sljit_get_label_addr(label);
#else
sljit_set_function_context(&compiler_common.machine->u.init_match, &compiler_common.machine->context, sljit_get_label_addr(label), regex_compile);
#endif
@@ -2325,19 +2325,19 @@ const char* regex_get_platform_name(void)
struct regex_match* regex_begin_match(struct regex_machine *machine)
{
- sljit_w *ptr1;
- sljit_w *ptr2;
- sljit_w *end;
- sljit_w *entry_addrs;
+ sljit_sw *ptr1;
+ sljit_sw *ptr2;
+ sljit_sw *end;
+ sljit_sw *entry_addrs;
- struct regex_match *match = (struct regex_match*)SLJIT_MALLOC(sizeof(struct regex_match) + (machine->size * 2 - 1) * sizeof(sljit_w));
+ struct regex_match *match = (struct regex_match*)SLJIT_MALLOC(sizeof(struct regex_match) + (machine->size * 2 - 1) * sizeof(sljit_sw));
if (!match)
return NULL;
ptr1 = match->states;
ptr2 = match->states + machine->size;
end = ptr2;
- entry_addrs = (sljit_w*)machine->entry_addrs;
+ entry_addrs = (sljit_sw*)machine->entry_addrs;
match->current = ptr1;
match->next = ptr2;
@@ -2395,8 +2395,8 @@ struct regex_match* regex_begin_match(struct regex_machine *machine)
void regex_reset_match(struct regex_match *match)
{
struct regex_machine *machine = match->machine;
- sljit_w current, ind;
- sljit_w *current_ptr;
+ sljit_sw current, ind;
+ sljit_sw *current_ptr;
match->best_end = 0;
match->fast_quit = 0;
@@ -2407,7 +2407,7 @@ void regex_reset_match(struct regex_match *match)
current = match->head;
current_ptr = match->current;
do {
- ind = (current / sizeof(sljit_w)) + 1;
+ ind = (current / sizeof(sljit_sw)) + 1;
current = current_ptr[ind];
current_ptr[ind] = -1;
} while (current != 0);
@@ -2428,7 +2428,7 @@ void regex_continue_match(struct regex_match *match, const regex_char_t *input_s
int regex_get_result(struct regex_match *match, int *end, int *id)
{
int flags = match->machine->flags;
- sljit_w no_states;
+ sljit_sw no_states;
*end = match->best_end;
*id = match->best_id;
@@ -2493,14 +2493,14 @@ int regex_is_match_finished(struct regex_match *match)
#ifdef REGEX_MATCH_VERBOSE
void regex_continue_match_debug(struct regex_match *match, const regex_char_t *input_string, int length)
{
- sljit_w *ptr;
- sljit_w *end;
- sljit_w count;
+ sljit_sw *ptr;
+ sljit_sw *end;
+ sljit_sw count;
#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- sljit_w current;
+ sljit_sw current;
#endif
- sljit_w no_states = match->machine->no_states;
- sljit_w len = match->machine->size;
+ sljit_sw no_states = match->machine->no_states;
+ sljit_sw len = match->machine->size;
while (length > 0) {
match->u.call_continue(match, input_string, 1);
@@ -2568,10 +2568,10 @@ void regex_continue_match_debug(struct regex_match *match, const regex_char_t *i
current = match->head;
ptr = match->current;
while (current != 0) {
- SLJIT_ASSERT(current >= 0 && current < len * sizeof(sljit_w));
- SLJIT_ASSERT((current % (no_states * sizeof(sljit_w))) == 0);
+ SLJIT_ASSERT(current >= 0 && current < len * sizeof(sljit_sw));
+ SLJIT_ASSERT((current % (no_states * sizeof(sljit_sw))) == 0);
SLJIT_ASSERT(count > 0);
- current = ptr[(current / sizeof(sljit_w)) + 1];
+ current = ptr[(current / sizeof(sljit_sw)) + 1];
count--;
}
SLJIT_ASSERT(count == 0);
View
51 sys/external/bsd/sljit/dist/regex_src/regexMain.c
@@ -24,10 +24,23 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/* Must be the first one. Must not depend on any other include. */
#include "regexJIT.h"
#include <stdio.h>
+#if defined _WIN32 || defined _WIN64
+#define COLOR_RED
+#define COLOR_GREEN
+#define COLOR_ARCH
+#define COLOR_DEFAULT
+#else
+#define COLOR_RED "\33[31m"
+#define COLOR_GREEN "\33[32m"
+#define COLOR_ARCH "\33[33m"
+#define COLOR_DEFAULT "\33[0m"
+#endif
+
#ifdef REGEX_USE_8BIT_CHARS
#define S(str) str
#else
@@ -90,7 +103,7 @@ struct test_case {
const regex_char_t *string; /* NULL : end of tests. */
};
-void run_tests(struct test_case* test)
+void run_tests(struct test_case* test, int verbose, int silent)
{
int error;
const regex_char_t *ptr;
@@ -99,8 +112,12 @@ void run_tests(struct test_case* test)
int begin, end, id, finished;
int success = 0, fail = 0;
+ if (!verbose && !silent)
+ printf("Pass -v to enable verbose, -s to disable this hint.\n\n");
+
for ( ; test->string ; test++) {
- printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
+ if (verbose)
+ printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
fail++;
if (test->pattern) {
@@ -114,15 +131,21 @@ void run_tests(struct test_case* test)
machine = regex_compile(test->pattern, ptr - test->pattern, test->flags, &error);
if (error) {
+ if (!verbose)
+ printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
printf("ABORT: Error %d\n", error);
return;
}
if (!machine) {
+ if (!verbose)
+ printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
printf("ABORT: machine must be exists. Report this bug, please\n");
return;
}
}
else if (test->flags != 0) {
+ if (!verbose)
+ printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
printf("ABORT: flag must be 0 if no pattern\n");
return;
}
@@ -134,6 +157,8 @@ void run_tests(struct test_case* test)
match = regex_begin_match(machine);
#ifdef REGEX_MATCH_VERBOSE
if (!match) {
+ if (!verbose)
+ printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
printf("ABORT: Not enough memory for matching\n");
regex_free_machine(machine);
return;
@@ -143,10 +168,14 @@ void run_tests(struct test_case* test)
finished = regex_is_match_finished(match);
if (begin != test->begin || end != test->end || id != test->id) {
+ if (!verbose)
+ printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
printf("FAIL A: begin: %d != %d || end: %d != %d || id: %d != %d\n", test->begin, begin, test->end, end, test->id, id);
continue;
}
if (test->finished != -1 && test->finished != !!finished) {
+ if (!verbose)
+ printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
printf("FAIL A: finish check\n");
continue;
}
@@ -159,26 +188,31 @@ void run_tests(struct test_case* test)
regex_free_match(match);
if (begin != test->begin || end != test->end || id != test->id) {
+ if (!verbose)
+ printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
printf("FAIL B: begin: %d != %d || end: %d != %d || id: %d != %d\n", test->begin, begin, test->end, end, test->id, id);
continue;
}
if (test->finished != -1 && test->finished != !!finished) {
+ if (!verbose)
+ printf("test: '%s' '%s': ", test->pattern ? test->pattern : "[[REUSE]]", test->string);
printf("FAIL B: finish check\n");
continue;
}
- printf("SUCCESS\n");
+ if (verbose)
+ printf("SUCCESS\n");
fail--;
success++;
}
if (machine)
regex_free_machine(machine);
- printf("On %s: ", regex_get_platform_name());
+ printf("REGEX tests: On " COLOR_ARCH "%s" COLOR_DEFAULT ": ", regex_get_platform_name());
if (fail == 0)
- printf("All tests are passed!\n");
+ printf("All tests are " COLOR_GREEN "PASSED" COLOR_DEFAULT "!\n");
else
- printf("Successful test ratio: %d%%.\n", success * 100 / (success + fail));
+ printf("Successful test ratio: " COLOR_RED "%d%%" COLOR_DEFAULT ".\n", success * 100 / (success + fail));
}
/* Testing. */
@@ -280,6 +314,8 @@ static struct test_case tests[] = {
int main(int argc, char* argv[])
{
+ int has_arg = (argc >= 2 && argv[1][0] == '-' && argv[1][2] == '\0');
+
/* verbose_test("a((b)((c|d))|)c|"); */
/* verbose_test("Xa{009,0010}Xb{,7}Xc{5,}Xd{,}Xe{1,}Xf{,1}X"); */
/* verbose_test("{3!}({3})({0!}){,"); */
@@ -287,7 +323,6 @@ int main(int argc, char* argv[])
/* verbose_test("^a({2!})*b+(a|{1!}b)+d$"); */
/* verbose_test("((a|b|c)*(xy)+)+", "asbcxyxy"); */
- run_tests(tests);
+ run_tests(tests, has_arg && argv[1][1] == 'v', has_arg && argv[1][1] == 's');
return 0;
}
-
View
12 sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h
@@ -44,10 +44,13 @@
/* #define SLJIT_CONFIG_ARM_V5 1 */
/* #define SLJIT_CONFIG_ARM_V7 1 */
/* #define SLJIT_CONFIG_ARM_THUMB2 1 */
+/* #define SLJIT_CONFIG_ARM_64 1 */
/* #define SLJIT_CONFIG_PPC_32 1 */
/* #define SLJIT_CONFIG_PPC_64 1 */
/* #define SLJIT_CONFIG_MIPS_32 1 */
+/* #define SLJIT_CONFIG_MIPS_64 1 */
/* #define SLJIT_CONFIG_SPARC_32 1 */
+/* #define SLJIT_CONFIG_TILEGX 1 */
/* #define SLJIT_CONFIG_AUTO 1 */
/* #define SLJIT_CONFIG_UNSUPPORTED 1 */
@@ -105,6 +108,13 @@
#define SLJIT_VERBOSE 1
#endif
-/* See the beginning of sljitConfigInternal.h */
+/*
+ SLJIT_IS_FPU_AVAILABLE
+ The availability of the FPU can be controlled by SLJIT_IS_FPU_AVAILABLE.
+ zero value - FPU is NOT present.
+ nonzero value - FPU is present.
+*/
+
+/* For further configurations, see the beginning of sljitConfigInternal.h */
#endif
View
140 sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h
@@ -33,8 +33,8 @@
Feature detection (boolean) macros:
SLJIT_32BIT_ARCHITECTURE : 32 bit architecture
SLJIT_64BIT_ARCHITECTURE : 64 bit architecture
- SLJIT_WORD_SHIFT : the shift required to apply when accessing a sljit_w/sljit_uw array by index
- SLJIT_FLOAT_SHIFT : the shift required to apply when accessing a double array by index
+ SLJIT_WORD_SHIFT : the shift required to apply when accessing a sljit_sw/sljit_uw array by index
+ SLJIT_DOUBLE_SHIFT : the shift required to apply when accessing a double array by index
SLJIT_LITTLE_ENDIAN : little endian architecture
SLJIT_BIG_ENDIAN : big endian architecture
SLJIT_UNALIGNED : allows unaligned memory accesses for non-fpu operations (only!)
@@ -42,10 +42,14 @@
SLJIT_RETURN_ADDRESS_OFFSET : a return instruction always adds this offset to the return address
Types and useful macros:
- sljit_b, sljit_ub : signed and unsigned 8 bit byte
- sljit_h, sljit_uh : signed and unsigned 16 bit half-word (short) type
- sljit_i, sljit_ui : signed and unsigned 32 bit integer type
- sljit_w, sljit_uw : signed and unsigned machine word, enough to store a pointer (same as intptr_t)
+ sljit_sb, sljit_ub : signed and unsigned 8 bit byte
+ sljit_sh, sljit_uh : signed and unsigned 16 bit half-word (short) type
+ sljit_si, sljit_ui : signed and unsigned 32 bit integer type
+ sljit_sw, sljit_uw : signed and unsigned machine word, enough to store a pointer
+ sljit_p : unsgined pointer value (usually the same as sljit_uw, but
+ some 64 bit ABIs may use 32 bit pointers)
+ sljit_s : single precision floating point value
+ sljit_d : double precision floating point value
SLJIT_CALL : C calling convention define for both calling JIT form C and C callbacks for JIT
SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (compiler independent helper)
*/
@@ -55,10 +59,13 @@
|| (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"
@@ -70,9 +77,12 @@
+ (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_TILEGX && SLJIT_CONFIG_TILEGX) \
+ (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_AUTO && SLJIT_CONFIG_AUTO) \
+ (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
@@ -96,14 +106,20 @@
#else
#define SLJIT_CONFIG_ARM_V5 1
#endif
+#elif defined (__aarch64__)
+#define SLJIT_CONFIG_ARM_64 1
#elif defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) || (defined(_POWER) && defined(__64BIT__))
#define SLJIT_CONFIG_PPC_64 1
#elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)
#define SLJIT_CONFIG_PPC_32 1
-#elif defined(__mips__)
+#elif defined(__mips__) && !defined(_LP64)
#define SLJIT_CONFIG_MIPS_32 1
+#elif defined(__mips64)
+#define SLJIT_CONFIG_MIPS_64 1
#elif defined(__sparc__) || defined(__sparc)
#define SLJIT_CONFIG_SPARC_32 1
+#elif defined(__tilegx__)
+#define SLJIT_CONFIG_TILEGX 1
#else
/* Unsupported architecture */
#define SLJIT_CONFIG_UNSUPPORTED 1
@@ -169,9 +185,13 @@
#endif /* !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY) */
#ifndef SLJIT_INLINE
-/* Inline functions. */
+/* Inline functions. Some old compilers do not support them. */
+#if defined(__SUNPRO_C) && __SUNPRO_C <= 0x510
+#define SLJIT_INLINE
+#else
#define SLJIT_INLINE __inline
#endif
+#endif /* !SLJIT_INLINE */
#ifndef SLJIT_CONST
/* Const variables. */
@@ -213,6 +233,13 @@
#define SLJIT_CACHE_FLUSH(from, to) \
sys_icache_invalidate((char*)(from), (char*)(to) - (char*)(from))
+#elif defined __ANDROID__
+
+/* Android lacks __clear_cache; instead, cacheflush should be used. */
+
+#define SLJIT_CACHE_FLUSH(from, to) \
+ cacheflush((long)(from), (long)(to), 0)
+
#elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
/* The __clear_cache() implementation of GCC is a dummy function on PowerPC. */
@@ -237,15 +264,15 @@
/* 8 bit byte type. */
typedef unsigned char sljit_ub;
-typedef signed char sljit_b;
+typedef signed char sljit_sb;
/* 16 bit half-word type. */
typedef unsigned short int sljit_uh;
-typedef signed short int sljit_h;
+typedef signed short int sljit_sh;
/* 32 bit integer type. */
typedef unsigned int sljit_ui;
-typedef signed int sljit_i;
+typedef signed int sljit_si;
/* Machine word type. Can encapsulate a pointer.
32 bit for 32 bit machines.
@@ -254,26 +281,39 @@ typedef signed int sljit_i;
/* Just to have something. */
#define SLJIT_WORD_SHIFT 0
typedef unsigned long int sljit_uw;
-typedef long int sljit_w;
-#elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+typedef long int sljit_sw;
+#elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
+ && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
+ && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
+ && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
+ && !(defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
#define SLJIT_32BIT_ARCHITECTURE 1
#define SLJIT_WORD_SHIFT 2
typedef unsigned int sljit_uw;
-typedef int sljit_w;
+typedef int sljit_sw;
#else
#define SLJIT_64BIT_ARCHITECTURE 1
#define SLJIT_WORD_SHIFT 3
#ifdef _WIN32
typedef unsigned __int64 sljit_uw;
-typedef __int64 sljit_w;
+typedef __int64 sljit_sw;
#else
typedef unsigned long int sljit_uw;
-typedef long int sljit_w;
+typedef long int sljit_sw;
#endif
#endif
-/* Double precision. */
-#define SLJIT_FLOAT_SHIFT 3
+typedef sljit_uw sljit_p;
+
+/* Floating point types. */
+typedef float sljit_s;
+typedef double sljit_d;
+
+/* Shift for pointer sized data. */
+#define SLJIT_POINTER_SHIFT SLJIT_WORD_SHIFT
+
+/* Shift for double precision sized data. */
+#define SLJIT_DOUBLE_SHIFT 3
#ifndef SLJIT_W
@@ -291,25 +331,29 @@ typedef long int sljit_w;
/* ABI (Application Binary Interface) types. */
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-#if defined(__GNUC__)
+#if defined(__GNUC__) && !defined(__APPLE__)
#define SLJIT_CALL __attribute__ ((fastcall))
#define SLJIT_X86_32_FASTCALL 1
-#elif defined(_WIN32)
+#elif defined(_MSC_VER)
-#ifdef __BORLANDC__
-#define SLJIT_CALL __msfastcall
-#else /* __BORLANDC__ */
#define SLJIT_CALL __fastcall
-#endif /* __BORLANDC__ */
#define SLJIT_X86_32_FASTCALL 1
-#else /* defined(_WIN32) */
-#define SLJIT_CALL __stdcall
+#elif defined(__BORLANDC__)
+
+#define SLJIT_CALL __msfastcall
+#define SLJIT_X86_32_FASTCALL 1
+
+#else /* Unknown compiler. */
+
+/* The cdecl attribute is the default. */
+#define SLJIT_CALL
+
#endif
-#else /* Other architectures. */
+#else /* Non x86-32 architectures. */
#define SLJIT_CALL
@@ -319,13 +363,18 @@ typedef long int sljit_w;
#if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
-/* These macros are useful for the application. */
+/* These macros are useful for the applications. */
#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
- || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
- || (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
+ || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+
+#ifdef __LITTLE_ENDIAN__
+#define SLJIT_LITTLE_ENDIAN 1
+#else
#define SLJIT_BIG_ENDIAN 1
+#endif
-#elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
+#elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
+ || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
#ifdef __MIPSEL__
#define SLJIT_LITTLE_ENDIAN 1
@@ -333,6 +382,10 @@ typedef long int sljit_w;
#define SLJIT_BIG_ENDIAN 1
#endif
+#elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
+
+#define SLJIT_BIG_ENDIAN 1
+
#else
#define SLJIT_LITTLE_ENDIAN 1
#endif
@@ -349,7 +402,8 @@ typedef long int sljit_w;
#endif
#ifndef SLJIT_INDIRECT_CALL
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32 && defined _AIX)
+#if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)) \
+ || ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX)
/* It seems certain ppc compilers use an indirect addressing for functions
which makes things complicated. */
#define SLJIT_INDIRECT_CALL 1
@@ -386,6 +440,7 @@ typedef long int sljit_w;
|| (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
|| (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)
#define SLJIT_UNALIGNED 1
@@ -396,21 +451,33 @@ typedef long int sljit_w;
#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
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_unused_memory_exec(void);
#define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size)
#define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
#endif
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG) || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
#include <stdio.h>
#endif
#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
-/* Feel free to redefine these two macros. */
-#ifndef SLJIT_ASSERT
+#if !defined(SLJIT_ASSERT) || !defined(SLJIT_ASSERT_STOP)
+
+/* SLJIT_HALT_PROCESS must halt the process. */
+#ifndef SLJIT_HALT_PROCESS
+#include <stdlib.h>
#define SLJIT_HALT_PROCESS() \
- *((int*)0) = 0
+ abort();
+#endif /* !SLJIT_HALT_PROCESS */
+
+#include <stdio.h>
+
+#endif /* !SLJIT_ASSERT || !SLJIT_ASSERT_STOP */
+
+/* Feel free to redefine these two macros. */
+#ifndef SLJIT_ASSERT
#define SLJIT_ASSERT(x) \
do { \
@@ -434,6 +501,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
#else /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
+/* Forcing empty, but valid statements. */
#undef SLJIT_ASSERT
#undef SLJIT_ASSERT_STOP
View
51 sys/external/bsd/sljit/dist/sljit_src/sljitExecAllocator.c
@@ -52,7 +52,7 @@
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.
@@ -83,7 +83,7 @@
static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
{
- return VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
+ return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
}
static SLJIT_INLINE void free_chunk(void* chunk, sljit_uw size)
@@ -94,11 +94,20 @@ static SLJIT_INLINE void free_chunk(void* chunk, sljit_uw size)
#else
-#include <sys/mman.h>
-
static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
{
- void* retval = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
+ void* retval;
+
+#ifdef MAP_ANON
+ retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
+#else
+ if (dev_zero < 0) {
+ if (open_dev_zero())
+ return NULL;
+ }
+ retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, dev_zero, 0);
+#endif
+
return (retval != MAP_FAILED) ? retval : NULL;
}
@@ -202,7 +211,10 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
chunk_size = (size + sizeof(struct block_header) + CHUNK_SIZE - 1) & CHUNK_MASK;
header = (struct block_header*)alloc_chunk(chunk_size);
- PTR_FAIL_IF(!header);
+ if (!header) {
+ allocator_release_lock();
+ return NULL;
+ }
chunk_size -= sizeof(struct block_header);
total_size += chunk_size;
@@ -237,14 +249,14 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
struct free_block* free_block;
allocator_grab_lock();
- header = AS_BLOCK_HEADER(ptr, -(sljit_w)sizeof(struct block_header));
+ header = AS_BLOCK_HEADER(ptr, -(sljit_sw)sizeof(struct block_header));
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_w)header->prev_size);
+ 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);
@@ -275,3 +287,26 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
allocator_release_lock();
}
+
+SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void)
+{
+ struct free_block* free_block;
+ struct free_block* next_free_block;
+
+ allocator_grab_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 block_header));
+ }
+ free_block = next_free_block;
+ }
+
+ SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks));
+ allocator_release_lock();
+}
View
663 sys/external/bsd/sljit/dist/sljit_src/sljitLir.c
@@ -83,13 +83,16 @@
#if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
#define GET_OPCODE(op) \
- ((op) & ~(SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
+ ((op) & ~(SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
#define GET_FLAGS(op) \
- ((op) & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C))
+ ((op) & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C))
#define GET_ALL_FLAGS(op) \
- ((op) & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
+ ((op) & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
+
+#define TYPE_CAST_NEEDED(op) \
+ (((op) >= SLJIT_MOV_UB && (op) <= SLJIT_MOV_SH) || ((op) >= SLJIT_MOVU_UB && (op) <= SLJIT_MOVU_SH))
#define BUF_SIZE 4096
@@ -99,130 +102,180 @@
#define ABUF_SIZE 4096
#endif
+/* Parameter parsing. */
+#define REG_MASK 0x3f
+#define OFFS_REG(reg) (((reg) >> 8) & REG_MASK)
+#define OFFS_REG_MASK (REG_MASK << 8)
+#define TO_OFFS_REG(reg) ((reg) << 8)
+/* When reg cannot be unused. */
+#define FAST_IS_REG(reg) ((reg) <= REG_MASK)
+/* When reg can be unused. */
+#define SLOW_IS_REG(reg) ((reg) > 0 && (reg) <= REG_MASK)
+
/* Jump flags. */
#define JUMP_LABEL 0x1
#define JUMP_ADDR 0x2
/* SLJIT_REWRITABLE_JUMP is 0x1000. */
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- #define PATCH_MB 0x4
- #define PATCH_MW 0x8
+# define PATCH_MB 0x4
+# define PATCH_MW 0x8
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- #define PATCH_MD 0x10
+# define PATCH_MD 0x10
#endif
#endif
#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
- #define IS_BL 0x4
- #define PATCH_B 0x8
+# define IS_BL 0x4
+# define PATCH_B 0x8
#endif
#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
- #define CPOOL_SIZE 512
+# define CPOOL_SIZE 512
#endif
#if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
- #define IS_COND 0x04
- #define IS_BL 0x08
- /* cannot be encoded as branch */
- #define B_TYPE0 0x00
+# define IS_COND 0x04
+# define IS_BL 0x08
/* conditional + imm8 */
- #define B_TYPE1 0x10
+# define PATCH_TYPE1 0x10
/* conditional + imm20 */
- #define B_TYPE2 0x20
+# define PATCH_TYPE2 0x20
/* IT + imm24 */
- #define B_TYPE3 0x30
+# define PATCH_TYPE3 0x30
/* imm11 */
- #define B_TYPE4 0x40
+# define PATCH_TYPE4 0x40
/* imm24 */
- #define B_TYPE5 0x50
+# define PATCH_TYPE5 0x50
/* BL + imm24 */
- #define BL_TYPE6 0x60
+# define PATCH_BL 0x60
/* 0xf00 cc code for branches */
#endif
+#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
+# define IS_COND 0x004
+# define IS_CBZ 0x008
+# define IS_BL 0x010
+# define PATCH_B 0x020
+# define PATCH_COND 0x040
+# define PATCH_ABS48 0x080
+# define PATCH_ABS64 0x100
+#endif
+
#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- #define UNCOND_B 0x04
- #define PATCH_B 0x08
- #define ABSOLUTE_B 0x10
+# define IS_COND 0x004
+# define IS_CALL 0x008
+# define PATCH_B 0x010
+# define PATCH_ABS_B 0x020
+#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+# define PATCH_ABS32 0x040
+# define PATCH_ABS48 0x080
+#endif
+# define REMOVE_COND 0x100
#endif
-#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
- #define IS_MOVABLE 0x04
- #define IS_JAL 0x08
- #define IS_BIT26_COND 0x10
- #define IS_BIT16_COND 0x20
+#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
+# define IS_MOVABLE 0x004
+# define IS_JAL 0x008
+# define IS_CALL 0x010
+# define IS_BIT26_COND 0x020
+# define IS_BIT16_COND 0x040
- #define IS_COND (IS_BIT26_COND | IS_BIT16_COND)
+# define IS_COND (IS_BIT26_COND | IS_BIT16_COND)
- #define PATCH_B 0x40
- #define PATCH_J 0x80
+# define PATCH_B 0x080
+# define PATCH_J 0x100
+
+#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
+# define PATCH_ABS32 0x200
+# define PATCH_ABS48 0x400
+#endif
/* instruction types */
- #define MOVABLE_INS 0
+# define MOVABLE_INS 0
/* 1 - 31 last destination register */
/* no destination (i.e: store) */
- #define UNMOVABLE_INS 32
+# define UNMOVABLE_INS 32
/* FPU status register */
- #define FCSR_FCC 33
+# define FCSR_FCC 33
+#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)
- #define IS_MOVABLE 0x04
- #define IS_COND 0x08
- #define IS_CALL 0x10
+# define IS_MOVABLE 0x04
+# define IS_COND 0x08
+# define IS_CALL 0x10
- #define PATCH_B 0x20
- #define PATCH_CALL 0x40
+# define PATCH_B 0x20
+# define PATCH_CALL 0x40
/* instruction types */
- #define MOVABLE_INS 0
+# define MOVABLE_INS 0
/* 1 - 31 last destination register */
/* no destination (i.e: store) */
- #define UNMOVABLE_INS 32
+# define UNMOVABLE_INS 32
- #define DST_INS_MASK 0xff
+# define DST_INS_MASK 0xff
/* ICC_SET is the same as SET_FLAGS. */
- #define ICC_IS_SET (1 << 23)
- #define FCC_IS_SET (1 << 24)
+# define ICC_IS_SET (1 << 23)
+# define FCC_IS_SET (1 << 24)
#endif
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
#define SLJIT_HAS_VARIABLE_LOCALS_OFFSET 1
+#if !(defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
+#define FIXED_LOCALS_OFFSET (3 * sizeof(sljit_sw))
+#endif
#endif
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
#ifdef _WIN64
-#define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w))
+#define FIXED_LOCALS_OFFSET ((4 + 2) * sizeof(sljit_sw))
#else
-#define FIXED_LOCALS_OFFSET (sizeof(sljit_w))
+#define FIXED_LOCALS_OFFSET (sizeof(sljit_sw))
+#endif
#endif
+
+#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
+#define SLJIT_HAS_VARIABLE_LOCALS_OFFSET 1
#endif
#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
-#define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
+#ifdef _AIX
+#define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_sw))
#else
-#define FIXED_LOCALS_OFFSET (2 * sizeof(sljit_w))
+#define FIXED_LOCALS_OFFSET (2 * sizeof(sljit_sw))
#endif
#endif
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
+#define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_sw))
#endif
#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_w))
+#define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_sw))
+#endif
+
+#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
+#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
+#define FIXED_LOCALS_OFFSET 0
#endif
#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#define FIXED_LOCALS_OFFSET (23 * sizeof(sljit_w))
+#define FIXED_LOCALS_OFFSET (23 * sizeof(sljit_sw))
#endif
#if (defined SLJIT_HAS_VARIABLE_LOCALS_OFFSET && SLJIT_HAS_VARIABLE_LOCALS_OFFSET)
@@ -264,7 +317,7 @@
#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || ((defined SLJIT_SSE2 && SLJIT_SSE2) && ((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)))
#define SLJIT_NEEDS_COMPILER_INIT 1
-static int compiler_initialized = 0;
+static sljit_si compiler_initialized = 0;
/* A thread safe initialization. */
static void init_compiler(void);
#endif
@@ -277,11 +330,18 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
SLJIT_ZEROMEM(compiler, sizeof(struct sljit_compiler));
SLJIT_COMPILE_ASSERT(
- sizeof(sljit_b) == 1 && sizeof(sljit_ub) == 1
- && sizeof(sljit_h) == 2 && sizeof(sljit_uh) == 2
- && sizeof(sljit_i) == 4 && sizeof(sljit_ui) == 4
- && ((sizeof(sljit_w) == 4 && sizeof(sljit_uw) == 4) || (sizeof(sljit_w) == 8 && sizeof(sljit_uw) == 8)),
+ sizeof(sljit_sb) == 1 && sizeof(sljit_ub) == 1
+ && sizeof(sljit_sh) == 2 && sizeof(sljit_uh) == 2
+ && sizeof(sljit_si) == 4 && sizeof(sljit_ui) == 4
+ && (sizeof(sljit_p) == 4 || sizeof(sljit_p) == 8)
+ && sizeof(sljit_p) <= sizeof(sljit_sw)
+ && (sizeof(sljit_sw) == 4 || sizeof(sljit_sw) == 8)
+ && (sizeof(sljit_uw) == 4 || sizeof(sljit_uw) == 8),
invalid_integer_types);
+ SLJIT_COMPILE_ASSERT(SLJIT_INT_OP == SLJIT_SINGLE_OP,
+ int_op_and_single_op_must_be_the_same);
+ SLJIT_COMPILE_ASSERT(SLJIT_REWRITABLE_JUMP != SLJIT_SINGLE_OP,
+ rewritable_jump_and_single_op_must_not_be_the_same);
/* Only the non-zero members must be set. */
compiler->error = SLJIT_SUCCESS;
@@ -303,7 +363,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
compiler->abuf->next = NULL;
compiler->abuf->used_size = 0;
- compiler->temporaries = -1;
+ compiler->scratches = -1;
compiler->saveds = -1;
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
@@ -322,7 +382,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
compiler->cpool_diff = 0xffffffff;
#endif
-#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
+#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
compiler->delay_slot = UNMOVABLE_INS;
#endif
@@ -397,8 +457,6 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sl
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target)
{
if (SLJIT_LIKELY(!!jump)) {
- SLJIT_ASSERT(jump->flags & SLJIT_REWRITABLE_JUMP);
-
jump->flags &= ~JUMP_LABEL;
jump->flags |= JUMP_ADDR;
jump->u.target = target;
@@ -409,12 +467,13 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw
/* Private functions */
/* --------------------------------------------------------------------- */
-static void* ensure_buf(struct sljit_compiler *compiler, int size)
+static void* ensure_buf(struct sljit_compiler *compiler, sljit_uw size)
{
sljit_ub *ret;
struct sljit_memory_fragment *new_frag;
- if (compiler->buf->used_size + size <= (int)(BUF_SIZE - sizeof(sljit_uw) - sizeof(void*))) {
+ SLJIT_ASSERT(size <= 256);
+ if (compiler->buf->used_size + size <= (BUF_SIZE - (sljit_uw)SLJIT_OFFSETOF(struct sljit_memory_fragment, memory))) {
ret = compiler->buf->memory + compiler->buf->used_size;
compiler->buf->used_size += size;
return ret;
@@ -427,12 +486,13 @@ static void* ensure_buf(struct sljit_compiler *compiler, int size)
return new_frag->memory;
}
-static void* ensure_abuf(struct sljit_compiler *compiler, int size)
+static void* ensure_abuf(struct sljit_compiler *compiler, sljit_uw size)
{
sljit_ub *ret;
struct sljit_memory_fragment *new_frag;
- if (compiler->abuf->used_size + size <= (int)(ABUF_SIZE - sizeof(sljit_uw) - sizeof(void*))) {
+ SLJIT_ASSERT(size <= 256);
+ if (compiler->abuf->used_size + size <= (ABUF_SIZE - (sljit_uw)SLJIT_OFFSETOF(struct sljit_memory_fragment, memory))) {
ret = compiler->abuf->memory + compiler->abuf->used_size;
compiler->abuf->used_size += size;
return ret;
@@ -445,7 +505,7 @@ static void* ensure_abuf(struct sljit_compiler *compiler, int size)
return new_frag->memory;
}
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, int size)
+SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, sljit_si size)
{
CHECK_ERROR_PTR();
@@ -488,7 +548,7 @@ static SLJIT_INLINE void set_label(struct sljit_label *label, struct sljit_compi
compiler->last_label = label;
}
-static SLJIT_INLINE void set_jump(struct sljit_jump *jump, struct sljit_compiler *compiler, int flags)
+static SLJIT_INLINE void set_jump(struct sljit_jump *jump, struct sljit_compiler *compiler, sljit_si flags)
{
jump->next = NULL;
jump->flags = flags;
@@ -511,7 +571,7 @@ static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_comp
}
#define ADDRESSING_DEPENDS_ON(exp, reg) \
- (((exp) & SLJIT_MEM) && (((exp) & 0xf) == reg || (((exp) >> 4) & 0xf) == reg))
+ (((exp) & SLJIT_MEM) && (((exp) & REG_MASK) == reg || OFFS_REG(exp) == reg))
#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
#define FUNCTION_CHECK_OP() \
@@ -525,40 +585,53 @@ static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_comp
case SLJIT_SHL: \
case SLJIT_LSHR: \
case SLJIT_ASHR: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C))); \
+ SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C))); \
break; \
case SLJIT_NEG: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_C))); \
+ SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
break; \
case SLJIT_MUL: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_C))); \
+ SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
break; \
- case SLJIT_FCMP: \
- SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
+ case SLJIT_CMPD: \
+ SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
SLJIT_ASSERT((op & (SLJIT_SET_E | SLJIT_SET_S))); \
break; \
case SLJIT_ADD: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U))); \
+ SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_S))); \
break; \
case SLJIT_SUB: \
break; \
case SLJIT_ADDC: \
case SLJIT_SUBC: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O))); \
+ SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O))); \
break; \
- default: \
+ case SLJIT_BREAKPOINT: \
+ case SLJIT_NOP: \
+ case SLJIT_UMUL: \
+ case SLJIT_SMUL: \
+ case SLJIT_MOV: \
+ case SLJIT_MOV_UI: \
+ case SLJIT_MOV_P: \
+ case SLJIT_MOVU: \
+ case SLJIT_MOVU_UI: \
+ case SLJIT_MOVU_P: \
/* Nothing allowed */ \
- SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
+ SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
+ break; \
+ default: \
+ /* Only SLJIT_INT_OP or SLJIT_SINGLE_OP is allowed. */ \
+ SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
break; \
}
#define FUNCTION_CHECK_IS_REG(r) \
((r) == SLJIT_UNUSED || \
- ((r) >= SLJIT_TEMPORARY_REG1 && (r) <= SLJIT_TEMPORARY_REG1 - 1 + compiler->temporaries) || \
+ ((r) >= SLJIT_SCRATCH_REG1 && (r) <= SLJIT_SCRATCH_REG1 - 1 + compiler->scratches) || \
((r) >= SLJIT_SAVED_REG1 && (r) <= SLJIT_SAVED_REG1 - 1 + compiler->saveds))
#define FUNCTION_CHECK_SRC(p, i) \
- SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \
+ SLJIT_ASSERT(compiler->scratches != -1 && compiler->saveds != -1); \
if (FUNCTION_CHECK_IS_REG(p)) \
SLJIT_ASSERT((i) == 0 && (p) != SLJIT_UNUSED); \
else if ((p) == SLJIT_IMM) \
@@ -566,57 +639,54 @@ static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_comp
else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
else if ((p) & SLJIT_MEM) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
- if ((p) & 0xf0) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
+ SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & REG_MASK)); \
+ if ((p) & OFFS_REG_MASK) { \
+ SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
SLJIT_ASSERT(!((i) & ~0x3)); \
} \
- SLJIT_ASSERT(((p) >> 9) == 0); \
+ SLJIT_ASSERT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
} \
else \
SLJIT_ASSERT_STOP();
#define FUNCTION_CHECK_DST(p, i) \
- SLJIT_ASSERT(compiler->temporaries != -1 && compiler->saveds != -1); \
+ SLJIT_ASSERT(compiler->scratches != -1 && compiler->saveds != -1); \
if (FUNCTION_CHECK_IS_REG(p)) \
SLJIT_ASSERT((i) == 0); \
else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \
SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
else if ((p) & SLJIT_MEM) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
- if ((p) & 0xf0) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
+ SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & REG_MASK)); \
+ if ((p) & OFFS_REG_MASK) { \
+ SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
SLJIT_ASSERT(!((i) & ~0x3)); \
} \
- SLJIT_ASSERT(((p) >> 9) == 0); \
+ SLJIT_ASSERT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
} \
else \
SLJIT_ASSERT_STOP();
#define FUNCTION_FCHECK(p, i) \
- if ((p) >= SLJIT_FLOAT_REG1 && (p) <= SLJIT_FLOAT_REG4) \
+ if ((p) >= SLJIT_FLOAT_REG1 && (p) <= SLJIT_FLOAT_REG6) \
SLJIT_ASSERT(i == 0); \
else if ((p) & SLJIT_MEM) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \
- if ((p) & 0xf0) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \
- SLJIT_ASSERT(((p) & 0xf0) != (SLJIT_LOCALS_REG << 4) && !(i & ~0x3)); \
+ SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & REG_MASK)); \
+ if ((p) & OFFS_REG_MASK) { \
+ SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
+ SLJIT_ASSERT(((p) & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_LOCALS_REG) && !(i & ~0x3)); \
} else \
- SLJIT_ASSERT((((p) >> 4) & 0xf) == 0); \
- SLJIT_ASSERT(((p) >> 9) == 0); \
+ SLJIT_ASSERT(OFFS_REG(p) == 0); \
+ SLJIT_ASSERT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
} \
else \
SLJIT_ASSERT_STOP();
#define FUNCTION_CHECK_OP1() \
- if (GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_MOVU_SI) { \
- SLJIT_ASSERT(!GET_ALL_FLAGS(op)); \
- } \
- if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_SI) { \
- SLJIT_ASSERT(!(src & SLJIT_MEM) || (src & 0xf) != SLJIT_LOCALS_REG); \
- SLJIT_ASSERT(!(dst & SLJIT_MEM) || (dst & 0xf) != SLJIT_LOCALS_REG); \
- if ((src & SLJIT_MEM) && (src & 0xf)) \
- SLJIT_ASSERT((dst & 0xf) != (src & 0xf) && ((dst >> 4) & 0xf) != (src & 0xf)); \
+ if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_P) { \
+ SLJIT_ASSERT(!(src & SLJIT_MEM) || (src & REG_MASK) != SLJIT_LOCALS_REG); \
+ SLJIT_ASSERT(!(dst & SLJIT_MEM) || (dst & REG_MASK) != SLJIT_LOCALS_REG); \
+ if ((src & SLJIT_MEM) && (src & REG_MASK)) \
+ SLJIT_ASSERT((dst & REG_MASK) != (src & REG_MASK) && OFFS_REG(dst) != (src & REG_MASK)); \
}
#endif
@@ -629,41 +699,42 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *comp
}
static char* reg_names[] = {
- (char*)"<noreg>", (char*)"t1", (char*)"t2", (char*)"t3",
- (char*)"te1", (char*)"te2", (char*)"s1", (char*)"s2",
- (char*)"s3", (char*)"se1", (char*)"se2", (char*)"lcr"
+ (char*)"unused", (char*)"s1", (char*)"s2", (char*)"s3",
+ (char*)"se1", (char*)"se2", (char*)"p1", (char*)"p2",
+ (char*)"p3", (char*)"pe1", (char*)"pe2", (char*)"lc"
};
static char* freg_names[] = {
- (char*)"<noreg>", (char*)"float_r1", (char*)"float_r2", (char*)"float_r3", (char*)"float_r4"
+ (char*)"unused", (char*)"f1", (char*)"f2", (char*)"f3",
+ (char*)"f4", (char*)"f5", (char*)"f6"
};
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+#if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
#ifdef _WIN64
- #define SLJIT_PRINT_D "I64"
+# define SLJIT_PRINT_D "I64"
#else
- #define SLJIT_PRINT_D "l"
+# define SLJIT_PRINT_D "l"
#endif
#else
- #define SLJIT_PRINT_D ""
+# define SLJIT_PRINT_D ""
#endif
#define sljit_verbose_param(p, i) \
if ((p) & SLJIT_IMM) \
fprintf(compiler->verbose, "#%" SLJIT_PRINT_D "d", (i)); \
else if ((p) & SLJIT_MEM) { \
- if ((p) & 0xf) { \
+ if ((p) & REG_MASK) { \
if (i) { \
- if (((p) >> 4) & 0xf) \
- fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \
+ if ((p) & OFFS_REG_MASK) \
+ fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & REG_MASK], reg_names[OFFS_REG(p)], 1 << (i)); \
else \
- fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \
+ fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & REG_MASK], (i)); \
} \
else { \
- if (((p) >> 4) & 0xf) \
- fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF]); \
+ if ((p) & OFFS_REG_MASK) \
+ fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & REG_MASK], reg_names[OFFS_REG(p)]); \
else \
- fprintf(compiler->verbose, "[%s]", reg_names[(p) & 0xF]); \
+ fprintf(compiler->verbose, "[%s]", reg_names[(p) & REG_MASK]); \
} \
} \
else \
@@ -672,18 +743,18 @@ static char* freg_names[] = {
fprintf(compiler->verbose, "%s", reg_names[p]);
#define sljit_verbose_fparam(p, i) \
if ((p) & SLJIT_MEM) { \
- if ((p) & 0xf) { \
+ if ((p) & REG_MASK) { \
if (i) { \
- if (((p) >> 4) & 0xf) \
- fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \
+ if ((p) & OFFS_REG_MASK) \
+ fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & REG_MASK], reg_names[OFFS_REG(p)], 1 << (i)); \
else \
- fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \
+ fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & REG_MASK], (i)); \
} \
else { \
- if (((p) >> 4) & 0xF) \
- fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF]); \
+ if ((p) & OFFS_REG_MASK) \
+ fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & REG_MASK], reg_names[OFFS_REG(p)]); \
else \
- fprintf(compiler->verbose, "[%s]", reg_names[(p) & 0xF]); \
+ fprintf(compiler->verbose, "[%s]", reg_names[(p) & REG_MASK]); \
} \
} \
else \
@@ -697,32 +768,32 @@ static SLJIT_CONST char* op_names[] = {
(char*)"umul", (char*)"smul", (char*)"udiv", (char*)"sdiv",
/* op1 */
(char*)"mov", (char*)"mov.ub", (char*)"mov.sb", (char*)"mov.uh",
- (char*)"mov.sh", (char*)"mov.ui", (char*)"mov.si", (char*)"movu",
- (char*)"movu.ub", (char*)"movu.sb", (char*)"movu.uh", (char*)"movu.sh",
- (char*)"movu.ui", (char*)"movu.si", (char*)"not", (char*)"neg",
- (char*)"clz",
+ (char*)"mov.sh", (char*)"mov.ui", (char*)"mov.si", (char*)"mov.p",
+ (char*)"movu", (char*)"movu.ub", (char*)"movu.sb", (char*)"movu.uh",
+ (char*)"movu.sh", (char*)"movu.ui", (char*)"movu.si", (char*)"movu.p",
+ (char*)"not", (char*)"neg", (char*)"clz",
/* op2 */
(char*)"add", (char*)"addc", (char*)"sub", (char*)"subc",
(char*)"mul", (char*)"and", (char*)"or", (char*)"xor",
(char*)"shl", (char*)"lshr", (char*)"ashr",
/* fop1 */
- (char*)"fcmp", (char*)"fmov", (char*)"fneg", (char*)"fabs",
+ (char*)"cmp", (char*)"mov", (char*)"neg", (char*)"abs",
/* fop2 */
- (char*)"fadd", (char*)"fsub", (char*)"fmul", (char*)"fdiv"
+ (char*)"add", (char*)"sub", (char*)"mul", (char*)"div"
};
static char* jump_names[] = {
- (char*)"c_equal", (char*)"c_not_equal",
- (char*)"c_less", (char*)"c_greater_equal",
- (char*)"c_greater", (char*)"c_less_equal",
- (char*)"c_sig_less", (char*)"c_sig_greater_equal",
- (char*)"c_sig_greater", (char*)"c_sig_less_equal",
- (char*)"c_overflow", (char*)"c_not_overflow",
- (char*)"c_mul_overflow", (char*)"c_mul_not_overflow",
- (char*)"c_float_equal", (char*)"c_float_not_equal",
- (char*)"c_float_less", (char*)"c_float_greater_equal",
- (char*)"c_float_greater", (char*)"c_float_less_equal",
- (char*)"c_float_nan", (char*)"c_float_not_nan",
+ (char*)"equal", (char*)"not_equal",
+ (char*)"less", (char*)"greater_equal",
+ (char*)"greater", (char*)"less_equal",
+ (char*)"sig_less", (char*)"sig_greater_equal",
+ (char*)"sig_greater", (char*)"sig_less_equal",
+ (char*)"overflow", (char*)"not_overflow",
+ (char*)"mul_overflow", (char*)"mul_not_overflow",
+ (char*)"float_equal", (char*)"float_not_equal",
+ (char*)"float_less", (char*)"float_greater_equal",
+ (char*)"float_greater", (char*)"float_less_equal",
+ (char*)"float_unordered", (char*)"float_ordered",
(char*)"jump", (char*)"fast_call",
(char*)"call0", (char*)"call1", (char*)"call2", (char*)"call3"
};
@@ -752,32 +823,32 @@ static SLJIT_INLINE void check_sljit_generate_code(struct sljit_compiler *compil
#endif
}
-static SLJIT_INLINE void check_sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
+static SLJIT_INLINE void check_sljit_emit_enter(struct sljit_compiler *compiler, sljit_si args, sljit_si scratches, sljit_si saveds, sljit_si local_size)
{
/* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
SLJIT_UNUSED_ARG(args);
- SLJIT_UNUSED_ARG(temporaries);
+ SLJIT_UNUSED_ARG(scratches);
SLJIT_UNUSED_ARG(saveds);
SLJIT_UNUSED_ARG(local_size);
SLJIT_ASSERT(args >= 0 && args <= 3);
- SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);
+ SLJIT_ASSERT(scratches >= 0 && scratches <= SLJIT_NO_TMP_REGISTERS);
SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS);
SLJIT_ASSERT(args <= saveds);
SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose))
- fprintf(compiler->verbose, " enter args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size);
+ fprintf(compiler->verbose, " enter args=%d scratches=%d saveds=%d local_size=%d\n", args, scratches, saveds, local_size);
#endif
}
-static SLJIT_INLINE void check_sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
+static SLJIT_INLINE void check_sljit_set_context(struct sljit_compiler *compiler, sljit_si args, sljit_si scratches, sljit_si saveds, sljit_si local_size)
{
/* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
SLJIT_UNUSED_ARG(args);
- SLJIT_UNUSED_ARG(temporaries);
+ SLJIT_UNUSED_ARG(scratches);
SLJIT_UNUSED_ARG(saveds);
SLJIT_UNUSED_ARG(local_size);
@@ -789,17 +860,17 @@ static SLJIT_INLINE void check_sljit_set_context(struct sljit_compiler *compiler
#endif
SLJIT_ASSERT(args >= 0 && args <= 3);
- SLJIT_ASSERT(temporaries >= 0 && temporaries <= SLJIT_NO_TMP_REGISTERS);
+ SLJIT_ASSERT(scratches >= 0 && scratches <= SLJIT_NO_TMP_REGISTERS);
SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NO_GEN_REGISTERS);
SLJIT_ASSERT(args <= saveds);
SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose))
- fprintf(compiler->verbose, " set_context args=%d temporaries=%d saveds=%d local_size=%d\n", args, temporaries, saveds, local_size);
+ fprintf(compiler->verbose, " set_context args=%d scratches=%d saveds=%d local_size=%d\n", args, scratches, saveds, local_size);
#endif
}
-static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw)
+static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
{
/* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
@@ -809,7 +880,7 @@ static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler
#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (op != SLJIT_UNUSED) {
- SLJIT_ASSERT(op >= SLJIT_MOV && op <= SLJIT_MOV_SI);
+ SLJIT_ASSERT(op >= SLJIT_MOV && op <= SLJIT_MOV_P);
FUNCTION_CHECK_SRC(src, srcw);
}
else
@@ -828,7 +899,7 @@ static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler
#endif
}
-static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw)
+static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
{
/* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
@@ -847,7 +918,7 @@ static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *comp
#endif
}
-static SLJIT_INLINE void check_sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw)
+static SLJIT_INLINE void check_sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
/* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
@@ -866,7 +937,7 @@ static SLJIT_INLINE void check_sljit_emit_fast_return(struct sljit_compiler *com
#endif
}
-static SLJIT_INLINE void check_sljit_emit_op0(struct sljit_compiler *compiler, int op)
+static SLJIT_INLINE void check_sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
{
/* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
@@ -880,9 +951,9 @@ static SLJIT_INLINE void check_sljit_emit_op0(struct sljit_compiler *compiler, i
#endif
}
-static SLJIT_INLINE void check_sljit_emit_op1(struct sljit_compiler *compiler, int op,
- int dst, sljit_w dstw,
- int src, sljit_w srcw)
+static SLJIT_INLINE void check_sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op,
+ sljit_si dst, sljit_sw dstw,
+ sljit_si src, sljit_sw srcw)
{
/* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
@@ -909,7 +980,8 @@ static SLJIT_INLINE void check_sljit_emit_op1(struct sljit_compiler *compiler, i
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)],
- !(op & SLJIT_SET_E) ? "" : "E", !(op & SLJIT_SET_S) ? "" : "S", !(op & SLJIT_SET_U) ? "" : "U", !(op & SLJIT_SET_O) ? "" : "O", !(op & SLJIT_SET_C) ? "" : "C", !(op & SLJIT_KEEP_FLAGS) ? "" : "K");
+ !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_U) ? "" : ".u", !(op & SLJIT_SET_S) ? "" : ".s",
+ !(op & SLJIT_SET_O) ? "" : ".o", !(op & SLJIT_SET_C) ? "" : ".c", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k");
sljit_verbose_param(dst, dstw);
fprintf(compiler->verbose, ", ");
sljit_verbose_param(src, srcw);
@@ -918,10 +990,10 @@ static SLJIT_INLINE void check_sljit_emit_op1(struct sljit_compiler *compiler, i
#endif
}
-static SLJIT_INLINE void check_sljit_emit_op2(struct sljit_compiler *compiler, int op,
- int dst, sljit_w dstw,
- int src1, sljit_w src1w,
- int src2, sljit_w src2w)
+static SLJIT_INLINE void check_sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op,
+ sljit_si dst, sljit_sw dstw,
+ sljit_si src1, sljit_sw src1w,
+ sljit_si src2, sljit_sw src2w)
{
/* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
@@ -950,7 +1022,8 @@ static SLJIT_INLINE void check_sljit_emit_op2(struct sljit_compiler *compiler, i
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)],
- !(op & SLJIT_SET_E) ? "" : "E", !(op & SLJIT_SET_S) ? "" : "S", !(op & SLJIT_SET_U) ? "" : "U", !(op & SLJIT_SET_O) ? "" : "O", !(op & SLJIT_SET_C) ? "" : "C", !(op & SLJIT_KEEP_FLAGS) ? "" : "K");
+ !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_U) ? "" : ".u", !(op & SLJIT_SET_S) ? "" : ".s",
+ !(op & SLJIT_SET_O) ? "" : ".o", !(op & SLJIT_SET_C) ? "" : ".c", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k");
sljit_verbose_param(dst, dstw);
fprintf(compiler->verbose, ", ");
sljit_verbose_param(src1, src1w);