Skip to content

Commit

Permalink
Fix btb compiler for variable cells
Browse files Browse the repository at this point in the history
  • Loading branch information
Bike committed Sep 25, 2023
1 parent f14ba72 commit 6deac7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/core/symbol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ CL_DEFUN VariableCell_sp core__ensure_variable_cell(Symbol_sp name) {
return name->ensureVariableCell();
}

CL_LISPIFY_NAME(variable-cell/name);
CL_DEFUN T_sp core__variable_cell_name(VariableCell_sp vcell) {
return vcell->name();
}

bool Symbol_O::boundP() const {
VariableCell_sp vcell = variableCell();
if (vcell.unboundp()) return false;
Expand Down
15 changes: 8 additions & 7 deletions src/lisp/kernel/cleavir/compile-bytecode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,10 +1090,10 @@
(defmethod compile-instruction ((mnemonic (eql :special-bind))
inserter annot context &rest args)
(declare (ignore annot))
(destructuring-bind (symbol) args
(destructuring-bind (vcell) args
(let* ((next (mapcar #'bt:block-entry-extra
(context-successors context)))
(const (inserter-vcell symbol inserter))
(const (inserter-vcell (core:variable-cell/name vcell) inserter))
(value (stack-pop context))
(bind (ast-to-bir:terminate inserter 'bir:constant-bind
:inputs (list const value)
Expand All @@ -1103,18 +1103,19 @@
(defmethod compile-instruction ((mnemonic (eql :symbol-value))
inserter annot context &rest args)
(declare (ignore annot))
(destructuring-bind (symbol) args
(let ((const (inserter-vcell symbol inserter))
(out (make-instance 'bir:output :name symbol)))
(destructuring-bind (vcell) args
(let* ((symbol (core:variable-cell/name vcell))
(const (inserter-vcell symbol inserter))
(out (make-instance 'bir:output :name symbol)))
(ast-to-bir:insert inserter 'bir:constant-symbol-value
:inputs (list const) :outputs (list out))
(stack-push out context))))

(defmethod compile-instruction ((mnemonic (eql :symbol-value-set))
inserter annot context &rest args)
(declare (ignore annot))
(destructuring-bind (symbol) args
(let ((const (inserter-vcell symbol inserter))
(destructuring-bind (vcell) args
(let ((const (inserter-vcell (core:variable-cell/name vcell) inserter))
(in (stack-pop context)))
(ast-to-bir:insert inserter 'bir:set-constant-symbol-value
:inputs (list const in)))))
Expand Down

0 comments on commit 6deac7c

Please sign in to comment.