ByteCodeCompiler.st
changeset 212 ff39051e219f
parent 211 1fd13827a2fc
child 214 683adf870f54
--- a/ByteCodeCompiler.st	Fri Feb 09 19:01:33 1996 +0100
+++ b/ByteCodeCompiler.st	Sat Feb 10 19:33:23 1996 +0100
@@ -77,6 +77,8 @@
                                                 controls when stc compilation is wanted
 
         ShareCode       <Boolean>               reuse byteArrays for common (simple) code sequences
+						This is normally a 'good' optimization,
+						expect if you plan to modify the byteCodes.
 "
 ! !
 
@@ -1142,11 +1144,18 @@
 
 checkForCommonCode:symbolicCodeArray
     "hook to return the code for common code sequences.
-     Not yet fully implemented - just an idea ..."
+     This reduces the in-memory number of byteArrays somewhat.
+
+     Not yet fully implemented - just an idea ... theres certainly more to do here
+     (does it make sense to scan all methods, collect code in a set and unify things
+      automatically in the background - or upon request ?)"
 
     |sz insn1|
 
     (sz := symbolicCodeArray size) == 2 ifTrue:[
+	"/
+	"/ a very common sequence: return the first literal
+	"/
 	(insn1 := symbolicCodeArray at:1) == #pushLit1 ifTrue:[
 	    (symbolicCodeArray at:2) == #retTop ifTrue:[
 		^ #[222 0]
@@ -1154,9 +1163,18 @@
 	]
     ].
     sz == 1 ifTrue:[
+	"/
+	"/ another common sequence: return the receiver
+	"/
 	(insn1 := symbolicCodeArray at:1) == #retSelf ifTrue:[
 	    ^ #[5]
-	]
+	].
+	insn1 == #retTrue ifTrue:[
+	    ^ #[2]
+	].
+	insn1 == #retFalse ifTrue:[
+	    ^ #[3]
+	].
     ].
     ^ nil
 !
@@ -2119,6 +2137,6 @@
 !ByteCodeCompiler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.65 1996-02-09 18:01:33 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.66 1996-02-10 18:33:10 cg Exp $'
 ! !
 ByteCodeCompiler initialize!