From c05d414844f6e1e0af05ef0cbcabe3313f5089d0 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 5 Sep 2019 17:24:02 +0200 Subject: [PATCH] emit fixnum constants as immediates --- src/comp.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/comp.c b/src/comp.c index 4f40d83f82b..ebc4e8fba0e 100644 --- a/src/comp.c +++ b/src/comp.c @@ -1013,12 +1013,24 @@ emit_PURE_P (gcc_jit_rvalue *ptr) static gcc_jit_rvalue * emit_mvar_val (Lisp_Object mvar) { + Lisp_Object const_vld = FUNCALL1 (comp-mvar-const-vld, mvar); + Lisp_Object constant = FUNCALL1 (comp-mvar-constant, mvar); - if (NILP (FUNCALL1 (comp-mvar-slot, mvar))) + if (!NILP (const_vld)) { - /* If the slot is not specified this must be a constant. */ - eassert (!NILP (FUNCALL1 (comp-mvar-const-vld, mvar))); - return emit_const_lisp_obj (FUNCALL1 (comp-mvar-constant, mvar)); + if (FIXNUMP (constant)) + { + /* We can still emit directly objects that are selfcontained in a word + read (fixnums). */ + emit_comment (SSDATA (Fprin1_to_string (constant, Qnil))); + gcc_jit_rvalue *word = + gcc_jit_context_new_rvalue_from_ptr(comp.ctxt, + comp.void_ptr_type, + constant); + return emit_cast (comp.lisp_obj_type, word); + } + /* Other const objects are fetched from the reloc array. */ + return emit_const_lisp_obj (constant); } return -- 2.39.5