[Vm-dev] VM Maker: VMMaker.oscog-djm.688.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Apr 29 15:19:47 UTC 2014
Douglas McPherson uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-djm.688.mcz
==================== Summary ====================
Name: VMMaker.oscog-djm.688
Author: djm
Time: 29 April 2014, 8:17:09.816 am
UUID: 39f5e8fc-f8f0-43cc-89f4-eb61de29c7fb
Ancestors: VMMaker.oscog-eem.687
Change dummyFloatFunction to loadFloatRegs since it is a better name. Define this function in a different C file (platforms/Cross/plugins/SqueakFFIPrims/sqFFIPlugin.c) so that C optimizer cannot optimize it away. This fixes a problem when calling out to functions taking float or double parameters when compiling with optimization level >0.
=============== Diff against VMMaker.oscog-eem.687 ===============
Item was removed:
- ----- Method: ThreadedARMFFIPlugin>>dummyFloatFunction:with:with:with:with:with:with:with: (in category 'callout support') -----
- dummyFloatFunction: d1 with: d2 with: d3 with: d4 with: d5 with: d6 with: d7 with: d8
- <var: #d1 type: #'double'>
- <var: #d2 type: #'double'>
- <var: #d3 type: #'double'>
- <var: #d4 type: #'double'>
- <var: #d5 type: #'double'>
- <var: #d6 type: #'double'>
- <var: #d7 type: #'double'>
- <var: #d8 type: #'double'>
- <returnTypeC: 'void'>
- <inline: false>
-
- !
Item was changed:
----- Method: ThreadedARMFFIPlugin>>ffiCalloutTo:SpecOnStack:in: (in category 'callout support') -----
ffiCalloutTo: procAddr SpecOnStack: specOnStack in: calloutState
<var: #procAddr type: #'void *'>
<var: #calloutState type: #'CalloutState *'>
+ <var: #loadFloatRegs declareC: 'extern void loadFloatRegs(double, double, double, double, double, double, double, double)'>
"Go out, call this guy and create the return value. This *must* be inlined because of
the alloca of the outgoing stack frame in ffiCall:WithFlags:NumArgs:Args:AndTypes:"
+ | myThreadIndex atomicType floatRet intRet loadFloatRegs |
- | myThreadIndex atomicType floatRet intRet |
<var: #floatRet type: #double>
<var: #intRet type: #usqLong>
<inline: true>
self cppIf: COGMTVM ifTrue:
[(calloutState callFlags anyMask: FFICallFlagThreaded) ifTrue:
[myThreadIndex := interpreterProxy disownVM: 0]].
self registerArgsSlop + self cStackAlignment > 0 ifTrue:
[self setsp: calloutState argVector].
calloutState floatRegisterIndex > 0
ifTrue:
[self
+ load: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 0)) to: 'double *') at: 0)
+ Flo: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 2)) to: 'double *') at: 0)
+ a: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 4)) to: 'double *') at: 0)
+ t: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 6)) to: 'double *') at: 0)
+ R: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 8)) to: 'double *') at: 0)
+ e: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 10)) to: 'double *') at: 0)
+ g: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 12)) to: 'double *') at: 0)
+ s: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 14)) to: 'double *') at: 0)
- dummyFloatFunction: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 0)) to: 'double *') at: 0)
- with: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 2)) to: 'double *') at: 0)
- with: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 4)) to: 'double *') at: 0)
- with: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 6)) to: 'double *') at: 0)
- with: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 8)) to: 'double *') at: 0)
- with: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 10)) to: 'double *') at: 0)
- with: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 12)) to: 'double *') at: 0)
- with: ((self cCoerceSimple: (self addressOf: (calloutState floatRegisters at: 14)) to: 'double *') at: 0)
].
atomicType := self atomicTypeOf: calloutState ffiRetHeader.
atomicType = FFITypeSingleFloat
ifTrue:
[floatRet := self
dispatchFunctionPointer: (self cCoerceSimple: procAddr to: 'float (*)(int, int, int, int)')
with: (calloutState integerRegisters at: 0)
with: (calloutState integerRegisters at: 1)
with: (calloutState integerRegisters at: 2)
with: (calloutState integerRegisters at: 3)].
atomicType = FFITypeDoubleFloat
ifTrue:
[floatRet := self
dispatchFunctionPointer: (self cCoerceSimple: procAddr to: 'double (*)(int, int, int, int)')
with: (calloutState integerRegisters at: 0)
with: (calloutState integerRegisters at: 1)
with: (calloutState integerRegisters at: 2)
with: (calloutState integerRegisters at: 3)]
ifFalse:
[intRet := self
dispatchFunctionPointer: (self cCoerceSimple: procAddr to: 'usqLong (*)(int, int, int, int)')
with: (calloutState integerRegisters at: 0)
with: (calloutState integerRegisters at: 1)
with: (calloutState integerRegisters at: 2)
with: (calloutState integerRegisters at: 3)].
"undo any callee argument pops because it may confuse stack management with the alloca."
(self isCalleePopsConvention: calloutState callFlags) ifTrue:
[self setsp: calloutState argVector].
self cppIf: COGMTVM ifTrue:
[(calloutState callFlags anyMask: FFICallFlagThreaded) ifTrue:
[interpreterProxy ownVM: myThreadIndex]].
"Note: Order is important here since FFIFlagPointer + FFIFlagStructure is used to represent
'typedef void* VoidPointer' and VoidPointer must be returned as pointer *not* as struct."
(calloutState ffiRetHeader anyMask: FFIFlagPointer) ifTrue:
[^self ffiReturnPointer: intRet ofType: (self ffiReturnType: specOnStack) in: calloutState].
(calloutState ffiRetHeader anyMask: FFIFlagStructure) ifTrue:
[^self ffiReturnStruct: intRet ofType: (self ffiReturnType: specOnStack) in: calloutState].
(atomicType = FFITypeSingleFloat
or: [atomicType = FFITypeDoubleFloat]) ifTrue:
[^interpreterProxy methodReturnValue: (interpreterProxy floatObjectOf: floatRet)].
^interpreterProxy methodReturnValue: (self ffiCreateIntegralResultOop: intRet
ofAtomicType: atomicType
in: calloutState)!
More information about the Vm-dev
mailing list