[Vm-dev] [NB] NativeBoost meets JIT

Igor Stasenko siguctua at gmail.com
Sun Sep 23 02:09:05 UTC 2012

Hello there..
So, with little change (see attached) , i made it work.

I simply put the check if method is cogged in #executeNewMethod
_before_ call to potential primitive,
and if so, it simply jumps to method's entry point.
So, then method can run primitive/activate itself by own.

If you followed me so far, with this change , the method:

	<primitive: 220 error: errorCode>
	^ {errorCode. thisContext xray }

if it doesn't contains native code in trailer, the:

(1 to: 4) collect: [: i | MyClass foo ]

always gives me:

 #(#(502 11) #(502 11) #(502 11) #(502 11))

where 502 is NB-specific error ErrNoNativeCodeInMethod "failed to find
a native code for primitive method",
and 11 means that method runs interpreted, again correct because
when cog tries to jit that method, it will always fail because prim
220 generator fails code generation if there's no native code in
method's trailer , and so VM forced to run this method interpreted.

Now, if i do this:

	| asm |
	asm := AJx86Assembler new noStackFrame.

		mov: (99 << 1) + 1 to: asm EDX;
		ret: 4 asUImm.

	NBNativeCodeGen installNativeCode:  asm bytes into: (MyClass class>>#foo).
"	(MyClass class>>#foo) forceJIT "

(1 to: 4) collect: [: i | MyClass foo ]
gives me:

#(#(505 11) 99 99 99)

and finally, if i uncomment #forceJIT send, it gives me:

#(99 99 99 99)

and no #(505 31) combination anymore! :)

And, even more. Now if i simply doit:

MyClass foo

it also answers 99!

Eliot, do you think it worth putting this change into common codebase
(because right now i keep it in NBCoInterpreter subclass)?

I do not expect a big changes in performance, and i cannot even tell
will it make things slower/faster,
but you might know better.

Best regards,
Igor Stasenko.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NBCoInterpreter-executeCoggedNewMethodmethodHeader.st
Type: application/octet-stream
Size: 1393 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20120923/15dc9f53/NBCoInterpreter-executeCoggedNewMethodmethodHeader.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NBCoInterpreter-executeNewMethod.st
Type: application/octet-stream
Size: 2097 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20120923/15dc9f53/NBCoInterpreter-executeNewMethod.obj

More information about the Vm-dev mailing list