Hi I recall that clement told me that returning 1,2 or 3 instead of negative, zero, positive was slow. And I wonder if the primitive got change to the logic clement proposed? Could we not introduce another primitive and use it from the image? 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]. -------------------------------------------- Stéphane Ducasse 03 59 35 87 52 Assistant: Julie Jonas FAX 03 59 57 78 50 TEL 03 59 35 86 16 S. Ducasse - Inria 40, avenue Halley, Parc Scientifique de la Haute Borne, Bât.A, Park Plaza Villeneuve d'Ascq 59650 France |
On Wed, Apr 10, 2019 at 10:42 AM Stéphane Ducasse
<[hidden email]> wrote: > > Hi > > I recall that clement told me that returning 1,2 or 3 instead of negative, zero, positive was slow. > And I wonder if the primitive got change to the logic clement proposed? > > Could we not introduce another primitive and use it from the image? Hi, I think Sophie already did most of the work to introduce a new primitive. The missing steps to use the new optimized way to compare strings are: - Add the primitive to the primitive table VM side for Pharo/Squeak and Newspeak - Use the new primitive in the image and call this one for string comparison With this new primitive performances on string comparison can be improved around x2.5 to x5 times faster. > > 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]. > > -------------------------------------------- > Stéphane Ducasse > http://stephane.ducasse.free.fr > http://www.synectique.eu / http://www.pharo.org > 03 59 35 87 52 > Assistant: Julie Jonas > FAX 03 59 57 78 50 > TEL 03 59 35 86 16 > S. Ducasse - Inria > 40, avenue Halley, > Parc Scientifique de la Haute Borne, Bât.A, Park Plaza > Villeneuve d'Ascq 59650 > France > -- Cyril Ferlicot https://ferlicot.fr |
If you know that it is done from the VM side let us know.
|
VMMaker.oscog-sk.2367 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 Le mer. 10 avr. 2019 à 11:56, ducasse <[hidden email]> a écrit :
|
Thanks nicolas so we can use them then.
|
Nicolas
I tried to find the new primitive and I did not find it here I found the old one. Did I look in the wrong place? Stef
|
On Wed, Apr 10, 2019 at 1:52 PM ducasse <[hidden email]> wrote:
> > Nicolas > > I tried to find the new primitive and I did not find it here > > https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/src/plugins/MiscPrimitivePlugin/MiscPrimitivePlugin.c > > I found the old one. > Did I look in the wrong place? > If I am not wrong it is directly in Slang and will be a numbered primitive. The primitive was added in the commit Nicolas quoted but I'm not sure the registration of the primitive in the primitive table was done. > Stef > > > -- Cyril Ferlicot https://ferlicot.fr |
In reply to this post by ducasse
Hi Stephane, If you google 'vm-dev
VMMaker.oscog-sk.2367'
and click one of the first hits https://marc.info/?l=squeak-vm-dev&m=152413936110744&w=2 you'll see the changes from Sophie: The new InterpreterPrimitives>>primitiveCompareWith should be linked to primitive 158. (and only for ByteString comparison). I did not try it, I have not much time to invest at the moment. Le mer. 10 avr. 2019 à 13:52, ducasse <[hidden email]> a écrit :
|
In reply to this post by CyrilFerlicot
> On 10 Apr 2019, at 14:01, Cyril Ferlicot <[hidden email]> wrote: > > On Wed, Apr 10, 2019 at 1:52 PM ducasse <[hidden email]> wrote: >> >> Nicolas >> >> I tried to find the new primitive and I did not find it here >> >> https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/src/plugins/MiscPrimitivePlugin/MiscPrimitivePlugin.c >> >> I found the old one. >> Did I look in the wrong place? >> > > If I am not wrong it is directly in Slang and will be a numbered primitive. I do not know :) Now the old one is there so…. I thought that the new one should be around. > The primitive was added in the commit Nicolas quoted but I'm not sure > the registration of the primitive in the primitive table was done. > >> Stef >> >> >> > > > -- > Cyril Ferlicot > https://ferlicot.fr > |
In reply to this post by Nicolas Cellier
Thanks I did not know it was on a mailing-list.
|
HI, We actually talked about this very primitive with Cyril not that long ago. I'll have a look at it with him this week so it can be used ! Sophie Le mer. 10 avr. 2019 à 14:10, ducasse <[hidden email]> a écrit :
|
tx!
|
Free forum by Nabble | Edit this page |