VM Maker: VMMaker.oscog-eem.2821.mcz

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

VM Maker: VMMaker.oscog-eem.2821.mcz

commits-2
 
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2821.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.2821
Author: eem
Time: 25 September 2020, 1:48:42.123223 pm
UUID: fa483503-c741-4558-9a10-7be84c51e4e8
Ancestors: VMMaker.oscog-eem.2820

SocketPlugin:
Make sure that all senders of socketValueOf: check for failure (e.g. primitiveSocketReceiveDataAvailable: primitiveSocketRemotePort: primitiveSocketSendDone: did not).

Make the four send/receive primitives that take bits array arguments accept any of Spur's native bits types, byte, double byte, quad byte or octa byte.

Add the bytesPerElement: function to InterpreterProxy/sqVirtualMachine to allow these primitives to determine the element size.

Slang: Have the SmartSyntaxPlugins use the methodReturnFoo: protocol where they can.

=============== Diff against VMMaker.oscog-eem.2820 ===============

Item was added:
+ ----- Method: InterpreterProxy>>bytesPerElement: (in category 'testing') -----
+ bytesPerElement: oop
+ <option: #(atLeastVMProxyMajor:minor: 1 17)>
+ ^oop bytesPerElement!

Item was changed:
  ----- Method: SmartSyntaxPluginTMethod>>pop:thenReturnExpr: (in category 'private') -----
  pop: anInteger thenReturnExpr: anExpression
+ "Use the methodReturnFoo: protocol; it's simpler, more concise, more reliable (var args)"
+ anExpression isSend ifTrue:
+ [#(asSmallIntegerObj asBooleanObj asFloatObj)
+ with: #(methodReturnInteger: methodReturnBool: methodReturnFloat:)
+ do:
+ [:abstractMessage :returnMessage|
+ anExpression selector == abstractMessage ifTrue:
+ [^TSendNode new
+ setSelector: returnMessage
+ receiver: (TVariableNode new setName: #interpreterProxy)
+ arguments: {anExpression receiver}]]].
-
  ^TSendNode new
+ setSelector: #methodReturnValue:
- setSelector: #pop:thenPush:
  receiver: (TVariableNode new setName: 'interpreterProxy')
+ arguments: {anExpression}!
- arguments: {TConstantNode new setValue: anInteger. anExpression}!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocket:getOptions: (in category 'primitives') -----
  primitiveSocket: socket getOptions: optionName
+ | s returnedValue errorCode results |
- | s optionNameStart optionNameSize returnedValue errorCode results |
  <var: #s type: #SocketPtr>
- <var: #optionNameStart type: #'char *'>
  self primitive: 'primitiveSocketGetOptions' parameters: #(Oop Oop).
 
  s := self socketValueOf: socket.
  interpreterProxy success: (interpreterProxy isBytes: optionName).
- optionNameStart := self cCoerce: (interpreterProxy firstIndexableField: optionName) to: #'char *'.
- optionNameSize := interpreterProxy slotSizeOf: optionName.
-
  interpreterProxy failed ifTrue: [^nil].
  returnedValue := 0.
-
  errorCode := self sqSocketGetOptions: s
+ optionNameStart: (self cCoerce: (interpreterProxy firstIndexableField: optionName) to: #'char *')
+ optionNameSize: (interpreterProxy byteSizeOf: optionName)
- optionNameStart: optionNameStart
- optionNameSize: optionNameSize
  returnedValue: (self addressOf: returnedValue put: [:val| returnedValue := val]).
 
  results := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 2.
  interpreterProxy
+ storeInteger: 0 ofObject: results withValue: errorCode;
+ storeInteger: 1 ofObject: results withValue: returnedValue.
- storePointer: 0 ofObject: results withValue: errorCode asSmallIntegerObj;
- storePointer: 1 ofObject: results withValue: returnedValue asSmallIntegerObj.
  ^results!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocket:listenOnPort:backlogSize: (in category 'primitives') -----
  primitiveSocket: socket listenOnPort: port backlogSize: backlog
  "second part of the wierdass dual prim primitiveSocketListenOnPort
  which was warped by some demented evil person determined to twist the
  very nature of reality"
  | s okToListen |
  <var: #s type: 'SocketPtr'>
  self primitive: 'primitiveSocketListenOnPortBacklog' parameters: #(#Oop #SmallInteger #SmallInteger ).
- s := self socketValueOf: socket.
  "If the security plugin can be loaded, use it to check for permission.
  If not, assume it's ok"
  sCCLOPfn ~= 0 ifTrue:
  [okToListen := self cCode: ' ((sqInt (*) (sqInt, sqInt)) sCCLOPfn)((sqInt)s, port)'.
  okToListen ifFalse:
  [^interpreterProxy primitiveFail]].
+ s := self socketValueOf: socket.
+ interpreterProxy failed ifFalse:
+ [self sqSocket: s ListenOnPort: port BacklogSize: backlog]!
- self sqSocket: s ListenOnPort: port BacklogSize: backlog!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocket:listenOnPort:backlogSize:interface: (in category 'primitives') -----
  primitiveSocket: socket listenOnPort: port backlogSize: backlog interface: ifAddr
  "Bind a socket to the given port and interface address with no more than backlog pending connections.  The socket can be UDP, in which case the backlog should be specified as zero."
 
  | s okToListen addr |
+ <var: #s type: #SocketPtr>
- <var: #s type: 'SocketPtr'>
  self primitive: 'primitiveSocketListenOnPortBacklogInterface' parameters: #(#Oop #SmallInteger #SmallInteger #ByteArray).
- s := self socketValueOf: socket.
  "If the security plugin can be loaded, use it to check for permission.
  If  not, assume it's ok"
  sCCLOPfn ~= 0 ifTrue:
  [okToListen := self cCode: ' ((sqInt (*) (sqInt, sqInt)) sCCLOPfn)((sqInt)s, port)'.
  okToListen ifFalse:
  [^ interpreterProxy primitiveFail]].
+ s := self socketValueOf: socket.
+ addr := self netAddressToInt: (self cCoerce: ifAddr to: #'unsigned char *').
+ interpreterProxy failed ifFalse:
+ [self sqSocket: s ListenOnPort: port BacklogSize: backlog Interface: addr]!
- addr := self netAddressToInt: (self cCoerce: ifAddr to: 'unsigned char *').
- self sqSocket: s ListenOnPort: port BacklogSize: backlog Interface: addr!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocket:receiveDataBuf:start:count: (in category 'primitives') -----
  primitiveSocket: socket receiveDataBuf: array start: startIndex count: count
+ | s elementSize arrayBase bytesReceived |
+ <var: #s type: #SocketPtr>
- | s byteSize arrayBase bufStart bytesReceived |
- <var: #s type: 'SocketPtr'>
- <var: #arrayBase type: 'char *'>
- <var: #bufStart type: 'char *'>
  self primitive: 'primitiveSocketReceiveDataBufCount'
+ parameters: #(Oop Oop SmallInteger SmallInteger).
- parameters: #(Oop Oop SmallInteger SmallInteger ).
- s := self socketValueOf: socket.
 
+ "buffer can be any indexable bits object"
+ elementSize := self cppIf: SPURVM
+ ifTrue: [interpreterProxy bytesPerElement: array]
+ ifFalse: [(interpreterProxy isWords: array) ifTrue: [4] ifFalse: [1]].
+ ((interpreterProxy isWordsOrBytes: array)
+ and: [elementSize > 0
+ and: [startIndex >= 1
+ and: [count >= 0
+ and: [startIndex + count - 1 <= (interpreterProxy slotSizeOf: array)]]]]) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+
+ s := self socketValueOf: socket.
+ interpreterProxy failed ifFalse: "Note: adjust bufStart for zero-origin indexing"
+ [arrayBase := self cCoerce: (interpreterProxy firstIndexableField: array) to: #'char *'.
+ bytesReceived := self
+ sqSocket: s
+ ReceiveDataBuf: arrayBase + (startIndex - 1 * elementSize)
+ Count: count * elementSize.
+ ^(bytesReceived // elementSize) asSmallIntegerObj]!
- "buffer can be any indexable words or bytes object"
- interpreterProxy success: (interpreterProxy isWordsOrBytes: array).
- (interpreterProxy isWords: array)
- ifTrue: [byteSize := 4]
- ifFalse: [byteSize := 1].
- interpreterProxy success: (startIndex >= 1
- and: [count >= 0 and: [startIndex + count - 1 <= (interpreterProxy slotSizeOf: array)]]).
- interpreterProxy failed
- ifFalse: ["Note: adjust bufStart for zero-origin indexing"
- arrayBase := self cCoerce: (interpreterProxy firstIndexableField: array) to: 'char *'.
- bufStart := arrayBase + (startIndex - 1 * byteSize).
- bytesReceived := self
- sqSocket: s
- ReceiveDataBuf: bufStart
- Count: count * byteSize].
- ^ (bytesReceived // byteSize) asSmallIntegerObj!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocket:receiveUDPDataBuf:start:count: (in category 'primitives') -----
  primitiveSocket: socket receiveUDPDataBuf: array start: startIndex count: count
+ | s elementSize arrayBase bytesReceived results address port moreFlag addressOop |
- | s elementSize arrayBase bufStart bytesReceived results address port moreFlag |
  <var: #s type: #SocketPtr>
  <var: #arrayBase type: #'char *'>
- <var: #bufStart type: #'char *'>
  self primitive: 'primitiveSocketReceiveUDPDataBufCount'
  parameters: #(Oop Oop SmallInteger SmallInteger).
  s := self socketValueOf: socket.
 
+ "buffer can be any indexable bits object"
+ elementSize := self cppIf: SPURVM
+ ifTrue: [interpreterProxy bytesPerElement: array]
+ ifFalse: [(interpreterProxy isWords: array) ifTrue: [4] ifFalse: [1]].
+ ((interpreterProxy isWordsOrBytes: array)
+ and: [elementSize > 0
+ and: [startIndex >= 1
+ and: [count >= 0
+ and: [startIndex + count - 1 <= (interpreterProxy slotSizeOf: array)]]]]) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
- "buffer can be any indexable words or bytes object"
- interpreterProxy success: (interpreterProxy isWordsOrBytes: array).
- (interpreterProxy isWords: array)
- ifTrue: [elementSize := 4]
- ifFalse: [elementSize := 1].
- interpreterProxy success: (startIndex >= 1
- and: [count >= 0 and: [startIndex + count - 1 <= (interpreterProxy slotSizeOf: array)]]).
- interpreterProxy failed
- ifFalse: ["Note: adjust bufStart for zero-origin indexing"
- arrayBase := self cCoerce: (interpreterProxy firstIndexableField: array) to: #'char *'.
- bufStart := arrayBase + (startIndex - 1 * elementSize).
- address := 0.
- port := 0.
- moreFlag := 0.
- bytesReceived := self sqSocket: s
- ReceiveUDPDataBuf: bufStart
- Count: count * elementSize
- address: (self addressOf: address)
- port: (self addressOf: port)
- moreFlag: (self addressOf: moreFlag).
 
+ "Note: adjust for zero-origin indexing"
+ arrayBase := self cCoerce: (interpreterProxy firstIndexableField: array) to: #'char *'.
+ address := port := moreFlag := 0.
+ bytesReceived := self sqSocket: s
+ ReceiveUDPDataBuf: arrayBase + (startIndex - 1 * elementSize)
+ Count: count * elementSize
+ address: (self addressOf: address put: [:v| address := v])
+ port: (self addressOf: port put: [:v| port := v])
+ moreFlag: (self addressOf: moreFlag put: [:v| moreFlag := v]).
+
+ "allocate storage for results, remapping newly allocated
+ oops in case GC happens during allocation"
+ addressOop := self intToNetAddress: address.
+ self remapOop: addressOop
+ in: [results := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 4].
+ interpreterProxy
+ storeInteger: 0 ofObject: results withValue: bytesReceived // elementSize;
+ storePointer: 1 ofObject: results withValue: addressOop;
+ storeInteger: 2 ofObject: results withValue: port;
+ storePointer: 3 ofObject: results withValue: (moreFlag
+ ifTrue: [interpreterProxy trueObject]
+ ifFalse: [interpreterProxy falseObject]).
+ ^results!
- "allocate storage for results, remapping newly allocated
- oops in case GC happens during allocation"
- interpreterProxy pushRemappableOop: (self intToNetAddress: address).
- results := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 4.
- interpreterProxy storePointer: 0 ofObject: results withValue: (bytesReceived // elementSize) asSmallIntegerObj.
- interpreterProxy storePointer: 1 ofObject: results withValue: interpreterProxy popRemappableOop.
- interpreterProxy storePointer: 2 ofObject: results withValue: port asSmallIntegerObj.
- interpreterProxy storePointer: 3 ofObject: results withValue: (moreFlag
- ifTrue: [interpreterProxy trueObject]
- ifFalse: [interpreterProxy falseObject]).
- ].
- ^ results!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocket:sendData:start:count: (in category 'primitives') -----
  primitiveSocket: socket sendData: array start: startIndex count: count
+ | s arrayBase bytesSent elementSize |
+ <var: #s type: #SocketPtr>
+ <var: #arrayBase type: #'char *'>
- | s byteSize arrayBase bufStart bytesSent |
- <var: #s type: 'SocketPtr'>
- <var: #arrayBase type: 'char *'>
- <var: #bufStart type: 'char *'>
  self primitive: 'primitiveSocketSendDataBufCount'
  parameters: #(Oop Oop SmallInteger SmallInteger ).
  s := self socketValueOf: socket.
 
+ "buffer can be any indexable bits object"
+ elementSize := self cppIf: SPURVM
+ ifTrue: [interpreterProxy bytesPerElement: array]
+ ifFalse: [(interpreterProxy isWords: array) ifTrue: [4] ifFalse: [1]].
+ ((interpreterProxy isWordsOrBytes: array)
+ and: [elementSize > 0
+ and: [startIndex >= 1
+ and: [count >= 0
+ and: [startIndex + count - 1 <= (interpreterProxy slotSizeOf: array)]]]]) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+
- "buffer can be any indexable words or bytes object except CompiledMethod "
- interpreterProxy success: (interpreterProxy isWordsOrBytes: array).
- (interpreterProxy isWords: array)
- ifTrue: [byteSize := 4]
- ifFalse: [byteSize := 1].
- interpreterProxy success: (startIndex >= 1
- and: [count >= 0 and: [startIndex + count - 1 <= (interpreterProxy slotSizeOf: array)]]).
  interpreterProxy failed
  ifFalse: ["Note: adjust bufStart for zero-origin indexing"
+ arrayBase := self cCoerce: (interpreterProxy firstIndexableField: array) to: #'char *'.
- arrayBase := self cCoerce: (interpreterProxy firstIndexableField: array) to: 'char *'.
- bufStart := arrayBase + (startIndex - 1 * byteSize).
  bytesSent := self
  sqSocket: s
+ SendDataBuf: arrayBase + (startIndex - 1 * elementSize)
+ Count: count * elementSize].
+ ^(bytesSent // elementSize) asSmallIntegerObj!
- SendDataBuf: bufStart
- Count: count * byteSize].
- ^ (bytesSent // byteSize) asSmallIntegerObj!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocket:sendUDPData:toHost:port:start:count: (in category 'primitives') -----
  primitiveSocket: socket sendUDPData: array toHost: hostAddress  port: portNumber start: startIndex count: count
+ | s elementSize arrayBase bytesSent |
+ <var: #s type: #SocketPtr>
- | s byteSize arrayBase bufStart bytesSent address |
- <var: #s type: 'SocketPtr'>
- <var: #arrayBase type: 'char *'>
- <var: #bufStart type: 'char *'>
  self primitive: 'primitiveSocketSendUDPDataBufCount'
+ parameters: #(Oop Oop ByteArray SmallInteger SmallInteger SmallInteger).
- parameters: #(Oop Oop ByteArray SmallInteger SmallInteger SmallInteger ).
- s := self socketValueOf: socket.
 
+ "buffer can be any indexable bits object"
+ elementSize := self cppIf: SPURVM
+ ifTrue: [interpreterProxy bytesPerElement: array]
+ ifFalse: [(interpreterProxy isWords: array) ifTrue: [4] ifFalse: [1]].
+ ((interpreterProxy isWordsOrBytes: array)
+ and: [elementSize > 0
+ and: [startIndex >= 1
+ and: [count >= 0
+ and: [startIndex + count - 1 <= (interpreterProxy slotSizeOf: array)]]]]) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+
+ s := self socketValueOf: socket.
+ interpreterProxy failed ifFalse:
+ ["Note: adjust bufStart for zero-origin indexing"
+ arrayBase := self cCoerce: (interpreterProxy firstIndexableField: array) to: #'char *'.
+ bytesSent := self
- "buffer can be any indexable words or bytes object except CompiledMethod "
- interpreterProxy success: (interpreterProxy isWordsOrBytes: array).
- (interpreterProxy isWords: array)
- ifTrue: [byteSize := 4]
- ifFalse: [byteSize := 1].
- interpreterProxy success: (startIndex >= 1
- and: [count >= 0 and: [startIndex + count - 1 <= (interpreterProxy slotSizeOf: array)]]).
- interpreterProxy failed
- ifFalse: ["Note: adjust bufStart for zero-origin indexing"
- arrayBase := self cCoerce: (interpreterProxy firstIndexableField: array) to: 'char *'.
- bufStart := arrayBase + (startIndex - 1 * byteSize).
- address := self netAddressToInt: (self cCoerce: hostAddress to: 'unsigned char *').
- bytesSent := self
  sqSocket: s
+ toHost: (self netAddressToInt: (self cCoerce: hostAddress to: #'unsigned char *'))
- toHost: address
  port: portNumber
+ SendDataBuf: arrayBase + (startIndex - 1 * elementSize)
+ Count: count * elementSize].
+ ^(bytesSent // elementSize) asSmallIntegerObj!
- SendDataBuf: bufStart
- Count: count * byteSize].
- ^ (bytesSent // byteSize) asSmallIntegerObj!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocket:setOptions:value: (in category 'primitives') -----
  primitiveSocket: socket setOptions: optionName value: optionValue
  "THIS BADLY NEEDS TO BE REWRITTEN TO TAKE Booleans AND Integers AS WELL AS (OR INSTEAD OF) Strings.
  It is only used with booleans and integers and parsing these back out of strings in
  sqSocketSetOptions:optionNameStart:optionNameSize:optionValueStart:optionValueSize:returnedValue:
  is STUPID."
+ | s returnedValue errorCode results |
- | s optionNameStart optionNameSize optionValueStart optionValueSize returnedValue errorCode results |
  <var: #s type: #SocketPtr>
- <var: #optionNameStart type: #'char *'>
- <var: #optionValueStart type: #'char *'>
  self primitive: 'primitiveSocketSetOptions' parameters: #(Oop Oop Oop).
 
  s := self socketValueOf: socket.
+ interpreterProxy success: ((interpreterProxy isBytes: optionName) and: [interpreterProxy isBytes: optionValue]).
- interpreterProxy success: (interpreterProxy isBytes: optionName).
- optionNameStart := self cCoerce: (interpreterProxy firstIndexableField: optionName) to: #'char *'.
- optionNameSize := interpreterProxy slotSizeOf: optionName.
- interpreterProxy success: (interpreterProxy isBytes: optionValue).
- optionValueStart:= self cCoerce: (interpreterProxy firstIndexableField: optionValue) to: #'char *'.
- optionValueSize := interpreterProxy slotSizeOf: optionValue.
-
  interpreterProxy failed ifTrue: [^nil].
  returnedValue := 0.
 
  errorCode := self sqSocketSetOptions: s
+ optionNameStart: (self cCoerce: (interpreterProxy firstIndexableField: optionName) to: #'char *')
+ optionNameSize: (interpreterProxy byteSizeOf: optionName)
+ optionValueStart: (self cCoerce: (interpreterProxy firstIndexableField: optionValue) to: #'char *')
+ optionValueSize: (interpreterProxy byteSizeOf: optionValue)
- optionNameStart: optionNameStart
- optionNameSize: optionNameSize
- optionValueStart: optionValueStart
- optionValueSize: optionValueSize
  returnedValue: (self addressOf: returnedValue put: [:val| returnedValue := val]).
 
  results := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 2.
  interpreterProxy
+ storeInteger: 0 ofObject: results withValue: errorCode;
+ storeInteger: 1 ofObject: results withValue: returnedValue.
- storePointer: 0 ofObject: results withValue: errorCode asSmallIntegerObj;
- storePointer: 1 ofObject: results withValue: returnedValue asSmallIntegerObj.
  ^results!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketAcceptFrom:rcvBufferSize:sndBufSize:semaIndex: (in category 'primitives') -----
  primitiveSocketAcceptFrom: sockHandle rcvBufferSize: recvBufSize sndBufSize: sendBufSize semaIndex: semaIndex
  | socketOop s serverSocket |
  <var: #s type: 'SocketPtr '>
  <var: #serverSocket type: 'SocketPtr '>
  self primitive: 'primitiveSocketAccept'
  parameters: #(Oop SmallInteger SmallInteger SmallInteger ).
  serverSocket := self socketValueOf: sockHandle.
 
+ interpreterProxy failed ifFalse:
+ [socketOop := interpreterProxy
+ instantiateClass: interpreterProxy classByteArray
+ indexableSize: self socketRecordSize.
+ s := self socketValueOf: socketOop.
+ interpreterProxy failed ifFalse:
+ [self
- interpreterProxy failed
- ifFalse: [socketOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self socketRecordSize.
- s := self socketValueOf: socketOop.
- self
  sqSocket: s
  AcceptFrom: serverSocket
  RecvBytes: recvBufSize
  SendBytes: sendBufSize
+ SemaID: semaIndex.
+ ^ socketOop]]!
- SemaID: semaIndex].
- ^ socketOop!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketAcceptFrom:rcvBufferSize:sndBufSize:semaIndex:readSemaIndex:writeSemaIndex: (in category 'primitives') -----
  primitiveSocketAcceptFrom: sockHandle rcvBufferSize: recvBufSize sndBufSize: sendBufSize semaIndex: semaIndex readSemaIndex: aReadSema writeSemaIndex: aWriteSema
  | socketOop s serverSocket |
  <var: #s type: 'SocketPtr '>
  <var: #serverSocket type: 'SocketPtr '>
  self primitive: 'primitiveSocketAccept3Semaphores'
  parameters: #(Oop SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger).
  serverSocket := self socketValueOf: sockHandle.
 
+ interpreterProxy failed ifFalse:
+ [socketOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self socketRecordSize.
+ s := self socketValueOf: socketOop.
+ interpreterProxy failed ifFalse:
+ [self
- interpreterProxy failed
- ifFalse: [socketOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self socketRecordSize.
- s := self socketValueOf: socketOop.
- self
  sqSocket: s
  AcceptFrom: serverSocket
  RecvBytes: recvBufSize
  SendBytes: sendBufSize
  SemaID: semaIndex
  ReadSemaID: aReadSema
+ WriteSemaID: aWriteSema.
+ ^ socketOop]]!
- WriteSemaID: aWriteSema].
- ^ socketOop!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketCreateNetwork:type:receiveBufferSize:sendBufSize:semaIndex: (in category 'primitives') -----
  primitiveSocketCreateNetwork: netType type: socketType receiveBufferSize: recvBufSize sendBufSize: sendBufSize semaIndex: semaIndex
  | socketOop s okToCreate |
  <var: #s type: 'SocketPtr '>
  self primitive: 'primitiveSocketCreate' parameters: #(#SmallInteger #SmallInteger #SmallInteger #SmallInteger #SmallInteger ).
  "If the security plugin can be loaded, use it to check for permission.
  If  not, assume it's ok"
  sCCSOTfn ~= 0 ifTrue:
  [okToCreate := self cCode: ' ((sqInt (*) (sqInt, sqInt)) sCCSOTfn)(netType, socketType)'.
  okToCreate ifFalse:
  [^ interpreterProxy primitiveFail]].
  socketOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self socketRecordSize.
  s := self socketValueOf: socketOop.
  interpreterProxy failed ifFalse:
  [self
  sqSocket: s
  CreateNetType: netType
  SocketType: socketType
  RecvBytes: recvBufSize
  SendBytes: sendBufSize
+ SemaID: semaIndex.
+ ^socketOop]!
- SemaID: semaIndex].
- ^socketOop!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketCreateNetwork:type:receiveBufferSize:sendBufSize:semaIndex:readSemaIndex:writeSemaIndex: (in category 'primitives') -----
  primitiveSocketCreateNetwork: netType type: socketType receiveBufferSize: recvBufSize sendBufSize: sendBufSize semaIndex: semaIndex readSemaIndex: aReadSema writeSemaIndex: aWriteSema
  | socketOop s okToCreate |
  <var: #s type: 'SocketPtr '>
  self primitive: 'primitiveSocketCreate3Semaphores' parameters: #(#SmallInteger #SmallInteger #SmallInteger #SmallInteger #SmallInteger #SmallInteger #SmallInteger ).
  "If the security plugin can be loaded, use it to check for permission.
  If not, assume it's ok"
  sCCSOTfn ~= 0 ifTrue:
  [okToCreate := self cCode: ' ((sqInt (*) (sqInt, sqInt)) sCCSOTfn)(netType, socketType)'.
  okToCreate ifFalse:
  [^ interpreterProxy primitiveFail]].
  socketOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self socketRecordSize.
  s := self socketValueOf: socketOop.
  interpreterProxy failed ifFalse:
  [self
  sqSocket: s
  CreateNetType: netType
  SocketType: socketType
  RecvBytes: recvBufSize
  SendBytes: sendBufSize
  SemaID: semaIndex
  ReadSemaID: aReadSema
+ WriteSemaID: aWriteSema.
+ ^socketOop]!
- WriteSemaID: aWriteSema].
- ^socketOop!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketCreateRaw:type:receiveBufferSize:sendBufSize:semaIndex:readSemaIndex:writeSemaIndex: (in category 'primitives') -----
  primitiveSocketCreateRaw: netType type: protoType receiveBufferSize: recvBufSize sendBufSize: sendBufSize semaIndex: semaIndex readSemaIndex: aReadSema writeSemaIndex: aWriteSema
  | socketOop s okToCreate |
  <var: #s type: 'SocketPtr '>
  self primitive: 'primitiveSocketCreateRAW' parameters: #(#SmallInteger #SmallInteger #SmallInteger #SmallInteger #SmallInteger #SmallInteger #SmallInteger ).
  "If the security plugin can be loaded, use it to check for permission.
  If not, assume it's ok"
  sCCSOTfn ~= 0 ifTrue:
  [okToCreate := self cCode: ' ((sqInt (*) (sqInt, sqInt)) sCCSOTfn)(netType, protoType)'.
  okToCreate ifFalse:
  [^ interpreterProxy primitiveFail]].
  socketOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self socketRecordSize.
  s := self socketValueOf: socketOop.
  interpreterProxy failed ifFalse:
  [self
  sqSocket: s
  CreateRaw: netType
  ProtoType: protoType
  RecvBytes: recvBufSize
  SendBytes: sendBufSize
  SemaID: semaIndex
  ReadSemaID: aReadSema
+ WriteSemaID: aWriteSema.
+ ^ socketOop]!
- WriteSemaID: aWriteSema].
- ^ socketOop!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketError: (in category 'primitives') -----
  primitiveSocketError: socket
 
+ | s |
+ <var: #s type: #SocketPtr>
- | s err |
- <var: #s type: 'SocketPtr '>
  self primitive: 'primitiveSocketError'
  parameters: #(Oop).
  s := self socketValueOf: socket.
+ interpreterProxy failed ifFalse:
+ [^(self sqSocketError: s) asSmallIntegerObj]!
- interpreterProxy failed ifFalse: [
- err := self sqSocketError: s].
- ^err asSmallIntegerObj!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketLocalAddressSize: (in category 'ipv6 primitives') -----
  primitiveSocketLocalAddressSize: socket
 
  | s size |
+ <var: #s type: #SocketPtr>
- <var: #s type: 'SocketPtr'>
  self primitive: 'primitiveSocketLocalAddressSize' parameters: #(#Oop).
  s := self socketValueOf: socket.
+ interpreterProxy failed ifFalse:
+ [size := self sqSocketLocalAddressSize: s.
+ interpreterProxy failed ifFalse:
+ [^size asSmallIntegerObj]]!
- interpreterProxy failed ifTrue: [^nil].
- size := self sqSocketLocalAddressSize: s.
- interpreterProxy failed ifTrue: [^nil].
- ^size asSmallIntegerObj!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketReceiveDataAvailable: (in category 'primitives') -----
  primitiveSocketReceiveDataAvailable: socket
 
+ | s |
+ <var: #s type: #SocketPtr>
- | s dataIsAvailable |
- <var: #s type: 'SocketPtr'>
  self primitive: 'primitiveSocketReceiveDataAvailable'
  parameters: #(Oop).
  s := self socketValueOf: socket.
+ interpreterProxy failed ifFalse:
+ [^(self sqSocketReceiveDataAvailable: s) asBooleanObj]!
- dataIsAvailable := self sqSocketReceiveDataAvailable: s.
- ^dataIsAvailable asBooleanObj!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketRemoteAddressSize: (in category 'ipv6 primitives') -----
  primitiveSocketRemoteAddressSize: socket
 
  | s size |
+ <var: #s type: #SocketPtr>
- <var: #s type: 'SocketPtr'>
  self primitive: 'primitiveSocketRemoteAddressSize' parameters: #(#Oop).
  s := self socketValueOf: socket.
+ interpreterProxy failed ifFalse:
+ [size := self sqSocketRemoteAddressSize: s.
+ interpreterProxy failed ifFalse:
+ [^size asSmallIntegerObj]]!
- interpreterProxy failed ifTrue: [^nil].
- size := self sqSocketRemoteAddressSize: s.
- interpreterProxy failed ifTrue: [^nil].
- ^size asSmallIntegerObj!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketRemotePort: (in category 'primitives') -----
  primitiveSocketRemotePort: socket
 
+ | s |
+ <var: #s type: #SocketPtr>
- | s port |
- <var: #s type: 'SocketPtr'>
  self primitive: 'primitiveSocketRemotePort'
  parameters: #(Oop).
  s := self socketValueOf: socket.
+ interpreterProxy failed ifFalse:
+ [^(self sqSocketRemotePort: s) asSmallIntegerObj]!
- port := self sqSocketRemotePort: s.
- ^port asSmallIntegerObj!

Item was changed:
  ----- Method: SocketPlugin>>primitiveSocketSendDone: (in category 'primitives') -----
  primitiveSocketSendDone: socket
 
+ | s |
+ <var: #s type: #SocketPtr>
- | s done |
- <var: #s type: 'SocketPtr'>
  self primitive: 'primitiveSocketSendDone'
  parameters: #(Oop).
  s := self socketValueOf: socket.
+ interpreterProxy failed ifFalse:
+ [^(self sqSocketSendDone: s) asBooleanObj]!
- done := self sqSocketSendDone: s.
- ^done asBooleanObj!

Item was added:
+ ----- Method: SpurMemoryManager>>bytesPerElement: (in category 'object access') -----
+ bytesPerElement: oop
+ "Answer the basic element size for the receiver.  Answer 0 for immediates and CompiledCode
+ (element size could be wordSize for literals or 1 for bytes, so its indeterminable).  Answer
+ wordSize for pointer objects.  Otherwise answer the actual element size of a bits container."
+ <api>
+ | fmt byteSizes |
+ <var: #byteSizes declareC: 'unsigned char byteSizes[16] =
+   { wordSize(),  wordSize(),  wordSize(),  wordSize(),
+ wordSize(),  wordSize(),  wordSize(),  0, /* forwarder */ wordSize(),
+ 8,
+ 4, 4,
+ 2, 2, 2, 2 }'>
+ (self isImmediate: oop) ifTrue:
+ [^0].
+ fmt := self formatOf: oop.
+ fmt >= self firstByteFormat ifTrue:
+ [fmt >= self firstCompiledMethodFormat ifTrue: [^0].
+ ^1].
+ ^(self cCode: [byteSizes] inSmalltalk:
+ [CArrayAccessor
+ on: { self wordSize. self wordSize. self wordSize. self wordSize.
+ self wordSize. self wordSize. self wordSize. 0. self wordSize.
+ 8.
+ 4. 4.
+ 2. 2. 2. 2 }])
+ at: fmt!