Use compact instruction records

ober

d997a1e564c9cc592de23f713d0274bf078ec54f

diff --git a/jasm b/jasm
index 2d0ced7..f231280 100755
Binary files a/jasm and b/jasm differ
diff --git a/lib/jasm/format.ss b/lib/jasm/format.ss
index 4d8d69d..4732aa5 100644
--- a/lib/jasm/format.ss
+++ b/lib/jasm/format.ss
@@ -7,12 +7,8 @@
 
   (import (chezscheme))
 
-  (define (instruction-ref insn key)
-    (let ([cell (assq key (cdr insn))])
-      (if cell (cdr cell) #f)))
-
-  (define (instruction-address insn) (instruction-ref insn 'address))
-  (define (instruction-text insn) (instruction-ref insn 'text))
+  (define (instruction-address insn) (vector-ref insn 2))
+  (define (instruction-text insn) (vector-ref insn 4))
 
   (define (ascii-downcase c)
     (if (and (char>=? c #\A) (char<=? c #\Z))
diff --git a/lib/jasm/instruction.ss b/lib/jasm/instruction.ss
index 8de402f..b68831a 100644
--- a/lib/jasm/instruction.ss
+++ b/lib/jasm/instruction.ss
@@ -13,22 +13,15 @@
   (import (chezscheme))
 
   (define (instruction? x)
-    (and (pair? x) (eq? (car x) 'instruction)))
+    (and (vector? x)
+         (= (vector-length x) 6)
+         (eq? (vector-ref x 0) 'instruction)))
 
   (define (make-instruction arch address size text bytes)
-    (list 'instruction
-          (cons 'arch arch)
-          (cons 'address address)
-          (cons 'size size)
-          (cons 'text text)
-          (cons 'bytes bytes)))
+    (vector 'instruction arch address size text bytes))
 
-  (define (instruction-ref insn key)
-    (let ([cell (assq key (cdr insn))])
-      (if cell (cdr cell) #f)))
-
-  (define (instruction-arch insn) (instruction-ref insn 'arch))
-  (define (instruction-address insn) (instruction-ref insn 'address))
-  (define (instruction-size insn) (instruction-ref insn 'size))
-  (define (instruction-text insn) (instruction-ref insn 'text))
-  (define (instruction-bytes insn) (instruction-ref insn 'bytes)))
+  (define (instruction-arch insn) (vector-ref insn 1))
+  (define (instruction-address insn) (vector-ref insn 2))
+  (define (instruction-size insn) (vector-ref insn 3))
+  (define (instruction-text insn) (vector-ref insn 4))
+  (define (instruction-bytes insn) (vector-ref insn 5)))
diff --git a/tests/test-jasm.ss b/tests/test-jasm.ss
index 089d0e6..82f4ba8 100644
--- a/tests/test-jasm.ss
+++ b/tests/test-jasm.ss
@@ -45,6 +45,14 @@
         (architecture-endianness 'mips64el))
   '(big little))
 
+(test "instruction records are vector-backed"
+  (let ([insn (car (disassemble-bytevector 'x86-64 (hex-string->bytevector "55")))])
+    (list (instruction? insn)
+          (instruction-arch insn)
+          (instruction-size insn)
+          (instruction-text insn)))
+  '(#t x86-64 1 "pushq\t%rbp"))
+
 (test "x86 push att"
   (one-text 'x86-64 "55")
   "pushq\t%rbp")