VM Maker: VMMaker.oscog-ul.2387.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-ul.2387.mcz

commits-2
 
Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2387.mcz

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

Name: VMMaker.oscog-ul.2387
Author: ul
Time: 21 May 2018, 1:27:39.444289 am
UUID: 23ca7c0a-07d2-4298-a5fc-f7e91132e5bb
Ancestors: VMMaker.oscog-topa.2386

General:
- added #methodReturnReceiver, another methodReturn* method, that pops argumentCount elements from the stack, leaving only the receiver there

MiscPrimitivePlugin:
- somewhat decreased the overhead of the primitive calls by trying to minimize interpreterProxy function calls
- primitiveFindFirstInString:
        - eliminated the start variable
        - fail with PrimErrBadIndex if the start index argument is invalid (<= 0)
- primitiveFindSubstring
        - fail with PrimErrBadArgument if matchTable is too short
- primitiveIndexOfAsciiInString
        - fail with PrimErrBadIndex if the start index argument is invalid (<= 0)
- primitiveStringHash
        - eliminated the byteArraySize variable
        - moved the masking out of the loop, so it's only evaluated once
- primitiveTranslateStringWithTable
        - fail with PrimErrBadIndex if the start or stop index argument is invalid (<= 0, >= size respectively)
- primitiveConvert8BitSigned
        - added primitive error codes
MiscPrimitivePluginTest:
- the primitive calls return with the error code symbol when they fail
- adjusted existing tests to take that into account
- fixed #testTranslateFromToTable, which used a too short ByteArray
- added a more thorgouht version of #testCompareWithCollated
- #testCompressToByteArray is still failing

=============== Diff against VMMaker.oscog-topa.2386 ===============

Item was added:
+ ----- Method: InterpreterProxy>>methodReturnReceiver (in category 'stack access') -----
+ methodReturnReceiver
+ "Sets the return value for a method"
+ self pop: argumentCount.
+ ^0!

Item was changed:
  ----- Method: MiscPrimitivePlugin>>primitiveCompareString (in category 'primitives') -----
  primitiveCompareString
  "ByteString (class) compare: string1 with: string2 collated: order"
  <export: true>
+ | len1 len2 order string1 string2 orderOop string1Oop string2Oop |
- | len1 len2 order string1 string2 |
 
  <var: 'order' type: #'unsigned char *'>
  <var: 'string1' type: #'unsigned char *'>
  <var: 'string2' type: #'unsigned char *'>
+ orderOop := interpreterProxy stackValue: 0.
+ string2Oop := interpreterProxy stackValue: 1.
+ string1Oop := interpreterProxy stackValue: 2.
+ ((interpreterProxy isBytes: orderOop)
+ and: [(interpreterProxy isBytes: string2Oop)
+ and: [interpreterProxy isBytes: string1Oop]]) ifFalse:
- ((interpreterProxy isBytes: (interpreterProxy stackValue: 0))
- and: [(interpreterProxy isBytes: (interpreterProxy stackValue: 1))
- and: [interpreterProxy isBytes: (interpreterProxy stackValue: 2)]]) ifFalse:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ order := interpreterProxy firstIndexableField: orderOop.
- string1 := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 2).
- string2 := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 1).
- order := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 0).
- len1 := interpreterProxy sizeOfSTArrayFromCPrimitive: string1.
- len2 := interpreterProxy sizeOfSTArrayFromCPrimitive: string2.
  (interpreterProxy sizeOfSTArrayFromCPrimitive: order) < 256 ifTrue:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ string1 := interpreterProxy firstIndexableField: string1Oop.
+ string2 := interpreterProxy firstIndexableField: string2Oop.
+ len1 := interpreterProxy sizeOfSTArrayFromCPrimitive: string1.
+ len2 := interpreterProxy sizeOfSTArrayFromCPrimitive: string2.
  0 to: (len1 min: len2) - 1 do:
  [ :i | | c1 c2 |
  c1 := order at: (string1 at: i).
  c2 := order at: (string2 at: i).
  c1 = c2 ifFalse:
  [^interpreterProxy methodReturnInteger: (c1 < c2 ifTrue: [1] ifFalse: [3])]].
  interpreterProxy methodReturnInteger:
  (len1 = len2 ifTrue: [2] ifFalse: [len1 < len2 ifTrue: [1] ifFalse: [3]])!

Item was changed:
  ----- Method: MiscPrimitivePlugin>>primitiveConvert8BitSigned (in category 'primitives') -----
  primitiveConvert8BitSigned
  "SampledSound (class) convert8bitSignedFrom: aByteArray to16Bit: aSoundBuffer"
  <export: true>
+ | aByteArray aSoundBuffer arraySize byteArrayOop soundBufferOop |
+
- | aByteArray aSoundBuffer arraySize |
  <var: 'aByteArray' type: #'unsigned char *'>
  <var: 'aSoundBuffer' type: #'unsigned short *'>
+ byteArrayOop := interpreterProxy stackValue: 1.
+ (interpreterProxy isBytes: byteArrayOop) ifFalse:
- (interpreterProxy isBytes: (interpreterProxy stackValue: 1)) ifFalse:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ aByteArray := interpreterProxy firstIndexableField: byteArrayOop.
+ soundBufferOop := interpreterProxy stackValue: 0.
- aByteArray := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 1).
  aSoundBuffer := self
+ cCode: [interpreterProxy arrayValueOf: soundBufferOop]
- cCode: [interpreterProxy arrayValueOf: (interpreterProxy stackValue: 0)]
  inSmalltalk: [interpreterProxy
+ cCoerce: (interpreterProxy arrayValueOf: soundBufferOop)
- cCoerce: (interpreterProxy arrayValueOf: (interpreterProxy stackValue: 0))
  to: #'unsigned short *'].
+ interpreterProxy failed ifTrue: [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ (interpreterProxy isOopImmutable: soundBufferOop) ifTrue:
- interpreterProxy failed ifTrue: [^nil].
- (interpreterProxy isOopImmutable: (interpreterProxy stackValue: 0)) ifTrue:
  [^interpreterProxy primitiveFailFor: PrimErrNoModification].
  arraySize := interpreterProxy sizeOfSTArrayFromCPrimitive: aByteArray.
+ (interpreterProxy byteSizeOf: soundBufferOop) < (2 * arraySize) ifTrue:
- (interpreterProxy byteSizeOf: (interpreterProxy stackValue: 0)) < (2 * arraySize) ifTrue:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
  0 to: arraySize - 1 do:
  [ :i | | s |
  s := aByteArray at: i.
  aSoundBuffer
  at: i
  put: (s > 127
  ifTrue: [s - 256 bitShift: 8]
  ifFalse: [s bitShift: 8])].
+ interpreterProxy methodReturnReceiver!
- interpreterProxy pop: interpreterProxy methodArgumentCount!

Item was changed:
  ----- Method: MiscPrimitivePlugin>>primitiveFindFirstInString (in category 'primitives') -----
  primitiveFindFirstInString
  "ByteString (class) findFirstInString: aString inSet: inclusionMap  startingAt: start"
  <export: true>
+
+ |  aString i inclusionMap stringSize aStringOop inclusionMapOop |
- |  aString i inclusionMap start stringSize |
  <var: 'aString' type: #'unsigned char *'>
+ <var: 'inclusionMap' type: #'unsigned char *'>
+ aStringOop := interpreterProxy stackValue: 2.
+ (interpreterProxy isBytes: aStringOop) ifFalse:
- <var: 'inclusionMap' type: #'char *'>
- ((interpreterProxy isIntegerObject: (interpreterProxy stackValue: 0))
- and: [(interpreterProxy isBytes: (interpreterProxy stackValue: 1))
- and: [interpreterProxy isBytes: (interpreterProxy stackValue: 2)]]) ifFalse:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ inclusionMapOop :=  interpreterProxy stackValue: 1.
+ (interpreterProxy isBytes: inclusionMapOop) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ i := interpreterProxy stackIntegerValue: 0.
+ interpreterProxy failed ifTrue: [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ i := i - 1. "Convert to 0-based index."
+ i < 0 ifTrue: [^interpreterProxy primitiveFailFor: PrimErrBadIndex].
+ inclusionMap := interpreterProxy firstIndexableField: inclusionMapOop.
- aString := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 2).
- inclusionMap := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 1).
- start := interpreterProxy integerValueOf: (interpreterProxy stackValue: 0).
  (interpreterProxy sizeOfSTArrayFromCPrimitive: inclusionMap) ~= 256 ifTrue:
  [^interpreterProxy methodReturnInteger: 0].
+ aString := interpreterProxy firstIndexableField: aStringOop.
- i := start - 1.
  stringSize := interpreterProxy sizeOfSTArrayFromCPrimitive: aString.
  [i < stringSize and: [(inclusionMap at: (aString at: i)) = 0]] whileTrue:
  [i := i + 1].
  interpreterProxy methodReturnInteger: (i >= stringSize ifTrue: [0] ifFalse: [i + 1])!

Item was changed:
  ----- Method: MiscPrimitivePlugin>>primitiveFindSubstring (in category 'primitives') -----
  primitiveFindSubstring
  "ByteString findSubstring: key in: body startingAt: start matchTable: matchTable"
  <export: true>
+
+ | body key keySize matchTable start bodyOop keyOop matchTableOop |
- | body key keySize matchTable start |
  <var: #key type: #'unsigned char *'>
  <var: #body type: #'unsigned char *'>
  <var: #matchTable type: #'unsigned char *'>
+ keyOop := interpreterProxy stackValue: 3.
+ (interpreterProxy isBytes: keyOop) ifFalse:
- ((interpreterProxy isBytes: (interpreterProxy stackValue: 0))
- and: [(interpreterProxy isIntegerObject: (interpreterProxy stackValue: 1))
- and: [(interpreterProxy isBytes: (interpreterProxy stackValue: 2))
- and: [interpreterProxy isBytes: (interpreterProxy stackValue: 3)]]]) ifFalse:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ bodyOop := interpreterProxy stackValue: 2.
+ (interpreterProxy isBytes: bodyOop) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ start := interpreterProxy stackIntegerValue: 1.
+ interpreterProxy failed ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ matchTableOop := interpreterProxy stackValue: 0.
+ (interpreterProxy isBytes: matchTableOop) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ matchTable := interpreterProxy firstIndexableField: matchTableOop.
+ (interpreterProxy sizeOfSTArrayFromCPrimitive: matchTable) < 256 ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ key := interpreterProxy firstIndexableField: keyOop.
- key := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 3).
- body := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 2).
- start := interpreterProxy integerValueOf: (interpreterProxy stackValue: 1).
- matchTable := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 0).
  (keySize := interpreterProxy sizeOfSTArrayFromCPrimitive: key) > 0 ifTrue:
+ [keySize := keySize - 1. "adjust for zero relative indexes"
+ start := start - 1 max: 0. "adjust for zero relative indexes"
+ body := interpreterProxy firstIndexableField: bodyOop.
+ start to: (interpreterProxy sizeOfSTArrayFromCPrimitive: body) - 1 - keySize do:
- [keySize := keySize - 1. "adjust for zero relative indxes"
- (start max: 1) to: (interpreterProxy sizeOfSTArrayFromCPrimitive: body) - keySize do:
  [ :startIndex | | index |
  index := 0.
+ [(matchTable at: (body at: startIndex + index)) = (matchTable at: (key at: index))] whileTrue:
- [(matchTable at: (body at: startIndex + index - 1)) = (matchTable at: (key at: index))] whileTrue:
  [index = keySize ifTrue:
+ [^interpreterProxy methodReturnInteger: startIndex + 1].
- [^interpreterProxy methodReturnInteger: startIndex].
  index := index + 1]]].
  ^interpreterProxy methodReturnInteger: 0!

Item was changed:
  ----- Method: MiscPrimitivePlugin>>primitiveIndexOfAsciiInString (in category 'primitives') -----
  primitiveIndexOfAsciiInString
  "ByteString indexOfAscii: anInteger inString: aString startingAt: start"
  <export: true>
+
+ | anInteger aString start stringSize aStringOop |
- | anInteger aString start stringSize |
  <var: #aString type: #'unsigned char *'>
+ anInteger := interpreterProxy stackIntegerValue: 2.
+ interpreterProxy failed ifTrue:
- ((interpreterProxy isIntegerObject: (interpreterProxy stackValue: 0))
- and: [(start := interpreterProxy integerValueOf: (interpreterProxy stackValue: 0)) >= 1
- and: [(interpreterProxy isBytes: (interpreterProxy stackValue: 1))
- and: [(interpreterProxy isIntegerObject: (interpreterProxy stackValue: 2))]]]) ifFalse:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ aStringOop := interpreterProxy stackValue: 1.
+ (interpreterProxy isBytes: aStringOop) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ start := interpreterProxy stackIntegerValue: 0.
+ interpreterProxy failed ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ start >= 1 ifFalse: [^interpreterProxy primitiveFailFor: PrimErrBadIndex].
+ aString := interpreterProxy firstIndexableField: aStringOop.
- anInteger := interpreterProxy integerValueOf: (interpreterProxy stackValue: 2).
- aString := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 1).
  stringSize := interpreterProxy sizeOfSTArrayFromCPrimitive: aString.
  start - 1 to: stringSize - 1 do:
  [ :pos |
  (aString at: pos) = anInteger ifTrue:
  [^interpreterProxy methodReturnInteger: pos + 1]].
  ^interpreterProxy methodReturnInteger: 0!

Item was changed:
  ----- Method: MiscPrimitivePlugin>>primitiveStringHash (in category 'primitives') -----
  primitiveStringHash
  "ByteArray (class) hashBytes: aByteArray startingWith: speciesHash"
  <export: true>
+
+ | aByteArray hash byteArrayOop |
- | aByteArray speciesHash byteArraySize hash |
  <var: 'aByteArray' type: #'unsigned char *'>
+ <var: 'hash' type: #'unsigned int'>
+ hash := interpreterProxy stackIntegerValue: 0.
+ interpreterProxy failed ifFalse:
- <var: 'speciesHash' type: #int>
- ((interpreterProxy isIntegerObject: (interpreterProxy stackValue: 0))
- and: [interpreterProxy isBytes: (interpreterProxy stackValue: 1)]) ifFalse:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ byteArrayOop := interpreterProxy stackValue: 1.
+ (interpreterProxy isBytes: byteArrayOop) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ aByteArray := interpreterProxy firstIndexableField: byteArrayOop.
+ 0 to: (interpreterProxy sizeOfSTArrayFromCPrimitive: aByteArray) - 1 do:
- aByteArray := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 1).
- speciesHash := interpreterProxy integerValueOf: (interpreterProxy stackValue: 0).
- byteArraySize := interpreterProxy sizeOfSTArrayFromCPrimitive: aByteArray.
- hash := speciesHash bitAnd: 16r0FFFFFFF.
- 0 to: byteArraySize - 1 do:
  [ :pos |
+ hash := hash + (aByteArray at: pos) * 16r19660D ].
+ interpreterProxy methodReturnInteger: (hash bitAnd: 16r0FFFFFFF)!
- hash := hash + (aByteArray at: pos).
- hash := hash * 16r19660D bitAnd: 16r0FFFFFFF].
- interpreterProxy methodReturnInteger: hash!

Item was changed:
  ----- Method: MiscPrimitivePlugin>>primitiveTranslateStringWithTable (in category 'primitives') -----
  primitiveTranslateStringWithTable
  "ByteString (class) translate: aString from: start to: stop table: table"
  <export: true>
+
+ | aString start stop table aStringOop tableOop |
- | aString start stop table |
  <var: #table type: #'unsigned char *'>
  <var: #aString type: #'unsigned char *'>
+ aStringOop := interpreterProxy stackValue: 3.
+ (interpreterProxy isBytes: aStringOop) ifFalse:
- ((interpreterProxy isBytes: (interpreterProxy stackValue: 0))
- and: [(interpreterProxy isIntegerObject: (interpreterProxy stackValue: 1))
- and: [(interpreterProxy isIntegerObject: (interpreterProxy stackValue: 2))
- and: [interpreterProxy isBytes: (interpreterProxy stackValue: 3)]]]) ifFalse:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ (interpreterProxy isOopImmutable: aStringOop) ifTrue:
- (interpreterProxy isOopImmutable: (interpreterProxy stackValue: 3)) ifTrue:
  [^interpreterProxy primitiveFailFor: PrimErrNoModification].
+ start := interpreterProxy stackIntegerValue: 2.
+ interpreterProxy failed ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ stop := interpreterProxy stackIntegerValue: 1.
+ interpreterProxy failed ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ tableOop := interpreterProxy stackValue: 0.
+ (interpreterProxy isBytes: tableOop) ifFalse:
+ [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ aString := interpreterProxy firstIndexableField: aStringOop.
- aString := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 3).
- start := interpreterProxy integerValueOf: (interpreterProxy stackValue: 2).
- stop := interpreterProxy integerValueOf: (interpreterProxy stackValue: 1).
- table := interpreterProxy firstIndexableField: (interpreterProxy stackValue: 0).
  (start >= 1 and: [stop <= (interpreterProxy sizeOfSTArrayFromCPrimitive: aString)]) ifFalse:
  [^interpreterProxy primitiveFailFor: PrimErrBadIndex].
+ table := interpreterProxy firstIndexableField: tableOop.
  (interpreterProxy sizeOfSTArrayFromCPrimitive: table) < 256 ifTrue:
  [^interpreterProxy primitiveFailFor: PrimErrBadArgument].
  start - 1 to: stop - 1 do: [ :i | aString at: i put: (table at: (aString at: i))].
+ interpreterProxy methodReturnReceiver!
- interpreterProxy pop: interpreterProxy methodArgumentCount!

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>compare:with:collated: (in category 'primitives') -----
  compare: string1 with: string2 collated: order
  "Return 1, 2 or 3, if string1 is <, =, or > string2, with the collating order of characters given by the order array."
 
+ <primitive: 'primitiveCompareString' module: 'MiscPrimitivePlugin'  error: ec>
+ ^ec!
- <primitive: 'primitiveCompareString' module: 'MiscPrimitivePlugin'>
- self primitiveFailed
- !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>compress:toByteArray: (in category 'primitives') -----
  compress: bm toByteArray: ba
 
+ <primitive: 'primitiveCompressToByteArray' module: 'MiscPrimitivePlugin' error: ec>
+ ^ec!
- <primitive: 'primitiveCompressToByteArray' module: 'MiscPrimitivePlugin'>
- self primitiveFailed!

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>convert8bitSignedFrom:to16Bit: (in category 'primitives') -----
  convert8bitSignedFrom: aByteArray to16Bit: aSoundBuffer
  "Copy the contents of the given array of signed 8-bit samples into the given array of 16-bit signed samples."
 
+ <primitive: 'primitiveConvert8BitSigned' module: 'MiscPrimitivePlugin' error: ec>
+ ^ec!
- <primitive: 'primitiveConvert8BitSigned' module: 'MiscPrimitivePlugin'>
- self primitiveFailed
- !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>decompress:fromByteArray:at: (in category 'primitives') -----
  decompress: bm fromByteArray: ba at: index
 
+ <primitive: 'primitiveDecompressFromByteArray' module: 'MiscPrimitivePlugin' error: ec>
+ ^ec!
- <primitive: 'primitiveDecompressFromByteArray' module: 'MiscPrimitivePlugin'>
- self primitiveFailed
- !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>findFirstInString:inSet:startingAt: (in category 'primitives') -----
  findFirstInString: aString  inSet: inclusionMap  startingAt: start
 
+ <primitive: 'primitiveFindFirstInString' module: 'MiscPrimitivePlugin'  error: ec>
+ ^ec!
- <primitive: 'primitiveFindFirstInString' module: 'MiscPrimitivePlugin'>
- self primitiveFailed
- !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>findSubstring:in:startingAt:matchTable: (in category 'primitives') -----
  findSubstring: key in: body startingAt: start matchTable: matchTable
  "Answer the index in the string body at which the substring key first occurs, at or beyond start.  The match is determined using matchTable, which can be used to effect, eg, case-insensitive matches.  If no match is found, zero will be returned."
 
+ <primitive: 'primitiveFindSubstring' module: 'MiscPrimitivePlugin' error: ec>
+ ^ec!
- <primitive: 'primitiveFindSubstring' module: 'MiscPrimitivePlugin'>
- self primitiveFailed
- !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>hashBytes:startingWith: (in category 'primitives') -----
  hashBytes: aByteArray startingWith: speciesHash
  "Answer the hash of a byte-indexed collection,
  using speciesHash as the initial value.
  See SmallInteger>>hashMultiply.
 
  The primitive should be renamed at a
  suitable point in the future"
 
+ <primitive: 'primitiveStringHash' module: 'MiscPrimitivePlugin' error: ec>
+ ^ec!
- <primitive: 'primitiveStringHash' module: 'MiscPrimitivePlugin'>
- self primitiveFailed
- !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>indexOfAscii:inString:startingAt: (in category 'primitives') -----
  indexOfAscii: anInteger inString: aString startingAt: start
 
+ <primitive: 'primitiveIndexOfAsciiInString' module: 'MiscPrimitivePlugin' error: ec>
+ ^ec!
- <primitive: 'primitiveIndexOfAsciiInString' module: 'MiscPrimitivePlugin'>
- self primitiveFailed
- !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>testCompareWithCollated (in category 'testing') -----
  testCompareWithCollated
- "Verify that primitive exists in the VM"
 
+ | collation |
+ collation := (0 to: 255) asByteArray.
+ self
+ assert: #'bad argument'
+ equals: (self compare: nil with: '' collated: collation)
+ description: 'First argument must be a bytes object';
+ assert: #'bad argument'
+ equals: (self compare: '' with: nil collated: collation)
+ description: 'Second argument must be a bytes object';
+ assert: #'bad argument'
+ equals: (self compare: '' with: '' collated: nil)
+ description: 'Third argument must be a bytes object';
+ assert: #'bad argument'
+ equals: (self compare: '' with: '' collated: collation allButLast)
+ description: 'Size of third argument must be at least 256'.
+ self
+ assert: 1 equals: (self compare: '' with: 'foo' collated: collation);
+ assert: 1 equals: (self compare: 'bar' with: 'foo' collated: collation);
+ assert: 1 equals: (self compare: 'bar' with: 'bare' collated: collation);
+ assert: 2 equals: (self compare: '' with: '' collated: collation);
+ assert: 2 equals: (self compare: 'bar' with: 'bar' collated: collation);
+ assert: 2 equals: (self compare: 'bar' with: 'bar' copy collated: collation);
+ assert: 3 equals: (self compare: 'foo' with: '' collated: collation);
+ assert: 3 equals: (self compare: 'foo' with: 'bar' collated: collation);
+ assert: 3 equals: (self compare: 'bare' with: 'bar' collated: collation).
+ collation
+ at: $b asInteger + 1 put: $f asInteger;
+ at: $a asInteger + 1 put: $o asInteger;
+ at: $r asInteger + 1 put: $o asInteger.
+ self
+ assert: 2 equals: (self compare: 'bar' with: 'foo' collated: collation);
+ assert: 2 equals: (self compare: 'foo' with: 'bar' collated: collation)!
- self assert: 3 = (self compare: 'foo' with: 'bar' collated: ((0 to: 255) as: ByteArray))
- !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>testFindSubstringInByteString (in category 'testing') -----
  testFindSubstringInByteString
  "Verify that primitive exists in the VM and works as expected for byte
  sized string and key. If key is a WideString, as may be the case if testing
  for a WideString as substring of a byte sized string, then the primitive
  should fail. Earlier version of the primitive would accept the non-bytes
  parameter, leading to incorrect results, as documented in
  testFindSubstringOldVersionWithMissingTypeChecks"
 
+ self
+ assert: 2
+ equals: (self
+ findSubstring: 'bc'
+ in: 'abcdef'
+ startingAt: 1
+ matchTable: (0 to: 255) asByteArray).
+ self
+ assert: #'bad argument'
+ equals: (self
+ findSubstring: 'bc' asWideString
+ in: 'abcdef'
+ startingAt: 1
+ matchTable: (0 to: 255) asByteArray)
- | position |
- position := MiscPrimitivePluginTest new
- findSubstring: 'bc'
- in: 'abcdef'
- startingAt: 1
- matchTable: ((0 to: 255)
- as: ByteArray).
- self assert: position = 2.
- self should: [MiscPrimitivePluginTest new
- findSubstring: 'bc' asWideString
- in: 'abcdef'
- startingAt: 1
- matchTable: ((0 to: 255)
- as: ByteArray)]
- raise: Error
-
  !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>testTranslateFromToTable (in category 'testing') -----
  testTranslateFromToTable
  "Verify that primitive exists in the VM"
 
  | s t |
  s := 'foo' copy. "copy so string is instantiated each time"
+ t := (0 to: 255) asByteArray replace: [ :each | each + 1 \\ 256 ].
+ self assert: self equals: (self translate: s from: 1 to: 3 table: t).
- t := ByteArray withAll: ((1 to: 255) as: ByteArray).
- self translate: s from: 1 to: 3 table: t.
  self assert: s = 'gpp'
  !

Item was changed:
  ----- Method: MiscPrimitivePluginTest>>translate:from:to:table: (in category 'primitives') -----
  translate: aString from: start  to: stop  table: table
  "translate the characters in the string by the given table, in place"
 
+ <primitive: 'primitiveTranslateStringWithTable' module: 'MiscPrimitivePlugin' error: ec>
+ ^ec!
- <primitive: 'primitiveTranslateStringWithTable' module: 'MiscPrimitivePlugin'>
- self primitiveFailed!

Item was added:
+ ----- Method: NewCoObjectMemorySimulator>>methodReturnReceiver (in category 'simulation only') -----
+ methodReturnReceiver
+ "hack around the CoInterpreter/ObjectMemory split refactoring"
+ ^coInterpreter methodReturnReceiver!

Item was added:
+ ----- Method: NewObjectMemorySimulator>>methodReturnReceiver (in category 'simulation only') -----
+ methodReturnReceiver
+ "hack around the CoInterpreter/ObjectMemory split refactoring"
+ ^coInterpreter methodReturnReceiver!

Item was added:
+ ----- Method: SpurMemoryManager>>methodReturnReceiver (in category 'simulation only') -----
+ methodReturnReceiver
+ "hack around the CoInterpreter/ObjectMemory split refactoring"
+ <doNotGenerate>
+ ^coInterpreter methodReturnReceiver!

Item was added:
+ ----- Method: StackInterpreter>>methodReturnReceiver (in category 'plugin primitive support') -----
+ methodReturnReceiver
+ "Sets the return value for a method"
+ self pop: argumentCount.
+ ^0!