--- a/IRBytecodeGenerator.st Wed Feb 25 16:49:21 2009 +0000
+++ b/IRBytecodeGenerator.st Mon Mar 30 14:47:18 2009 +0000
@@ -3,7 +3,7 @@
Object subclass:#IRBytecodeGenerator
instanceVariableNames:'seqOrder orderSeq jumps literals lastLiteral currentSeqId
currentSeqNum lastSpecialReturn instrMaps instrMap maxTemp stacks
- stack primNum numArgs properties code seqCode lastLine'
+ stack primNum numArgs numVars properties code seqCode lastLine'
classVariableNames:'BytecodeTable Bytecodes SpecialConstants SpecialSelectors'
poolDictionaries:''
category:'NewCompiler-Bytecode'
@@ -53,6 +53,7 @@
maxTemp := 0.
primNum := 0.
numArgs := 0.
+ numVars := 0.
currentSeqNum := 0.
orderSeq := OrderedDictionary new. "reverse map of seqOrder"
lastLine := 0.
@@ -60,7 +61,7 @@
"starting label in case one is not provided by client"
self label: self newDummySeqId.
- "Modified: / 02-12-2008 / 09:08:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 30-03-2009 / 13:52:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
numArgs: n
@@ -208,6 +209,34 @@
"Modified: / 11-06-2008 / 14:13:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
+pushMethodArg: index
+
+ | |
+
+ stack push.
+ numArgs := index max: numArgs.
+
+ self
+ nextPut: #pushMethodArg;
+ nextPut: index
+
+ "Created: / 30-03-2009 / 13:50:57 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+pushMethodVar: index
+
+ | |
+
+ stack push.
+ numVars := index max: numVars.
+
+ self
+ nextPut: #pushMethodVar;
+ nextPut: index
+
+ "Created: / 30-03-2009 / 14:12:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
pushReceiver
stack push.
@@ -217,24 +246,6 @@
"Modified: / 11-06-2008 / 14:14:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
-pushTemp: index
-
- | instr idx |
-
- stack push.
- maxTemp := index max: maxTemp.
-
- idx := index.
- instr := index <= numArgs
- ifTrue:[#pushMethodArg]
- ifFalse:[idx := idx - numArgs.#pushMethodVar].
- self
- nextPut: instr;
- nextPut: idx
-
- "Modified: / 11-06-2008 / 14:46:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
pushThisContext
stack push.
@@ -353,18 +364,16 @@
"Modified: / 11-06-2008 / 16:23:06 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
-storeTemp: index
+storeMethodVar: index
- stack pop.
- maxTemp := index max: maxTemp.
+ stack pop.
+ numVars := index max: numVars.
- index <= numArgs ifTrue:[self error:'Cannot store to method argument!!'].
+ self
+ nextPut:#storeMethodVar;
+ nextPut:index
- self
- nextPut:#storeMethodVar;
- nextPut:index - numArgs
-
- "Modified: / 11-06-2008 / 16:24:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Created: / 30-03-2009 / 13:57:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !
!IRBytecodeGenerator methodsFor:'mapping'!
@@ -566,31 +575,22 @@
"Created: / 03-11-2008 / 14:20:32 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
-compiledMethod
-
- ^ self compiledMethodUsing: Method
-
- "Modified: / 11-06-2008 / 14:01:51 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
-compiledMethodUsing: aCompiledMethodClass
-
+compiledCodeUsing:aCompiledMethodClass
"
- self symboliccodes
- "
-
- | bytecodesAndLiteralArray |
- bytecodesAndLiteralArray := self bytecodesAndLiteralArray.
+ self symboliccodes"
+
+ |bytecodesAndLiteralArray|
- ^(aCompiledMethodClass new: literals size)
- numberOfArgs: numArgs;
- numberOfVars: maxTemp - numArgs ;
- byteCode: bytecodesAndLiteralArray first;
- literals: bytecodesAndLiteralArray second asArray;
+ bytecodesAndLiteralArray := self bytecodesAndLiteralArray.
+ ^ (aCompiledMethodClass new:literals size)
+ numberOfArgs:numArgs;
+ numberOfVars:numVars;
+ byteCode:bytecodesAndLiteralArray first;
+ literals:bytecodesAndLiteralArray second asArray;
yourself
"Created: / 11-06-2008 / 14:02:03 / Jan Vrany <vranyj1@fel.cvut.cz>"
- "Modified: / 03-11-2008 / 14:22:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 30-03-2009 / 13:53:40 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
literals
@@ -615,7 +615,9 @@
numTemps
- ^ maxTemp
+ ^ numArgs + numVars
+
+ "Modified: / 30-03-2009 / 13:53:32 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
relativeJumpsToAbsoluteIn: symbolicCode