# HG changeset patch # User Steve Losh # Date 1462830098 0 # Node ID 4050f38d971597c22b93177a155a44244f0550a1 # Parent b36cb61805d4fca21b3f81f896208f397525b317 Rename `heap-cell` to just `cell` This is in preparation for the big register-content switch, when registers and stack frames will contain actual cells, not just addresses. So really these things aren't heap-specific, so we should just call them "cells". diff -r b36cb61805d4 -r 4050f38d9715 src/wam/cells.lisp --- a/src/wam/cells.lisp Sun May 08 21:25:08 2016 +0000 +++ b/src/wam/cells.lisp Mon May 09 21:41:38 2016 +0000 @@ -27,16 +27,16 @@ ;;; symbol lives. Arity is the arity of the functor. -(defun* cell-type ((cell heap-cell)) - (:returns heap-cell-tag) +(defun* cell-type ((cell cell)) + (:returns cell-tag) (logand cell +cell-tag-bitmask+)) -(defun* cell-value ((cell heap-cell)) - (:returns heap-cell-value) +(defun* cell-value ((cell cell)) + (:returns cell-value) (ash cell (- +cell-tag-width+))) -(defun* cell-type-name ((cell heap-cell)) +(defun* cell-type-name ((cell cell)) (:returns string) (eswitch ((cell-type cell) :test #'=) (+tag-null+ "NULL") @@ -44,7 +44,7 @@ (+tag-reference+ "REFERENCE") (+tag-functor+ "FUNCTOR"))) -(defun* cell-type-short-name ((cell heap-cell)) +(defun* cell-type-short-name ((cell cell)) (:returns string) (eswitch ((cell-type cell) :test #'=) (+tag-null+ "NUL") @@ -53,12 +53,12 @@ (+tag-functor+ "FUN"))) -(defun* cell-functor-index ((cell heap-cell)) +(defun* cell-functor-index ((cell cell)) (:returns functor-index) (cell-value cell)) -(defun* cell-aesthetic ((cell heap-cell)) +(defun* cell-aesthetic ((cell cell)) "Return a compact, human-friendly string representation of the cell." (format nil "[~A~A]" (cell-type-short-name cell) @@ -73,43 +73,43 @@ (format nil " ~X" (cell-value cell)))))) -(defun* cell-null-p ((cell heap-cell)) +(defun* cell-null-p ((cell cell)) (:returns boolean) (= (cell-type cell) +tag-null+)) -(defun* cell-reference-p ((cell heap-cell)) +(defun* cell-reference-p ((cell cell)) (:returns boolean) (= (cell-type cell) +tag-reference+)) -(defun* cell-functor-p ((cell heap-cell)) +(defun* cell-functor-p ((cell cell)) (:returns boolean) (= (cell-type cell) +tag-functor+)) -(defun* cell-structure-p ((cell heap-cell)) +(defun* cell-structure-p ((cell cell)) (:returns boolean) (= (cell-type cell) +tag-structure+)) -(defun* make-cell ((tag heap-cell-tag) (value heap-cell-value)) - (:returns heap-cell) +(defun* make-cell ((tag cell-tag) (value cell-value)) + (:returns cell) (values (logior (ash value +cell-tag-width+) tag))) (defun* make-cell-null () - (:returns heap-cell) + (:returns cell) (make-cell +tag-null+ 0)) -(defun* make-cell-structure ((value heap-cell-value)) - (:returns heap-cell) +(defun* make-cell-structure ((value cell-value)) + (:returns cell) (make-cell +tag-structure+ value)) -(defun* make-cell-reference ((value heap-cell-value)) - (:returns heap-cell) +(defun* make-cell-reference ((value cell-value)) + (:returns cell) (make-cell +tag-reference+ value)) (defun* make-cell-functor ((functor-index functor-index)) - (:returns heap-cell) + (:returns cell) (make-cell +tag-functor+ functor-index)) diff -r b36cb61805d4 -r 4050f38d9715 src/wam/constants.lisp --- a/src/wam/constants.lisp Sun May 08 21:25:08 2016 +0000 +++ b/src/wam/constants.lisp Mon May 09 21:41:38 2016 +0000 @@ -1,7 +1,7 @@ (in-package #:bones.wam) (define-constant +cell-width+ 16 - :documentation "Number of bits in each heap cell.") + :documentation "Number of bits in each cell.") (define-constant +cell-tag-width+ 2 :documentation "Number of bits reserved for cell type tags.") diff -r b36cb61805d4 -r 4050f38d9715 src/wam/types.lisp --- a/src/wam/types.lisp Sun May 08 21:25:08 2016 +0000 +++ b/src/wam/types.lisp Mon May 09 21:41:38 2016 +0000 @@ -1,12 +1,12 @@ (in-package #:bones.wam) -(deftype heap-cell () +(deftype cell () `(unsigned-byte ,+cell-width+)) -(deftype heap-cell-tag () +(deftype cell-tag () `(unsigned-byte ,+cell-tag-width+)) -(deftype heap-cell-value () +(deftype cell-value () `(unsigned-byte ,+cell-value-width+)) diff -r b36cb61805d4 -r 4050f38d9715 src/wam/vm.lisp --- a/src/wam/vm.lisp Sun May 08 21:25:08 2016 +0000 +++ b/src/wam/vm.lisp Mon May 09 21:41:38 2016 +0000 @@ -8,12 +8,12 @@ ;;;; Utilities (defun* push-unbound-reference! ((wam wam)) - (:returns (values heap-cell heap-index)) + (:returns (values cell heap-index)) "Push a new unbound reference cell onto the heap." (wam-heap-push! wam (make-cell-reference (wam-heap-pointer wam)))) (defun* push-new-structure! ((wam wam)) - (:returns (values heap-cell heap-index)) + (:returns (values cell heap-index)) "Push a new structure cell onto the heap. The structure cell's value will point at the next address, so make sure you @@ -23,7 +23,7 @@ (wam-heap-push! wam (make-cell-structure (1+ (wam-heap-pointer wam))))) (defun* push-new-functor! ((wam wam) (functor functor-index)) - (:returns (values heap-cell heap-index)) + (:returns (values cell heap-index)) "Push a new functor cell onto the heap." (wam-heap-push! wam (make-cell-functor functor))) @@ -44,7 +44,7 @@ (and (cell-reference-p cell) (= (cell-value cell) address))))) -(defun* matching-functor-p ((cell heap-cell) +(defun* matching-functor-p ((cell cell) (functor functor-index)) (:returns boolean) "Return whether `cell` is a functor cell containing `functor`." @@ -52,8 +52,8 @@ (and (cell-functor-p cell) (= (cell-functor-index cell) functor)))) -(defun* functors-match-p ((functor-cell-1 heap-cell) - (functor-cell-2 heap-cell)) +(defun* functors-match-p ((functor-cell-1 cell) + (functor-cell-2 cell)) (:returns boolean) "Return whether the two functor cells represent the same functor." (= (cell-value functor-cell-1) diff -r b36cb61805d4 -r 4050f38d9715 src/wam/wam.lisp --- a/src/wam/wam.lisp Sun May 08 21:25:08 2016 +0000 +++ b/src/wam/wam.lisp Mon May 09 21:41:38 2016 +0000 @@ -42,8 +42,8 @@ :fill-pointer +stack-end+ :adjustable t :initial-element (make-cell-null) - :element-type 'heap-cell) - :type (vector heap-cell) + :element-type 'cell) + :type (vector cell) :read-only t) (code ;; The WAM bytecode is all stored in this array. The first @@ -103,8 +103,8 @@ ;;; TODO: Should we privilege heap address 0 to mean "unset" so we have a good ;;; sentinal value for HB, S, etc? -(defun* wam-heap-push! ((wam wam) (cell heap-cell)) - (:returns (values heap-cell heap-index)) +(defun* wam-heap-push! ((wam wam) (cell cell)) + (:returns (values cell heap-index)) "Push the cell onto the WAM heap and increment the heap pointer. Returns the cell and the address it was pushed to. @@ -125,7 +125,7 @@ (defun* wam-heap-cell ((wam wam) (address heap-index)) - (:returns heap-cell) + (:returns cell) "Return the heap cell at the given address." (aref (wam-store wam) address)) @@ -275,7 +275,7 @@ &optional ((e environment-pointer) (wam-environment-pointer wam))) - (:returns heap-cell) + (:returns cell) (wam-heap-cell wam (wam-stack-frame-arg wam n e))) @@ -381,7 +381,7 @@ &optional ((b backtrack-pointer) (wam-backtrack-pointer wam))) - (:returns heap-cell) + (:returns cell) (wam-heap-cell wam (wam-stack-choice-arg wam n b)))