- method stackSize is now correctly initialized
- #makeBlock offsets are now patched when serializing basic blocks
--- a/IRBuilderTest.st Wed May 13 08:23:00 2009 +0000
+++ b/IRBuilderTest.st Wed May 13 09:30:49 2009 +0000
@@ -859,6 +859,36 @@
"Created: / 30-03-2009 / 23:03:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
+testBlock_block_in_another_basic_block
+ |aCompiledMethod irBuilder|
+
+ irBuilder := (IRBuilder new)
+ numRargs:1;
+ addTemps:#( #self );
+ pushLiteral: false;
+ pushLiteral: true;
+ jumpAheadTo: #end if: false;
+ pushBlockUsingBuilder:[:builder |
+ builder
+ numRargs: 0;
+ pushLiteral: true;
+ returnTop
+ ];
+ send: #value;
+ jumpAheadTarget: #end;
+ returnTop;
+ ir.
+ "
+ irBuilder ir
+ "
+
+ aCompiledMethod := irBuilder compiledCode.
+ self assert:(aCompiledMethod isKindOf:CompiledMethod).
+ self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true).
+
+ "Created: / 13-05-2009 / 11:24:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
testBlock_exceptionHandler
|aCompiledMethod irBuilder|
--- 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'!