diff options
| author | Nickolas Lloyd | 2016-12-22 20:05:16 -0500 |
|---|---|---|
| committer | Nickolas Lloyd | 2016-12-22 20:05:16 -0500 |
| commit | ca2e32dcc4ed8bba25a700cd7c8fa8aba6c94ae5 (patch) | |
| tree | bfb09bc34f6de7c34a930d9bbeaddb6f82048cc5 /src | |
| parent | 52a3e81487641cd81cef777540fa5791fdd93ddb (diff) | |
| download | emacs-ca2e32dcc4ed8bba25a700cd7c8fa8aba6c94ae5.tar.gz emacs-ca2e32dcc4ed8bba25a700cd7c8fa8aba6c94ae5.zip | |
; 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/bytecode-jit.c | 22 | ||||
| -rw-r--r-- | src/bytecode.c | 24 | ||||
| -rw-r--r-- | src/bytecode.h | 10 | ||||
| -rw-r--r-- | src/eval.c | 6 | ||||
| -rw-r--r-- | 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) | |||
| 605 | JIT_SIG (native_integer_p, jit_type_Lisp_Object, jit_type_Lisp_Object); | 605 | JIT_SIG (native_integer_p, jit_type_Lisp_Object, jit_type_Lisp_Object); |
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | static Lisp_Object | 608 | Lisp_Object |
| 609 | jit_exec (Lisp_Object byte_code, Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) | 609 | jit_exec (Lisp_Object byte_code, Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) |
| 610 | { | 610 | { |
| 611 | Lisp_Object *top; | 611 | Lisp_Object *top; |
| @@ -668,7 +668,7 @@ jit_exec (Lisp_Object byte_code, Lisp_Object args_template, ptrdiff_t nargs, Lis | |||
| 668 | } | 668 | } |
| 669 | } | 669 | } |
| 670 | 670 | ||
| 671 | static void | 671 | void |
| 672 | jit_byte_code__ (Lisp_Object byte_code) | 672 | jit_byte_code__ (Lisp_Object byte_code) |
| 673 | { | 673 | { |
| 674 | ptrdiff_t count = SPECPDL_INDEX (); | 674 | ptrdiff_t count = SPECPDL_INDEX (); |
| @@ -2094,24 +2094,6 @@ jit_byte_code__ (Lisp_Object byte_code) | |||
| 2094 | } | 2094 | } |
| 2095 | } | 2095 | } |
| 2096 | 2096 | ||
| 2097 | Lisp_Object | ||
| 2098 | jit_byte_code (Lisp_Object byte_code, Lisp_Object args_template, | ||
| 2099 | ptrdiff_t nargs, Lisp_Object *args) | ||
| 2100 | { | ||
| 2101 | if (AREF (byte_code, COMPILED_JIT_ID)) | ||
| 2102 | return jit_exec (byte_code, args_template, nargs, args); | ||
| 2103 | else if (!byte_code_jit_on) | ||
| 2104 | return exec_byte_code (AREF (byte_code, COMPILED_BYTECODE), | ||
| 2105 | AREF (byte_code, COMPILED_CONSTANTS), | ||
| 2106 | AREF (byte_code, COMPILED_STACK_DEPTH), | ||
| 2107 | args_template, nargs, args); | ||
| 2108 | else | ||
| 2109 | { | ||
| 2110 | jit_byte_code__ (byte_code); | ||
| 2111 | return jit_exec (byte_code, args_template, nargs, args); | ||
| 2112 | } | ||
| 2113 | } | ||
| 2114 | |||
| 2115 | DEFUN ("jit-compile", Fjit_compile, Sjit_compile, 1, 1, 0, | 2097 | DEFUN ("jit-compile", Fjit_compile, Sjit_compile, 1, 1, 0, |
| 2116 | doc: /* Function used internally in byte-compiled code. | 2098 | doc: /* Function used internally in byte-compiled code. |
| 2117 | The first argument, BYTECODE, is a compiled byte code object. */) | 2099 | 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. | |||
| 137 | If the third argument is incorrect, Emacs may crash. */) | 137 | If the third argument is incorrect, Emacs may crash. */) |
| 138 | (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth) | 138 | (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth) |
| 139 | { | 139 | { |
| 140 | return exec_byte_code (bytestr, vector, maxdepth, Qnil, 0, NULL); | 140 | return exec_byte_code__ (bytestr, vector, maxdepth, Qnil, 0, NULL); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | void | 143 | void |
| @@ -155,8 +155,8 @@ bcall0 (Lisp_Object f) | |||
| 155 | executing BYTESTR. */ | 155 | executing BYTESTR. */ |
| 156 | 156 | ||
| 157 | Lisp_Object | 157 | Lisp_Object |
| 158 | exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | 158 | exec_byte_code__ (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, |
| 159 | Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) | 159 | Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) |
| 160 | { | 160 | { |
| 161 | #ifdef BYTE_CODE_METER | 161 | #ifdef BYTE_CODE_METER |
| 162 | int volatile this_op = 0; | 162 | int volatile this_op = 0; |
| @@ -1283,6 +1283,24 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 1283 | return result; | 1283 | return result; |
| 1284 | } | 1284 | } |
| 1285 | 1285 | ||
| 1286 | Lisp_Object | ||
| 1287 | exec_byte_code (Lisp_Object byte_code, Lisp_Object args_template, | ||
| 1288 | ptrdiff_t nargs, Lisp_Object *args) | ||
| 1289 | { | ||
| 1290 | if (AREF (byte_code, COMPILED_JIT_ID)) | ||
| 1291 | return jit_exec (byte_code, args_template, nargs, args); | ||
| 1292 | else if (!byte_code_jit_on) | ||
| 1293 | return exec_byte_code__ (AREF (byte_code, COMPILED_BYTECODE), | ||
| 1294 | AREF (byte_code, COMPILED_CONSTANTS), | ||
| 1295 | AREF (byte_code, COMPILED_STACK_DEPTH), | ||
| 1296 | args_template, nargs, args); | ||
| 1297 | else | ||
| 1298 | { | ||
| 1299 | jit_byte_code__ (byte_code); | ||
| 1300 | return jit_exec (byte_code, args_template, nargs, args); | ||
| 1301 | } | ||
| 1302 | } | ||
| 1303 | |||
| 1286 | /* `args_template' has the same meaning as in exec_byte_code() above. */ | 1304 | /* `args_template' has the same meaning as in exec_byte_code() above. */ |
| 1287 | Lisp_Object | 1305 | Lisp_Object |
| 1288 | get_byte_code_arity (Lisp_Object args_template) | 1306 | 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 | |||
| 301 | 301 | ||
| 302 | extern void | 302 | extern void |
| 303 | bcall0 (Lisp_Object f); | 303 | bcall0 (Lisp_Object f); |
| 304 | |||
| 305 | extern void | ||
| 306 | jit_byte_code__ (Lisp_Object); | ||
| 307 | |||
| 308 | extern Lisp_Object | ||
| 309 | jit_exec (Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *); | ||
| 310 | |||
| 311 | extern Lisp_Object | ||
| 312 | exec_byte_code__ (Lisp_Object, Lisp_Object, Lisp_Object, | ||
| 313 | 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, | |||
| 2954 | and constants vector yet, fetch them from the file. */ | 2954 | and constants vector yet, fetch them from the file. */ |
| 2955 | if (CONSP (AREF (fun, COMPILED_BYTECODE))) | 2955 | if (CONSP (AREF (fun, COMPILED_BYTECODE))) |
| 2956 | Ffetch_bytecode (fun); | 2956 | Ffetch_bytecode (fun); |
| 2957 | return jit_byte_code (fun, syms_left, | 2957 | return exec_byte_code (fun, syms_left, |
| 2958 | nargs, arg_vector); | 2958 | nargs, arg_vector); |
| 2959 | } | 2959 | } |
| 2960 | lexenv = Qnil; | 2960 | lexenv = Qnil; |
| 2961 | } | 2961 | } |
| @@ -3029,7 +3029,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, | |||
| 3029 | and constants vector yet, fetch them from the file. */ | 3029 | and constants vector yet, fetch them from the file. */ |
| 3030 | if (CONSP (AREF (fun, COMPILED_BYTECODE))) | 3030 | if (CONSP (AREF (fun, COMPILED_BYTECODE))) |
| 3031 | Ffetch_bytecode (fun); | 3031 | Ffetch_bytecode (fun); |
| 3032 | val = jit_byte_code (fun, Qnil, 0, 0); | 3032 | val = exec_byte_code (fun, Qnil, 0, 0); |
| 3033 | } | 3033 | } |
| 3034 | 3034 | ||
| 3035 | return unbind_to (count, val); | 3035 | 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); | |||
| 4340 | /* Defined in bytecode.c. */ | 4340 | /* Defined in bytecode.c. */ |
| 4341 | extern void syms_of_bytecode (void); | 4341 | extern void syms_of_bytecode (void); |
| 4342 | extern void relocate_byte_stack (struct byte_stack *); | 4342 | extern void relocate_byte_stack (struct byte_stack *); |
| 4343 | extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object, | 4343 | extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *); |
| 4344 | Lisp_Object, ptrdiff_t, Lisp_Object *); | ||
| 4345 | extern Lisp_Object get_byte_code_arity (Lisp_Object); | 4344 | extern Lisp_Object get_byte_code_arity (Lisp_Object); |
| 4346 | 4345 | ||
| 4347 | /* Defined in bytecode-jit.c */ | 4346 | /* Defined in bytecode-jit.c */ |
| 4348 | extern void syms_of_bytecode_jit (void); | 4347 | extern void syms_of_bytecode_jit (void); |
| 4349 | extern Lisp_Object jit_byte_code (Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *); | ||
| 4350 | 4348 | ||
| 4351 | /* Defined in macros.c. */ | 4349 | /* Defined in macros.c. */ |
| 4352 | extern void init_macros (void); | 4350 | extern void init_macros (void); |