On 28 April 2010 10:24, Adrian Lienhard <adi@netstyle.ch> wrote:
Igor, I was wondering whether you or somebody else have a real example where NativeBoost boosts performance. For instance in an often used library class...
It depends. I provided comparisons before. But if you have any real-world example in mind, i will happily implement it and give you the numbers. Apparently there is nothing else, which can run faster than native code. I'm giving you control to implement own primitives using native code. As for FFI interface you will have a full control on how to coerce types between C and Smalltalk worlds and so, it will run as fast as you made it. :) For example, here the FFI plugin code which coercing a smalltalk object to integer value for pushing it on stack: ffiIntegerValueOf: oop "Support for generic callout. Return an integer value that is coerced as C would do." | oopClass | self inline: true. (interpreterProxy isIntegerObject: oop) ifTrue:[^interpreterProxy integerValueOf: oop]. oop == interpreterProxy nilObject ifTrue:[^0]. "@@: should we really allow this????" oop == interpreterProxy falseObject ifTrue:[^0]. oop == interpreterProxy trueObject ifTrue:[^1]. oopClass := interpreterProxy fetchClassOf: oop. oopClass == interpreterProxy classFloat ifTrue:[^(interpreterProxy floatValueOf: oop) asInteger]. oopClass == interpreterProxy classCharacter ifTrue:[^interpreterProxy fetchInteger: 0 ofObject: oop]. oopClass == interpreterProxy classLargePositiveInteger ifTrue:[^interpreterProxy positive32BitValueOf: oop]. ^interpreterProxy signed32BitValueOf: oop "<- will fail if not integer". See , how generic it is? It tries to accept every possible combination which could be translated to native integer value. Now, suppose, that you know _exactly_ that your function will be called only with smallintegers as arguments, and want to fail primitive if it get called with wrong argument. This is what you can do with NativeBoost, but you can't with FFI, because it is C code, compiled and made in stone.
Cheers, Adrian
-- Best regards, Igor Stasenko AKA sig.