IRBytecodeGenerator.st
changeset 19 3bb7360f9dff
parent 18 e6921b3a5d5b
child 20 7d49846b36bd
--- a/IRBytecodeGenerator.st	Wed May 13 08:23:00 2009 +0000
+++ b/IRBytecodeGenerator.st	Wed May 13 09:30:49 2009 +0000
@@ -693,12 +693,13 @@
     ^ (aCompiledMethodClass new:literals size)
         numberOfArgs:numArgs;
         numberOfVars:numVars;
+        stackSize: self stackSize;
         byteCode:bytecodesAndLiteralArray first;
         literals:bytecodesAndLiteralArray second asArray;
         yourself
 
     "Created: / 11-06-2008 / 14:02:03 / Jan Vrany <vranyj1@fel.cvut.cz>"
-    "Modified: / 30-03-2009 / 13:53:40 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 13-05-2009 / 10:42:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
 !
 
 literals
@@ -751,23 +752,33 @@
 
 symboliccodes
 
-        | stream |
+        | stream basicBlockStartOffset |
         [ orderSeq
                 inject: false
                 into: [:changed :seqId | (self updateJump: seqId) | changed]
         ] whileTrue.
 
         stream := (OrderedCollection new: 200) writeStream.
+        basicBlockStartOffset := 0. 
         orderSeq do: [:seqId |
                 (instrMaps at: seqId) do: [:assoc |
                         assoc key "instr" bytecodeIndex: stream position + assoc value.
                 ].
+                "Patch makeBlock offsets"
+                (seqCode at: seqId) withIndexDo:
+                    [:instr :index|
+                    instr == #makeBlock ifTrue:
+                        [(seqCode at: seqId) 
+                            at: index + 1
+                            put: ((seqCode at: seqId) at: index + 1) + basicBlockStartOffset]].
+
                 stream nextPutAll: (seqCode at: seqId).
+                basicBlockStartOffset := basicBlockStartOffset + (seqCode at: seqId) size.
         ].
         ^self relativeJumpsToAbsoluteIn:stream contents
 
     "Created: / 11-06-2008 / 14:00:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
-    "Modified: / 05-11-2008 / 10:33:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 13-05-2009 / 11:15:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
 ! !
 
 !IRBytecodeGenerator class methodsFor:'documentation'!