diff options
| author | Zach Shaftel | 2020-06-18 01:09:31 -0400 |
|---|---|---|
| committer | Zach Shaftel | 2020-06-18 01:09:31 -0400 |
| commit | e1aee0ffe8aa51a8963737f8a957cf19eabdb9d7 (patch) | |
| tree | be1ff734ed32fa702c4cd88adfabca389e1a1bc6 /src/eval.c | |
| parent | 3d5ac37d36ecae90a634515b78608062fc9729be (diff) | |
| download | emacs-feature/zach-soc-funcall-from-bytecode.tar.gz emacs-feature/zach-soc-funcall-from-bytecode.zip | |
Don't call Ffuncall directly from exec_byte_codefeature/zach-soc-funcall-from-bytecode
* src/bytecode.c (exec_byte_code): Do a good chunk of Ffuncall's
work in the Bcall ops, so Ffuncall no longer needs to be called. As
it stands, it's an ugly clone of the contents of Ffuncall (and
some of funcall_lambda). Work in progress.
* src/eval.c (record_in_backtrace_with_offset): New function. Like
record_in_backtrace but accepts the bytecode offset and stores it
in the pertinent backtrace frame.
(record_in_backtrace): Don't record the offset.
(funcall_lambda): Remove unnecessary SYMBOLP check.
* src/lisp.h (funcall_lambda, do_debug_on_call)
(record_in_backtrace_with_offset , backtrace_debug_on_exit):
Declare.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/eval.c b/src/eval.c index 5b43b81a6ca..544dfc25af9 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -56,8 +56,6 @@ Lisp_Object Vrun_hooks; | |||
| 56 | /* FIXME: We should probably get rid of this! */ | 56 | /* FIXME: We should probably get rid of this! */ |
| 57 | Lisp_Object Vsignaling_function; | 57 | Lisp_Object Vsignaling_function; |
| 58 | 58 | ||
| 59 | int backtrace_byte_offset = -1; | ||
| 60 | |||
| 61 | /* These would ordinarily be static, but they need to be visible to GDB. */ | 59 | /* These would ordinarily be static, but they need to be visible to GDB. */ |
| 62 | bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE; | 60 | bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE; |
| 63 | Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE; | 61 | Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE; |
| @@ -65,7 +63,6 @@ Lisp_Object backtrace_function (union specbinding *) EXTERNALLY_VISIBLE; | |||
| 65 | union specbinding *backtrace_next (union specbinding *) EXTERNALLY_VISIBLE; | 63 | union specbinding *backtrace_next (union specbinding *) EXTERNALLY_VISIBLE; |
| 66 | union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; | 64 | union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; |
| 67 | 65 | ||
| 68 | static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); | ||
| 69 | static Lisp_Object apply_lambda (Lisp_Object, Lisp_Object, ptrdiff_t); | 66 | static Lisp_Object apply_lambda (Lisp_Object, Lisp_Object, ptrdiff_t); |
| 70 | static Lisp_Object lambda_arity (Lisp_Object); | 67 | static Lisp_Object lambda_arity (Lisp_Object); |
| 71 | 68 | ||
| @@ -146,7 +143,7 @@ backtrace_bytecode_offset (union specbinding *pdl) | |||
| 146 | return pdl->bt.bytecode_offset; | 143 | return pdl->bt.bytecode_offset; |
| 147 | } | 144 | } |
| 148 | 145 | ||
| 149 | static bool | 146 | bool |
| 150 | backtrace_debug_on_exit (union specbinding *pdl) | 147 | backtrace_debug_on_exit (union specbinding *pdl) |
| 151 | { | 148 | { |
| 152 | eassert (pdl->kind == SPECPDL_BACKTRACE); | 149 | eassert (pdl->kind == SPECPDL_BACKTRACE); |
| @@ -354,7 +351,7 @@ call_debugger (Lisp_Object arg) | |||
| 354 | return unbind_to (count, val); | 351 | return unbind_to (count, val); |
| 355 | } | 352 | } |
| 356 | 353 | ||
| 357 | static void | 354 | void |
| 358 | do_debug_on_call (Lisp_Object code, ptrdiff_t count) | 355 | do_debug_on_call (Lisp_Object code, ptrdiff_t count) |
| 359 | { | 356 | { |
| 360 | debug_on_next_call = 0; | 357 | debug_on_next_call = 0; |
| @@ -2146,6 +2143,27 @@ grow_specpdl (void) | |||
| 2146 | } | 2143 | } |
| 2147 | 2144 | ||
| 2148 | ptrdiff_t | 2145 | ptrdiff_t |
| 2146 | record_in_backtrace_with_offset (Lisp_Object function, Lisp_Object *args, | ||
| 2147 | ptrdiff_t nargs, int offset) | ||
| 2148 | { | ||
| 2149 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 2150 | |||
| 2151 | eassert (nargs >= UNEVALLED); | ||
| 2152 | specpdl_ptr->bt.kind = SPECPDL_BACKTRACE; | ||
| 2153 | specpdl_ptr->bt.debug_on_exit = false; | ||
| 2154 | specpdl_ptr->bt.function = function; | ||
| 2155 | current_thread->stack_top = specpdl_ptr->bt.args = args; | ||
| 2156 | specpdl_ptr->bt.nargs = nargs; | ||
| 2157 | specpdl_ptr->bt.bytecode_offset = -1; | ||
| 2158 | union specbinding *nxt = backtrace_top (); | ||
| 2159 | if (backtrace_p (nxt) && nxt->kind == SPECPDL_BACKTRACE) | ||
| 2160 | nxt->bt.bytecode_offset = offset; | ||
| 2161 | grow_specpdl (); | ||
| 2162 | |||
| 2163 | return count; | ||
| 2164 | } | ||
| 2165 | |||
| 2166 | ptrdiff_t | ||
| 2149 | record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) | 2167 | record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) |
| 2150 | { | 2168 | { |
| 2151 | ptrdiff_t count = SPECPDL_INDEX (); | 2169 | ptrdiff_t count = SPECPDL_INDEX (); |
| @@ -2156,10 +2174,7 @@ record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) | |||
| 2156 | specpdl_ptr->bt.function = function; | 2174 | specpdl_ptr->bt.function = function; |
| 2157 | current_thread->stack_top = specpdl_ptr->bt.args = args; | 2175 | current_thread->stack_top = specpdl_ptr->bt.args = args; |
| 2158 | specpdl_ptr->bt.nargs = nargs; | 2176 | specpdl_ptr->bt.nargs = nargs; |
| 2159 | union specbinding *nxt = specpdl_ptr; | 2177 | specpdl_ptr->bt.bytecode_offset = -1; |
| 2160 | nxt = backtrace_next(nxt); | ||
| 2161 | if (nxt->kind == SPECPDL_BACKTRACE) | ||
| 2162 | nxt->bt.bytecode_offset = backtrace_byte_offset; | ||
| 2163 | grow_specpdl (); | 2178 | grow_specpdl (); |
| 2164 | 2179 | ||
| 2165 | return count; | 2180 | return count; |
| @@ -2965,7 +2980,7 @@ apply_lambda (Lisp_Object fun, Lisp_Object args, ptrdiff_t count) | |||
| 2965 | FUN must be either a lambda-expression, a compiled-code object, | 2980 | FUN must be either a lambda-expression, a compiled-code object, |
| 2966 | or a module function. */ | 2981 | or a module function. */ |
| 2967 | 2982 | ||
| 2968 | static Lisp_Object | 2983 | Lisp_Object |
| 2969 | funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, | 2984 | funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, |
| 2970 | register Lisp_Object *arg_vector) | 2985 | register Lisp_Object *arg_vector) |
| 2971 | { | 2986 | { |
| @@ -3053,7 +3068,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, | |||
| 3053 | arg = Qnil; | 3068 | arg = Qnil; |
| 3054 | 3069 | ||
| 3055 | /* Bind the argument. */ | 3070 | /* Bind the argument. */ |
| 3056 | if (!NILP (lexenv) && SYMBOLP (next)) | 3071 | if (!NILP (lexenv)) |
| 3057 | /* Lexically bind NEXT by adding it to the lexenv alist. */ | 3072 | /* Lexically bind NEXT by adding it to the lexenv alist. */ |
| 3058 | lexenv = Fcons (Fcons (next, arg), lexenv); | 3073 | lexenv = Fcons (Fcons (next, arg), lexenv); |
| 3059 | else | 3074 | else |