[squeak-dev] [NativeBoost] New update available

Igor Stasenko siguctua at gmail.com
Fri May 14 04:03:42 UTC 2010


Hello all,

i just published a heavily updated version of NativeBoost project.
See http://code.google.com/p/nativeboost/wiki/Installation
Also, a newer prebuilt win32 vm is available for download.

Here the list of changes:

VM side.

- plugin no longer requires platform specific support code. All
platform specific stuff is now [can be] implemented at language side.
- added a small extension to Interpreter
(#swapActiveContext:restoreMethod:) for callbacks support

Language side.

- NBUtils renamed to NativeBoost class and now will serve as a core
API class, which is a starting place of most basic NativeBoost
functionality
- added a lazy and seamless image restart handling. None of
NativeBoost code contributing to image startup phase. It starting up
lazily and automatically,
 upon first access to its functionality.

- added an external native function generator, to support generating a
code and placing it into non-movable external memory region
- various tests, bells & whistles.

And last , but not least

- added initial callback support

There are two kinds of callbacks supported: native and language-side.
With native callbacks , there is nothing fancy: generate native code
and copy it to external memory. Then pass its address to any function
which takes callback as argument. Period.

A language-side callbacks required much more implementation effort to
function properly, but easy to use by developers.
You just need to subclass the NBFFICallback class,
and override two methods at class side in your subclass:

fnSpec & 	callType

a #fnSpec should answer a callback function specification , like:
  #(int ( int a, int b))

and callType should answer either #cdecl or #stdcall, which tells what
calling convention your function should use.


To create a callback , just do:

callback := MyCallback on: [:arg1 :arg2 | ... do something here .. ].

and then simply pass it to any FFI callout method which takes it as argument:

self foo: x bar: y callback: callback

where #foo:bar:callback: defined as FFI callout as followin:

foo: aFoo bar: cylinder callback: fn

<primitive: #primitiveNativeCall module: #NativeBoostPlugin>
	
^ NBFFICallout cdecl: #(void qsort (int aFoo, ulong cylinder,
MyCallback fn)) module: 'myModule'

note the name of class 'MyCallback' , supplied as argument type.


This stuff is not tested throughoutly, so take care.
I am used only a single function for testing callbacks - a qsort(),
provided by C run-time library.


The difference between natively-implemented callbacks and
language-side ones is paramount (but that was expected, isnt? :)

NBFFICallbackTests new benchQSort
#(2689 184 21322)

2689   - array sort using purely smalltalk
184     - array sort with native callback
21322 - array sort with callback to a language side.


Any comments and questions are wellcome.

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list