[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 5376563 17/19: Fix `comp-add-call-cstr' and add a te
From: |
Andrea Corallo |
Subject: |
feature/native-comp 5376563 17/19: Fix `comp-add-call-cstr' and add a test |
Date: |
Mon, 21 Dec 2020 14:52:41 -0500 (EST) |
branch: feature/native-comp
commit 5376563517f2235b8b79f661c213fd74dd62b654
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
Fix `comp-add-call-cstr' and add a test
* lisp/emacs-lisp/comp.el (comp-add-call-cstr): Fix it.
* test/src/comp-tests.el (assume-in-loop-1): New test.
* test/src/comp-test-funcs.el (comp-test-assume-in-loop-1-f): New
function.
---
lisp/emacs-lisp/comp.el | 13 ++++++++-----
test/src/comp-test-funcs.el | 12 ++++++++++++
test/src/comp-tests.el | 4 ++++
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 895e1ac..5345e20 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -2017,21 +2017,24 @@ TARGET-BB-SYM is the symbol name of the target block."
(pcase insn
(`(set ,lhs (,(pred comp-call-op-p) ,f . ,args))
(when-let ((cstr-f (gethash f comp-known-func-cstr-h)))
- (cl-values cstr-f lhs args)))
+ (cl-values f cstr-f lhs args)))
(`(,(pred comp-call-op-p) ,f . ,args)
(when-let ((cstr-f (gethash f comp-known-func-cstr-h)))
- (cl-values cstr-f nil args))))))
- (cl-multiple-value-bind (cstr-f lhs args) match
+ (cl-values f cstr-f nil args))))))
+ (cl-multiple-value-bind (f cstr-f lhs args) match
(cl-loop
+ with gen = (comp-lambda-list-gen (comp-cstr-f-args cstr-f))
for arg in args
- for gen = (comp-lambda-list-gen (comp-cstr-f-args cstr-f))
for cstr = (funcall gen)
for target = (comp-cond-cstrs-target-mvar arg insn bb)
+ unless (comp-cstr-p cstr)
+ do (signal 'native-ice
+ (list "Incoherent type specifier for function" f))
when (and target
(or (null lhs)
(not (eql (comp-mvar-slot lhs)
(comp-mvar-slot target)))))
- do (comp-emit-call-cstr target insn-cell cstr)))))))
+ do (comp-emit-call-cstr target insn-cell cstr)))))))
(defun comp-add-cstrs (_)
"Rewrite conditional branches adding appropriate 'assume' insns.
diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el
index 7f70fc2..a2663ea 100644
--- a/test/src/comp-test-funcs.el
+++ b/test/src/comp-test-funcs.el
@@ -405,6 +405,18 @@
;; collection is t, not (member t)!
(member value collection)))
+(defun comp-test-assume-in-loop-1-f (arg)
+ ;; Reduced from `comint-delim-arg'.
+ (let ((args nil)
+ (pos 0)
+ (len (length arg)))
+ (while (< pos len)
+ (let ((start pos))
+ (while (< pos len)
+ (setq pos (1+ pos)))
+ (setq args (cons (substring arg start pos) args))))
+ args))
+
;;;;;;;;;;;;;;;;;;;;
;; Tromey's tests ;;
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index eeff599..0594a4e 100644
--- a/test/src/comp-tests.el
+++ b/test/src/comp-tests.el
@@ -405,6 +405,10 @@
https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
"In fwprop assumtions (not (not (member x))) /= (member x)."
(should-not (comp-test-assume-double-neg-f "bar" "foo")))
+(comp-deftest assume-in-loop-1 ()
+ "Broken call args assumptions lead to infinite loop."
+ (should (equal (comp-test-assume-in-loop-1-f "cd") '("cd"))))
+
(defvar comp-test-primitive-advice)
(comp-deftest primitive-advice ()
"Test effectiveness of primitive advicing."
- feature/native-comp 0255108 08/19: * Rename comp-cond-cstr into comp-add-cstrs, (continued)
- feature/native-comp 0255108 08/19: * Rename comp-cond-cstr into comp-add-cstrs, Andrea Corallo, 2020/12/21
- feature/native-comp 48d43f5 04/19: * Improve constraint simplification logic in comp-cstr.el, Andrea Corallo, 2020/12/21
- feature/native-comp 07b75de 10/19: Enhance type inference constraining function arguments, Andrea Corallo, 2020/12/21
- feature/native-comp e0f20da 14/19: Simplify correctly (or (integer 1 1) (not (integer 1 1))) as t, Andrea Corallo, 2020/12/21
- feature/native-comp 6f3570c 16/19: Fix value type inference for doubly negate constraints, Andrea Corallo, 2020/12/21
- feature/native-comp d072ee9 07/19: * Two minors in comp.el, Andrea Corallo, 2020/12/21
- feature/native-comp 23791cf 09/19: * Allow for modifying insn-cell inside `comp-loop-insn-in-block', Andrea Corallo, 2020/12/21
- feature/native-comp 9bbe6ea 15/19: Fix native compiler tests when they are bytecompiled, Andrea Corallo, 2020/12/21
- feature/native-comp 8e816b0 11/19: Symplify type specifier (not t) as nil, Andrea Corallo, 2020/12/21
- feature/native-comp c70c080 12/19: * Allow for overlapping src and dst in cstr set operations, Andrea Corallo, 2020/12/21
- feature/native-comp 5376563 17/19: Fix `comp-add-call-cstr' and add a test,
Andrea Corallo <=
- feature/native-comp ebf8963 18/19: * Fix a bunch of known type specifiers, Andrea Corallo, 2020/12/21
- feature/native-comp 9676e4d 19/19: * Fix a test in auth-source-tests.el, Andrea Corallo, 2020/12/21
- feature/native-comp 3540b1f 13/19: * Guarantee fwprop convergence and termination, Andrea Corallo, 2020/12/21