More disassembly cleanups.
authorBrian T. Rice <briantrice@gmail.com>
Fri, 5 Feb 2010 06:27:33 +0000 (22:27 -0800)
committerBrian T. Rice <briantrice@gmail.com>
Fri, 5 Feb 2010 06:27:33 +0000 (22:27 -0800)
src/mobius/compiler.slate
src/mobius/disassemble.slate

index e9a49bc..5746840 100644 (file)
@@ -992,30 +992,3 @@ gen@(VM SSACompiler traits) generate: _@#<-* on: args from: msg result: result
            result: result]
     ifFalse: [resend]
 ].
-
-gen@(VM SSACompiler traits) printInstructionAt: pos in: m@(CompiledMethod traits) on: out
-[| instr arguments nextStart instrVal |
-  instrVal: (m code at: pos).
-  instr: (VM SSACode instructionInfo detect: [| :elem | elem key = instrVal]
-                                     ifNone: [error: 'Cannot find instruction  at ' ; pos printString ; ' in ' ; m code printString]) value.
-  out ;
-    ([| :out |
-      out ; '(' ; pos printString ; ') ' ; instrVal printString ; ' ' ; instr key printString.
-      nextStart: (pos + 1 + instr value first +
-        (instr value size > 1
-           ifTrue: [| sum |
-                    sum: 0.
-                    instr value allButFirstDo: [| :offset | sum: sum + (m code at: pos + 1 + offset)].
-                    sum]
-           ifFalse: [0])).
-      (pos + 1 until: nextStart) do:
-       [| :i | out ; ' ' ; (m code at: i) printString]] writingAs: String).
-  nextStart
-].
-
-gen@(VM SSACompiler traits) decompile: m@(CompiledMethod traits) on: out
-[| pos |
-  pos: 0.
-  [pos < m code size] whileTrue:
-    [| instr | pos: (gen printInstructionAt: pos in: m code)].
-].
index b6e77a0..739e6a5 100644 (file)
@@ -96,6 +96,32 @@ i@(CompiledMethod OpStream traits) disassembleOn: s
     offset: i codePosition].
 ].
 
+m@(CompiledMethod traits) printInstructionAt: pos on: out
+[| instr arguments nextStart instrVal |
+  instrVal: (m code at: pos).
+  instr: (VM SSACode instructionInfo detect: [| :elem | elem key = instrVal]
+                                     ifNone: [error: 'Cannot find instruction  at ' ; pos printString ; ' in ' ; m code printString]) value.
+  out ; '(' ; pos printString ; ') ' ; instrVal printString ; ' ' ; instr key printString.
+  nextStart: (pos + 1 + instr value first +
+    (instr value size > 1
+       ifTrue: [| sum |
+                sum: 0.
+                instr value allButFirstDo: [| :offset | sum: sum + (m code at: pos + 1 + offset)].
+                sum]
+       ifFalse: [0])).
+  (pos + 1 until: nextStart) do:
+    [| :i | out ; ' ' ; (m code at: i) printString].
+  out ; '\n'.
+  nextStart
+].
+
+m@(CompiledMethod traits) printInstructionsOn: out
+[| pos |
+  pos: 0.
+  [pos < m code size] whileTrue:
+    [| instr | pos: (m printInstructionAt: pos on: out)].
+].
+
 m@(CompiledMethod traits) disassemble &output: s
 "Print out method meta-data and then the instruction stream."
 [
@@ -108,8 +134,7 @@ m@(CompiledMethod traits) disassemble &output: s
     ; 'rest parameter: ' ; m restVariable printString ; '\n'
     ; 'optional keywords: ' ; (m optionalKeywords isEmpty
         ifTrue: ['(none)'] ifFalse: [m optionalKeywords join &separator: ' '])  ; '\n'.
-  "m opReader disassembleOn: s."
-  VM SSACompiler decompile: m on: s.
+  m printInstructionsOn: s.
 ].
 
 closure@(Closure traits) disassemble &output: s