]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
Add the "--dont-fold" option to Dynamic Pascal, so that we can run
authorRhys Weatherley <rweather@southern-storm.com.au>
Wed, 12 May 2004 07:33:45 +0000 (07:33 +0000)
committerRhys Weatherley <rweather@southern-storm.com.au>
Wed, 12 May 2004 07:33:45 +0000 (07:33 +0000)
the test cases without folding.

ChangeLog
dpas/dpas-main.c
include/jit/jit-context.h
jit/jit-context.c
jit/jit-insn.c
tests/Makefile.am

index 9ab07a1604095c5bf98001b8af7a28cae1bb0ebb..59315e932f1ea6b506dc38ca723f56d5fed43841 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        * 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  <rweather@southern-storm.com.au>
 
        * include/jit/jit-insn.h, jit/jit-insn.c, jit/jit-interp.cpp,
index 737e35524edcb4d86c02e8fceeca847159af4d6a..7c762a8e310cc024c2bbf4ff2c2d9888e1578239 100644 (file)
@@ -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);
+       }
 }
index 3acedeba673aaa0a810fbeda2f18cafe906dfe9b..33ff8ed125c8f98ab6ed8cb11a6bf42075b42e7a 100644 (file)
@@ -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
 };
index 8cf099fe97ee33de1aba8d49c53b10d0e3d1a59b..4856d11e8bb0634580791ec13bbc2820ed2a0c01 100644 (file)
@@ -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.
index 1822676011b195f2ca18dd8c7ebed6f7fbefbd86..9d0b590130530189caaa628fea7501edcb64f363 100644 (file)
@@ -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);
index bdb7ad5e1ade0677ab14eeba3908f7b1fd0a0cd8..965b787fbd9c50cab23db167d4dbf91e4e8faf05 100644 (file)
@@ -1,4 +1,4 @@
 
 TESTS = coerce.pas \
                math.pas
-TESTS_ENVIRONMENT = $(top_builddir)/dpas/dpas
+TESTS_ENVIRONMENT = $(top_builddir)/dpas/dpas --dont-fold