[Vm-dev] VM Maker: VMMaker.oscog-eem.2566.mcz
Nicolas Cellier
nicolas.cellier.aka.nice at gmail.com
Sat Sep 21 12:19:48 UTC 2019
Le jeu. 19 sept. 2019 à 06:26, <commits at source.squeak.org> a écrit :
>
> Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
> http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2566.mcz
>
> ==================== Summary ====================
>
> Name: VMMaker.oscog-eem.2566
> Author: eem
> Time: 18 September 2019, 9:23:01.791049 pm
> UUID: 71a20c6c-db1d-45e9-b85d-54aa2fd0cf8e
> Ancestors: VMMaker.oscog-eem.2565
>
> Simulator:
> Complete the simulation support for the SocketTest suite tests.
> Make sure that the processes spawned by the SocketPluginSimulator run at a
> higher priority than the VM simulator and that they do not preempt it until
> they are all spawned.
> Fix a slip in SocketPluginSimulator>>closeAndDestroy:.
>
> =============== Diff against VMMaker.oscog-eem.2565 ===============
>
> Item was changed:
> ----- Method: SocketPluginSimulator>>closeAndDestroy: (in category
> 'initialize-release') -----
> closeAndDestroy: socketHandle
> "c.f. Socket closeAndDestroy: timeoutSeconds"
> | fakeSocket |
> fakeSocket := Socket basicNew.
> [(fakeSocket primSocketConnectionStatus: socketHandle) = (Socket
> classPool at: #Connected) ifTrue:
> [fakeSocket primSocketCloseConnection: socketHandle].
> fakeSocket
> primSocketAbortConnection: socketHandle;
> primSocketDestroy: socketHandle]
> on: SocketPrimitiveFailed
> + do: [:ex| Transcript cr; show: ex messageText]!
> - do: [:ex| Transcript cr; show: ex message]!
>
> Item was changed:
> ----- Method:
> SocketPluginSimulator>>map:to:type:register:spawning:and:and: (in category
> 'simulation support') -----
> map: hostSocketHandle to: simSockPtr type: socketType register:
> semaphores spawning: blockOne and: blockTwo and: blockThree
> + | simSocket ourPriority |
> - | simSocket |
> "SQSocket is typedef struct { int sessionID; int socketType; void
> *privateSocketPtr; } SQSocket"
> simSocket := ByteArray new: (self sizeof: #SQSocket).
> simSocket
> unsignedLongAt: 1 put: interpreterProxy getThisSessionID;
> unsignedLongAt: 5 put: socketType.
> simSocket size = 12
> ifTrue: [simSocket unsignedLongAt: 9 put:
> (fakeAddressCounter := fakeAddressCounter + 64)]
> ifFalse: [simSocket unsignedLongLongAt: 9 put:
> (fakeAddressCounter := fakeAddressCounter + 80)].
> self assert: ((interpreterProxy isBytes: simSockPtr cPtrAsOop)
> and: [(interpreterProxy numBytesOf:
> simSockPtr cPtrAsOop) = simSocket size]).
> 1 to: simSocket size do:
> [:i| simSockPtr at: i - 1 put: (simSocket at: i)].
> self assert: (self simSocketHandleFrom: simSockPtr) = simSocket.
> openSocketHandles add: hostSocketHandle.
> hostSocketToSimSocketMap at: hostSocketHandle put: simSocket.
> simSocketToHostSocketMap at: simSocket put: hostSocketHandle.
> externalSemaphores addAll: semaphores.
> "N.B. These don't need registering. Eventually they will end up
> waiting on semaphores that have been unregistered, and hence
> + will get garbage collected, along with these processes. But a)
> run them at one higher than the current priority, and
> + b) ensure that they all effectively resume at the same time; i.e.
> ensure this code doesn;t get preempted by the first
> + process to start running."
> + ourPriority := Processor activePriority.
> + [({blockOne. blockTwo. blockThree}
> + collect: [:b| b newProcess priority:
> ourPriority + 1; yourself])
> + do: [:each| each resume]]
> + valueAt: ourPriority + 2!
> - will get garbage collected, along with these processes."
> - blockOne fork.
> - blockTwo fork.
> - blockThree fork!
>
> Item was added:
> + ----- Method:
> SocketPluginSimulator>>primitiveSocketListenWithOrWithoutBacklog (in
> category 'primitives') -----
> + primitiveSocketListenWithOrWithoutBacklog
> + "This is a hack to get around limitations in the simulated
> dispatch of smart syntax primitives."
> + interpreterProxy methodArgumentCount = 2 ifTrue:
> + ["self primitive: 'primitiveSocketListenOnPort'
> parameters: #(#Oop #SmallInteger)"
> + ^self primitiveSocket: (interpreterProxy stackValue: 1)
> + listenOnPort: (interpreterProxy
> stackIntegerValue: 0)].
> + "self primitive: 'primitiveSocketListenOnPortBacklog' parameters:
> #(#Oop #SmallInteger #SmallInteger)"
> + ^self primitiveSocket: (interpreterProxy stackValue: 1)
> + listenOnPort: (interpreterProxy stackIntegerValue: 0)
> + backlogSize: (interpreterProxy stackIntegerValue: 0)!
>
Is this correct? Or shouldn't it be:
^self primitiveSocket: (interpreterProxy stackValue: 2)
listenOnPort: (interpreterProxy stackIntegerValue: 1)
backlogSize: (interpreterProxy stackIntegerValue: 0)!
In VMMaker.oscog-nice.2565 I dispatched to the simulator so that it can use
its doesNotUnderstand trick...
interpreterProxy methodArgumentCount = 2
ifTrue:[^simulator primitiveSocketListenOnPort]
ifFalse:[^simulator primitiveSocketListenOnPortBacklog]
It might be slower, but avoid duplicating too much code...
>
> Item was added:
> + ----- Method: SocketPluginSimulator>>sqSocket:ListenOnPort: (in category
> 'simulation') -----
> + sqSocket: socketHandle ListenOnPort: portNumber
> + ^[Socket basicNew
> + primSocket: ((self
> hostSocketHandleFromSimSocketHandle: socketHandle) ifNil: [^self])
> + listenOn: portNumber]
> + on: SocketPrimitiveFailed
> + do: [:ex|
> + interpreterProxy primitiveFail.
> + 0]!
>
> Item was added:
> + ----- Method: SocketPluginSimulator>>sqSocketLocalPort: (in category
> 'simulation') -----
> + sqSocketLocalPort: socketHandleCArray
> + ^[Socket basicNew
> + primSocketLocalPort: ((self
> hostSocketHandleFromSimSocketHandle: socketHandleCArray) ifNil: [^false])]
> + on: SocketPrimitiveFailed
> + do: [:ex|
> + interpreterProxy primitiveFail.
> + false]!
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20190921/7ab54552/attachment.html>
More information about the Vm-dev
mailing list