[Vm-dev] VM Maker: VMMaker.oscog-eem.1995.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Nov 19 17:56:53 UTC 2016
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1995.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1995
Author: eem
Time: 19 November 2016, 9:55:59.802779 am
UUID: 39c0e7ea-03ef-453e-b7d1-5570ab78dede
Ancestors: VMMaker.oscog-nice.1994
Fix the FilePlugin for Spur 32-bit and 16-bit integer arrays.
=============== Diff against VMMaker.oscog-nice.1994 ===============
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 |
- | count startIndex array file 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).
- count := interpreterProxy positive32BitValueOf: (interpreterProxy stackValue: 0).
- startIndex := interpreterProxy positive32BitValueOf: (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:
- elementSize := (interpreterProxy isWords: array) ifTrue: [4] ifFalse: [1].
- (startIndex >= 1
- and: [(startIndex + count - 1) <= (interpreterProxy slotSizeOf: array)]) ifFalse:
[^interpreterProxy primitiveFailFor: PrimErrBadIndex].
+ "Note: adjust startIndex for zero-origin byte indexing"
+ elementSize := (interpreterProxy byteSizeOf: array) // slotSize.
- "Note: adjust startIndex for zero-origin indexing"
bytesRead := self
sqFile: file
Read: count * elementSize
Into: (interpreterProxy cCoerce: (interpreterProxy firstIndexableField: array) to: #'char *')
+ At: startIndex - 1 * elementSize.
- 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 |
- | count startIndex array file 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'>
- <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).
- count := interpreterProxy positive32BitValueOf: (interpreterProxy stackValue: 0).
- startIndex := interpreterProxy positive32BitValueOf: (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:
- elementSize := (interpreterProxy isWords: array) ifTrue: [4] ifFalse: [1].
- (startIndex >= 1
- and: [(startIndex + count - 1) <= (interpreterProxy slotSizeOf: array)]) ifFalse:
[^interpreterProxy primitiveFailFor: PrimErrBadIndex].
+ "Note: adjust startIndex for zero-origin byte indexing"
+ elementSize := (interpreterProxy byteSizeOf: array) // slotSize.
- "Note: adjust startIndex for zero-origin indexing"
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