[tode_st] Fixing GemStone CGI overrides over FFI

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

[tode_st] Fixing GemStone CGI overrides over FFI

Mariano Martinez Peck
Dale,

As you may know, the GemStone CGI has overrides over FFI :(
I am trying to fix one in #compileFields: specArray withAccessors: aBool.
Please see attached diff. Left side is original code and right code is your override.

Is this #asSymbol needed in GemStone because of the fact that a symbol and a string with same contents are not #= ?  If this is the case...I still don't get it, as the FFI code runs IN PHARO, not in GemStone....

--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

Screen Shot 2016-03-29 at 10.08.01 PM.png (302K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [tode_st] Fixing GemStone CGI overrides over FFI

Dale Henrichs-3


On 3/29/16 6:12 PM, Mariano Martinez Peck wrote:

> Dale,
>
> As you may know, the GemStone CGI has overrides over FFI :(
> I am trying to fix one in #compileFields: specArray withAccessors: aBool.
> Please see attached diff. Left side is original code and right code is
> your override.
>
> Is this #asSymbol needed in GemStone because of the fact that a symbol
> and a string with same contents are not #= ?  If this is the case...I
> still don't get it, as the FFI code runs IN PHARO, not in GemStone....
>
> Thoughts?


The #asSymbol was added, because the Symbol-ness of the argument is lost
by #findTokens: and note that a little bit later, #hasInterned: is used
on the fieldType and it must be a symbol to end up getting a
#structTypeNamed: ... and I needed to have pointers to my custom types
so that the sizes of the structs came out right ... I was lucky to be
able to hack FFI so that the calculations were done for me ... it was
going to be too much work to manage the calculations otherwise:)

Dale

--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [tode_st] Fixing GemStone CGI overrides over FFI

Mariano Martinez Peck


On Tue, Mar 29, 2016 at 11:02 PM, Dale Henrichs <[hidden email]> wrote:


On 3/29/16 6:12 PM, Mariano Martinez Peck wrote:
Dale,

As you may know, the GemStone CGI has overrides over FFI :(
I am trying to fix one in #compileFields: specArray withAccessors: aBool.
Please see attached diff. Left side is original code and right code is your override.

Is this #asSymbol needed in GemStone because of the fact that a symbol and a string with same contents are not #= ?  If this is the case...I still don't get it, as the FFI code runs IN PHARO, not in GemStone....

Thoughts?


The #asSymbol was added, because the Symbol-ness of the argument is lost by #findTokens: and note that a little bit later, #hasInterned: is used on the fieldType and it must be a symbol to end up getting a #structTypeNamed: ... and I needed to have pointers to my custom types so that the sizes of the structs came out right ... I was lucky to be able to hack FFI so that the calculations were done for me ... it was going to be too much work to manage the calculations otherwise:)


OK Dale, yes, from what I can test, if the argument to #hasInterned:ifTrue:  is a symbol then it ALWAYS (even for new symbols) answers true:

Symbol hasInterned: #sadasdjaslkdjaskldjalksjdkaskldja ifTrue:  [ :sym | true  ] -----> true
Symbol hasInterned: #class ifTrue:  [ :sym | true  ] -----> true

But...if we pass a string:

Symbol hasInterned: 'XXXXXsadasdjaslkdjaskldjalksjdkaskldja' ifTrue:  [ :sym | true  ]  ----->   false
Symbol hasInterned: 'class' ifTrue:  [ :sym | true  ]  -----> true

Esteban...do you think we should integrate Dale's patch or there could be another way? 


--

--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [tode_st] Fixing GemStone CGI overrides over FFI

Mariano Martinez Peck


On Wed, Mar 30, 2016 at 12:21 AM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, Mar 29, 2016 at 11:02 PM, Dale Henrichs <[hidden email]> wrote:


On 3/29/16 6:12 PM, Mariano Martinez Peck wrote:
Dale,

As you may know, the GemStone CGI has overrides over FFI :(
I am trying to fix one in #compileFields: specArray withAccessors: aBool.
Please see attached diff. Left side is original code and right code is your override.

Is this #asSymbol needed in GemStone because of the fact that a symbol and a string with same contents are not #= ?  If this is the case...I still don't get it, as the FFI code runs IN PHARO, not in GemStone....

Thoughts?


The #asSymbol was added, because the Symbol-ness of the argument is lost by #findTokens: and note that a little bit later, #hasInterned: is used on the fieldType and it must be a symbol to end up getting a #structTypeNamed: ... and I needed to have pointers to my custom types so that the sizes of the structs came out right ... I was lucky to be able to hack FFI so that the calculations were done for me ... it was going to be too much work to manage the calculations otherwise:)


OK Dale, yes, from what I can test, if the argument to #hasInterned:ifTrue:  is a symbol then it ALWAYS (even for new symbols) answers true:

Symbol hasInterned: #sadasdjaslkdjaskldjalksjdkaskldja ifTrue:  [ :sym | true  ] -----> true
Symbol hasInterned: #class ifTrue:  [ :sym | true  ] -----> true

But...if we pass a string:

Symbol hasInterned: 'XXXXXsadasdjaslkdjaskldjalksjdkaskldja' ifTrue:  [ :sym | true  ]  ----->   false
Symbol hasInterned: 'class' ifTrue:  [ :sym | true  ]  -----> true

Esteban...do you think we should integrate Dale's patch or there could be another way? 


Dale...what I don't understand is...

wasSymbol := fieldType isSymbol.
fieldType := (fieldType findTokens: ' *') first.
wasSymbol ifTrue: [  fieldType := fieldType asSymbol ].
So....IF the object was a symbol (`fieldType isSymbol` answering true)...then it should have been interned (otherwise how could have that instance be created)... therefore, even if you keep it as a string (without the extra #asSymbol), the lines:

Symbol
hasInterned: fieldType
ifTrue: [:sym | externalType := ExternalType structTypeNamed: sym].

should evaluate to true. 




--

--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [tode_st] Fixing GemStone CGI overrides over FFI

Dale Henrichs-3


On 3/29/16 8:27 PM, Mariano Martinez Peck wrote:


On Wed, Mar 30, 2016 at 12:21 AM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, Mar 29, 2016 at 11:02 PM, Dale Henrichs <[hidden email]> wrote:


On 3/29/16 6:12 PM, Mariano Martinez Peck wrote:
Dale,

As you may know, the GemStone CGI has overrides over FFI :(
I am trying to fix one in #compileFields: specArray withAccessors: aBool.
Please see attached diff. Left side is original code and right code is your override.

Is this #asSymbol needed in GemStone because of the fact that a symbol and a string with same contents are not #= ?  If this is the case...I still don't get it, as the FFI code runs IN PHARO, not in GemStone....

Thoughts?


The #asSymbol was added, because the Symbol-ness of the argument is lost by #findTokens: and note that a little bit later, #hasInterned: is used on the fieldType and it must be a symbol to end up getting a #structTypeNamed: ... and I needed to have pointers to my custom types so that the sizes of the structs came out right ... I was lucky to be able to hack FFI so that the calculations were done for me ... it was going to be too much work to manage the calculations otherwise:)


OK Dale, yes, from what I can test, if the argument to #hasInterned:ifTrue:  is a symbol then it ALWAYS (even for new symbols) answers true:

Symbol hasInterned: #sadasdjaslkdjaskldjalksjdkaskldja ifTrue:  [ :sym | true  ] -----> true
Symbol hasInterned: #class ifTrue:  [ :sym | true  ] -----> true

But...if we pass a string:

Symbol hasInterned: 'XXXXXsadasdjaslkdjaskldjalksjdkaskldja' ifTrue:  [ :sym | true  ]  ----->   false
Symbol hasInterned: 'class' ifTrue:  [ :sym | true  ]  -----> true

Esteban...do you think we should integrate Dale's patch or there could be another way? 


Dale...what I don't understand is...

wasSymbol := fieldType isSymbol.
fieldType := (fieldType findTokens: ' *') first.
wasSymbol ifTrue: [  fieldType := fieldType asSymbol ].
So....IF the object was a symbol (`fieldType isSymbol` answering true)...then it should have been interned (otherwise how could have that instance be created)... therefore, even if you keep it as a string (without the extra #asSymbol), the lines:

Symbol
hasInterned: fieldType
ifTrue: [:sym | externalType := ExternalType structTypeNamed: sym].

should evaluate to true. 


However, when findTokens: is done with the symbol: `fieldType := (fieldType findTokens: ' *') first.`, you get a String as the #first token and the fact that fieldType WAS a symbol is lost (at least that was my experience)...

BTW, I was using Pharo4.0 for Tugrik, so the behavior for #findTokens: could have changed along the way ...


Dale

--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [tode_st] Fixing GemStone CGI overrides over FFI

Mariano Martinez Peck


On Wed, Mar 30, 2016 at 10:31 AM, Dale Henrichs <[hidden email]> wrote:


On 3/29/16 8:27 PM, Mariano Martinez Peck wrote:


On Wed, Mar 30, 2016 at 12:21 AM, Mariano Martinez Peck <[hidden email][hidden email]> wrote:


On Tue, Mar 29, 2016 at 11:02 PM, Dale Henrichs <[hidden email]> wrote:


On 3/29/16 6:12 PM, Mariano Martinez Peck wrote:
Dale,

As you may know, the GemStone CGI has overrides over FFI :(
I am trying to fix one in #compileFields: specArray withAccessors: aBool.
Please see attached diff. Left side is original code and right code is your override.

Is this #asSymbol needed in GemStone because of the fact that a symbol and a string with same contents are not #= ?  If this is the case...I still don't get it, as the FFI code runs IN PHARO, not in GemStone....

Thoughts?


The #asSymbol was added, because the Symbol-ness of the argument is lost by #findTokens: and note that a little bit later, #hasInterned: is used on the fieldType and it must be a symbol to end up getting a #structTypeNamed: ... and I needed to have pointers to my custom types so that the sizes of the structs came out right ... I was lucky to be able to hack FFI so that the calculations were done for me ... it was going to be too much work to manage the calculations otherwise:)


OK Dale, yes, from what I can test, if the argument to #hasInterned:ifTrue:  is a symbol then it ALWAYS (even for new symbols) answers true:

Symbol hasInterned: #sadasdjaslkdjaskldjalksjdkaskldja ifTrue:  [ :sym | true  ] -----> true
Symbol hasInterned: #class ifTrue:  [ :sym | true  ] -----> true

But...if we pass a string:

Symbol hasInterned: 'XXXXXsadasdjaslkdjaskldjalksjdkaskldja' ifTrue:  [ :sym | true  ]  ----->   false
Symbol hasInterned: 'class' ifTrue:  [ :sym | true  ]  -----> true

Esteban...do you think we should integrate Dale's patch or there could be another way? 


Dale...what I don't understand is...

wasSymbol := fieldType isSymbol.
fieldType := (fieldType findTokens: ' *') first.
wasSymbol ifTrue: [  fieldType := fieldType asSymbol ].
So....IF the object was a symbol (`fieldType isSymbol` answering true)...then it should have been interned (otherwise how could have that instance be created)... therefore, even if you keep it as a string (without the extra #asSymbol), the lines:

Symbol
hasInterned: fieldType
ifTrue: [:sym | externalType := ExternalType structTypeNamed: sym].

should evaluate to true. 


However, when findTokens: is done with the symbol: `fieldType := (fieldType findTokens: ' *') first.`, you get a String as the #first token and the fact that fieldType WAS a symbol is lost (at least that was my experience)...


I understand that. But if it was a symbol on the first place and now a string ( lost in the #findTokens), then Symbol table should have it interned. So #hasInterned: should have gone in  the `true` path. Correct?  See my test above:

Symbol hasInterned: 'class' ifTrue:  [ :sym | true  ]  -----> true
That means that even if you pass a string, if it was already interned (like #class) then it will answer true.

 That's what I do not understand. 

 
BTW, I was using Pharo4.0 for Tugrik, so the behavior for #findTokens: could have changed along the way ...


Dale

--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--

--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [tode_st] Fixing GemStone CGI overrides over FFI

Dale Henrichs-3
Mariano,

If the GCI code works without the wasSymbol code, then it isn't needed ... I did the work in the debugger and made the hack so that the FFI would properly calculate the size of the GciGsOopType class ... I also made a number of other hacks to the FFI along the way ... I'm only explaining what I recall seeing in the debugger and the code "worked for me" --- try taking out the wasSymbol hack and see if it works...

When I stepped through in the debugger, the hasInterned: step was being skipped and the wasSymbol hack worked for me ...

Dale

On 3/30/16 6:46 AM, Mariano Martinez Peck wrote:


On Wed, Mar 30, 2016 at 10:31 AM, Dale Henrichs <[hidden email]> wrote:


On 3/29/16 8:27 PM, Mariano Martinez Peck wrote:


On Wed, Mar 30, 2016 at 12:21 AM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, Mar 29, 2016 at 11:02 PM, Dale Henrichs <[hidden email]> wrote:


On 3/29/16 6:12 PM, Mariano Martinez Peck wrote:
Dale,

As you may know, the GemStone CGI has overrides over FFI :(
I am trying to fix one in #compileFields: specArray withAccessors: aBool.
Please see attached diff. Left side is original code and right code is your override.

Is this #asSymbol needed in GemStone because of the fact that a symbol and a string with same contents are not #= ?  If this is the case...I still don't get it, as the FFI code runs IN PHARO, not in GemStone....

Thoughts?


The #asSymbol was added, because the Symbol-ness of the argument is lost by #findTokens: and note that a little bit later, #hasInterned: is used on the fieldType and it must be a symbol to end up getting a #structTypeNamed: ... and I needed to have pointers to my custom types so that the sizes of the structs came out right ... I was lucky to be able to hack FFI so that the calculations were done for me ... it was going to be too much work to manage the calculations otherwise:)


OK Dale, yes, from what I can test, if the argument to #hasInterned:ifTrue:  is a symbol then it ALWAYS (even for new symbols) answers true:

Symbol hasInterned: #sadasdjaslkdjaskldjalksjdkaskldja ifTrue:  [ :sym | true  ] -----> true
Symbol hasInterned: #class ifTrue:  [ :sym | true  ] -----> true

But...if we pass a string:

Symbol hasInterned: 'XXXXXsadasdjaslkdjaskldjalksjdkaskldja' ifTrue:  [ :sym | true  ]  ----->   false
Symbol hasInterned: 'class' ifTrue:  [ :sym | true  ]  -----> true

Esteban...do you think we should integrate Dale's patch or there could be another way? 


Dale...what I don't understand is...

wasSymbol := fieldType isSymbol.
fieldType := (fieldType findTokens: ' *') first.
wasSymbol ifTrue: [  fieldType := fieldType asSymbol ].
So....IF the object was a symbol (`fieldType isSymbol` answering true)...then it should have been interned (otherwise how could have that instance be created)... therefore, even if you keep it as a string (without the extra #asSymbol), the lines:

Symbol
hasInterned: fieldType
ifTrue: [:sym | externalType := ExternalType structTypeNamed: sym].

should evaluate to true. 


However, when findTokens: is done with the symbol: `fieldType := (fieldType findTokens: ' *') first.`, you get a String as the #first token and the fact that fieldType WAS a symbol is lost (at least that was my experience)...


I understand that. But if it was a symbol on the first place and now a string ( lost in the #findTokens), then Symbol table should have it interned. So #hasInterned: should have gone in  the `true` path. Correct?  See my test above:

Symbol hasInterned: 'class' ifTrue:  [ :sym | true  ]  -----> true
That means that even if you pass a string, if it was already interned (like #class) then it will answer true.

 That's what I do not understand. 

 
BTW, I was using Pharo4.0 for Tugrik, so the behavior for #findTokens: could have changed along the way ...


Dale
--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "tODE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.