--- a/src/wam/bytecode.lisp Sun Apr 17 21:36:15 2016 +0000
+++ b/src/wam/bytecode.lisp Mon Apr 18 13:08:47 2016 +0000
@@ -10,7 +10,6 @@
"
(eswitch (opcode)
(+opcode-get-structure-local+ 3)
- (+opcode-get-structure-stack+ 3)
(+opcode-unify-variable-local+ 2)
(+opcode-unify-variable-stack+ 2)
(+opcode-unify-value-local+ 2)
@@ -21,7 +20,6 @@
(+opcode-get-value-stack+ 3)
(+opcode-put-structure-local+ 3)
- (+opcode-put-structure-stack+ 3)
(+opcode-set-variable-local+ 2)
(+opcode-set-variable-stack+ 2)
(+opcode-set-value-local+ 2)
@@ -41,7 +39,6 @@
(:returns string)
(eswitch (opcode)
(+opcode-get-structure-local+ "GET-STRUCTURE")
- (+opcode-get-structure-stack+ "GET-STRUCTURE")
(+opcode-unify-variable-local+ "UNIFY-VARIABLE")
(+opcode-unify-variable-stack+ "UNIFY-VARIABLE")
(+opcode-unify-value-local+ "UNIFY-VALUE")
@@ -52,7 +49,6 @@
(+opcode-get-value-stack+ "GET-VALUE")
(+opcode-put-structure-local+ "PUT-STRUCTURE")
- (+opcode-put-structure-stack+ "PUT-STRUCTURE")
(+opcode-set-variable-local+ "SET-VARIABLE")
(+opcode-set-variable-stack+ "SET-VARIABLE")
(+opcode-set-value-local+ "SET-VALUE")
@@ -71,7 +67,6 @@
(:returns string)
(eswitch (opcode)
(+opcode-get-structure-local+ "GETS")
- (+opcode-get-structure-stack+ "GETS")
(+opcode-unify-variable-local+ "UVAR")
(+opcode-unify-variable-stack+ "UVAR")
(+opcode-unify-value-local+ "UVLU")
@@ -82,7 +77,6 @@
(+opcode-get-value-stack+ "GVLU")
(+opcode-put-structure-local+ "PUTS")
- (+opcode-put-structure-stack+ "PUTS")
(+opcode-set-variable-local+ "SVAR")
(+opcode-set-variable-stack+ "SVAR")
(+opcode-set-value-local+ "SVLU")
--- a/src/wam/compiler.lisp Sun Apr 17 21:36:15 2016 +0000
+++ b/src/wam/compiler.lisp Mon Apr 18 13:08:47 2016 +0000
@@ -415,10 +415,9 @@
('(:argument nil :program :stack) +opcode-get-value-stack+)
('(:argument nil :query :local) +opcode-put-value-local+)
('(:argument nil :query :stack) +opcode-put-value-stack+)
+ ;; Structures can only live locally, they never go on the stack
('(:structure nil :program :local) +opcode-get-structure-local+)
- ('(:structure nil :program :stack) +opcode-get-structure-stack+)
('(:structure nil :query :local) +opcode-put-structure-local+)
- ('(:structure nil :query :stack) +opcode-put-structure-stack+)
('(:register t :program :local) +opcode-unify-variable-local+)
('(:register t :program :stack) +opcode-unify-variable-stack+)
('(:register t :query :local) +opcode-set-variable-local+)
--- a/src/wam/constants.lisp Sun Apr 17 21:36:15 2016 +0000
+++ b/src/wam/constants.lisp Mon Apr 18 13:08:47 2016 +0000
@@ -86,35 +86,33 @@
;;;; Opcodes
;;; Program
(define-constant +opcode-get-structure-local+ 0)
-(define-constant +opcode-get-structure-stack+ 1)
-(define-constant +opcode-unify-variable-local+ 2)
-(define-constant +opcode-unify-variable-stack+ 3)
-(define-constant +opcode-unify-value-local+ 4)
-(define-constant +opcode-unify-value-stack+ 5)
-(define-constant +opcode-get-variable-local+ 6)
-(define-constant +opcode-get-variable-stack+ 7)
-(define-constant +opcode-get-value-local+ 8)
-(define-constant +opcode-get-value-stack+ 9)
+(define-constant +opcode-unify-variable-local+ 1)
+(define-constant +opcode-unify-variable-stack+ 2)
+(define-constant +opcode-unify-value-local+ 3)
+(define-constant +opcode-unify-value-stack+ 4)
+(define-constant +opcode-get-variable-local+ 5)
+(define-constant +opcode-get-variable-stack+ 6)
+(define-constant +opcode-get-value-local+ 7)
+(define-constant +opcode-get-value-stack+ 8)
;;; Query
-(define-constant +opcode-put-structure-local+ 10)
-(define-constant +opcode-put-structure-stack+ 11)
-(define-constant +opcode-set-variable-local+ 12)
-(define-constant +opcode-set-variable-stack+ 13)
-(define-constant +opcode-set-value-local+ 14)
-(define-constant +opcode-set-value-stack+ 15)
-(define-constant +opcode-put-variable-local+ 16)
-(define-constant +opcode-put-variable-stack+ 17)
-(define-constant +opcode-put-value-local+ 18)
-(define-constant +opcode-put-value-stack+ 19)
+(define-constant +opcode-put-structure-local+ 9)
+(define-constant +opcode-set-variable-local+ 10)
+(define-constant +opcode-set-variable-stack+ 11)
+(define-constant +opcode-set-value-local+ 12)
+(define-constant +opcode-set-value-stack+ 13)
+(define-constant +opcode-put-variable-local+ 14)
+(define-constant +opcode-put-variable-stack+ 15)
+(define-constant +opcode-put-value-local+ 16)
+(define-constant +opcode-put-value-stack+ 17)
;;; Control
-(define-constant +opcode-call+ 20)
-(define-constant +opcode-proceed+ 21)
-(define-constant +opcode-allocate+ 22)
-(define-constant +opcode-deallocate+ 23)
+(define-constant +opcode-call+ 18)
+(define-constant +opcode-proceed+ 19)
+(define-constant +opcode-allocate+ 20)
+(define-constant +opcode-deallocate+ 21)
;;;; Debug Config
--- a/src/wam/dump.lisp Sun Apr 17 21:36:15 2016 +0000
+++ b/src/wam/dump.lisp Mon Apr 18 13:08:47 2016 +0000
@@ -143,25 +143,12 @@
(second arguments)
(pretty-functor (first arguments) functor-list)))
-(defmethod instruction-details ((opcode (eql +opcode-get-structure-stack+)) arguments functor-list)
- (format nil "GETS~A ; Y~A = ~A"
- (pretty-arguments arguments)
- (second arguments)
- (pretty-functor (first arguments) functor-list)))
-
(defmethod instruction-details ((opcode (eql +opcode-put-structure-local+)) arguments functor-list)
(format nil "PUTS~A ; X~A <- new ~A"
(pretty-arguments arguments)
(second arguments)
(pretty-functor (first arguments) functor-list)))
-(defmethod instruction-details ((opcode (eql +opcode-put-structure-stack+)) arguments functor-list)
- (format nil "PUTS~A ; Y~A <- new ~A"
- (pretty-arguments arguments)
- (second arguments)
- (pretty-functor (first arguments) functor-list)))
-
-
(defmethod instruction-details ((opcode (eql +opcode-get-variable-local+)) arguments functor-list)
(format nil "GVAR~A ; X~A <- A~A"
(pretty-arguments arguments)
--- a/src/wam/interpreter.lisp Sun Apr 17 21:36:15 2016 +0000
+++ b/src/wam/interpreter.lisp Mon Apr 18 13:08:47 2016 +0000
@@ -162,13 +162,13 @@
;;;; Query Instructions
-(define-instructions (%put-structure-local %put-structure-stack)
+(define-instruction %put-structure-local
((wam wam)
(functor functor-index)
(register register-index))
(->> (push-new-structure! wam)
(nth-value 1)
- (setf (%wam-register% wam register)))
+ (setf (wam-local-register wam register)))
(push-new-functor! wam functor))
(define-instructions (%set-variable-local %set-variable-stack)
@@ -203,12 +203,11 @@
;;;; Program Instructions
-;; TODO: do we really need both of these variants?
-(define-instructions (%get-structure-local %get-structure-stack)
+(define-instruction %get-structure-local
((wam wam)
(functor functor-index)
(register register-index))
- (let* ((addr (deref wam (%wam-register% wam register)))
+ (let* ((addr (deref wam (wam-local-register wam register)))
(cell (wam-heap-cell wam addr)))
(cond
;; If the register points at a reference cell, we push two new cells onto
@@ -387,7 +386,6 @@
(eswitch (opcode)
;; Query
(+opcode-put-structure-local+ (instruction %put-structure-local 2))
- (+opcode-put-structure-stack+ (instruction %put-structure-stack 2))
(+opcode-set-variable-local+ (instruction %set-variable-local 1))
(+opcode-set-variable-stack+ (instruction %set-variable-stack 1))
(+opcode-set-value-local+ (instruction %set-value-local 1))
@@ -398,7 +396,6 @@
(+opcode-put-value-stack+ (instruction %put-value-stack 2))
;; Program
(+opcode-get-structure-local+ (instruction %get-structure-local 2))
- (+opcode-get-structure-stack+ (instruction %get-structure-stack 2))
(+opcode-unify-variable-local+ (instruction %unify-variable-local 1))
(+opcode-unify-variable-stack+ (instruction %unify-variable-stack 1))
(+opcode-unify-value-local+ (instruction %unify-value-local 1))
@@ -443,7 +440,6 @@
(progn
(eswitch (opcode)
(+opcode-put-structure-local+ (instruction %put-structure-local 2))
- (+opcode-put-structure-stack+ (instruction %put-structure-stack 2))
(+opcode-set-variable-local+ (instruction %set-variable-local 1))
(+opcode-set-variable-stack+ (instruction %set-variable-stack 1))
(+opcode-set-value-local+ (instruction %set-value-local 1))
--- a/src/wam/types.lisp Sun Apr 17 21:36:15 2016 +0000
+++ b/src/wam/types.lisp Mon Apr 18 13:08:47 2016 +0000
@@ -39,7 +39,7 @@
(deftype opcode ()
- '(integer 0 23))
+ '(integer 0 21))
(deftype stack-frame-size ()