]> Nishi Git Mirror - gwion.git/commitdiff
:art: Make memoization optionnal
authorfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 21 Jan 2019 09:22:41 +0000 (10:22 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 21 Jan 2019 09:22:41 +0000 (10:22 +0100)
Makefile
config.mk.orig
include/memoize.h
src/emit/emit.c
src/lib/instr.c

index e8989d6bfc8262cdbb513fe637ad50b995600219..4d9a9f31bf9f3d986e8572d60c43b0bf230cf228 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -88,6 +88,9 @@ endif
 ifeq (${USE_JIT}, 1)
 include jit/config.mk
 endif
+ifeq (${USE_NOMEMOIZE}, 1)
+CFLAGS += -DNOMEMOIZE
+endif
 
 ifeq (${USE_VMBENCH}, 1)
 CFLAGS += -DVMBENCH
index 50bac7dd09f7aa96db59219c348cabbf00a3a734..17093354157e4d48e02818bb67bef106fc278e44 100644 (file)
@@ -17,18 +17,18 @@ CFLAGS += -mtune=native
 #CFLAGS += -fPIC
 
 # handle boolean options
-USE_DOUBLE    = 0
-USE_COVERAGE ?= 0
-USE_MEMCHECK ?= 0
-USE_GWREPL   ?= 0
-USE_GWUDP    ?= 0
-USE_OPTIMIZE ?= 0
-USE_OBSTACK  ?= 0
-USE_COLOR    ?= 0
-USE_JIT      ?= 0
-USE_LTO      ?= 0
-USE_VMBENCH  ?= 0
-
+USE_DOUBLE     = 0
+USE_COVERAGE  ?= 0
+USE_MEMCHECK  ?= 0
+USE_GWREPL    ?= 0
+USE_GWUDP     ?= 0
+USE_OPTIMIZE  ?= 0
+USE_OBSTACK   ?= 0
+USE_COLOR     ?= 0
+USE_JIT       ?= 0
+USE_LTO       ?= 0
+USE_VMBENCH   ?= 0
+USE_NOMEMOIZE ?= 0
 # handle definitions
 D_FUNC       ?= dummy_driver
 
index 22fc6879411d4b6485fa3cd7e83176dbbb91f80a..ab52d618e918c22d6706d364bcc5a4afa8e60126 100644 (file)
@@ -1,9 +1,18 @@
 #ifndef __MEMOIZE
 #define __MEMOIZE
+
+#ifndef NOMEMOIZE
+#define MEMOIZE_CALL  if(GET_FLAG(f, pure)) emit_add_instr(emit, MemoizeCall);
+#define MEMOIZE_STORE if(GET_FLAG(emit->env->func, pure)) emit_add_instr(emit, MemoizeStore);
+#define MEMOIZE_INI   if(GET_FLAG(func, pure)) func->code->memoize = memoize_ini(func, kindof(func->def->ret_type->size, !func->def->ret_type->size));
 typedef struct Memoize_ * Memoize;
-//m_bool memoize_get(VM_Shred shred);
 Memoize memoize_ini(const Func f, const enum Kind);
 void memoize_end(Memoize m);
 INSTR(MemoizeCall);
 INSTR(MemoizeStore);
+#else
+#define MEMOIZE_CALL
+#define MEMOIZE_STORE
+#define MEMOIZE_INI
+#endif
 #endif
index 8b59dbb17adf8c5f61bd4fa0a7ed370cfe7cbabc..09a7d48965ce9009115be5ddf5a32f978c036052 100644 (file)
@@ -674,8 +674,7 @@ ANN static m_bool emit_exp_call1_code(const Emitter emit, const Func f) {
 }
 
 ANN static Instr emit_call(const Emitter emit, const Func f) {
-  if(GET_FLAG(f, pure))
-    emit_add_instr(emit, MemoizeCall);
+  MEMOIZE_CALL
   const Type t = actual_type(f->value_ref->type);
   const f_instr exec = isa(t, t_fptr) < 0 ? GET_FLAG(f->def, builtin) ?
      GET_FLAG(f, member) ? FuncMember : FuncStatic : FuncUsr : FuncPtr;
@@ -1480,8 +1479,7 @@ ANN static void emit_func_def_return(const Emitter emit) { GWDEBUG_EXE
   }
   vector_clear(&emit->code->stack_return);
   emit_pop_scope(emit);
-  if(GET_FLAG(emit->env->func, pure))
-    emit_add_instr(emit, MemoizeStore);
+  MEMOIZE_STORE
   emit_add_instr(emit, FuncReturn);
 }
 
@@ -1531,8 +1529,7 @@ ANN static m_bool emit_func_def(const Emitter emit, const Func_Def func_def) { G
   emit_func_def_code(emit, func);
   emit->env->func = former;
   emit_pop_code(emit);
-  if(GET_FLAG(func, pure))
-    func->code->memoize = memoize_ini(func, kindof(func->def->ret_type->size, !func->def->ret_type->size));
+  MEMOIZE_INI
   return GW_OK;
 }
 
index 1b657cdc294d1507da9dae6ee33d5f6198246a2b..dcc5eb80cc1889d3f6d613828d3fba5d4a0e0536 100644 (file)
@@ -69,7 +69,6 @@ INSTR(RegPush##name) { GWDEBUG_EXE               \
   PUSH_REG(shred, size);                         \
 }
 
-describe_regpushimmxxx(Imm,  m_int,   SZ_INT)
 describe_regpushimmxxx(Imm2, m_float, SZ_FLOAT)
 INSTR(RegPushImm3) { GWDEBUG_EXE
   memcpy(REG(0), instr->ptr, instr->m_val2);