]> git.eshelyaron.com Git - emacs.git/commitdiff
add save-restriction support
authorAndrea Corallo <andrea_corallo@yahoo.it>
Sun, 11 Aug 2019 12:10:57 +0000 (14:10 +0200)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:33:59 +0000 (11:33 +0100)
lisp/emacs-lisp/comp.el
src/comp.c

index 357085ee479836f9ec54127b45c501210ab524b0..3789a517740a1a586c67599f5727bccf13e80f7c 100644 (file)
@@ -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)
index 90fa5ccdfa326c925b66e2952eb8a5a1c15ce2c8..a4793a36ada0e5804198e48907314f243fb874e2 100644 (file)
@@ -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);
+
 \f
 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 ());
+}
+
+\f
 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);