diff --git a/src/lisp/kernel/cleavir/ast-interpreter.lisp b/src/lisp/kernel/cleavir/ast-interpreter.lisp index 98bd19cbdc..d13840d285 100644 --- a/src/lisp/kernel/cleavir/ast-interpreter.lisp +++ b/src/lisp/kernel/cleavir/ast-interpreter.lisp @@ -1,9 +1,8 @@ (defpackage #:interpret-ast (:use #:cl) (:export #:interpret) - (:shadow #:variable) - ;; FIXME: lose this asap - (:export #:*system*)) + (:export #:cannot-interpret #:cannot-interpret-ast) + (:shadow #:variable)) ;;;; NOTE: Some methods in this file must be compiled with cleavir, ;;;; as they use cleavir special operators - metacircularity, eh? @@ -50,20 +49,26 @@ ;; Do actual work (interpret-ast ast env))) +(define-condition cannot-interpret (error) + ((ast :reader cannot-interpret-ast :initarg :ast)) + (:report (lambda (condition stream) + (format stream "Interpreter not implemented for AST: ~a" + (cannot-interpret-ast condition))))) + ;;; meat (defgeneric interpret-ast (ast env)) (defmethod interpret-ast (ast env) (declare (ignore env)) - (error "AST interpreter not implemented for ~a" ast)) + (error 'cannot-interpret :ast ast)) ;;; distinguished only to make sure the input ast is correct (defgeneric interpret-boolean (condition env)) (defmethod interpret-boolean (condition env) (declare (ignore then else env)) - (error "AST boolean interpreter not implemented for ~a" condition)) + (error 'cannot-interpret :ast condition)) (defmethod interpret-ast ((ast cleavir-ast:immediate-ast) env) (declare (ignore env)) diff --git a/src/lisp/kernel/cleavir/setup.lisp b/src/lisp/kernel/cleavir/setup.lisp index 9d8a56e3e6..3f8fc22871 100644 --- a/src/lisp/kernel/cleavir/setup.lisp +++ b/src/lisp/kernel/cleavir/setup.lisp @@ -311,7 +311,12 @@ when this is t a lot of graphs will be generated.") (cond (core:*use-interpreter-for-eval* (core:interpret form (cleavir-env->interpreter env))) (*use-ast-interpreter* - (ast-interpret-form form env)) + (handler-case + (ast-interpret-form form env) + (interpret-ast:cannot-interpret (c) + (declare (ignore c)) + ;; If the AST interpreter doesn't work, fall back. + (cclasp-eval form env)))) (t (cclasp-eval form env)))) diff --git a/src/lisp/kernel/cmp/compile-file-parallel.lsp b/src/lisp/kernel/cmp/compile-file-parallel.lsp index d7c4ba3ecc..739a14a7d2 100644 --- a/src/lisp/kernel/cmp/compile-file-parallel.lsp +++ b/src/lisp/kernel/cmp/compile-file-parallel.lsp @@ -370,27 +370,7 @@ Compile a lisp source file into an LLVM module." (bformat t "conditions: %s%N" c))) (compile-file-results output-path conditions)))))) - -(defun contains-defcallback-p (path) - (let ((data (with-open-file (stream path) - (let ((data (make-string (file-length stream)))) - (read-sequence data stream) - data)))) - (search "defcallback" data :test #'string-equal))) - - (defvar *compile-file-parallel* nil) -#+(or) -(defun cl:compile-file (input-file &rest args) - "Ok, this is a horrible hack - if the file DOESN'T contain defcallback then compile-file-parallel it" - (if *compile-file-parallel* - (if (null (contains-defcallback-p input-file)) - (apply #'compile-file-parallel input-file args) - (progn - (format t "!~%!~%!~% Falling back to compile-file-serial for ~s because it contains DEFCALLBACK~%!~%~~%" - input-file) - (apply #'compile-file-serial input-file args))) - (apply #'compile-file-serial input-file args))) (defun cl:compile-file (input-file &rest args) (if *compile-file-parallel* @@ -399,5 +379,4 @@ Compile a lisp source file into an LLVM module." (eval-when (:load-toplevel) (setf *compile-file-parallel* t) - #-cst (setf clasp-cleavir::*use-ast-interpreter* t))