Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/sljit/dist Initial import of sljit @ r175.
details: https://anonhg.NetBSD.org/src/rev/c680452ff7c0
branches: trunk
changeset: 781913:c680452ff7c0
user: alnsn <alnsn%NetBSD.org@localhost>
date: Sat Oct 06 18:24:18 2012 +0000
description:
Initial import of sljit @ r175.
svn co https://sljit.svn.sourceforge.net/svnroot/sljit@r175 dist
diffstat:
sys/external/bsd/sljit/dist/Makefile | 53 +
sys/external/bsd/sljit/dist/README | 22 +
sys/external/bsd/sljit/dist/regex_src/regexJIT.c | 2591 ++++++
sys/external/bsd/sljit/dist/regex_src/regexJIT.h | 98 +
sys/external/bsd/sljit/dist/regex_src/regexMain.c | 293 +
sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h | 109 +
sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h | 432 +
sys/external/bsd/sljit/dist/sljit_src/sljitExecAllocator.c | 277 +
sys/external/bsd/sljit/dist/sljit_src/sljitLir.c | 1682 ++++
sys/external/bsd/sljit/dist/sljit_src/sljitLir.h | 863 ++
sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_Thumb2.c | 1939 +++++
sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_v5.c | 2456 ++++++
sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_32.c | 405 +
sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_common.c | 1831 ++++
sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_32.c | 262 +
sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_64.c | 419 +
sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c | 1920 +++++
sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_32.c | 523 +
sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_64.c | 790 ++
sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c | 2683 +++++++
sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c | 280 +
sys/external/bsd/sljit/dist/test_src/sljitMain.c | 86 +
sys/external/bsd/sljit/dist/test_src/sljitTest.c | 3771 ++++++++++
23 files changed, 23785 insertions(+), 0 deletions(-)
diffs (truncated from 23877 to 300 lines):
diff -r 32af0b839921 -r c680452ff7c0 sys/external/bsd/sljit/dist/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/sljit/dist/Makefile Sat Oct 06 18:24:18 2012 +0000
@@ -0,0 +1,53 @@
+# default compier
+CC = gcc
+
+# Cross compiler for ARM
+#CC = arm-linux-gcc
+
+# Cross compiler for PPC
+#CC = powerpc-linux-gnu-gcc
+
+# Cross compiler for PPC-64
+#CC = powerpc64-unknown-linux-gnu-gcc
+
+CFLAGS = -O2 -Wall -DSLJIT_CONFIG_AUTO=1
+LDFLAGS=
+
+TARGET = sljit_test regex_test
+
+BINDIR = bin
+SRCDIR = sljit_src
+TESTDIR = test_src
+REGEXDIR = regex_src
+
+CFLAGS += -Isljit_src
+REGEX_CFLAGS = -fshort-wchar
+
+all: $(BINDIR) $(TARGET)
+
+$(BINDIR) :
+ mkdir $(BINDIR)
+
+$(BINDIR)/sljitLir.o : $(addprefix $(SRCDIR)/, sljitLir.c sljitLir.h sljitConfig.h sljitExecAllocator.c sljitNativeX86_common.c sljitNativeX86_32.c sljitNativeX86_64.c sljitNativeARM_v5.c
sljitNativeARM_Thumb2.c sljitNativePPC_common.c sljitNativePPC_32.c sljitNativePPC_64.c sljitNativeMIPS_common.c sljitNativeMIPS_32.c) $(BINDIR)
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(BINDIR)/sljitMain.o : $(TESTDIR)/sljitMain.c $(BINDIR) $(SRCDIR)/sljitLir.h $(SRCDIR)/sljitConfig.h
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(BINDIR)/sljitTest.o : $(TESTDIR)/sljitTest.c $(BINDIR) $(SRCDIR)/sljitLir.h $(SRCDIR)/sljitConfig.h
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(BINDIR)/regexMain.o : $(REGEXDIR)/regexMain.c $(BINDIR) $(REGEXDIR)/regexJIT.h $(SRCDIR)/sljitConfig.h
+ $(CC) $(CFLAGS) $(REGEX_CFLAGS) -c -o $@ $<
+
+$(BINDIR)/regexJIT.o : $(REGEXDIR)/regexJIT.c $(BINDIR) $(SRCDIR)/sljitLir.h $(SRCDIR)/sljitConfig.h $(REGEXDIR)/regexJIT.h
+ $(CC) $(CFLAGS) $(REGEX_CFLAGS) -c -o $@ $<
+
+clean:
+ rm -f $(BINDIR)/*.o $(addprefix $(BINDIR)/, $(TARGET))
+
+sljit_test: $(addprefix $(BINDIR)/, sljitMain.o sljitTest.o sljitLir.o)
+ $(CC) $(LDFLAGS) $^ -o $(BINDIR)/$@ -lm
+
+regex_test: $(addprefix $(BINDIR)/, regexMain.o regexJIT.o sljitLir.o)
+ $(CC) $(LDFLAGS) $^ -o $(BINDIR)/$@ -lm
diff -r 32af0b839921 -r c680452ff7c0 sys/external/bsd/sljit/dist/README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/sljit/dist/README Sat Oct 06 18:24:18 2012 +0000
@@ -0,0 +1,22 @@
+
+ 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.
+
+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.
+
+More info:
+ http://sljit.sourceforge.net/
+
+Contact:
+ hzmester%freemail.hu@localhost
diff -r 32af0b839921 -r c680452ff7c0 sys/external/bsd/sljit/dist/regex_src/regexJIT.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/sljit/dist/regex_src/regexJIT.c Sat Oct 06 18:24:18 2012 +0000
@@ -0,0 +1,2591 @@
+/*
+ * Stack-less Just-In-Time compiler
+ *
+ * Copyright 2009-2010 Zoltan Herczeg (hzmester%freemail.hu@localhost). 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.
+ */
+
+#include "sljitLir.h"
+#include "regexJIT.h"
+
+#ifdef REGEX_MATCH_VERBOSE
+#include <stdio.h>
+#endif
+
+/* Extra, hidden flags:
+ {id!} where id > 0 found in the code. */
+#define REGEX_ID_CHECK 0x100
+/* When REGEX_NEWLINE && REGEX_MATCH_BEGIN defined, the pattern turn to a normal search,
+ which starts with [\r\n] character range. */
+#define REGEX_FAKE_MATCH_BEGIN 0x200
+/* When REGEX_NEWLINE && REGEX_MATCH_END defined, the pattern turn to a normal search,
+ which ends with [\r\n] character range. */
+#define REGEX_FAKE_MATCH_END 0x400
+
+/* Check match completition after every (FINISH_TEST + 1) steps. */
+#define FINISH_TEST 0x7
+
+/* --------------------------------------------------------------------- */
+/* Structures for JIT-ed pattern matching */
+/* --------------------------------------------------------------------- */
+
+struct regex_machine
+{
+ /* flags. */
+ int flags;
+ /* Number of state descriptors for one term. */
+ sljit_w no_states;
+ /* Total size. */
+ sljit_w size;
+
+ union {
+ void *init_match;
+ sljit_w (SLJIT_CALL *call_init)(void *next, void* match);
+ } u;
+#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
+ struct sljit_function_context context;
+#endif
+
+ void *continue_match;
+
+ /* Variable sized array to contain the handler addresses. */
+ sljit_uw entry_addrs[1];
+};
+
+struct regex_match
+{
+ /* Current and next state array. */
+ sljit_w *current;
+ sljit_w *next;
+ /* Starting. */
+ sljit_w head;
+ /* String character index (ever increasing). */
+ sljit_w index;
+ /* Best match found so far (members in priority order). */
+ sljit_w best_begin;
+ sljit_w best_end;
+ sljit_w best_id;
+ /* Bool flags (encoded as word). */
+ sljit_w fast_quit;
+ sljit_w fast_forward;
+ /* Machine. */
+ struct regex_machine *machine;
+
+ union {
+ void *continue_match;
+ void (SLJIT_CALL *call_continue)(struct regex_match *match, const regex_char_t *input_string, int length);
+ } u;
+
+ /* Variable sized array to contain the state arrays. */
+ sljit_w states[1];
+};
+
+/* State vector
+ ITEM[0] - pointer to the address inside the machine code
+ ITEM[1] - next pointer
+ ITEM[2] - string started from (optional)
+ ITEM[3] - max ID (optional) */
+
+/* Register allocation. */
+/* Current state array (loaded & stored: regex_match->current). */
+#define R_CURR_STATE SLJIT_SAVED_REG1
+/* Next state array (loaded & stored: regex_match->next). */
+#define R_NEXT_STATE SLJIT_SAVED_REG2
+/* Head (loaded & stored: regex_match->head). */
+#define R_NEXT_HEAD SLJIT_SAVED_REG3
+/* String fragment pointer. */
+#define R_STRING SLJIT_SAVED_EREG1
+/* String fragment length. */
+#define R_LENGTH SLJIT_SAVED_EREG2
+/* 'struct regex_match*' */
+#define R_REGEX_MATCH SLJIT_TEMPORARY_REG1
+/* Current character. */
+#define R_CURR_CHAR SLJIT_TEMPORARY_REG2
+/* Temporary register. */
+#define R_TEMP SLJIT_TEMPORARY_REG3
+/* Caches the regex_match->best_begin. */
+#define R_BEST_BEGIN SLJIT_TEMPORARY_EREG1
+/* Current character index. */
+#define R_CURR_INDEX SLJIT_TEMPORARY_EREG2
+
+/* --------------------------------------------------------------------- */
+/* Stack management */
+/* --------------------------------------------------------------------- */
+
+/* Try to allocate 2^n blocks. */
+#define STACK_FRAGMENT_SIZE (((64 * sizeof(struct stack_item)) - (sizeof(struct stack_fragment_data))) / (sizeof(struct stack_item)))
+
+struct stack_item {
+ int type;
+ int value;
+};
+
+struct stack_fragment_data {
+ struct stack_fragment *next;
+ struct stack_fragment *prev;
+};
+
+struct stack_fragment {
+ struct stack_fragment_data data;
+ struct stack_item items[STACK_FRAGMENT_SIZE];
+};
+
+struct stack {
+ struct stack_fragment *first;
+ struct stack_fragment *last;
+ int index;
+ int count;
+};
+
+#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+
+static void stack_check(struct stack *stack)
+{
+ struct stack_fragment *curr;
+ int found;
+
+ if (!stack)
+ return;
+
+ SLJIT_ASSERT(stack->index >= 0 && stack->index < STACK_FRAGMENT_SIZE);
+
+ if (stack->first == NULL) {
+ SLJIT_ASSERT(stack->first == NULL && stack->last == NULL);
+ SLJIT_ASSERT(stack->index == STACK_FRAGMENT_SIZE - 1 && stack->count == 0);
+ return;
+ }
+
+ found = 0;
+ if (stack->last == NULL) {
+ SLJIT_ASSERT(stack->index == STACK_FRAGMENT_SIZE - 1 && stack->count == 0);
+ found = 1;
+ }
+ else
+ SLJIT_ASSERT(stack->index >= 0 && stack->count >= 0);
+
+ SLJIT_ASSERT(stack->first->data.prev == NULL);
+ curr = stack->first;
+ while (curr) {
+ if (curr == stack->last)
+ found = 1;
+ if (curr->data.next)
+ SLJIT_ASSERT(curr->data.next->data.prev == curr);
+ curr = curr->data.next;
+ }
+ SLJIT_ASSERT(found);
+}
+
+#endif
+
+static void stack_init(struct stack *stack)
+{
+ stack->first = NULL;
+ stack->last = NULL;
+ stack->index = STACK_FRAGMENT_SIZE - 1;
+ stack->count = 0;
+}
+
+static void stack_destroy(struct stack *stack)
+{
+ struct stack_fragment *curr = stack->first;
+ struct stack_fragment *prev;
+
+#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+ stack_check(stack);
Home |
Main Index |
Thread Index |
Old Index