[squeak-dev] FFI: FFI-Callbacks-mt.29.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Apr 15 08:28:45 UTC 2022


Marcel Taeumel uploaded a new version of FFI-Callbacks to project FFI:
http://source.squeak.org/FFI/FFI-Callbacks-mt.29.mcz

==================== Summary ====================

Name: FFI-Callbacks-mt.29
Author: mt
Time: 15 April 2022, 10:28:45.41376 am
UUID: 7d01860b-f019-334e-baaa-ddac9e6267e7
Ancestors: FFI-Callbacks-mt.28

Fixes thunk init on ARM64.

=============== Diff against FFI-Callbacks-mt.28 ===============

Item was changed:
  ----- Method: FFICallback>>init__ccall_ARM64 (in category 'private') -----
  init__ccall_ARM64
  	<abi: #ARM64> <init_ccall>
  	"Initialize the receiver with a __ccall thunk.  The thunk calls thunkEntry in the Alien/IA32ABI plugin,
  	 whose source is in platforms/Cross/plugins/IA32ABI/arm64abicc.c.  thunkEntry is the entry point
  	 for Callbacks. The objective of the thunk is to call thunkEntry with all arguments to the call of the
  	 thunk (registers and stack) as well as a pointer to the thunk itself.  thunkEntry is as follows:
  	
  		long long
  		thunkEntry(long x0, long x1, long x2, long x3,
  				       long x4, long x5, long x6, long x7,
  				       double d0, double d1, double d2, double d3,
  				       double d4, double d5, double d6, double d7,
+ 				       void *thunkpPlus20, sqIntptr_t *stackp)
- 				       void *thunkpPlus16, sqIntptr_t *stackp)
  
  	thunkEntry then collects the various arguments (thunk, integer register arguments, floating-point
  	register arguments, stack pointer) in a VMCallbackContext and invokes the callback via invokeCallbackContext:."
  
  	| bytes |
  	bytes := #["0		mov	x16, sp"			16rF0 16r03 16r00 16r91
  				"4		sub	sp, sp, #0x20"			16rFF 16r83 16r00 16rD1
  				"8		stp	x16, x30, [sp, #0x8]"	16rF0 16rFB 16r00 16rA9
  				"c		bl		0x10"				16r01 16r00 16r00 16r94
  				"10		str		x30, [sp]"			16rFE 16r03 16r00 16rF9
  				"14		ldr		x16, #0x14"		16rB0 16r00 16r00 16r58
  				"18		blr		x16	"				16r00 16r02 16r3F 16rD6
  				 "1C	ldr		x30, [sp, #0x16]"	16rFE 16r0B 16r40 16rF9
  				 "20	add		sp, sp, #0x20"		16rFF 16r83 16r00 16r91
  				 "24	ret"							16rC0 16r03 16r5F 16rD6
  													0 0 0 0 0 0 0 0] copy.
+ 	bytes type: #pointer at: 41 put: self thunkEntryAddress.
- 	bytes type: #pointer at: 41 put: self primThunkEntryAddress.
  	self class writeExecutableBlockAt: handle "thunk" bytes: bytes.
  	
  	"self newCCall"!

Item was changed:
  ----- Method: FFICallback>>primThunkEntryAddress (in category 'private') -----
  primThunkEntryAddress "^<Integer>"
  	"Answer the address of the entry-point for thunk callbacks:
  		IA32: long
  			thunkEntry(void *thunkp, long *stackp);
  		X64: long
  			thunkEntry(long a0, long a1, long a2, long a3, long a4, long a5,
  							double d0, double d1, double d2, double d3,
  							double d4, double d5, double d6, double d7,
  							void *thunkp, sqIntptr_t *stackp);
  		X64Win64 long long
  			thunkEntry(long long rcx, long long rdx,
  							long long r8, long long r9,
  							void *thunkp, sqIntptr_t *stackp);
  		ARM32: long long
  			thunkEntry(long r0, long r1, long r2, long r3,
  							double d0, double d1, double d2, double d3,
  							double d4, double d5, double d6, double d7,
  							void *thunkpPlus16, sqIntptr_t *stackp);
  		ARM64: long long
  			thunkEntry(long x0, long x1, long x2, long x3,
  							long x4, long x5, long x6, long x7,
  							double d0, double d1, double d2, double d3,
  							double d4, double d5, double d6, double d7,
+ 							void *thunkpPlus20, sqIntptr_t *stackp);
- 							void *thunkpPlus16, sqIntptr_t *stackp);
  	 etc.
  	 This is the function a callback thunk/trampoline should call to initiate a callback."
  	<primitive: 'primThunkEntryAddress' module: 'IA32ABI' error: errorCode>
  	^self primitiveFailed!

Item was changed:
  ----- Method: FFICallback>>thunkEntryAddress (in category 'private') -----
  thunkEntryAddress
  
+ 	self flag: #todo. "mt: A SqueakFFI compatible primitive should answer an instance of ExternalAddress directly, not just an integer."
  	^ ExternalAddress fromInteger: self primThunkEntryAddress!



More information about the Squeak-dev mailing list