From ca2e32dcc4ed8bba25a700cd7c8fa8aba6c94ae5 Mon Sep 17 00:00:00 2001 From: Nickolas Lloyd Date: Thu, 22 Dec 2016 20:05:16 -0500 Subject: [PATCH] ; Minor reorg of bytecode interpreter/JIT compiler ; * src/bytecode.c (exec_byte_code, exec_byte_code__): Use exec_byte_code as the single entrypoint for both the interpreter and JIT compiler. ; * src/bytecode-jit.c (jit_byte_code): Remove jit_byte_code to be replaced by exec_byte_code. ; * src/bytecode.h: Add function prototypes. ; * src/eval.c (funcall_lambda): Use exec_byte_code instead of jit_byte_code. ; * src/lisp.h: Update function prototypes. --- src/bytecode-jit.c | 22 ++-------------------- src/bytecode.c | 24 +++++++++++++++++++++--- src/bytecode.h | 10 ++++++++++ src/eval.c | 6 +++--- src/lisp.h | 4 +--- 5 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/bytecode-jit.c b/src/bytecode-jit.c index 095892d067c..734371dc772 100644 --- a/src/bytecode-jit.c +++ b/src/bytecode-jit.c @@ -605,7 +605,7 @@ emacs_jit_init (void) JIT_SIG (native_integer_p, jit_type_Lisp_Object, jit_type_Lisp_Object); } -static Lisp_Object +Lisp_Object jit_exec (Lisp_Object byte_code, Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object *top; @@ -668,7 +668,7 @@ jit_exec (Lisp_Object byte_code, Lisp_Object args_template, ptrdiff_t nargs, Lis } } -static void +void jit_byte_code__ (Lisp_Object byte_code) { ptrdiff_t count = SPECPDL_INDEX (); @@ -2094,24 +2094,6 @@ jit_byte_code__ (Lisp_Object byte_code) } } -Lisp_Object -jit_byte_code (Lisp_Object byte_code, Lisp_Object args_template, - ptrdiff_t nargs, Lisp_Object *args) -{ - if (AREF (byte_code, COMPILED_JIT_ID)) - return jit_exec (byte_code, args_template, nargs, args); - else if (!byte_code_jit_on) - return exec_byte_code (AREF (byte_code, COMPILED_BYTECODE), - AREF (byte_code, COMPILED_CONSTANTS), - AREF (byte_code, COMPILED_STACK_DEPTH), - args_template, nargs, args); - else - { - jit_byte_code__ (byte_code); - return jit_exec (byte_code, args_template, nargs, args); - } -} - DEFUN ("jit-compile", Fjit_compile, Sjit_compile, 1, 1, 0, doc: /* Function used internally in byte-compiled code. The first argument, BYTECODE, is a compiled byte code object. */) diff --git a/src/bytecode.c b/src/bytecode.c index c88ca509119..76ec066c637 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -137,7 +137,7 @@ the third, MAXDEPTH, the maximum stack depth used in this function. If the third argument is incorrect, Emacs may crash. */) (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth) { - return exec_byte_code (bytestr, vector, maxdepth, Qnil, 0, NULL); + return exec_byte_code__ (bytestr, vector, maxdepth, Qnil, 0, NULL); } void @@ -155,8 +155,8 @@ bcall0 (Lisp_Object f) executing BYTESTR. */ Lisp_Object -exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, - Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) +exec_byte_code__ (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, + Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) { #ifdef BYTE_CODE_METER int volatile this_op = 0; @@ -1283,6 +1283,24 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, return result; } +Lisp_Object +exec_byte_code (Lisp_Object byte_code, Lisp_Object args_template, + ptrdiff_t nargs, Lisp_Object *args) +{ + if (AREF (byte_code, COMPILED_JIT_ID)) + return jit_exec (byte_code, args_template, nargs, args); + else if (!byte_code_jit_on) + return exec_byte_code__ (AREF (byte_code, COMPILED_BYTECODE), + AREF (byte_code, COMPILED_CONSTANTS), + AREF (byte_code, COMPILED_STACK_DEPTH), + args_template, nargs, args); + else + { + jit_byte_code__ (byte_code); + return jit_exec (byte_code, args_template, nargs, args); + } +} + /* `args_template' has the same meaning as in exec_byte_code() above. */ Lisp_Object get_byte_code_arity (Lisp_Object args_template) diff --git a/src/bytecode.h b/src/bytecode.h index aa59b943952..25f11f1ce1f 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -301,3 +301,13 @@ struct byte_stack extern void bcall0 (Lisp_Object f); + +extern void +jit_byte_code__ (Lisp_Object); + +extern Lisp_Object +jit_exec (Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *); + +extern Lisp_Object +exec_byte_code__ (Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object, ptrdiff_t, Lisp_Object *); diff --git a/src/eval.c b/src/eval.c index 7d32daf0e4e..f2e6ba85214 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2954,8 +2954,8 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, and constants vector yet, fetch them from the file. */ if (CONSP (AREF (fun, COMPILED_BYTECODE))) Ffetch_bytecode (fun); - return jit_byte_code (fun, syms_left, - nargs, arg_vector); + return exec_byte_code (fun, syms_left, + nargs, arg_vector); } lexenv = Qnil; } @@ -3029,7 +3029,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, and constants vector yet, fetch them from the file. */ if (CONSP (AREF (fun, COMPILED_BYTECODE))) Ffetch_bytecode (fun); - val = jit_byte_code (fun, Qnil, 0, 0); + val = exec_byte_code (fun, Qnil, 0, 0); } return unbind_to (count, val); diff --git a/src/lisp.h b/src/lisp.h index 65468dfbf29..fc600a50cab 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4340,13 +4340,11 @@ extern int read_bytecode_char (bool); /* Defined in bytecode.c. */ extern void syms_of_bytecode (void); extern void relocate_byte_stack (struct byte_stack *); -extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object, ptrdiff_t, Lisp_Object *); +extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *); extern Lisp_Object get_byte_code_arity (Lisp_Object); /* Defined in bytecode-jit.c */ extern void syms_of_bytecode_jit (void); -extern Lisp_Object jit_byte_code (Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *); /* Defined in macros.c. */ extern void init_macros (void); -- 2.39.5