diff options
| author | Andrea Corallo | 2019-09-09 21:35:31 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:37:46 +0100 |
| commit | 24dcbf47d826f46821ed484f93ffb89d306a0b2d (patch) | |
| tree | e55c13c314e6f03256f14996a4bfec6b606436ce /src/comp.c | |
| parent | 63ecf01d0b0897b948296eaaffd690290d536b72 (diff) | |
| download | emacs-24dcbf47d826f46821ed484f93ffb89d306a0b2d.tar.gz emacs-24dcbf47d826f46821ed484f93ffb89d306a0b2d.zip | |
fix broken selfcall optimization
Diffstat (limited to 'src/comp.c')
| -rw-r--r-- | src/comp.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/comp.c b/src/comp.c index f966a2427b7..98932f79bb0 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -147,6 +147,7 @@ typedef struct { | |||
| 147 | gcc_jit_field *cast_union_as_lisp_obj; | 147 | gcc_jit_field *cast_union_as_lisp_obj; |
| 148 | gcc_jit_field *cast_union_as_lisp_obj_ptr; | 148 | gcc_jit_field *cast_union_as_lisp_obj_ptr; |
| 149 | gcc_jit_function *func; /* Current function being compiled. */ | 149 | gcc_jit_function *func; /* Current function being compiled. */ |
| 150 | Lisp_Object lfunc; | ||
| 150 | gcc_jit_block *block; /* Current basic block being compiled. */ | 151 | gcc_jit_block *block; /* Current basic block being compiled. */ |
| 151 | gcc_jit_lvalue **frame; /* Frame for the current function. */ | 152 | gcc_jit_lvalue **frame; /* Frame for the current function. */ |
| 152 | gcc_jit_rvalue *most_positive_fixnum; | 153 | gcc_jit_rvalue *most_positive_fixnum; |
| @@ -210,7 +211,7 @@ static void | |||
| 210 | ice (const char* msg) | 211 | ice (const char* msg) |
| 211 | { | 212 | { |
| 212 | if (msg) | 213 | if (msg) |
| 213 | msg = format_string ("Internal native compiler error: %s", msg); | 214 | msg = format_string ("Internal native compiler error: %s", msg); |
| 214 | else | 215 | else |
| 215 | msg = "Internal native compiler error"; | 216 | msg = "Internal native compiler error"; |
| 216 | error ("%s", msg); | 217 | error ("%s", msg); |
| @@ -394,6 +395,16 @@ static gcc_jit_rvalue * | |||
| 394 | emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, unsigned nargs, | 395 | emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, unsigned nargs, |
| 395 | gcc_jit_rvalue **args) | 396 | gcc_jit_rvalue **args) |
| 396 | { | 397 | { |
| 398 | /* Self call optimization. */ | ||
| 399 | if (!NILP (comp.lfunc) && | ||
| 400 | comp_speed >= 2 && | ||
| 401 | EQ (subr_sym, FUNCALL1 (comp-func-symbol-name, comp.lfunc))) | ||
| 402 | return gcc_jit_context_new_call (comp.ctxt, | ||
| 403 | NULL, | ||
| 404 | comp.func, | ||
| 405 | nargs, | ||
| 406 | args); | ||
| 407 | |||
| 397 | Lisp_Object value = Fgethash (subr_sym, comp.func_hash, Qnil); | 408 | Lisp_Object value = Fgethash (subr_sym, comp.func_hash, Qnil); |
| 398 | ICE_IF (NILP (value), "missing function declaration"); | 409 | ICE_IF (NILP (value), "missing function declaration"); |
| 399 | 410 | ||
| @@ -2651,6 +2662,8 @@ compile_function (Lisp_Object func) | |||
| 2651 | EMACS_INT frame_size = XFIXNUM (FUNCALL1 (comp-func-frame-size, func)); | 2662 | EMACS_INT frame_size = XFIXNUM (FUNCALL1 (comp-func-frame-size, func)); |
| 2652 | bool ncall = (FUNCALL1 (comp-nargs-p, args)); | 2663 | bool ncall = (FUNCALL1 (comp-nargs-p, args)); |
| 2653 | 2664 | ||
| 2665 | comp.lfunc = func; | ||
| 2666 | |||
| 2654 | if (!ncall) | 2667 | if (!ncall) |
| 2655 | { | 2668 | { |
| 2656 | EMACS_INT max_args = XFIXNUM (FUNCALL1 (comp-args-max, args)); | 2669 | EMACS_INT max_args = XFIXNUM (FUNCALL1 (comp-args-max, args)); |
| @@ -2733,6 +2746,7 @@ compile_function (Lisp_Object func) | |||
| 2733 | format_string ("failing to compile function %s with error: %s", | 2746 | format_string ("failing to compile function %s with error: %s", |
| 2734 | SSDATA (SYMBOL_NAME (FUNCALL1 (comp-func-symbol-name, func))), | 2747 | SSDATA (SYMBOL_NAME (FUNCALL1 (comp-func-symbol-name, func))), |
| 2735 | err)); | 2748 | err)); |
| 2749 | comp.lfunc = Qnil; | ||
| 2736 | SAFE_FREE (); | 2750 | SAFE_FREE (); |
| 2737 | } | 2751 | } |
| 2738 | 2752 | ||