Alien initialization

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

Alien initialization

Tobias Pape
 
Hi,

can someone with commit rights on Alien please change the following method?


UnsafeAlien class>>ensureInSpecialObjectsArray
        "UnsafeAlien must be in the specialObjectsArray to enable the Newsqueak FFI.
         Because of the bootstrap the specialObjectsArray may already have been
         partially initialized with the callback selector and to be large enough (as part of
         loading immutability), but it will be missing UnsafeAlien until UnsafeAlien is loaded.
         So check if the specialObjectsArray is of the expected size before recreating
         and slam UnsafeAlien in if the specialObjectsArray is already large enough."

        | index |
        self ~~ UnsafeAlien ifTrue: [^self].

        index := 55.
        (((Smalltalk includesKey: #VMObjectIndices)
         and: [((Smalltalk at: #VMObjectIndices) classPool at: #ClassUnsafeAlien ifAbsent: []) == (index - 1)])
        or: [
                ((Smalltalk includesKey: #ObjectMemory)
                 and: [((Smalltalk at: #ObjectMemory) classPool at: #ClassUnsafeAlien ifAbsent: []) == (index - 1)])])
        ifFalse:
                        [self error: 'index probably wrong'].

        Smalltalk specialObjectsArray size < index ifTrue:
                [Smalltalk recreateSpecialObjectsArray].
       
        (Smalltalk specialObjectsArray size < index
         or: [(Smalltalk specialObjectsArray at: index) ~~ nil
                and: [(Smalltalk specialObjectsArray at: index) ~~ self]]) ifTrue:
                [self error: 'SystemDictionary>>recreateSpecialObjectsArray appears incompatible'].

        (Smalltalk specialObjectsArray at: index) == nil ifTrue:
                [Smalltalk specialObjectsArray at: index put: self]


This is necessary as in the current spur architecture the #Class.... class variables are no longer in ObjectMemory but in a Shared Pool.

Hence, it breaks on loading.


Best regards
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: Alien initialization

Eliot Miranda-2
 
Hi Tobias,

    done.  I've made it match Alien class>>ensureInSpecialObjectsArray and so it only looks in VMObjectIndices.  But this should be OK right?

On Fri, Feb 23, 2018 at 11:45 AM, Tobias Pape <[hidden email]> wrote:

Hi,

can someone with commit rights on Alien please change the following method?


UnsafeAlien class>>ensureInSpecialObjectsArray
        "UnsafeAlien must be in the specialObjectsArray to enable the Newsqueak FFI.
         Because of the bootstrap the specialObjectsArray may already have been
         partially initialized with the callback selector and to be large enough (as part of
         loading immutability), but it will be missing UnsafeAlien until UnsafeAlien is loaded.
         So check if the specialObjectsArray is of the expected size before recreating
         and slam UnsafeAlien in if the specialObjectsArray is already large enough."

        | index |
        self ~~ UnsafeAlien ifTrue: [^self].

        index := 55.
        (((Smalltalk includesKey: #VMObjectIndices)
         and: [((Smalltalk at: #VMObjectIndices) classPool at: #ClassUnsafeAlien ifAbsent: []) == (index - 1)])
        or: [
                ((Smalltalk includesKey: #ObjectMemory)
                 and: [((Smalltalk at: #ObjectMemory) classPool at: #ClassUnsafeAlien ifAbsent: []) == (index - 1)])])
        ifFalse:
                        [self error: 'index probably wrong'].

        Smalltalk specialObjectsArray size < index ifTrue:
                [Smalltalk recreateSpecialObjectsArray].

        (Smalltalk specialObjectsArray size < index
         or: [(Smalltalk specialObjectsArray at: index) ~~ nil
                and: [(Smalltalk specialObjectsArray at: index) ~~ self]]) ifTrue:
                [self error: 'SystemDictionary>>recreateSpecialObjectsArray appears incompatible'].

        (Smalltalk specialObjectsArray at: index) == nil ifTrue:
                [Smalltalk specialObjectsArray at: index put: self]


This is necessary as in the current spur architecture the #Class.... class variables are no longer in ObjectMemory but in a Shared Pool.

Hence, it breaks on loading.


Best regards
        -Tobias



--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: Alien initialization

Tobias Pape
 
Hi Eliot

> On 23.02.2018, at 23:36, Eliot Miranda <[hidden email]> wrote:
>
> Hi Tobias,
>
>     done.  

thankyouverymuch

> I've made it match Alien class>>ensureInSpecialObjectsArray and so it only looks in VMObjectIndices.  But this should be OK right?

I think so.
I just wanted to install a current VMMaker and it bailed all the way.
So I decided that I have no clue what's going on and proposed a fix that only added and did not remove a thing.

Best regards
        -Tobias

>
> On Fri, Feb 23, 2018 at 11:45 AM, Tobias Pape <[hidden email]> wrote:
>
> Hi,
>
> can someone with commit rights on Alien please change the following method?
>
>
> UnsafeAlien class>>ensureInSpecialObjectsArray
>         "UnsafeAlien must be in the specialObjectsArray to enable the Newsqueak FFI.
>          Because of the bootstrap the specialObjectsArray may already have been
>          partially initialized with the callback selector and to be large enough (as part of
>          loading immutability), but it will be missing UnsafeAlien until UnsafeAlien is loaded.
>          So check if the specialObjectsArray is of the expected size before recreating
>          and slam UnsafeAlien in if the specialObjectsArray is already large enough."
>
>         | index |
>         self ~~ UnsafeAlien ifTrue: [^self].
>
>         index := 55.
>         (((Smalltalk includesKey: #VMObjectIndices)
>          and: [((Smalltalk at: #VMObjectIndices) classPool at: #ClassUnsafeAlien ifAbsent: []) == (index - 1)])
>         or: [
>                 ((Smalltalk includesKey: #ObjectMemory)
>                  and: [((Smalltalk at: #ObjectMemory) classPool at: #ClassUnsafeAlien ifAbsent: []) == (index - 1)])])
>         ifFalse:
>                         [self error: 'index probably wrong'].
>
>         Smalltalk specialObjectsArray size < index ifTrue:
>                 [Smalltalk recreateSpecialObjectsArray].
>
>         (Smalltalk specialObjectsArray size < index
>          or: [(Smalltalk specialObjectsArray at: index) ~~ nil
>                 and: [(Smalltalk specialObjectsArray at: index) ~~ self]]) ifTrue:
>                 [self error: 'SystemDictionary>>recreateSpecialObjectsArray appears incompatible'].
>
>         (Smalltalk specialObjectsArray at: index) == nil ifTrue:
>                 [Smalltalk specialObjectsArray at: index put: self]
>
>
> This is necessary as in the current spur architecture the #Class.... class variables are no longer in ObjectMemory but in a Shared Pool.
>
> Hence, it breaks on loading.
>
>
> Best regards
>         -Tobias
>
>
>
> --
> _,,,^..^,,,_
> best, Eliot