On 29.04.2010 17:13, Igor Stasenko wrote:
Core packages were broken, and were unable to load w/o errors.
But now seems everything loads well.
Use NBInstaller install.

Thanks to Henrik for help!
Here's a small example, as well as profile:

SmallInteger >> nbFib
<primitive: 'primitiveNativeCall' module: 'NativeBoostPlugin'>
    ^ NBNativeCodeGen methodAssembly: [:gen |
        | loopStart proxy asm  EAX EBX ECX |
        asm := gen asm.
        proxy := NBInterpreterProxy new asm: asm.
        loopStart := asm uniqueLabelName: 'loopStart'.

        EAX := asm assembler reg0.
        EBX := asm assembler reg3.
        ECX := asm assembler reg1.
        proxy receiver.
        proxy integerValueOf: EAX.

        asm mov: EAX to: ECX;
                mov: 0 to: EAX;
                mov: 1 to: EBX;
                label: loopStart;
                add: EAX with: EBX;
                xchg: EAX with: EBX;
"next three could be replaced by loopnz and a dec ECX before loop, but loopnz isn't there yet"
                dec: ECX;
                cmp: ECX with: 1;
                jg: loopStart.

        proxy positive32BitIntegerFor: EBX.
        gen epilogue]

SmallInteger >>fib
    |tmp res|
    tmp := 1.
    res := 0.
    0 to: self -1 do: [:ix | |oldRes|
            oldRes := res.
            res := tmp + res.
            tmp := oldRes.].
    ^res

Neither work for negative integers, and nbFib overflows for 48, haven't added largeInt creation logic :)

[1 to: 100000 do: [:ix | 47 fib]] timeToRun 361
[1 to: 100000 do: [:ix | 47 nbFib]] timeToRun 21
[1 to: 100000 do: [:ix | ]] timeToRun 2

Cheers,
Henry




_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to