VM Maker: VMMaker.oscog-cb.2349.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-cb.2349.mcz

commits-2
 
ClementBera uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-cb.2349.mcz

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

Name: VMMaker.oscog-cb.2349
Author: cb
Time: 8 March 2018, 3:41:21.074453 pm
UUID: 2b2dea46-f9b6-4890-a225-c2e492ea4761
Ancestors: VMMaker.oscog-cb.2348

Merge back the DoubleWordArray code from a fresh image. Normally everything should be merged, up and running.

Note that I have exhaustive tests for all unsafe operations and some of them are known not to be working. I don't know how to export SUnit results to show which ones are working which one aren't, especially the tests are injecting sequences of bytecodes in methods so they are "Green or VM crash" tests instead of "Green or red"

=============== Diff against VMMaker.oscog-cb.2348 ===============

Item was added:
+ ----- Method: DoubleWordArray class>>defaultIntegerBaseInDebugger (in category '*VMMaker-debugger') -----
+ defaultIntegerBaseInDebugger
+ ^16!

Item was added:
+ ----- Method: DoubleWordArray>>byteAt: (in category '*VMMaker-JITSimulation') -----
+ byteAt: byteAddress
+ "Extract a byte from a DoubleWordArray (little-endian version)"
+ | lowBits |
+ lowBits := byteAddress - 1 bitAnd: 7.
+ ^((self at: byteAddress - 1 - lowBits // 8 + 1)
+ bitShift: lowBits * -8)
+ bitAnd: 16rFF!

Item was added:
+ ----- Method: DoubleWordArray>>long64At: (in category '*VMMaker-JITSimulation') -----
+ long64At: byteIndex
+ | lowBits wordIndex value high low |
+ wordIndex := byteIndex - 1 // 8 + 1.
+ (lowBits := byteIndex - 1 \\ 8) = 0
+ ifTrue:
+ [value := self at: wordIndex]
+ ifFalse:
+ [high := ((self at: wordIndex + 1) bitAnd: (1 bitShift: lowBits * 8) - 1) bitShift: 8 - lowBits * 8.
+ low := (self at: wordIndex) bitShift: lowBits * -8.
+ high = 0 ifTrue:
+ [^low].
+ value := high + low].
+ ^(value bitShift: -56) <= 127
+ ifTrue: [value]
+ ifFalse: [value - 16r10000000000000000]!

Item was added:
+ ----- Method: DoubleWordArray>>long64At:put: (in category '*VMMaker-JITSimulation') -----
+ long64At: byteIndex put: aValue
+ "Compatiblity with the ByteArray & Alien methods of the same name."
+ | wordIndex lowBits mask allOnes |
+ wordIndex := byteIndex - 1 // 8 + 1.
+ ((aValue bitShift: -63) between: -1 and: 0) ifFalse:
+ [self errorImproperStore].
+ allOnes := 16rFFFFFFFFFFFFFFFF.
+ (lowBits := byteIndex - 1 bitAnd: 7) = 0 ifTrue:
+ [^self at: wordIndex put: (aValue >= 0 ifTrue: [aValue] ifFalse: [aValue bitAnd: allOnes])].
+ mask := allOnes bitShift: 8 - lowBits * -8.
+ self at: wordIndex put: (((self at: wordIndex) bitAnd: mask) bitXor: ((aValue bitShift: lowBits * 8) bitAnd: allOnes - mask)).
+ self at: wordIndex + 1 put: (((self at: wordIndex + 1) bitAnd: allOnes - mask) bitXor: (allOnes bitAnd: ((aValue bitShift: 8 - lowBits * -8) bitAnd: mask))).
+ ^aValue!

Item was added:
+ ----- Method: DoubleWordArray>>longAt: (in category '*VMMaker-JITSimulation') -----
+ longAt: byteIndex
+ "Compatiblity with the ByteArray & Alien methods of the same name."
+ | wordIndex lowBits word hiWord |
+ wordIndex := byteIndex - 1 // 8 + 1.
+ lowBits := byteIndex - 1 bitAnd: 7.
+ word := (self at: wordIndex) bitShift: lowBits * -8.
+ lowBits > 4 ifTrue: "access straddles two words"
+ [hiWord := (self at: wordIndex + 1) bitShift: 8 - lowBits * 8.
+ word := word + hiWord].
+ word := word bitAnd: 16rFFFFFFFF.
+ (word bitShift: -24) > 127 ifTrue:
+ [word := word - 16r100000000].
+ ^word!

Item was added:
+ ----- Method: DoubleWordArray>>longAt:bigEndian: (in category '*VMMaker-JITSimulation') -----
+ longAt: byteIndex bigEndian: bigEndian
+ "Compatiblity with the ByteArray & Alien methods of the same name."
+ | wordIndex lowBits word hiWord |
+ wordIndex := byteIndex - 1 // 8 + 1.
+ lowBits := byteIndex - 1 bitAnd: 7.
+ word := (self at: wordIndex) bitShift: lowBits * -8.
+ lowBits > 4 ifTrue: "access straddles two words"
+ [hiWord := (self at: wordIndex + 1) bitShift: 8 - lowBits * 8.
+ word := word + hiWord].
+ word := word bitAnd: 16rFFFFFFFF.
+ bigEndian ifTrue:
+ [word := ((word bitShift: -24) bitAnd: 16rFF)
+ + ((word bitShift: -8) bitAnd: 16rFF00)
+   + ((word bitAnd: 16rFF00) bitShift: 8)
+ + ((word bitAnd: 16rFF) bitShift: 24)].
+ (word bitShift: -24) > 127 ifTrue:
+ [word := word - 16r100000000].
+ ^word!

Item was added:
+ ----- Method: DoubleWordArray>>longAt:put: (in category '*VMMaker-JITSimulation') -----
+ longAt: byteIndex put: aValue
+ "Compatiblity with the ByteArray & Alien methods of the same name."
+ | wordIndex lowBits word allOnes loMask hiMask |
+ wordIndex := byteIndex - 1 // 8 + 1.
+ lowBits := byteIndex - 1 bitAnd: 7.
+ ((aValue bitShift: -31) between: -1 and: 0) ifFalse:
+ [self errorImproperStore].
+ lowBits <= 4 ifTrue: "access fits in a single word"
+ [| mask |
+ mask := 16rFFFFFFFF bitShift: lowBits * 8.
+ word := self at: wordIndex.
+ self at: wordIndex put: ((word bitOr: mask) bitXor: (((aValue bitShift: lowBits * 8) bitAnd: mask) bitXor: mask)).
+ ^aValue].
+ "access straddles two words; make lowMask ones where destination is unchanged to avoid overflow"
+ allOnes := 16rFFFFFFFFFFFFFFFF.
+ loMask := allOnes bitShift: 8 - lowBits * -8.
+ hiMask := 16rFFFFFFFF bitShift: 8 - lowBits * -8.
+ word := self at: wordIndex.
+ self at: wordIndex put: ((word bitAnd: loMask) bitOr: ((aValue bitAnd: (16rFFFFFFFF bitShift: (lowBits bitAnd: 3) * -8)) bitShift: lowBits * 8)).
+ word := self at: wordIndex + 1.
+ self at: wordIndex + 1 put: ((word bitOr: hiMask) bitXor: ((((aValue bitShift: 4 - (lowBits bitAnd: 3) * -8)) bitAnd: hiMask) bitXor: hiMask)).
+ ^aValue!

Item was added:
+ ----- Method: DoubleWordArray>>unsignedByteAt: (in category '*VMMaker-JITSimulation') -----
+ unsignedByteAt: byteAddress
+ "Extract a byte from a 64-bit word array (little-endian version)"
+ | lowBits |
+ lowBits := byteAddress - 1 bitAnd: 7.
+ ^((self at: byteAddress - 1 - lowBits // 8 + 1)
+ bitShift: lowBits * -8)
+ bitAnd: 16rFF!

Item was added:
+ ----- Method: DoubleWordArray>>unsignedByteAt:put: (in category '*VMMaker-JITSimulation') -----
+ unsignedByteAt: byteAddress put: byte
+ "Insert a byte into a 64-bit word (little-endian version)"
+ | longWord shift lowBits longAddr |
+ (byte < 0 or: [byte > 255]) ifTrue:[^self errorImproperStore].
+ lowBits := byteAddress - 1 bitAnd: 7.
+ longWord := self at: (longAddr := (byteAddress - 1 - lowBits) // 8 + 1).
+ shift := lowBits * 8.
+ longWord := longWord
+ - (longWord bitAnd: (16rFF bitShift: shift))
+ + (byte bitShift: shift).
+ self at: longAddr put: longWord.
+ ^byte!

Item was added:
+ ----- Method: DoubleWordArray>>unsignedLong64At: (in category '*VMMaker-JITSimulation') -----
+ unsignedLong64At: byteIndex
+ "Compatiblity with the ByteArray & Alien methods of the same name."
+ | wordIndex lowBits high low |
+ wordIndex := byteIndex - 1 // 8 + 1.
+ (lowBits := byteIndex - 1 bitAnd: 7) = 0 ifTrue:
+ [^self at: wordIndex].
+ high := ((self at: wordIndex + 1) bitAnd: (1 bitShift: lowBits * 8) - 1) bitShift: 8 - lowBits * 8.
+ low := (self at: wordIndex) bitShift: lowBits * -8.
+ ^high = 0 ifTrue: [low] ifFalse: [high + low]!

Item was added:
+ ----- Method: DoubleWordArray>>unsignedLong64At:put: (in category '*VMMaker-JITSimulation') -----
+ unsignedLong64At: byteIndex put: aValue
+ "Compatiblity with the ByteArray & Alien methods of the same name."
+ | wordIndex lowBits mask allOnes |
+ wordIndex := byteIndex - 1 // 8 + 1.
+ (lowBits := byteIndex - 1 bitAnd: 7) = 0 ifTrue:
+ [^self at: wordIndex put: aValue].
+ (aValue bitShift: -64) = 0 ifFalse:
+ [self errorImproperStore].
+ mask := (allOnes := 16rFFFFFFFFFFFFFFFF) bitShift: 8 - lowBits * -8.
+ self at: wordIndex put: (((self at: wordIndex) bitAnd: mask) bitXor: ((aValue bitShift: lowBits * 8) bitAnd: allOnes - mask)).
+ self at: wordIndex + 1 put: (((self at: wordIndex + 1) bitAnd: allOnes - mask) bitXor: (allOnes bitAnd: ((aValue bitShift: 8 - lowBits * -8) bitAnd: mask))).
+ ^aValue!

Item was added:
+ ----- Method: DoubleWordArray>>unsignedLongAt: (in category '*VMMaker-JITSimulation') -----
+ unsignedLongAt: byteIndex
+ "Compatiblity with the ByteArray & Alien methods of the same name."
+ | wordIndex lowBits word hiWord |
+ wordIndex := byteIndex - 1 // 8 + 1.
+ lowBits := byteIndex - 1 bitAnd: 7.
+ word := (self at: wordIndex) bitShift: lowBits * -8.
+ lowBits > 4 ifTrue: "access straddles two words"
+ [hiWord := (self at: wordIndex + 1) bitShift: 8 - lowBits * 8.
+ word := word + hiWord].
+ ^word bitAnd: 16rFFFFFFFF!

Item was added:
+ ----- Method: DoubleWordArray>>unsignedLongAt:put: (in category '*VMMaker-JITSimulation') -----
+ unsignedLongAt: byteIndex put: aValue
+ "Compatiblity with the ByteArray & Alien methods of the same name."
+ | wordIndex lowBits word allOnes loMask hiMask |
+ wordIndex := byteIndex - 1 // 8 + 1.
+ lowBits := byteIndex - 1 bitAnd: 7.
+ (aValue bitShift: -32) ~= 0 ifTrue:
+ [self errorImproperStore].
+ lowBits <= 4 ifTrue: "access fits in a single word"
+ [| mask |
+ mask := 16rFFFFFFFF bitShift: lowBits * 8.
+ word := self at: wordIndex.
+ self at: wordIndex put: ((word bitOr: mask) bitXor: (((aValue bitShift: lowBits * 8) bitAnd: mask) bitXor: mask)).
+ ^aValue].
+ "access straddles two words; make lowMask ones where destination is unchanged to avoid overflow"
+ allOnes := 16rFFFFFFFFFFFFFFFF.
+ loMask := allOnes bitShift: 8 - lowBits * -8.
+ hiMask := 16rFFFFFFFF bitShift: 8 - lowBits * -8.
+ word := self at: wordIndex.
+ self at: wordIndex put: ((word bitAnd: loMask) bitOr: ((aValue bitAnd: (16rFFFFFFFF bitShift: (lowBits bitAnd: 3) * -8)) bitShift: lowBits * 8)).
+ word := self at: wordIndex + 1.
+ self at: wordIndex + 1 put: ((word bitOr: hiMask) bitXor: ((((aValue bitShift: 4 - (lowBits bitAnd: 3) * -8)) bitAnd: hiMask) bitXor: hiMask)).
+ ^aValue!

Item was added:
+ ----- Method: DoubleWordArray>>unsignedShortAt: (in category '*VMMaker-JITSimulation') -----
+ unsignedShortAt: byteIndex
+ "Compatiblity with the ByteArray & Alien methods of the same name."
+ | zi word |
+ zi := byteIndex - 1.
+ word := self at: zi // 8 + 1.
+ (zi bitAnd: 1) ~= 0 ifTrue:
+ [self notYetImplemented]. "i.e. odd access implies implementing straddling two words"
+ (zi bitAnd: 7) ~= 0 ifTrue:
+ [word := word bitShift: (zi bitAnd: 7) * -8].
+ ^word bitAnd: 16rFFFF!

Item was added:
+ ----- Method: DoubleWordArray>>unsignedShortAt:put: (in category '*VMMaker-JITSimulation') -----
+ unsignedShortAt: byteAddress put: short
+ "Insert a double byte into a 64-bit word (little-endian version)"
+ | longWord shift lowBits longAddr |
+ (short < 0 or: [short > 65535]) ifTrue:[^self errorImproperStore].
+ lowBits := byteAddress - 1 bitAnd: 7.
+ (lowBits bitAnd: 1) ~= 0 ifTrue:
+ [self notYetImplemented]. "i.e. odd access implies implementing straddling two words"
+ longWord := self at: (longAddr := (byteAddress - 1 - lowBits) // 8 + 1).
+ shift := lowBits * 8.
+ longWord := longWord
+ - (longWord bitAnd: (16rFFFF bitShift: shift))
+ + (short bitShift: shift).
+ self at: longAddr put: longWord.
+ ^short!