From: Rhys Weatherley Date: Wed, 12 May 2004 07:33:45 +0000 (+0000) Subject: Add the "--dont-fold" option to Dynamic Pascal, so that we can run X-Git-Tag: r.0.0.2~3 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=77420753380280b45b2bd019678c19e9e548ffdc;p=francis%2Flibjit.git Add the "--dont-fold" option to Dynamic Pascal, so that we can run the test cases without folding. --- diff --git a/ChangeLog b/ChangeLog index 9ab07a1..59315e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,10 @@ * dpas/dpas-parser.y, jit/jit-interp.cpp, tests/Makefile.am, tests/math.pas: test cases and bug fixes for mathematical operations. + * dpas/dpas-main.c, include/jit/jit-context.h, jit/jit-context.c, + jit/jit-insn.c, tests/Makefile.am: add the "--dont-fold" option + to Dynamic Pascal, so that we can run the test cases without folding. + 2004-05-11 Rhys Weatherley * include/jit/jit-insn.h, jit/jit-insn.c, jit/jit-interp.cpp, diff --git a/dpas/dpas-main.c b/dpas/dpas-main.c index 737e355..7c762a8 100644 --- a/dpas/dpas-main.c +++ b/dpas/dpas-main.c @@ -31,6 +31,7 @@ static char **include_dirs = 0; static int num_include_dirs = 0; static char **using_seen = 0; static int num_using_seen = 0; +static int dont_fold = 0; /* * Forward declarations. @@ -81,6 +82,10 @@ int main(int argc, char **argv) { dpas_dump_functions = 2; } + else if(!jit_strcmp(argv[1], "--dont-fold")) + { + dont_fold = 1; + } else { usage(); @@ -277,4 +282,9 @@ static void initialize(void) { jit_init(); dpas_init_types(); + if(dont_fold) + { + jit_context_set_meta_numeric + (dpas_current_context(), JIT_OPTION_DONT_FOLD, 1); + } } diff --git a/include/jit/jit-context.h b/include/jit/jit-context.h index 3acedeb..33ff8ed 100644 --- a/include/jit/jit-context.h +++ b/include/jit/jit-context.h @@ -48,6 +48,7 @@ void jit_context_free_meta(jit_context_t context, int type) JIT_NOTHROW; #define JIT_OPTION_CACHE_LIMIT 10000 #define JIT_OPTION_CACHE_PAGE_SIZE 10001 #define JIT_OPTION_PRE_COMPILE 10002 +#define JIT_OPTION_DONT_FOLD 10003 #ifdef __cplusplus }; diff --git a/jit/jit-context.c b/jit/jit-context.c index 8cf099f..4856d11 100644 --- a/jit/jit-context.c +++ b/jit/jit-context.c @@ -207,6 +207,12 @@ int jit_context_set_meta * pre-compiled contexts cannot be executed directly. Instead, they * can be written out to disk in ELF format to be reloaded at * some future time. + * + * @vindex JIT_OPTION_DONT_FOLD + * @item JIT_OPTION_DONT_FOLD + * A numeric option that disables constant folding when it is set to a + * non-zero value. This is useful for debugging, as it forces @code{libjit} to + * always execute constant expressions at run time, instead of at compile time. * @end table * * Metadata type values of 10000 or greater are reserved for internal use. diff --git a/jit/jit-insn.c b/jit/jit-insn.c index 1822676..9d0b590 100644 --- a/jit/jit-insn.c +++ b/jit/jit-insn.c @@ -5426,7 +5426,8 @@ jit_value_t jit_insn_call_intrinsic } /* If the arguments are constant, then invoke the intrinsic now */ - if(jit_value_is_constant(arg1) && (!arg2 || jit_value_is_constant(arg2))) + if(jit_value_is_constant(arg1) && (!arg2 || jit_value_is_constant(arg2)) && + !jit_context_get_meta_numeric(func->context, JIT_OPTION_DONT_FOLD)) { const1 = jit_value_get_constant(arg1); const2 = jit_value_get_constant(arg2); diff --git a/tests/Makefile.am b/tests/Makefile.am index bdb7ad5..965b787 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ TESTS = coerce.pas \ math.pas -TESTS_ENVIRONMENT = $(top_builddir)/dpas/dpas +TESTS_ENVIRONMENT = $(top_builddir)/dpas/dpas --dont-fold