[Vm-dev] VMMaker : Inlining loop with MiscPrimitivesPlugin on Pharo

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue Nov 3 13:06:36 UTC 2009

2009/11/3 David T. Lewis <lewis at mail.msen.com>:
> On Tue, Nov 03, 2009 at 11:46:50AM +0100, arnaud Jean Baptiste wrote:
>> the MiscPrimitivesPlugin loop when generating.
>> the cause is :
>> the primitives: #findSubstring:in:startingAt:matchTable:
>> was change to the primitive that name is now:
>> #findSubstringViaPrimitive:in:startingAt: matchTable:
>> i can simply change the name in #translatedPrimitives
>> (MiscPrimitivePlugin ) method but i am looking for long term solution.
> Good question.
> Pharo is doing this in ByteString:
> findSubstring: key in: body startingAt: start matchTable: matchTable
>        key isWideString ifTrue: [^super findSubstring: key in: body startingAt: start matchTable: matchTable].
>        ^self findSubstringViaPrimitive: key in: body startingAt: start matchTable: matchTable
> I am not familiar with WideString usage, perhaps someone can comment as
> to whether the the #findSubstringViaPrimitive:in:startingAt:matchTable: is
> likely to be adopted in Squeak generally. If yes, then we should probably
> change MiscPrimitivePlugin class>>translatedPrimitives to look for that
> selector if present in the image. Or perhaps the check for WideString
> belongs in the primitive itself?
> Dave

http://bugs.squeak.org/view.php?id=6366 has been solved differently in
trunk and Pharo.
Changes in Pharo are stamped with an anterior date and might come from
another project (Sophie ?).

I think the check for WideString belongs to primitive, and super call
belongs to fallback code.

Concerning super, I note that Pharo version works if and only if this
invariant is true:
Character charCode > 255 ==> (Character leadingChar ~~ 0).

un-carefull synthetic String don't respect it and then fail:
(WideString with: 300 asCharacter with: 400 asCharacter)
        findString: (WideString with: 300 asCharacter) startingAt: 1
caseSensitive: false

If we refactor to have unicode leadingChar = 0, then Pharo version
will have to be changed.


More information about the Vm-dev mailing list