diff options
| author | Mattias EngdegÄrd | 2022-02-12 16:05:17 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-02-12 18:00:21 +0100 |
| commit | a8245e122075175df2f124b20e9e5b1b583eff89 (patch) | |
| tree | 4e7c180a785879d056149013c2933b62445f1361 /src/eval.c | |
| parent | be06b40ebdd6cfbd23558ce210a8a7ad2b4c7a40 (diff) | |
| download | emacs-a8245e122075175df2f124b20e9e5b1b583eff89.tar.gz emacs-a8245e122075175df2f124b20e9e5b1b583eff89.zip | |
Replace ptrdiff_t with new specpdl_ref type for specpdl references
The specpdl_ref type is just an alias for ptrdiff_t; the compiled code
remains the same. All operations on specpdl_ref (arithmetic,
comparison etc) now go through inline functions.
The bulk of the change is almost completely mechanical. It is done to
prepare for a type-safe representation and subsequent performance
improvement.
* src/lisp.h (specpdl_ref, specpdl_count_to_ref, specpdl_ref_to_count)
(specpdl_ref_eq, specpdl_ref_lt, specpdl_ref_valid_p)
(make_invalid_specpdl_ref, specpdl_ref_add, specpdl_ref_to_ptr): New.
(SPECPDL_INDEX, struct handler, USE_SAFE_ALLOCA, safe_free)
(safe_free_unbind_to):
* src/alloc.c (run_finalizer_function, inhibit_garbage_collection)
(garbage_collect, Fgarbage_collect, which_symbols):
* src/bidi.c (bidi_at_paragraph_end, bidi_find_paragraph_start):
* src/buffer.c (Fkill_buffer, Fset_buffer_major_mode, Fmove_overlay)
(Fdelete_overlay):
* src/bytecode.c (exec_byte_code):
* src/callint.c (Ffuncall_interactively, Fcall_interactively):
* src/callproc.c (Fcall_process, call_process, create_temp_file)
(Fcall_process_region):
* src/charset.c (load_charset_map_from_file):
* src/coding.c (decode_coding_gap, decode_coding_object)
(encode_coding_object, Fread_coding_system):
* src/comp.c (emit_static_object, helper_unbind_n, load_comp_unit):
* src/composite.c (update_compositions, autocmp_chars):
* src/cygw32.c (conv_filename_to_w32_unicode)
(conv_filename_from_w32_unicode):
* src/data.c (notify_variable_watchers):
* src/decompress.c (Fzlib_decompress_region):
* src/dired.c (directory_files_internal, file_name_completion)
(file_attributes):
* src/dispnew.c (Fredisplay):
* src/doc.c (get_doc_string, Fsnarf_documentation):
* src/editfns.c (Fsave_excursion, Fsave_current_buffer)
(Freplace_buffer_contents, Fsubst_char_in_region, Fsave_restriction)
(styled_format):
* src/emacs-module.c (Fmodule_load, funcall_module):
* src/emacs.c (init_cmdargs, Fdump_emacs):
* src/eval.c (call_debugger, do_debug_on_call, FletX, Flet)
(Ffuncall_with_delayed_message, Funwind_protect)
(internal_lisp_condition_case, signal_or_quit)
(load_with_autoload_queue, Feval, grow_specpdl_allocation)
(record_in_backtrace, eval_sub, Ffuncall, apply_lambda)
(funcall_lambda, clear_unwind_protect, set_unwind_protect)
(set_unwind_protect_ptr, unbind_to, Fbacktrace_eval):
* src/fileio.c (Fmake_temp_file_internal, Fcopy_file, Frename_file)
(Finsert_file_contents, write_region, Fdo_auto_save):
* src/fns.c (Fyes_or_no_p, Frequire, hash_table_user_defined_call):
* src/fringe.c (update_window_fringes):
* src/gtkutil.c (xg_dialog_run):
* src/haiku_io.c (c_specpdl_idx_from_cxx):
* src/haiku_support.cc (be_popup_file_dialog):
* src/haiku_support.h (c_specpdl_idx_from_cxx):
* src/haikufns.c (haiku_create_frame, haiku_create_tip_frame)
(haiku_hide_tip, Fx_show_tip, Fhaiku_read_file_name):
* src/haikumenu.c (haiku_popup_dialog, set_frame_menubar):
* src/image.c (slurp_file):
* src/indent.c (line_number_display_width, Fvertical_motion):
* src/insdel.c (signal_before_change, signal_after_change)
(Fcombine_after_change_execute):
* src/intervals.c (get_local_map):
* src/json.c (lisp_to_json_nonscalar_1, Fjson_serialize, Fjson_insert)
(Fjson_parse_string, Fjson_parse_buffer):
* src/keyboard.c (recursive_edit_1, Frecursive_edit, cmd_error)
(Finternal_track_mouse, command_loop_1, read_menu_command)
(safe_run_hooks, read_event_from_main_queue, read_char, timer_check_2)
(menu_item_eval_property, read_key_sequence, read_key_sequence_vs)
(Fsuspend_emacs):
* src/keymap.c (Fcurrent_active_maps, Fdescribe_vector)
(Fhelp__describe_vector):
* src/lread.c (Fload, save_match_data_load, readevalloop)
(Feval_buffer, Feval_region, grow_read_buffer, read_integer, read1):
* src/macros.c (Fexecute_kbd_macro):
* src/menu.c (x_popup_menu_1):
* src/minibuf.c (read_minibuf, set_minibuffer_mode)
(read_minibuf_unwind, Fread_string, Fread_buffer):
* src/nsfns.m (Fx_create_frame, Fx_show_tip):
* src/nsmenu.m (ns_update_menubar, ns_menu_show, ns_popup_dialog):
* src/pdumper.c (Fdump_emacs_portable):
* src/pgtkfns.c (Fx_create_frame, x_create_tip_frame, x_hide_tip)
(Fx_show_tip, Fpgtk_print_frames_dialog, Fx_file_dialog, Fx_select_font):
* src/pgtkmenu.c (set_frame_menubar, create_and_show_popup_menu)
(pgtk_menu_show, create_and_show_dialog, pgtk_dialog_show)
(pgtk_popup_dialog):
* src/pgtkterm.c (pgtk_cr_export_frames):
* src/print.c (PRINTPREPARE, temp_output_buffer_setup)
(Fprin1_to_string, print_vectorlike):
* src/process.c (Fmake_process, create_process, Fmake_pipe_process)
(Fmake_serial_process, connect_network_socket, Fmake_network_process)
(network_interface_info, server_accept_connection)
(wait_reading_process_output, read_process_output, exec_sentinel):
* src/regex-emacs.c (re_match_2_internal):
* src/search.c (looking_at_1, fast_looking_at, search_buffer_re):
* src/sound.c (Fplay_sound_internal):
* src/sysdep.c (system_process_attributes):
* src/term.c (tty_menu_show):
* src/textprop.c (Fnext_single_char_property_change)
(Fprevious_single_char_property_change, add_text_properties_1)
(set_text_properties, set_text_properties_1, Fremove_text_properties)
(Fremove_list_of_text_properties):
* src/thread.c (Fmutex_lock, invoke_thread_function):
* src/undo.c (truncate_undo_list):
* src/w32fns.c (Fx_create_frame, w32_create_tip_frame, w32_hide_tip)
(Fx_show_tip, Fx_file_dialog):
* src/w32font.c (Fx_select_font):
* src/w32menu.c (set_frame_menubar):
* src/window.c (window_list, next_window, window_list_1)
(run_window_configuration_change_hook, Frun_window_scroll_functions)
(run_window_change_functions, set_window_buffer)
(temp_output_buffer_show, window_scroll, scroll_command)
(Fscroll_other_window, Fscroll_other_window_down):
* src/xdisp.c (safe__call, handle_fontified_prop, handle_face_prop)
(handle_single_display_spec, Fbuffer_text_pixel_size)
(message_dolog, with_echo_area_buffer, setup_echo_area_for_printing)
(display_echo_area, set_message, clear_message, echo_area_display)
(gui_consider_frame_title, prepare_menu_bars, update_menu_bar)
(update_tab_bar, update_tool_bar, redisplay_internal)
(redisplay_preserve_echo_area, run_window_scroll_functions)
(redisplay_window, extend_face_to_end_of_line)
(display_count_lines_logically, display_count_lines_visually)
(display_mode_lines, display_mode_line, Fformat_mode_line)
(decode_mode_spec):
* src/xfns.c (Fx_create_frame, x_create_tip_frame, x_hide_tip)
(Fx_show_tip, Fx_file_dialog, Fx_select_font, Fx_print_frames_dialog):
* src/xmenu.c (set_frame_menubar, create_and_show_popup_menu)
(x_menu_show, create_and_show_dialog, x_dialog_show)
(xw_popup_dialog):
* src/xselect.c (x_get_local_selection, x_reply_selection_request)
(x_handle_selection_request, wait_for_property_change):
* src/xterm.c (x_cr_export_frames, x_connection_closed):
Replace ptrdiff_t with specpdl_ref for referencing specpdl and use the
corresponding functions instead of direct arithmetic.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 89 |
1 files changed, 46 insertions, 43 deletions
diff --git a/src/eval.c b/src/eval.c index ae9b18da0bd..d1c45fca56b 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -65,7 +65,7 @@ union specbinding *backtrace_next (union specbinding *) EXTERNALLY_VISIBLE; | |||
| 65 | union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; | 65 | union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; |
| 66 | 66 | ||
| 67 | static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); | 67 | static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); |
| 68 | static Lisp_Object apply_lambda (Lisp_Object, Lisp_Object, ptrdiff_t); | 68 | static Lisp_Object apply_lambda (Lisp_Object, Lisp_Object, specpdl_ref); |
| 69 | static Lisp_Object lambda_arity (Lisp_Object); | 69 | static Lisp_Object lambda_arity (Lisp_Object); |
| 70 | 70 | ||
| 71 | static Lisp_Object | 71 | static Lisp_Object |
| @@ -282,11 +282,12 @@ Lisp_Object | |||
| 282 | call_debugger (Lisp_Object arg) | 282 | call_debugger (Lisp_Object arg) |
| 283 | { | 283 | { |
| 284 | bool debug_while_redisplaying; | 284 | bool debug_while_redisplaying; |
| 285 | ptrdiff_t count = SPECPDL_INDEX (); | 285 | specpdl_ref count = SPECPDL_INDEX (); |
| 286 | Lisp_Object val; | 286 | Lisp_Object val; |
| 287 | intmax_t old_depth = max_lisp_eval_depth; | 287 | intmax_t old_depth = max_lisp_eval_depth; |
| 288 | /* Do not allow max_specpdl_size less than actual depth (Bug#16603). */ | 288 | /* Do not allow max_specpdl_size less than actual depth (Bug#16603). */ |
| 289 | intmax_t old_max = max (max_specpdl_size, count); | 289 | ptrdiff_t counti = specpdl_ref_to_count (count); |
| 290 | intmax_t old_max = max (max_specpdl_size, counti); | ||
| 290 | 291 | ||
| 291 | /* The previous value of 40 is too small now that the debugger | 292 | /* The previous value of 40 is too small now that the debugger |
| 292 | prints using cl-prin1 instead of prin1. Printing lists nested 8 | 293 | prints using cl-prin1 instead of prin1. Printing lists nested 8 |
| @@ -296,9 +297,9 @@ call_debugger (Lisp_Object arg) | |||
| 296 | 297 | ||
| 297 | /* While debugging Bug#16603, previous value of 100 was found | 298 | /* While debugging Bug#16603, previous value of 100 was found |
| 298 | too small to avoid specpdl overflow in the debugger itself. */ | 299 | too small to avoid specpdl overflow in the debugger itself. */ |
| 299 | max_ensure_room (&max_specpdl_size, count, 200); | 300 | max_ensure_room (&max_specpdl_size, counti, 200); |
| 300 | 301 | ||
| 301 | if (old_max == count) | 302 | if (old_max == counti) |
| 302 | { | 303 | { |
| 303 | /* We can enter the debugger due to specpdl overflow (Bug#16603). */ | 304 | /* We can enter the debugger due to specpdl overflow (Bug#16603). */ |
| 304 | specpdl_ptr--; | 305 | specpdl_ptr--; |
| @@ -348,10 +349,10 @@ call_debugger (Lisp_Object arg) | |||
| 348 | } | 349 | } |
| 349 | 350 | ||
| 350 | void | 351 | void |
| 351 | do_debug_on_call (Lisp_Object code, ptrdiff_t count) | 352 | do_debug_on_call (Lisp_Object code, specpdl_ref count) |
| 352 | { | 353 | { |
| 353 | debug_on_next_call = 0; | 354 | debug_on_next_call = 0; |
| 354 | set_backtrace_debug_on_exit (specpdl + count, true); | 355 | set_backtrace_debug_on_exit (specpdl_ref_to_ptr (count), true); |
| 355 | call_debugger (list1 (code)); | 356 | call_debugger (list1 (code)); |
| 356 | } | 357 | } |
| 357 | 358 | ||
| @@ -929,7 +930,7 @@ usage: (let* VARLIST BODY...) */) | |||
| 929 | (Lisp_Object args) | 930 | (Lisp_Object args) |
| 930 | { | 931 | { |
| 931 | Lisp_Object var, val, elt, lexenv; | 932 | Lisp_Object var, val, elt, lexenv; |
| 932 | ptrdiff_t count = SPECPDL_INDEX (); | 933 | specpdl_ref count = SPECPDL_INDEX (); |
| 933 | 934 | ||
| 934 | lexenv = Vinternal_interpreter_environment; | 935 | lexenv = Vinternal_interpreter_environment; |
| 935 | 936 | ||
| @@ -989,7 +990,7 @@ usage: (let VARLIST BODY...) */) | |||
| 989 | { | 990 | { |
| 990 | Lisp_Object *temps, tem, lexenv; | 991 | Lisp_Object *temps, tem, lexenv; |
| 991 | Lisp_Object elt; | 992 | Lisp_Object elt; |
| 992 | ptrdiff_t count = SPECPDL_INDEX (); | 993 | specpdl_ref count = SPECPDL_INDEX (); |
| 993 | ptrdiff_t argnum; | 994 | ptrdiff_t argnum; |
| 994 | USE_SAFE_ALLOCA; | 995 | USE_SAFE_ALLOCA; |
| 995 | 996 | ||
| @@ -1093,7 +1094,7 @@ If FUNCTION takes less time to execute than TIMEOUT seconds, MESSAGE | |||
| 1093 | is not displayed. */) | 1094 | is not displayed. */) |
| 1094 | (Lisp_Object timeout, Lisp_Object message, Lisp_Object function) | 1095 | (Lisp_Object timeout, Lisp_Object message, Lisp_Object function) |
| 1095 | { | 1096 | { |
| 1096 | ptrdiff_t count = SPECPDL_INDEX (); | 1097 | specpdl_ref count = SPECPDL_INDEX (); |
| 1097 | 1098 | ||
| 1098 | CHECK_NUMBER (timeout); | 1099 | CHECK_NUMBER (timeout); |
| 1099 | CHECK_STRING (message); | 1100 | CHECK_STRING (message); |
| @@ -1306,7 +1307,7 @@ usage: (unwind-protect BODYFORM UNWINDFORMS...) */) | |||
| 1306 | (Lisp_Object args) | 1307 | (Lisp_Object args) |
| 1307 | { | 1308 | { |
| 1308 | Lisp_Object val; | 1309 | Lisp_Object val; |
| 1309 | ptrdiff_t count = SPECPDL_INDEX (); | 1310 | specpdl_ref count = SPECPDL_INDEX (); |
| 1310 | 1311 | ||
| 1311 | record_unwind_protect (prog_ignore, XCDR (args)); | 1312 | record_unwind_protect (prog_ignore, XCDR (args)); |
| 1312 | val = eval_sub (XCAR (args)); | 1313 | val = eval_sub (XCAR (args)); |
| @@ -1430,7 +1431,7 @@ internal_lisp_condition_case (Lisp_Object var, Lisp_Object bodyform, | |||
| 1430 | /* Bind HANDLER_VAR to VAL while evaluating HANDLER_BODY. | 1431 | /* Bind HANDLER_VAR to VAL while evaluating HANDLER_BODY. |
| 1431 | The unbind_to undoes just this binding; whoever longjumped | 1432 | The unbind_to undoes just this binding; whoever longjumped |
| 1432 | to us unwound the stack to C->pdlcount before throwing. */ | 1433 | to us unwound the stack to C->pdlcount before throwing. */ |
| 1433 | ptrdiff_t count = SPECPDL_INDEX (); | 1434 | specpdl_ref count = SPECPDL_INDEX (); |
| 1434 | specbind (handler_var, val); | 1435 | specbind (handler_var, val); |
| 1435 | return unbind_to (count, Fprogn (handler_body)); | 1436 | return unbind_to (count, Fprogn (handler_body)); |
| 1436 | } | 1437 | } |
| @@ -1451,7 +1452,7 @@ internal_lisp_condition_case (Lisp_Object var, Lisp_Object bodyform, | |||
| 1451 | handler_var = Qinternal_interpreter_environment; | 1452 | handler_var = Qinternal_interpreter_environment; |
| 1452 | } | 1453 | } |
| 1453 | 1454 | ||
| 1454 | ptrdiff_t count = SPECPDL_INDEX (); | 1455 | specpdl_ref count = SPECPDL_INDEX (); |
| 1455 | specbind (handler_var, result); | 1456 | specbind (handler_var, result); |
| 1456 | return unbind_to (count, Fprogn (success_handler)); | 1457 | return unbind_to (count, Fprogn (success_handler)); |
| 1457 | } | 1458 | } |
| @@ -1815,7 +1816,8 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit) | |||
| 1815 | { | 1816 | { |
| 1816 | /* Edebug takes care of restoring these variables when it exits. */ | 1817 | /* Edebug takes care of restoring these variables when it exits. */ |
| 1817 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 20); | 1818 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 20); |
| 1818 | max_ensure_room (&max_specpdl_size, SPECPDL_INDEX (), 40); | 1819 | ptrdiff_t counti = specpdl_ref_to_count (SPECPDL_INDEX ()); |
| 1820 | max_ensure_room (&max_specpdl_size, counti, 40); | ||
| 1819 | 1821 | ||
| 1820 | call2 (Vsignal_hook_function, error_symbol, data); | 1822 | call2 (Vsignal_hook_function, error_symbol, data); |
| 1821 | } | 1823 | } |
| @@ -1883,8 +1885,9 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit) | |||
| 1883 | && !NILP (Ffboundp (Qdebug_early))) | 1885 | && !NILP (Ffboundp (Qdebug_early))) |
| 1884 | { | 1886 | { |
| 1885 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); | 1887 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); |
| 1886 | max_ensure_room (&max_specpdl_size, SPECPDL_INDEX (), 200); | 1888 | specpdl_ref count = SPECPDL_INDEX (); |
| 1887 | ptrdiff_t count = SPECPDL_INDEX (); | 1889 | ptrdiff_t counti = specpdl_ref_to_count (count); |
| 1890 | max_ensure_room (&max_specpdl_size, counti, 200); | ||
| 1888 | specbind (Qdebugger, Qdebug_early); | 1891 | specbind (Qdebugger, Qdebug_early); |
| 1889 | call_debugger (list2 (Qerror, Fcons (error_symbol, data))); | 1892 | call_debugger (list2 (Qerror, Fcons (error_symbol, data))); |
| 1890 | unbind_to (count, Qnil); | 1893 | unbind_to (count, Qnil); |
| @@ -2271,7 +2274,7 @@ load_with_autoload_queue | |||
| 2271 | (Lisp_Object file, Lisp_Object noerror, Lisp_Object nomessage, | 2274 | (Lisp_Object file, Lisp_Object noerror, Lisp_Object nomessage, |
| 2272 | Lisp_Object nosuffix, Lisp_Object must_suffix) | 2275 | Lisp_Object nosuffix, Lisp_Object must_suffix) |
| 2273 | { | 2276 | { |
| 2274 | ptrdiff_t count = SPECPDL_INDEX (); | 2277 | specpdl_ref count = SPECPDL_INDEX (); |
| 2275 | 2278 | ||
| 2276 | /* If autoloading gets an error (which includes the error of failing | 2279 | /* If autoloading gets an error (which includes the error of failing |
| 2277 | to define the function being called), we use Vautoload_queue | 2280 | to define the function being called), we use Vautoload_queue |
| @@ -2350,7 +2353,7 @@ LEXICAL can also be an actual lexical environment, in the form of an | |||
| 2350 | alist mapping symbols to their value. */) | 2353 | alist mapping symbols to their value. */) |
| 2351 | (Lisp_Object form, Lisp_Object lexical) | 2354 | (Lisp_Object form, Lisp_Object lexical) |
| 2352 | { | 2355 | { |
| 2353 | ptrdiff_t count = SPECPDL_INDEX (); | 2356 | specpdl_ref count = SPECPDL_INDEX (); |
| 2354 | specbind (Qinternal_interpreter_environment, | 2357 | specbind (Qinternal_interpreter_environment, |
| 2355 | CONSP (lexical) || NILP (lexical) ? lexical : list1 (Qt)); | 2358 | CONSP (lexical) || NILP (lexical) ? lexical : list1 (Qt)); |
| 2356 | return unbind_to (count, eval_sub (form)); | 2359 | return unbind_to (count, eval_sub (form)); |
| @@ -2361,7 +2364,7 @@ grow_specpdl_allocation (void) | |||
| 2361 | { | 2364 | { |
| 2362 | eassert (specpdl_ptr == specpdl + specpdl_size); | 2365 | eassert (specpdl_ptr == specpdl + specpdl_size); |
| 2363 | 2366 | ||
| 2364 | ptrdiff_t count = SPECPDL_INDEX (); | 2367 | specpdl_ref count = SPECPDL_INDEX (); |
| 2365 | ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); | 2368 | ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); |
| 2366 | union specbinding *pdlvec = specpdl - 1; | 2369 | union specbinding *pdlvec = specpdl - 1; |
| 2367 | ptrdiff_t pdlvecsize = specpdl_size + 1; | 2370 | ptrdiff_t pdlvecsize = specpdl_size + 1; |
| @@ -2375,7 +2378,7 @@ grow_specpdl_allocation (void) | |||
| 2375 | pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl); | 2378 | pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl); |
| 2376 | specpdl = pdlvec + 1; | 2379 | specpdl = pdlvec + 1; |
| 2377 | specpdl_size = pdlvecsize - 1; | 2380 | specpdl_size = pdlvecsize - 1; |
| 2378 | specpdl_ptr = specpdl + count; | 2381 | specpdl_ptr = specpdl_ref_to_ptr (count); |
| 2379 | } | 2382 | } |
| 2380 | 2383 | ||
| 2381 | /* Grow the specpdl stack by one entry. | 2384 | /* Grow the specpdl stack by one entry. |
| @@ -2396,10 +2399,10 @@ grow_specpdl (void) | |||
| 2396 | grow_specpdl_allocation (); | 2399 | grow_specpdl_allocation (); |
| 2397 | } | 2400 | } |
| 2398 | 2401 | ||
| 2399 | ptrdiff_t | 2402 | specpdl_ref |
| 2400 | record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) | 2403 | record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) |
| 2401 | { | 2404 | { |
| 2402 | ptrdiff_t count = SPECPDL_INDEX (); | 2405 | specpdl_ref count = SPECPDL_INDEX (); |
| 2403 | 2406 | ||
| 2404 | eassert (nargs >= UNEVALLED); | 2407 | eassert (nargs >= UNEVALLED); |
| 2405 | specpdl_ptr->bt.kind = SPECPDL_BACKTRACE; | 2408 | specpdl_ptr->bt.kind = SPECPDL_BACKTRACE; |
| @@ -2449,7 +2452,7 @@ eval_sub (Lisp_Object form) | |||
| 2449 | CHECK_LIST (original_args); | 2452 | CHECK_LIST (original_args); |
| 2450 | 2453 | ||
| 2451 | /* This also protects them from gc. */ | 2454 | /* This also protects them from gc. */ |
| 2452 | ptrdiff_t count | 2455 | specpdl_ref count |
| 2453 | = record_in_backtrace (original_fun, &original_args, UNEVALLED); | 2456 | = record_in_backtrace (original_fun, &original_args, UNEVALLED); |
| 2454 | 2457 | ||
| 2455 | if (debug_on_next_call) | 2458 | if (debug_on_next_call) |
| @@ -2498,13 +2501,13 @@ eval_sub (Lisp_Object form) | |||
| 2498 | vals[argnum++] = eval_sub (arg); | 2501 | vals[argnum++] = eval_sub (arg); |
| 2499 | } | 2502 | } |
| 2500 | 2503 | ||
| 2501 | set_backtrace_args (specpdl + count, vals, argnum); | 2504 | set_backtrace_args (specpdl_ref_to_ptr (count), vals, argnum); |
| 2502 | 2505 | ||
| 2503 | val = XSUBR (fun)->function.aMANY (argnum, vals); | 2506 | val = XSUBR (fun)->function.aMANY (argnum, vals); |
| 2504 | 2507 | ||
| 2505 | lisp_eval_depth--; | 2508 | lisp_eval_depth--; |
| 2506 | /* Do the debug-on-exit now, while VALS still exists. */ | 2509 | /* Do the debug-on-exit now, while VALS still exists. */ |
| 2507 | if (backtrace_debug_on_exit (specpdl + count)) | 2510 | if (backtrace_debug_on_exit (specpdl_ref_to_ptr (count))) |
| 2508 | val = call_debugger (list2 (Qexit, val)); | 2511 | val = call_debugger (list2 (Qexit, val)); |
| 2509 | SAFE_FREE (); | 2512 | SAFE_FREE (); |
| 2510 | specpdl_ptr--; | 2513 | specpdl_ptr--; |
| @@ -2520,7 +2523,7 @@ eval_sub (Lisp_Object form) | |||
| 2520 | args_left = Fcdr (args_left); | 2523 | args_left = Fcdr (args_left); |
| 2521 | } | 2524 | } |
| 2522 | 2525 | ||
| 2523 | set_backtrace_args (specpdl + count, argvals, numargs); | 2526 | set_backtrace_args (specpdl_ref_to_ptr (count), argvals, numargs); |
| 2524 | 2527 | ||
| 2525 | switch (i) | 2528 | switch (i) |
| 2526 | { | 2529 | { |
| @@ -2592,7 +2595,7 @@ eval_sub (Lisp_Object form) | |||
| 2592 | } | 2595 | } |
| 2593 | if (EQ (funcar, Qmacro)) | 2596 | if (EQ (funcar, Qmacro)) |
| 2594 | { | 2597 | { |
| 2595 | ptrdiff_t count1 = SPECPDL_INDEX (); | 2598 | specpdl_ref count1 = SPECPDL_INDEX (); |
| 2596 | Lisp_Object exp; | 2599 | Lisp_Object exp; |
| 2597 | /* Bind lexical-binding during expansion of the macro, so the | 2600 | /* Bind lexical-binding during expansion of the macro, so the |
| 2598 | macro can know reliably if the code it outputs will be | 2601 | macro can know reliably if the code it outputs will be |
| @@ -2624,7 +2627,7 @@ eval_sub (Lisp_Object form) | |||
| 2624 | } | 2627 | } |
| 2625 | 2628 | ||
| 2626 | lisp_eval_depth--; | 2629 | lisp_eval_depth--; |
| 2627 | if (backtrace_debug_on_exit (specpdl + count)) | 2630 | if (backtrace_debug_on_exit (specpdl_ref_to_ptr (count))) |
| 2628 | val = call_debugger (list2 (Qexit, val)); | 2631 | val = call_debugger (list2 (Qexit, val)); |
| 2629 | specpdl_ptr--; | 2632 | specpdl_ptr--; |
| 2630 | 2633 | ||
| @@ -3070,7 +3073,7 @@ Thus, (funcall \\='cons \\='x \\='y) returns (x . y). | |||
| 3070 | usage: (funcall FUNCTION &rest ARGUMENTS) */) | 3073 | usage: (funcall FUNCTION &rest ARGUMENTS) */) |
| 3071 | (ptrdiff_t nargs, Lisp_Object *args) | 3074 | (ptrdiff_t nargs, Lisp_Object *args) |
| 3072 | { | 3075 | { |
| 3073 | ptrdiff_t count; | 3076 | specpdl_ref count; |
| 3074 | 3077 | ||
| 3075 | maybe_quit (); | 3078 | maybe_quit (); |
| 3076 | 3079 | ||
| @@ -3092,7 +3095,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 3092 | Lisp_Object val = funcall_general (args[0], nargs - 1, args + 1); | 3095 | Lisp_Object val = funcall_general (args[0], nargs - 1, args + 1); |
| 3093 | 3096 | ||
| 3094 | lisp_eval_depth--; | 3097 | lisp_eval_depth--; |
| 3095 | if (backtrace_debug_on_exit (specpdl + count)) | 3098 | if (backtrace_debug_on_exit (specpdl_ref_to_ptr (count))) |
| 3096 | val = call_debugger (list2 (Qexit, val)); | 3099 | val = call_debugger (list2 (Qexit, val)); |
| 3097 | specpdl_ptr--; | 3100 | specpdl_ptr--; |
| 3098 | return val; | 3101 | return val; |
| @@ -3183,7 +3186,7 @@ fetch_and_exec_byte_code (Lisp_Object fun, ptrdiff_t args_template, | |||
| 3183 | } | 3186 | } |
| 3184 | 3187 | ||
| 3185 | static Lisp_Object | 3188 | static Lisp_Object |
| 3186 | apply_lambda (Lisp_Object fun, Lisp_Object args, ptrdiff_t count) | 3189 | apply_lambda (Lisp_Object fun, Lisp_Object args, specpdl_ref count) |
| 3187 | { | 3190 | { |
| 3188 | Lisp_Object *arg_vector; | 3191 | Lisp_Object *arg_vector; |
| 3189 | Lisp_Object tem; | 3192 | Lisp_Object tem; |
| @@ -3200,12 +3203,12 @@ apply_lambda (Lisp_Object fun, Lisp_Object args, ptrdiff_t count) | |||
| 3200 | arg_vector[i] = tem; | 3203 | arg_vector[i] = tem; |
| 3201 | } | 3204 | } |
| 3202 | 3205 | ||
| 3203 | set_backtrace_args (specpdl + count, arg_vector, numargs); | 3206 | set_backtrace_args (specpdl_ref_to_ptr (count), arg_vector, numargs); |
| 3204 | tem = funcall_lambda (fun, numargs, arg_vector); | 3207 | tem = funcall_lambda (fun, numargs, arg_vector); |
| 3205 | 3208 | ||
| 3206 | lisp_eval_depth--; | 3209 | lisp_eval_depth--; |
| 3207 | /* Do the debug-on-exit now, while arg_vector still exists. */ | 3210 | /* Do the debug-on-exit now, while arg_vector still exists. */ |
| 3208 | if (backtrace_debug_on_exit (specpdl + count)) | 3211 | if (backtrace_debug_on_exit (specpdl_ref_to_ptr (count))) |
| 3209 | tem = call_debugger (list2 (Qexit, tem)); | 3212 | tem = call_debugger (list2 (Qexit, tem)); |
| 3210 | SAFE_FREE (); | 3213 | SAFE_FREE (); |
| 3211 | specpdl_ptr--; | 3214 | specpdl_ptr--; |
| @@ -3222,7 +3225,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, | |||
| 3222 | register Lisp_Object *arg_vector) | 3225 | register Lisp_Object *arg_vector) |
| 3223 | { | 3226 | { |
| 3224 | Lisp_Object val, syms_left, next, lexenv; | 3227 | Lisp_Object val, syms_left, next, lexenv; |
| 3225 | ptrdiff_t count = SPECPDL_INDEX (); | 3228 | specpdl_ref count = SPECPDL_INDEX (); |
| 3226 | ptrdiff_t i; | 3229 | ptrdiff_t i; |
| 3227 | bool optional, rest; | 3230 | bool optional, rest; |
| 3228 | 3231 | ||
| @@ -3820,9 +3823,9 @@ record_unwind_protect_nothing (void) | |||
| 3820 | It need not be at the top of the stack. */ | 3823 | It need not be at the top of the stack. */ |
| 3821 | 3824 | ||
| 3822 | void | 3825 | void |
| 3823 | clear_unwind_protect (ptrdiff_t count) | 3826 | clear_unwind_protect (specpdl_ref count) |
| 3824 | { | 3827 | { |
| 3825 | union specbinding *p = specpdl + count; | 3828 | union specbinding *p = specpdl_ref_to_ptr (count); |
| 3826 | p->unwind_void.kind = SPECPDL_UNWIND_VOID; | 3829 | p->unwind_void.kind = SPECPDL_UNWIND_VOID; |
| 3827 | p->unwind_void.func = do_nothing; | 3830 | p->unwind_void.func = do_nothing; |
| 3828 | } | 3831 | } |
| @@ -3832,10 +3835,10 @@ clear_unwind_protect (ptrdiff_t count) | |||
| 3832 | previous value without invoking it. */ | 3835 | previous value without invoking it. */ |
| 3833 | 3836 | ||
| 3834 | void | 3837 | void |
| 3835 | set_unwind_protect (ptrdiff_t count, void (*func) (Lisp_Object), | 3838 | set_unwind_protect (specpdl_ref count, void (*func) (Lisp_Object), |
| 3836 | Lisp_Object arg) | 3839 | Lisp_Object arg) |
| 3837 | { | 3840 | { |
| 3838 | union specbinding *p = specpdl + count; | 3841 | union specbinding *p = specpdl_ref_to_ptr (count); |
| 3839 | p->unwind.kind = SPECPDL_UNWIND; | 3842 | p->unwind.kind = SPECPDL_UNWIND; |
| 3840 | p->unwind.func = func; | 3843 | p->unwind.func = func; |
| 3841 | p->unwind.arg = arg; | 3844 | p->unwind.arg = arg; |
| @@ -3843,9 +3846,9 @@ set_unwind_protect (ptrdiff_t count, void (*func) (Lisp_Object), | |||
| 3843 | } | 3846 | } |
| 3844 | 3847 | ||
| 3845 | void | 3848 | void |
| 3846 | set_unwind_protect_ptr (ptrdiff_t count, void (*func) (void *), void *arg) | 3849 | set_unwind_protect_ptr (specpdl_ref count, void (*func) (void *), void *arg) |
| 3847 | { | 3850 | { |
| 3848 | union specbinding *p = specpdl + count; | 3851 | union specbinding *p = specpdl_ref_to_ptr (count); |
| 3849 | p->unwind_ptr.kind = SPECPDL_UNWIND_PTR; | 3852 | p->unwind_ptr.kind = SPECPDL_UNWIND_PTR; |
| 3850 | p->unwind_ptr.func = func; | 3853 | p->unwind_ptr.func = func; |
| 3851 | p->unwind_ptr.arg = arg; | 3854 | p->unwind_ptr.arg = arg; |
| @@ -3855,13 +3858,13 @@ set_unwind_protect_ptr (ptrdiff_t count, void (*func) (void *), void *arg) | |||
| 3855 | depth COUNT is reached. Return VALUE. */ | 3858 | depth COUNT is reached. Return VALUE. */ |
| 3856 | 3859 | ||
| 3857 | Lisp_Object | 3860 | Lisp_Object |
| 3858 | unbind_to (ptrdiff_t count, Lisp_Object value) | 3861 | unbind_to (specpdl_ref count, Lisp_Object value) |
| 3859 | { | 3862 | { |
| 3860 | Lisp_Object quitf = Vquit_flag; | 3863 | Lisp_Object quitf = Vquit_flag; |
| 3861 | 3864 | ||
| 3862 | Vquit_flag = Qnil; | 3865 | Vquit_flag = Qnil; |
| 3863 | 3866 | ||
| 3864 | while (specpdl_ptr != specpdl + count) | 3867 | while (specpdl_ptr != specpdl_ref_to_ptr (count)) |
| 3865 | { | 3868 | { |
| 3866 | /* Copy the binding, and decrement specpdl_ptr, before we do | 3869 | /* Copy the binding, and decrement specpdl_ptr, before we do |
| 3867 | the work to unbind it. We decrement first | 3870 | the work to unbind it. We decrement first |
| @@ -4152,7 +4155,7 @@ NFRAMES and BASE specify the activation frame to use, as in `backtrace-frame'. | |||
| 4152 | (Lisp_Object exp, Lisp_Object nframes, Lisp_Object base) | 4155 | (Lisp_Object exp, Lisp_Object nframes, Lisp_Object base) |
| 4153 | { | 4156 | { |
| 4154 | union specbinding *pdl = get_backtrace_frame (nframes, base); | 4157 | union specbinding *pdl = get_backtrace_frame (nframes, base); |
| 4155 | ptrdiff_t count = SPECPDL_INDEX (); | 4158 | specpdl_ref count = SPECPDL_INDEX (); |
| 4156 | ptrdiff_t distance = specpdl_ptr - pdl; | 4159 | ptrdiff_t distance = specpdl_ptr - pdl; |
| 4157 | eassert (distance >= 0); | 4160 | eassert (distance >= 0); |
| 4158 | 4161 | ||