]> git.eshelyaron.com Git - emacs.git/commitdiff
BdiscardN support
authorAndrea Corallo <andrea_corallo@yahoo.it>
Sun, 16 Jun 2019 10:40:23 +0000 (12:40 +0200)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:33:42 +0000 (11:33 +0100)
src/comp.c
test/src/comp-tests.el

index fd7e7beda1e81dd2fd00faf34e866988a9e1feb2..f19fc84479bc23da5e2511835a4af7147851e2a2 100644 (file)
@@ -1197,20 +1197,16 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
        case Bstack_ref3:
        case Bstack_ref4:
        case Bstack_ref5:
-         {
-           PUSH_LVAL (stack_base[(stack - stack_base) - (op - Bstack_ref) - 1]);
-           break;
-         }
+         PUSH_LVAL (stack_base[(stack - stack_base) - (op - Bstack_ref) - 1]);
+         break;
+
        case Bstack_ref6:
-         {
-           PUSH_LVAL (stack_base[(stack - stack_base) - FETCH - 1]);
-           break;
-         }
+         PUSH_LVAL (stack_base[(stack - stack_base) - FETCH - 1]);
+         break;
+
        case Bstack_ref7:
-         {
-           PUSH_LVAL (stack_base[(stack - stack_base) - FETCH2 - 1]);
-           break;
-         }
+         PUSH_LVAL (stack_base[(stack - stack_base) - FETCH2 - 1]);
+         break;
 
        case Bvarref7:
          op = FETCH2;
@@ -1966,8 +1962,20 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
        case Bstack_set2:
          error ("Bstack_set2 not supported");
          break;
+
        case BdiscardN:
-         error ("BdiscardN not supported");
+         op = FETCH;
+         if (op & 0x80)
+           {
+             op &= 0x7F;
+             POP1;
+             gcc_jit_block_add_assignment (comp.bblock->gcc_bb,
+                                           NULL,
+                                           *(stack - op - 1),
+                                           args[0]);
+           }
+
+         stack -= op;
          break;
        case Bswitch:
          error ("Bswitch not supported");
@@ -1978,6 +1986,7 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
             a constant on the stack.  */
          goto fail;
          break;
+
        default:
        case Bconstant:
          {
index 9d1ee65e4ee11f370d27762b1569807299e6f435..f1acc42b8cafdd14e2086246dbe377a80198e47c 100644 (file)
   (should (eq (comp-tests-numberp-f 'a) nil))
   (should (eq (comp-tests-numberp-f 3.5) t)))
 
+(ert-deftest comp-tests-stack ()
+  "Test some stack operation."
+  (defun comp-tests-discardn-f (x)
+    ;; BdiscardN
+    (1+ (let ((a 1)
+            (_b)
+            (_c))
+        a)))
+
+  (byte-compile #'comp-tests-discardn-f)
+  (native-compile #'comp-tests-discardn-f)
+
+  (should (= (comp-tests-discardn-f 10) 2)))
+
 (ert-deftest comp-tests-gc ()
   "Try to do some longer computation to let the gc kick in."
   (dotimes (_ 100000)