aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2019-08-16 17:15:35 +0200
committerAndrea Corallo2020-01-01 11:34:01 +0100
commitc4d723e865e86a83cf87d4cc42e7dbca799dc4ff (patch)
tree5f86c4b06cae68651dc46583bb592707893a4b2a /src
parentbdcd8dd9fe4a9926a0dbc46ee1180ef53a91bf17 (diff)
downloademacs-c4d723e865e86a83cf87d4cc42e7dbca799dc4ff.tar.gz
emacs-c4d723e865e86a83cf87d4cc42e7dbca799dc4ff.zip
add comp-compile-ctxt-to-file
Diffstat (limited to 'src')
-rw-r--r--src/comp.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/src/comp.c b/src/comp.c
index 1e1060fd878..b150292041b 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -224,7 +224,7 @@ type_to_cast_field (gcc_jit_type *type)
224 else if (type == comp.lisp_obj_ptr_type) 224 else if (type == comp.lisp_obj_ptr_type)
225 field = comp.cast_union_as_lisp_obj_ptr; 225 field = comp.cast_union_as_lisp_obj_ptr;
226 else 226 else
227 error ("unsupported cast\n"); 227 error ("Unsupported cast");
228 228
229 return field; 229 return field;
230} 230}
@@ -2327,7 +2327,7 @@ DEFUN ("comp-init-ctxt", Fcomp_init_ctxt, Scomp_init_ctxt,
2327{ 2327{
2328 if (comp.ctxt) 2328 if (comp.ctxt)
2329 { 2329 {
2330 error ("Compiler context already taken."); 2330 error ("Compiler context already taken");
2331 return Qnil; 2331 return Qnil;
2332 } 2332 }
2333 2333
@@ -2611,6 +2611,48 @@ DEFUN ("comp-add-func-to-ctxt", Fcomp_add_func_to_ctxt, Scomp_add_func_to_ctxt,
2611 return Qt; 2611 return Qt;
2612} 2612}
2613 2613
2614DEFUN ("comp-compile-ctxt-to-file", Fcomp_compile_ctxt_to_file,
2615 Scomp_compile_ctxt_to_file,
2616 1, 1, 0,
2617 doc: /* Compile as native code the current context to file. */)
2618 (Lisp_Object ctxtname)
2619{
2620 if (!STRINGP (ctxtname))
2621 error ("Argument ctxtname not a string");
2622
2623 gcc_jit_context_set_int_option (comp.ctxt,
2624 GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
2625 comp_speed);
2626 /* Gcc doesn't like being interrupted at all. */
2627 sigset_t oldset;
2628 sigset_t blocked;
2629 sigemptyset (&blocked);
2630 sigaddset (&blocked, SIGALRM);
2631 sigaddset (&blocked, SIGINT);
2632 sigaddset (&blocked, SIGIO);
2633 pthread_sigmask (SIG_BLOCK, &blocked, &oldset);
2634
2635 if (COMP_DEBUG)
2636 {
2637 AUTO_STRING (dot_c, ".c");
2638 const char *filename =
2639 (const char *) SDATA (CALLN (Fconcat, ctxtname, dot_c));
2640 gcc_jit_context_dump_to_file (comp.ctxt, filename, 1);
2641 }
2642
2643 AUTO_STRING (dot_so, ".so");
2644 const char *filename =
2645 (const char *) SDATA (CALLN (Fconcat, ctxtname, dot_so));
2646
2647 gcc_jit_context_compile_to_file (comp.ctxt,
2648 GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY,
2649 filename);
2650
2651 pthread_sigmask (SIG_SETMASK, &oldset, 0);
2652
2653 return Qt;
2654}
2655
2614DEFUN ("comp-compile-and-load-ctxt", Fcomp_compile_and_load_ctxt, 2656DEFUN ("comp-compile-and-load-ctxt", Fcomp_compile_and_load_ctxt,
2615 Scomp_compile_and_load_ctxt, 2657 Scomp_compile_and_load_ctxt,
2616 0, 1, 0, 2658 0, 1, 0,
@@ -2772,6 +2814,7 @@ syms_of_comp (void)
2772 defsubr (&Scomp_init_ctxt); 2814 defsubr (&Scomp_init_ctxt);
2773 defsubr (&Scomp_release_ctxt); 2815 defsubr (&Scomp_release_ctxt);
2774 defsubr (&Scomp_add_func_to_ctxt); 2816 defsubr (&Scomp_add_func_to_ctxt);
2817 defsubr (&Scomp_compile_ctxt_to_file);
2775 defsubr (&Scomp_compile_and_load_ctxt); 2818 defsubr (&Scomp_compile_and_load_ctxt);
2776 2819
2777 staticpro (&comp.func_hash); 2820 staticpro (&comp.func_hash);