GsMethod>recompileIntoMethodDict:intoCategories: in GS/64 3.0.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

GsMethod>recompileIntoMethodDict:intoCategories: in GS/64 3.0.0

Georg Gollmann
Hello,

in GS/64 3.0.0 the method GsMethod>recompileIntoMethodDict:intoCategories: seems to be broken in a few places. I have attached a version that works for me.

Kind regards
Georg


_______________________________________________
GemStone-Smalltalk mailing list
Archive: http://forum.world.st/Gemstone-Customers-f1461796.html


recompileIntoMethodDict (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: GsMethod>recompileIntoMethodDict:intoCategories: in GS/64 3.0.0

Bill Erickson
Georg,

Could you say a few words about how the original implementation was broken and how you've fixed it?

Regards,
Bill Erickson
Reply | Threaded
Open this post in threaded view
|

Re: GsMethod>recompileIntoMethodDict:intoCategories: in GS/64 3.0.0

Georg Gollmann

Am 14.09.2011 um 19:09 schrieb Bill Erickson:

> Could you say a few words about how the original implementation was broken
> and how you've fixed it?


Sure.

> recompileIntoMethodDict: aMethodDict intoCategories: aCategDict
>
> "Recompiles the method for execution in a Gs64 v3.0 or later system.
>
>  Literal variables whose key is in the GsMethod class variable ObsoleteClassesDict
>  are replaced by the appropriate association from the ObsoleteClassesDict .
>  Other literal variables are looked up in the literal pool of the receiver,
>  before searching class variables, class pool dictionaries, or
>  the current symbolList.  Thus recompilation should work without knowing
>  what symbolList was used when the receiver was created.  
>
>  The result is a GsNMethod if compilation succeeds, otherwise
>  an error is generated.  environmentId zero is used for all compilations.
>
>  If aMethodDict is not nil, and the compilation succeeds,
>  the resulting method is added to aMethodDict instead of to
>  the receiver's method dictionary.  This is used to add methods
>  to per-session dictionaries.
>
>  If aMethodDict is not nil and aCategDict is not nil and
>  the compilation succeeds, the resulting method is added aCategDict
>  instead of the receiver's categories.
>
>  If the receiver is an anonymous method, the sender of this method is
>  reponsible for saving the result."
>
> | cls litVars symAssocCls obsDict newSrc |
> litVars := { }  .
> symAssocCls := SymbolAssociation .
> obsDict := ObsoleteClassesDict .
> literalsOffset to: self size do: [:i | | aLit |
>   (aLit isKindOf: symAssocCls) ifTrue:[ | litName obsArr aVal newLit |

1) aLit is used but not set, therefore the test always fails.

>     obsArr := obsDict at: (litName:= aLit key) otherwise: nil .
>     obsArr ~~ nil ifTrue:[
>       aVal := aLit value .
>       (aVal ~~ nil and:[ aVal == (obsArr at:1)]) ifTrue:[ | newName |
>          newName := obsArr at: 2 .
>          newName ~~ nil ifTrue:[
>            newLit := Globals associationAt: newName   "such as ExceptionA-->Exception"
>          ] ifFalse:[
>            newLit := Globals associationAt: litName   "such as GsFile-->GsFile"
>          ].
>       ].
>     ].
>     newLit ~~ nil ifTrue:[
>       litVars add: newLit
>     ] ifFalse:[
>       litVars add: aLit
>     ].
>   ].
> ].
> newSrc := GsNMethod convertArrayBuildersInString: sourceString  .
> cls := self inClass .
> cls ifNil:[
>   ^ newSrc _compileInContext: nil symbolList: nil oldLitVars: litVars

2) The comment notes that the current symbolList will be used for compilation. Actually nil is passed.

> environmentId: 0
> ] ifNotNil:[ | sel categ |
>  categ := cls categoryOfSelector: sel .

3) sel is used but not set, therefore categoryOfSelector: always throws an exception.

>   ^ cls _checkCompileResult: ( cls _primitiveCompileMethod: newSrc symbolList: nil

4) See number 2 above. 1, 2 and 4 combine to make the compiler complain on all global references.

>          category: categ oldLitVars: litVars
>          intoMethodDict: aMethodDict intoCategories: aCategDict
>          intoPragmas: nil environmentId: 0 )
>        source: newSrc .
> ]

The fixes are obvious, other changes are for readability.

Kind regards
Georg


_______________________________________________
GemStone-Smalltalk mailing list
Archive: http://forum.world.st/Gemstone-Customers-f1461796.html

Reply | Threaded
Open this post in threaded view
|

Re: GsMethod>recompileIntoMethodDict:intoCategories: in GS/64 3.0.0

Georg Gollmann

Am 15.09.2011 um 08:58 schrieb Georg Gollmann:

>> recompileIntoMethodDict: aMethodDict intoCategories: aCategDict

> 1) aLit is used but not set, therefore the test always fails.
> 2) The comment notes that the current symbolList will be used for compilation. Actually nil is passed.
> 3) sel is used but not set, therefore categoryOfSelector: always throws an exception.
> 4) See number 2 above. 1, 2 and 4 combine to make the compiler complain on all global references.


This method (in gsmethod.gs) is still broken in 3.0.1 :-(

Kind regards
 Georg


_______________________________________________
GemStone-Smalltalk mailing list
Archive: http://forum.world.st/Gemstone-Customers-f1461796.html