diff options
| author | Andrea Corallo | 2019-11-21 16:09:30 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:38:08 +0100 |
| commit | 71b363e2b3c709e64f8ef8ab7446cc3a19573eeb (patch) | |
| tree | 0967d036c2e057cc899fcc9079a2cab943f80786 | |
| parent | 23874aee8825a6f670b6c2da9eca2d9cf643b3af (diff) | |
| download | emacs-71b363e2b3c709e64f8ef8ab7446cc3a19573eeb.tar.gz emacs-71b363e2b3c709e64f8ef8ab7446cc3a19573eeb.zip | |
error handling rework
| -rw-r--r-- | lisp/emacs-lisp/comp.el | 70 | ||||
| -rw-r--r-- | src/comp.c | 100 |
2 files changed, 100 insertions, 70 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index e1f0e657864..666d467051e 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el | |||
| @@ -389,7 +389,8 @@ Put PREFIX in front of it." | |||
| 389 | (defun comp-decrypt-lambda-list (x) | 389 | (defun comp-decrypt-lambda-list (x) |
| 390 | "Decript lambda list X." | 390 | "Decript lambda list X." |
| 391 | (unless (fixnump x) | 391 | (unless (fixnump x) |
| 392 | (error "Can't native compile a non lexical scoped function")) | 392 | (signal 'native-compiler-error |
| 393 | "can't native compile a non lexical scoped function")) | ||
| 393 | (let ((rest (not (= (logand x 128) 0))) | 394 | (let ((rest (not (= (logand x 128) 0))) |
| 394 | (mandatory (logand x 127)) | 395 | (mandatory (logand x 127)) |
| 395 | (nonrest (ash x -8))) | 396 | (nonrest (ash x -8))) |
| @@ -409,7 +410,7 @@ Put PREFIX in front of it." | |||
| 409 | 410 | ||
| 410 | (defun comp-spill-lap-function (_function-name) | 411 | (defun comp-spill-lap-function (_function-name) |
| 411 | "Byte compile FUNCTION-NAME spilling data from the byte compiler." | 412 | "Byte compile FUNCTION-NAME spilling data from the byte compiler." |
| 412 | (error "To be reimplemented") | 413 | (signal 'native-ice "to be reimplemented") |
| 413 | ;; (let* ((f (symbol-function function-name)) | 414 | ;; (let* ((f (symbol-function function-name)) |
| 414 | ;; (func (make-comp-func :symbol-name function-name | 415 | ;; (func (make-comp-func :symbol-name function-name |
| 415 | ;; :c-func-name (comp-c-func-name | 416 | ;; :c-func-name (comp-c-func-name |
| @@ -435,7 +436,7 @@ Put PREFIX in front of it." | |||
| 435 | "Byte compile FILENAME spilling data from the byte compiler." | 436 | "Byte compile FILENAME spilling data from the byte compiler." |
| 436 | (byte-compile-file filename) | 437 | (byte-compile-file filename) |
| 437 | (unless byte-to-native-top-level-forms | 438 | (unless byte-to-native-top-level-forms |
| 438 | (error "Empty byte compiler output")) | 439 | (signal 'native-compiler-error "empty byte compiler output")) |
| 439 | (setf (comp-ctxt-top-level-forms comp-ctxt) (reverse byte-to-native-top-level-forms)) | 440 | (setf (comp-ctxt-top-level-forms comp-ctxt) (reverse byte-to-native-top-level-forms)) |
| 440 | (cl-loop | 441 | (cl-loop |
| 441 | for f in (cl-loop for x in byte-to-native-top-level-forms ; All non anonymous. | 442 | for f in (cl-loop for x in byte-to-native-top-level-forms ; All non anonymous. |
| @@ -538,7 +539,7 @@ Restore the original value afterwards." | |||
| 538 | (defsubst comp-label-to-addr (label) | 539 | (defsubst comp-label-to-addr (label) |
| 539 | "Find the address of LABEL." | 540 | "Find the address of LABEL." |
| 540 | (or (gethash label (comp-limplify-label-to-addr comp-pass)) | 541 | (or (gethash label (comp-limplify-label-to-addr comp-pass)) |
| 541 | (error "Can't find label %d" label))) | 542 | (signal 'native-ice (list "label not found" label)))) |
| 542 | 543 | ||
| 543 | (defsubst comp-mark-curr-bb-closed () | 544 | (defsubst comp-mark-curr-bb-closed () |
| 544 | "Mark the current basic block as closed." | 545 | "Mark the current basic block as closed." |
| @@ -556,8 +557,9 @@ The basic block is returned regardless it was already declared or not." | |||
| 556 | (comp-limplify-pending-blocks comp-pass))))) | 557 | (comp-limplify-pending-blocks comp-pass))))) |
| 557 | (if bb | 558 | (if bb |
| 558 | (progn | 559 | (progn |
| 559 | (cl-assert (or (null sp) (= sp (comp-block-sp bb))) | 560 | (unless (or (null sp) (= sp (comp-block-sp bb))) |
| 560 | (sp (comp-block-sp bb)) "sp %d %d differs") | 561 | (signal 'native-ice (list "incoherent stack pointers" |
| 562 | sp (comp-block-sp bb)))) | ||
| 561 | bb) | 563 | bb) |
| 562 | (car (push (make--comp-block lap-addr sp (comp-new-block-sym)) | 564 | (car (push (make--comp-block lap-addr sp (comp-new-block-sym)) |
| 563 | (comp-limplify-pending-blocks comp-pass)))))) | 565 | (comp-limplify-pending-blocks comp-pass)))))) |
| @@ -607,7 +609,7 @@ If the callee function is known to have a return type propagate it." | |||
| 607 | (defun comp-copy-slot (src-n &optional dst-n) | 609 | (defun comp-copy-slot (src-n &optional dst-n) |
| 608 | "Set slot number DST-N to slot number SRC-N as source. | 610 | "Set slot number DST-N to slot number SRC-N as source. |
| 609 | If DST-N is specified use it otherwise assume it to be the current slot." | 611 | If DST-N is specified use it otherwise assume it to be the current slot." |
| 610 | (comp-with-sp (if dst-n dst-n (comp-sp)) | 612 | (comp-with-sp (or dst-n (comp-sp)) |
| 611 | (let ((src-slot (comp-slot-n src-n))) | 613 | (let ((src-slot (comp-slot-n src-n))) |
| 612 | (cl-assert src-slot) | 614 | (cl-assert src-slot) |
| 613 | (comp-emit `(set ,(comp-slot) ,src-slot))))) | 615 | (comp-emit `(set ,(comp-slot) ,src-slot))))) |
| @@ -749,28 +751,28 @@ Return value is the fall through block name." | |||
| 749 | ;; All fall through are artificially created here except the last one. | 751 | ;; All fall through are artificially created here except the last one. |
| 750 | (puthash ff-bb-name ff-bb (comp-func-blocks comp-func)) | 752 | (puthash ff-bb-name ff-bb (comp-func-blocks comp-func)) |
| 751 | (setf (comp-limplify-curr-block comp-pass) ff-bb)))) | 753 | (setf (comp-limplify-curr-block comp-pass) ff-bb)))) |
| 752 | (_ (error "Missing previous setimm while creating a switch")))) | 754 | (_ (signal 'native-ice |
| 755 | "missing previous setimm while creating a switch")))) | ||
| 753 | 756 | ||
| 754 | (defun comp-emit-set-call-subr (subr-name sp-delta) | 757 | (defun comp-emit-set-call-subr (subr-name sp-delta) |
| 755 | "Emit a call for SUBR-NAME. | 758 | "Emit a call for SUBR-NAME. |
| 756 | SP-DELTA is the stack adjustment." | 759 | SP-DELTA is the stack adjustment." |
| 757 | (let ((subr (symbol-function subr-name)) | 760 | (let ((subr (symbol-function subr-name)) |
| 758 | (subr-str (symbol-name subr-name)) | ||
| 759 | (nargs (1+ (- sp-delta)))) | 761 | (nargs (1+ (- sp-delta)))) |
| 760 | (cl-assert (subrp subr) nil | 762 | (unless (subrp subr) |
| 761 | "%s not a subr" subr-str) | 763 | (signal 'native-ice (list "not a subr" subr))) |
| 762 | (let* ((arity (subr-arity subr)) | 764 | (let* ((arity (subr-arity subr)) |
| 763 | (minarg (car arity)) | 765 | (minarg (car arity)) |
| 764 | (maxarg (cdr arity))) | 766 | (maxarg (cdr arity))) |
| 765 | (cl-assert (not (eq maxarg 'unevalled)) nil | 767 | (when (eq maxarg 'unevalled) |
| 766 | "%s contains unevalled arg" subr-name) | 768 | (signal 'native-ice (list "subr contains unevalled args" subr-name))) |
| 767 | (if (eq maxarg 'many) | 769 | (if (eq maxarg 'many) |
| 768 | ;; callref case. | 770 | ;; callref case. |
| 769 | (comp-emit-set-call (comp-callref subr-name nargs (comp-sp))) | 771 | (comp-emit-set-call (comp-callref subr-name nargs (comp-sp))) |
| 770 | ;; Normal call. | 772 | ;; Normal call. |
| 771 | (cl-assert (and (>= maxarg nargs) (<= minarg nargs)) | 773 | (unless (and (>= maxarg nargs) (<= minarg nargs)) |
| 772 | (nargs maxarg minarg) | 774 | (signal 'native-ice |
| 773 | "Incoherent stack adjustment %d, maxarg %d minarg %d") | 775 | (list "incoherent stack adjustment" nargs maxarg minarg))) |
| 774 | (let* ((subr-name subr-name) | 776 | (let* ((subr-name subr-name) |
| 775 | (slots (cl-loop for i from 0 below maxarg | 777 | (slots (cl-loop for i from 0 below maxarg |
| 776 | collect (comp-slot-n (+ i (comp-sp)))))) | 778 | collect (comp-slot-n (+ i (comp-sp)))))) |
| @@ -817,9 +819,9 @@ the annotation emission." | |||
| 817 | `(cl-incf (comp-sp) ,sp-delta)) | 819 | `(cl-incf (comp-sp) ,sp-delta)) |
| 818 | ,@(comp-body-eff body op-name sp-delta)) | 820 | ,@(comp-body-eff body op-name sp-delta)) |
| 819 | else | 821 | else |
| 820 | collect `(',op (error ,(concat "Unsupported LAP op " | 822 | collect `(',op (signal 'native-ice |
| 821 | op-name)))) | 823 | (list "unsupported LAP op" ',op-name)))) |
| 822 | (_ (error "Unexpected LAP op %s" (symbol-name op))))) | 824 | (_ (signal 'native-ice (list "unexpected LAP op" (symbol-name op)))))) |
| 823 | 825 | ||
| 824 | (defun comp-limplify-lap-inst (insn) | 826 | (defun comp-limplify-lap-inst (insn) |
| 825 | "Limplify LAP instruction INSN pushng it in the proper basic block." | 827 | "Limplify LAP instruction INSN pushng it in the proper basic block." |
| @@ -1011,8 +1013,7 @@ the annotation emission." | |||
| 1011 | (cl-incf (comp-sp) (- 1 arg)) | 1013 | (cl-incf (comp-sp) (- 1 arg)) |
| 1012 | (comp-emit-set-call (comp-callref 'insert arg (comp-sp)))) | 1014 | (comp-emit-set-call (comp-callref 'insert arg (comp-sp)))) |
| 1013 | (byte-stack-set | 1015 | (byte-stack-set |
| 1014 | (comp-with-sp (1+ (comp-sp)) ;; FIXME!! | 1016 | (comp-copy-slot (1+ (comp-sp)) (- (comp-sp) arg -1))) |
| 1015 | (comp-copy-slot (comp-sp) (- (comp-sp) arg)))) | ||
| 1016 | (byte-stack-set2 (cl-assert nil)) ;; TODO | 1017 | (byte-stack-set2 (cl-assert nil)) ;; TODO |
| 1017 | (byte-discardN | 1018 | (byte-discardN |
| 1018 | (cl-incf (comp-sp) (- arg))) | 1019 | (cl-incf (comp-sp) (- arg))) |
| @@ -1203,9 +1204,9 @@ Top level forms for the current context are rendered too." | |||
| 1203 | ;; This pass should be run every time basic blocks or mvar are shuffled. | 1204 | ;; This pass should be run every time basic blocks or mvar are shuffled. |
| 1204 | 1205 | ||
| 1205 | (cl-defun make-comp-ssa-mvar (&key slot (constant nil const-vld) type) | 1206 | (cl-defun make-comp-ssa-mvar (&key slot (constant nil const-vld) type) |
| 1206 | (make--comp-mvar :id (funcall (comp-func-ssa-cnt-gen comp-func)) | 1207 | (make--comp-mvar :id (funcall (comp-func-ssa-cnt-gen comp-func)) |
| 1207 | :slot slot :const-vld const-vld :constant constant | 1208 | :slot slot :const-vld const-vld :constant constant |
| 1208 | :type type)) | 1209 | :type type)) |
| 1209 | 1210 | ||
| 1210 | (defun comp-compute-edges () | 1211 | (defun comp-compute-edges () |
| 1211 | "Compute the basic block edges for the current function." | 1212 | "Compute the basic block edges for the current function." |
| @@ -1234,8 +1235,10 @@ Top level forms for the current context are rendered too." | |||
| 1234 | (edge-add :src bb :dst (gethash forth blocks))) | 1235 | (edge-add :src bb :dst (gethash forth blocks))) |
| 1235 | (return) | 1236 | (return) |
| 1236 | (otherwise | 1237 | (otherwise |
| 1237 | (error "Block %s does not end with a branch in func %s" | 1238 | (signal 'native-ice |
| 1238 | bb (comp-func-symbol-name comp-func)))) | 1239 | (list "block does not end with a branch" |
| 1240 | bb | ||
| 1241 | (comp-func-symbol-name comp-func))))) | ||
| 1239 | finally (progn | 1242 | finally (progn |
| 1240 | (setf (comp-func-edges comp-func) | 1243 | (setf (comp-func-edges comp-func) |
| 1241 | (nreverse (comp-func-edges comp-func))) | 1244 | (nreverse (comp-func-edges comp-func))) |
| @@ -1280,7 +1283,7 @@ Top level forms for the current context are rendered too." | |||
| 1280 | (first-processed (l) | 1283 | (first-processed (l) |
| 1281 | (if-let ((p (cl-find-if (lambda (p) (comp-block-dom p)) l))) | 1284 | (if-let ((p (cl-find-if (lambda (p) (comp-block-dom p)) l))) |
| 1282 | p | 1285 | p |
| 1283 | (error "Cant't find first preprocessed")))) | 1286 | (signal 'native-ice "cant't find first preprocessed")))) |
| 1284 | 1287 | ||
| 1285 | (when-let ((blocks (comp-func-blocks comp-func)) | 1288 | (when-let ((blocks (comp-func-blocks comp-func)) |
| 1286 | (entry (gethash 'entry blocks)) | 1289 | (entry (gethash 'entry blocks)) |
| @@ -1845,7 +1848,8 @@ If INPUT is a string, use it as the file path to be native compiled. | |||
| 1845 | Return the compilation unit filename." | 1848 | Return the compilation unit filename." |
| 1846 | (unless (or (symbolp input) | 1849 | (unless (or (symbolp input) |
| 1847 | (stringp input)) | 1850 | (stringp input)) |
| 1848 | (error "Trying to native compile something not a symbol function or file")) | 1851 | (signal 'native-compiler-error |
| 1852 | (list "not a symbol function or file" input))) | ||
| 1849 | (let ((data input) | 1853 | (let ((data input) |
| 1850 | (comp-native-compiling t) | 1854 | (comp-native-compiling t) |
| 1851 | (comp-ctxt (make-comp-ctxt | 1855 | (comp-ctxt (make-comp-ctxt |
| @@ -1858,7 +1862,12 @@ Return the compilation unit filename." | |||
| 1858 | (comp-log (format "Running pass %s:\n" pass) 2) | 1862 | (comp-log (format "Running pass %s:\n" pass) 2) |
| 1859 | (setq data (funcall pass data))) | 1863 | (setq data (funcall pass data))) |
| 1860 | comp-passes) | 1864 | comp-passes) |
| 1861 | (error (error "While compiling %s: %s" input (error-message-string err)))) | 1865 | (native-compiler-error |
| 1866 | ;; Add source input. | ||
| 1867 | (let ((err-val (cdr err))) | ||
| 1868 | (signal (car err) (if (consp err-val) | ||
| 1869 | (cons input err-val) | ||
| 1870 | (list input err-val)))))) | ||
| 1862 | data)) | 1871 | data)) |
| 1863 | 1872 | ||
| 1864 | ;;;###autoload | 1873 | ;;;###autoload |
| @@ -1874,7 +1883,8 @@ Follow folders RECURSIVELY if non nil." | |||
| 1874 | (directory-files input t "\\.el$")) | 1883 | (directory-files input t "\\.el$")) |
| 1875 | (if (file-exists-p input) | 1884 | (if (file-exists-p input) |
| 1876 | (list input) | 1885 | (list input) |
| 1877 | (error "Input not a file nor directory"))))) | 1886 | (signal 'native-compiler-error |
| 1887 | "input not a file nor directory"))))) | ||
| 1878 | (with-mutex comp-src-pool-mutex | 1888 | (with-mutex comp-src-pool-mutex |
| 1879 | (setf comp-src-pool (nconc files comp-src-pool))) | 1889 | (setf comp-src-pool (nconc files comp-src-pool))) |
| 1880 | (cl-loop repeat jobs | 1890 | (cl-loop repeat jobs |
diff --git a/src/comp.c b/src/comp.c index f7950bcc72c..61f297ea3d0 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -70,14 +70,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 70 | #endif | 70 | #endif |
| 71 | #define SETJMP_NAME STR (SETJMP) | 71 | #define SETJMP_NAME STR (SETJMP) |
| 72 | 72 | ||
| 73 | /* Raise an internal compiler error if test. | ||
| 74 | msg is evaluated only in that case. */ | ||
| 75 | #define ICE_IF(test, msg) \ | ||
| 76 | do { \ | ||
| 77 | if (test) \ | ||
| 78 | ice (msg); \ | ||
| 79 | } while (0) | ||
| 80 | |||
| 81 | /* C side of the compiler context. */ | 73 | /* C side of the compiler context. */ |
| 82 | 74 | ||
| 83 | typedef struct { | 75 | typedef struct { |
| @@ -211,15 +203,6 @@ format_string (const char *format, ...) | |||
| 211 | } | 203 | } |
| 212 | 204 | ||
| 213 | static void | 205 | static void |
| 214 | ice (const char* msg) | ||
| 215 | { | ||
| 216 | if (msg) | ||
| 217 | xsignal1 (Qinternal_native_compiler_error, build_string (msg)); | ||
| 218 | else | ||
| 219 | xsignal0 (Qinternal_native_compiler_error); | ||
| 220 | } | ||
| 221 | |||
| 222 | static void | ||
| 223 | bcall0 (Lisp_Object f) | 206 | bcall0 (Lisp_Object f) |
| 224 | { | 207 | { |
| 225 | Ffuncall (1, &f); | 208 | Ffuncall (1, &f); |
| @@ -273,7 +256,7 @@ type_to_cast_field (gcc_jit_type *type) | |||
| 273 | else if (type == comp.lisp_obj_ptr_type) | 256 | else if (type == comp.lisp_obj_ptr_type) |
| 274 | field = comp.cast_union_as_lisp_obj_ptr; | 257 | field = comp.cast_union_as_lisp_obj_ptr; |
| 275 | else | 258 | else |
| 276 | ice ("unsupported cast"); | 259 | xsignal1 (Qnative_ice, build_string ("unsupported cast")); |
| 277 | 260 | ||
| 278 | return field; | 261 | return field; |
| 279 | } | 262 | } |
| @@ -282,7 +265,9 @@ static gcc_jit_block * | |||
| 282 | retrive_block (Lisp_Object block_name) | 265 | retrive_block (Lisp_Object block_name) |
| 283 | { | 266 | { |
| 284 | Lisp_Object value = Fgethash (block_name, comp.func_blocks_h, Qnil); | 267 | Lisp_Object value = Fgethash (block_name, comp.func_blocks_h, Qnil); |
| 285 | ICE_IF (NILP (value), "missing basic block"); | 268 | |
| 269 | if (NILP (value)) | ||
| 270 | xsignal1 (Qnative_ice, build_string ("missing basic block")); | ||
| 286 | 271 | ||
| 287 | return (gcc_jit_block *) xmint_pointer (value); | 272 | return (gcc_jit_block *) xmint_pointer (value); |
| 288 | } | 273 | } |
| @@ -293,8 +278,10 @@ declare_block (Lisp_Object block_name) | |||
| 293 | char *name_str = SSDATA (SYMBOL_NAME (block_name)); | 278 | char *name_str = SSDATA (SYMBOL_NAME (block_name)); |
| 294 | gcc_jit_block *block = gcc_jit_function_new_block (comp.func, name_str); | 279 | gcc_jit_block *block = gcc_jit_function_new_block (comp.func, name_str); |
| 295 | Lisp_Object value = make_mint_ptr (block); | 280 | Lisp_Object value = make_mint_ptr (block); |
| 296 | ICE_IF (!NILP (Fgethash (block_name, comp.func_blocks_h, Qnil)), | 281 | |
| 297 | "double basic block declaration"); | 282 | if (!NILP (Fgethash (block_name, comp.func_blocks_h, Qnil))) |
| 283 | xsignal1 (Qnative_ice, build_string ("double basic block declaration")); | ||
| 284 | |||
| 298 | Fputhash (block_name, value, comp.func_blocks_h); | 285 | Fputhash (block_name, value, comp.func_blocks_h); |
| 299 | } | 286 | } |
| 300 | 287 | ||
| @@ -343,8 +330,10 @@ declare_imported_func (Lisp_Object subr_sym, gcc_jit_type *ret_type, | |||
| 343 | int nargs, gcc_jit_type **types) | 330 | int nargs, gcc_jit_type **types) |
| 344 | { | 331 | { |
| 345 | /* Don't want to declare the same function two times. */ | 332 | /* Don't want to declare the same function two times. */ |
| 346 | ICE_IF (!NILP (Fgethash (subr_sym, comp.imported_funcs_h, Qnil)), | 333 | if (!NILP (Fgethash (subr_sym, comp.imported_funcs_h, Qnil))) |
| 347 | "unexpected double function declaration"); | 334 | xsignal2 (Qnative_ice, |
| 335 | build_string ("unexpected double function declaration"), | ||
| 336 | subr_sym); | ||
| 348 | 337 | ||
| 349 | if (nargs == MANY) | 338 | if (nargs == MANY) |
| 350 | { | 339 | { |
| @@ -396,7 +385,10 @@ emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, ptrdiff_t nargs, | |||
| 396 | Lisp_Object func = | 385 | Lisp_Object func = |
| 397 | Fgethash (subr_sym, direct ? comp.exported_funcs_h: comp.imported_funcs_h, | 386 | Fgethash (subr_sym, direct ? comp.exported_funcs_h: comp.imported_funcs_h, |
| 398 | Qnil); | 387 | Qnil); |
| 399 | ICE_IF (NILP (func), "missing function declaration"); | 388 | if (NILP (func)) |
| 389 | xsignal2 (Qnative_ice, | ||
| 390 | build_string ("missing function declaration"), | ||
| 391 | subr_sym); | ||
| 400 | 392 | ||
| 401 | if (direct) | 393 | if (direct) |
| 402 | { | 394 | { |
| @@ -414,7 +406,10 @@ emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, ptrdiff_t nargs, | |||
| 414 | gcc_jit_lvalue_access_field (comp.func_relocs, | 406 | gcc_jit_lvalue_access_field (comp.func_relocs, |
| 415 | NULL, | 407 | NULL, |
| 416 | (gcc_jit_field *) xmint_pointer (func)); | 408 | (gcc_jit_field *) xmint_pointer (func)); |
| 417 | ICE_IF (!f_ptr, "undeclared function relocation"); | 409 | if (!f_ptr) |
| 410 | xsignal2 (Qnative_ice, | ||
| 411 | build_string ("missing function relocation"), | ||
| 412 | subr_sym); | ||
| 418 | emit_comment (format_string ("calling subr: %s", | 413 | emit_comment (format_string ("calling subr: %s", |
| 419 | SSDATA (SYMBOL_NAME (subr_sym)))); | 414 | SSDATA (SYMBOL_NAME (subr_sym)))); |
| 420 | return gcc_jit_context_new_call_through_ptr (comp.ctxt, | 415 | return gcc_jit_context_new_call_through_ptr (comp.ctxt, |
| @@ -1092,7 +1087,11 @@ emit_set_internal (Lisp_Object args) | |||
| 1092 | #s(comp-mvar 6 1 t 3 nil)) | 1087 | #s(comp-mvar 6 1 t 3 nil)) |
| 1093 | */ | 1088 | */ |
| 1094 | /* TODO: Inline the most common case. */ | 1089 | /* TODO: Inline the most common case. */ |
| 1095 | ICE_IF (list_length (args) != 3, "unexpected arg length for insns"); | 1090 | if (list_length (args) != 3) |
| 1091 | xsignal2 (Qnative_ice, | ||
| 1092 | build_string ("unexpected arg length for insns"), | ||
| 1093 | args); | ||
| 1094 | |||
| 1096 | args = XCDR (args); | 1095 | args = XCDR (args); |
| 1097 | int i = 0; | 1096 | int i = 0; |
| 1098 | gcc_jit_rvalue *gcc_args[4]; | 1097 | gcc_jit_rvalue *gcc_args[4]; |
| @@ -1272,7 +1271,7 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1272 | else if (EQ (handler_spec, Qcondition_case)) | 1271 | else if (EQ (handler_spec, Qcondition_case)) |
| 1273 | h_num = CONDITION_CASE; | 1272 | h_num = CONDITION_CASE; |
| 1274 | else | 1273 | else |
| 1275 | ice ("incoherent insn"); | 1274 | xsignal2 (Qnative_ice, build_string ("incoherent insn"), insn); |
| 1276 | gcc_jit_rvalue *handler_type = | 1275 | gcc_jit_rvalue *handler_type = |
| 1277 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, | 1276 | gcc_jit_context_new_rvalue_from_int (comp.ctxt, |
| 1278 | comp.int_type, | 1277 | comp.int_type, |
| @@ -1372,9 +1371,13 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1372 | else if (EQ (FIRST (arg1), Qdirect_callref)) | 1371 | else if (EQ (FIRST (arg1), Qdirect_callref)) |
| 1373 | res = emit_limple_call_ref (XCDR (arg1), true); | 1372 | res = emit_limple_call_ref (XCDR (arg1), true); |
| 1374 | else | 1373 | else |
| 1375 | ice ("LIMPLE inconsistent arg1 for op ="); | 1374 | xsignal2 (Qnative_ice, |
| 1375 | build_string ("LIMPLE inconsistent arg1 for insn"), | ||
| 1376 | insn); | ||
| 1376 | 1377 | ||
| 1377 | ICE_IF (!res, gcc_jit_context_get_first_error (comp.ctxt)); | 1378 | if (!res) |
| 1379 | xsignal1 (Qnative_ice, | ||
| 1380 | build_string (gcc_jit_context_get_first_error (comp.ctxt))); | ||
| 1378 | 1381 | ||
| 1379 | emit_frame_assignment (arg[0], res); | 1382 | emit_frame_assignment (arg[0], res); |
| 1380 | } | 1383 | } |
| @@ -1480,7 +1483,9 @@ emit_limple_insn (Lisp_Object insn) | |||
| 1480 | } | 1483 | } |
| 1481 | else | 1484 | else |
| 1482 | { | 1485 | { |
| 1483 | ice ("LIMPLE op inconsistent"); | 1486 | xsignal2 (Qnative_ice, |
| 1487 | build_string ("LIMPLE op inconsistent"), | ||
| 1488 | op); | ||
| 1484 | } | 1489 | } |
| 1485 | } | 1490 | } |
| 1486 | 1491 | ||
| @@ -2860,7 +2865,10 @@ compile_function (Lisp_Object func) | |||
| 2860 | Lisp_Object block_name = HASH_KEY (ht, i); | 2865 | Lisp_Object block_name = HASH_KEY (ht, i); |
| 2861 | Lisp_Object block = HASH_VALUE (ht, i); | 2866 | Lisp_Object block = HASH_VALUE (ht, i); |
| 2862 | Lisp_Object insns = CALL1I (comp-block-insns, block); | 2867 | Lisp_Object insns = CALL1I (comp-block-insns, block); |
| 2863 | ICE_IF (NILP (block) || NILP (insns), "basic block is missing or empty"); | 2868 | if (NILP (block) || NILP (insns)) |
| 2869 | xsignal1 (Qnative_ice, | ||
| 2870 | build_string ("basic block is missing or empty")); | ||
| 2871 | |||
| 2864 | 2872 | ||
| 2865 | comp.block = retrive_block (block_name); | 2873 | comp.block = retrive_block (block_name); |
| 2866 | while (CONSP (insns)) | 2874 | while (CONSP (insns)) |
| @@ -2871,10 +2879,12 @@ compile_function (Lisp_Object func) | |||
| 2871 | } | 2879 | } |
| 2872 | } | 2880 | } |
| 2873 | const char *err = gcc_jit_context_get_first_error (comp.ctxt); | 2881 | const char *err = gcc_jit_context_get_first_error (comp.ctxt); |
| 2874 | ICE_IF (err, | 2882 | if (err) |
| 2875 | format_string ("failing to compile function %s with error: %s", | 2883 | xsignal3 (Qnative_ice, |
| 2876 | SSDATA (SYMBOL_NAME (CALL1I (comp-func-symbol-name, func))), | 2884 | build_string ("failing to compile function"), |
| 2877 | err)); | 2885 | CALL1I (comp-func-symbol-name, func), |
| 2886 | build_string (err)); | ||
| 2887 | |||
| 2878 | SAFE_FREE (); | 2888 | SAFE_FREE (); |
| 2879 | } | 2889 | } |
| 2880 | 2890 | ||
| @@ -2890,7 +2900,8 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt, | |||
| 2890 | { | 2900 | { |
| 2891 | if (comp.ctxt) | 2901 | if (comp.ctxt) |
| 2892 | { | 2902 | { |
| 2893 | ice ("compiler context already taken"); | 2903 | xsignal1 (Qnative_ice, |
| 2904 | build_string ("compiler context already taken")); | ||
| 2894 | return Qnil; | 2905 | return Qnil; |
| 2895 | } | 2906 | } |
| 2896 | 2907 | ||
| @@ -3396,12 +3407,21 @@ syms_of_comp (void) | |||
| 3396 | DEFSYM (Qadvice, "advice"); | 3407 | DEFSYM (Qadvice, "advice"); |
| 3397 | 3408 | ||
| 3398 | /* To be signaled. */ | 3409 | /* To be signaled. */ |
| 3399 | DEFSYM (Qinternal_native_compiler_error, "internal-native-compiler-error"); | 3410 | |
| 3400 | Fput (Qinternal_native_compiler_error, Qerror_conditions, | 3411 | /* By the compiler. */ |
| 3401 | pure_list (Qinternal_native_compiler_error, Qerror)); | 3412 | DEFSYM (Qnative_compiler_error, "native-compiler-error"); |
| 3402 | Fput (Qinternal_native_compiler_error, Qerror_message, | 3413 | Fput (Qnative_compiler_error, Qerror_conditions, |
| 3414 | pure_list (Qnative_compiler_error, Qerror)); | ||
| 3415 | Fput (Qnative_compiler_error, Qerror_message, | ||
| 3416 | build_pure_c_string ("Native compiler error")); | ||
| 3417 | |||
| 3418 | DEFSYM (Qnative_ice, "native-ice"); | ||
| 3419 | Fput (Qnative_ice, Qerror_conditions, | ||
| 3420 | pure_list (Qnative_ice, Qnative_compiler_error, Qerror)); | ||
| 3421 | Fput (Qnative_ice, Qerror_message, | ||
| 3403 | build_pure_c_string ("Internal native compiler error")); | 3422 | build_pure_c_string ("Internal native compiler error")); |
| 3404 | 3423 | ||
| 3424 | /* By the load machinery. */ | ||
| 3405 | DEFSYM (Qnative_lisp_load_failed, "native-lisp-load-failed"); | 3425 | DEFSYM (Qnative_lisp_load_failed, "native-lisp-load-failed"); |
| 3406 | Fput (Qnative_lisp_load_failed, Qerror_conditions, | 3426 | Fput (Qnative_lisp_load_failed, Qerror_conditions, |
| 3407 | pure_list (Qnative_lisp_load_failed, Qerror)); | 3427 | pure_list (Qnative_lisp_load_failed, Qerror)); |