Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use faster string primitives #3156

Ducasse opened this Issue Apr 10, 2019 · 2 comments


None yet
1 participant
Copy link

Ducasse commented Apr 10, 2019

Author: sk
Time: 19 April 2018, 12:02:35.661622 pm
UUID: 0c2401e3-1450-4f73-8e81-958f50171595
Ancestors: VMMaker.oscog- nice.2366

** new primitive to compare strings (slang + JIT)
answers negative smi, 0 or positive smi (instead of 1, 2 or 3 in the MiscPlugin)

  • Slang (primitiveCompareWith)
    order is optionnal.
    comparison loop performed in rawCompare: string1 length: strLength1 with: string2 length: strLength2 accessBlock: accessBlock

  • JIT (genPrimitiveStringCompareWith)
    the JIT primitive does not take order as parameter (assumed asciiOrder)
    quick jump if one of the strings is empty


This comment has been minimized.

Copy link
Member Author

Ducasse commented Apr 10, 2019

we should not use anymore

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."

| len1 len2 c1 c2 |
<primitive: 'primitiveCompareString' module: 'MiscPrimitivePlugin'>

<var: #string1 declareC: 'unsigned char *string1'>
<var: #string2 declareC: 'unsigned char *string2'>
<var: #order declareC: 'unsigned char *order'>

len1 := string1 size.
len2 := string2 size.
1 to: (len1 min: len2) do:
	[:i |
	c1 := order at: (string1 basicAt: i) + 1.
	c2 := order at: (string2 basicAt: i) + 1.
	c1 = c2 ifFalse: 
		[c1 < c2 ifTrue: [^ 1] ifFalse: [^ 3]]].
len1 = len2 ifTrue: [^ 2].
len1 < len2 ifTrue: [^ 1] ifFalse: [^ 3].

This comment has been minimized.

Copy link
Member Author

Ducasse commented Apr 10, 2019

Hi Stephane,
If you google 'vm-dev VMMaker.oscog-sk.2367'
and click one of the first hits

you'll see the changes from Sophie:
The new InterpreterPrimitives>>primitiveCompareWith should be linked to primitive 158.
(and only for ByteString comparison).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.