Marcel Taeumel uploaded a new version of FFI-Callbacks to project FFI:
http://source.squeak.org/FFI/FFI-Callbacks-mt.23.mcz ==================== Summary ==================== Name: FFI-Callbacks-mt.23 Author: mt Time: 28 May 2021, 12:54:05.2767 pm UUID: 5829377d-876a-5747-a754-3d4c5f9f3257 Ancestors: FFI-Callbacks-mt.22 Minor speed-up for callback evaluation. =============== Diff against FFI-Callbacks-mt.22 =============== Item was changed: ----- Method: FFICallback class>>evaluateCallbackForContext: (in category 'instance lookup') ----- evaluateCallbackForContext: callbackContext "<FFICallbackContext> ^<Integer> typeCode" ^ ThunkToCallbackMap + at: callbackContext thunkp_address - at: callbackContext thunkp getHandle ifPresent: [:callback | callback valueInContext: callbackContext] ifAbsent: [self error: 'could not locate Callback instance corresponding to thunk address'] ! Item was changed: ----- Method: FFICallbackContext class>>fields (in category 'field definition') ----- fields " self defineFields. " ^ #( + (thunkp 'FFICallback*') - (thunkp 'void*') (stackPtr 'byte*') "was: char*" ), (FFIPlatformDescription current abiSend: #fields to: self), #( (nil 'void*') "was: savedCStackPointer" (nil 'void*') "was: savedCFramePointer" (rvs 'FFICallbackResult') (nil 'void*') "was: savedPrimFunctionPointer" (outerContext 'FFICallbackContext*') "jmp_buf trampoline --- for debugging only?" ) " typedef struct { void *thunkp; char *stackptr; long *intRegArgs; double *floatRegArgs; void *savedCStackPointer; void *savedCFramePointer; union { intptr_t vallong; struct { int low, high; } valleint64; struct { int high, low; } valbeint64; double valflt64; struct { void *addr; intptr_t size; } valstruct; } rvs; void *savedPrimFunctionPointer; jmp_buf trampoline; jmp_buf savedReenterInterpreter; } VMCallbackContext; "! Item was added: + ----- Method: FFICallbackContext class>>generateStructureFieldAccessorsFor:startingAt:type: (in category 'field definition - support') ----- + generateStructureFieldAccessorsFor: fieldName startingAt: byteOffset type: type + "Overwritten to also generate a shortcut for thunkp + self defineFields. + " + super + generateStructureFieldAccessorsFor: fieldName + startingAt: byteOffset + type: type. + + fieldName = 'thunkp' ifTrue: [ + | shortcutCode shortcutSelector | + shortcutSelector := fieldName, '_address'. + shortcutCode := '{1}\ ^ handle pointerAt: {2} length: {3}' withCRs + format: { shortcutSelector . byteOffset . type byteSize }. + self maybeCompileAccessor: shortcutCode withSelector: shortcutSelector asSymbol].! |
Free forum by Nabble | Edit this page |