[Vm-dev] VM Maker: VMMaker.oscog-eem.1997.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Nov 21 00:21:28 UTC 2016
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1997.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1997
Author: eem
Time: 20 November 2016, 4:20:26.447594 pm
UUID: 6d4a1cc8-5117-438d-b6ab-6ef315dd0210
Ancestors: VMMaker.oscog-eem.1996
The new FilePlugin code must protect against zero-divide when given empty arrays.
=============== Diff against VMMaker.oscog-eem.1996 ===============
Item was changed:
----- Method: FilePlugin>>primitiveFileReadWithPinning (in category 'file primitives') -----
primitiveFileReadWithPinning
"This version of primitiveFileRead is for garbage collectors that support pinning."
| count startIndex array file slotSize elementSize bytesRead |
<inline: true>
<var: 'file' type: #'SQFile *'>
<var: 'count' type: #'size_t'>
<var: 'startIndex' type: #'size_t'>
<var: 'slotSize' type: #'size_t'>
<var: 'elementSize' type: #'size_t'>
count := interpreterProxy positiveMachineIntegerValueOf: (interpreterProxy stackValue: 0).
startIndex := interpreterProxy positiveMachineIntegerValueOf: (interpreterProxy stackValue: 1).
array := interpreterProxy stackValue: 2.
file := self fileValueOf: (interpreterProxy stackValue: 3).
(interpreterProxy failed
"buffer can be any indexable words or bytes object except CompiledMethod"
or: [(interpreterProxy isWordsOrBytes: array) not]) ifTrue:
[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
slotSize := interpreterProxy slotSizeOf: array.
(startIndex >= 1 and: [startIndex + count - 1 <= slotSize]) ifFalse:
[^interpreterProxy primitiveFailFor: PrimErrBadIndex].
"Note: adjust startIndex for zero-origin byte indexing"
+ elementSize := slotSize = 0
+ ifTrue: [0]
+ ifFalse: [(interpreterProxy byteSizeOf: array) // slotSize].
- elementSize := (interpreterProxy byteSizeOf: array) // slotSize.
bytesRead := self
sqFile: file
Read: count * elementSize
Into: (interpreterProxy cCoerce: (interpreterProxy firstIndexableField: array) to: #'char *')
At: startIndex - 1 * elementSize.
interpreterProxy failed ifFalse:
[interpreterProxy
pop: 5 "pop rcvr, file, array, startIndex, count"
thenPush:(interpreterProxy integerObjectOf: bytesRead // elementSize) "push # of elements read"]!
Item was changed:
----- Method: FilePlugin>>primitiveFileWrite (in category 'file primitives') -----
primitiveFileWrite
| count startIndex array file slotSize elementSize bytesWritten |
<var: 'file' type: 'SQFile *'>
<var: 'count' type: 'size_t'>
<var: 'startIndex' type: 'size_t'>
<var: 'slotSize' type: #'size_t'>
<var: 'elementSize' type: #'size_t'>
<export: true>
count := interpreterProxy positiveMachineIntegerValueOf: (interpreterProxy stackValue: 0).
startIndex := interpreterProxy positiveMachineIntegerValueOf: (interpreterProxy stackValue: 1).
array := interpreterProxy stackValue: 2.
file := self fileValueOf: (interpreterProxy stackValue: 3).
(interpreterProxy failed
"buffer can be any indexable words or bytes object except CompiledMethod"
or: [(interpreterProxy isWordsOrBytes: array) not]) ifTrue:
[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
slotSize := interpreterProxy slotSizeOf: array.
(startIndex >= 1 and: [startIndex + count - 1 <= slotSize]) ifFalse:
[^interpreterProxy primitiveFailFor: PrimErrBadIndex].
"Note: adjust startIndex for zero-origin byte indexing"
+ elementSize := slotSize = 0
+ ifTrue: [0]
+ ifFalse: [(interpreterProxy byteSizeOf: array) // slotSize].
- elementSize := (interpreterProxy byteSizeOf: array) // slotSize.
bytesWritten := self
sqFile: file
Write: count * elementSize
From: (interpreterProxy cCoerce: (interpreterProxy firstIndexableField: array) to: #'char *')
At: startIndex - 1 * elementSize.
interpreterProxy failed ifFalse:
[interpreterProxy pop: 5 thenPush: (interpreterProxy integerObjectOf: bytesWritten // elementSize)]!
More information about the Vm-dev
mailing list