From: Andrea Corallo Date: Sun, 11 Aug 2019 12:10:57 +0000 (+0200) Subject: add save-restriction support X-Git-Tag: emacs-28.0.90~2727^2~1295 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7dc99d5d51fcadafcd7e38f169ef8b353db61e81;p=emacs.git add save-restriction support --- diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 357085ee479..3789a517740 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -642,14 +642,15 @@ the annotation emission." (byte-save-excursion (comp-emit '(call record_unwind_protect_excursion))) (byte-save-window-excursion-OBSOLETE) - (byte-save-restriction) - (byte-catch) + (byte-save-restriction + '(call helper-save-restriction)) + (byte-catch) ;; Obsolete (byte-unwind-protect (comp-emit `(call helper_unwind_protect ,(comp-slot-next)))) - (byte-condition-case) + (byte-condition-case) ;; Obsolete (byte-temp-output-buffer-setup-OBSOLETE) (byte-temp-output-buffer-show-OBSOLETE) - (byte-unbind-all) + (byte-unbind-all) ;; Obsolete (byte-set-marker auto) (byte-match-beginning auto) (byte-match-end auto) diff --git a/src/comp.c b/src/comp.c index 90fa5ccdfa3..a4793a36ada 100644 --- a/src/comp.c +++ b/src/comp.c @@ -165,6 +165,8 @@ Lisp_Object helper_unbind_n (Lisp_Object n); bool helper_PSEUDOVECTOR_TYPEP_XUNTAG (const union vectorlike_header *a, enum pvec_type code); +void helper_emit_save_restriction (void); + static char * ATTRIBUTE_FORMAT_PRINTF (1, 2) format_string (const char *format, ...) @@ -2075,6 +2077,8 @@ DEFUN ("comp-init-ctxt", Fcomp_init_ctxt, Scomp_init_ctxt, emit_simple_limple_call_lisp_ret); register_emitter (Qrecord_unwind_protect_excursion, emit_simple_limple_call_void_ret); + register_emitter (Qhelper_save_restriction, + emit_simple_limple_call_void_ret); } comp.ctxt = gcc_jit_context_acquire(); @@ -2389,6 +2393,8 @@ DEFUN ("comp-compile-and-load-ctxt", Fcomp_compile_and_load_ctxt, /******************************************************************************/ /* Helper functions called from the runtime. */ /* These can't be statics till shared mechanism is used to solve relocations. */ +/* Note: this are all potentially definable directly to gcc and are here just */ +/* for lazyness. Change this if a performance impact is measured. */ /******************************************************************************/ Lisp_Object @@ -2402,7 +2408,8 @@ helper_save_window_excursion (Lisp_Object v1) return v1; } -void helper_unwind_protect (Lisp_Object handler) +void +helper_unwind_protect (Lisp_Object handler) { /* Support for a function here is new in 24.4. */ record_unwind_protect (FUNCTIONP (handler) ? bcall0 : prog_ignore, @@ -2432,6 +2439,14 @@ helper_PSEUDOVECTOR_TYPEP_XUNTAG (const union vectorlike_header *a, code); } +void +helper_emit_save_restriction (void) +{ + record_unwind_protect (save_restriction_restore, + save_restriction_save ()); +} + + void syms_of_comp (void) { @@ -2457,6 +2472,7 @@ syms_of_comp (void) DEFSYM (Qrecord_unwind_protect_excursion, "record_unwind_protect_excursion"); DEFSYM (Qhelper_unbind_n, "helper_unbind_n"); DEFSYM (Qhelper_unwind_protect, "helper_unwind_protect"); + DEFSYM (Qhelper_save_restriction, "helper_save_restriction") defsubr (&Scomp_init_ctxt); defsubr (&Scomp_release_ctxt);