[Vm-dev] [commit] r2469 - CogVM source as per
VMMaker.oscog-eem.110. Fix the SqueakFFIPrims plugin for
commits at squeakvm.org
commits at squeakvm.org
Thu Jul 21 23:04:49 UTC 2011
Author: eliot
Date: 2011-07-21 16:04:48 -0700 (Thu, 21 Jul 2011)
New Revision: 2469
Modified:
branches/Cog/macbuild/makevm
branches/Cog/src/plugins/SqueakFFIPrims/SqueakFFIPrims.c
branches/Cog/unixbuild/mtbld/
Log:
CogVM source as per VMMaker.oscog-eem.110. Fix the SqueakFFIPrims plugin for
the COGMTVM. Props for the linux mt build dir.
Modified: branches/Cog/macbuild/makevm
===================================================================
--- branches/Cog/macbuild/makevm 2011-07-20 21:37:01 UTC (rev 2468)
+++ branches/Cog/macbuild/makevm 2011-07-21 23:04:48 UTC (rev 2469)
@@ -9,6 +9,7 @@
VMAPP=".app"
DEST="Croquet"
VMXCP=CoreVM
+SFP=SqueakFFIPrims
KEEP=
USAGE="usage: `basename $0` -[admskh?]"
@@ -24,7 +25,8 @@
XCD_BUILD_CONFIGURATION=Debug
DEST=Debug;;
m) VMAPP="MT.app";
- VMXCP=CoreMTVM;;
+ VMXCP=CoreMTVM;
+ SFP=SqueakMTFFIPrims;;
s) BUILD_CONFIGURATION=DeploymentSymbols
DEST=Fast;;
k) KEEP=1;;
@@ -44,7 +46,7 @@
if [ -z "$DEVELOPER_SDK_DIR" ]; then
DEVELOPER_SDK_DIR=/Developer/SDKs
fi
-test -d "$DEVELOPER_SDK_DIR" || echo '$DEVELOPER_SDK_DIR' "$DEVELOPER_SDK_DIR" does not exist \(needed by SqueakFFIPrims project\)
+test -d "$DEVELOPER_SDK_DIR" || echo '$DEVELOPER_SDK_DIR' "$DEVELOPER_SDK_DIR" does not exist \(needed by $SFP project\)
export DEVELOPER_SDK_DIR
if [ ! -d "$DEVELOPER_SDK_DIR/MacOSX10.5.sdk" ]; then
if [ -d "$DEVELOPER_SDK_DIR/MacOSX10.4u.sdk" ]; then
@@ -93,10 +95,10 @@
# Build the FFI plugin (New as of 27 March 2008)
echo
-echo SqueakFFIPlugin xcodebuild -project SqueakFFIPrims/SqueakFFI.xcodeproj -configuration $NSD_BUILD_CONFIGURATION
-xcodebuild -project SqueakFFIPrims/SqueakFFI.xcodeproj -configuration $NSD_BUILD_CONFIGURATION
+echo SqueakFFIPlugin xcodebuild -project $SFP/SqueakFFI.xcodeproj -configuration $NSD_BUILD_CONFIGURATION
+xcodebuild -project $SFP/SqueakFFI.xcodeproj -configuration $NSD_BUILD_CONFIGURATION
rm -rf "$DEST/Contents/Resources/SqueakFFIPrims.bundle"
-cp -R SqueakFFIPrims/build/$NSD_BUILD_CONFIGURATION/SqueakFFIPrims.bundle "$DEST/Contents/Resources"
+cp -R $SFP/build/$NSD_BUILD_CONFIGURATION/SqueakFFIPrims.bundle "$DEST/Contents/Resources"
# Build the BochsIA32Plugin
# N.B. To build the plugin you also have to build the Bochs libraries in
Modified: branches/Cog/src/plugins/SqueakFFIPrims/SqueakFFIPrims.c
===================================================================
--- branches/Cog/src/plugins/SqueakFFIPrims/SqueakFFIPrims.c 2011-07-20 21:37:01 UTC (rev 2468)
+++ branches/Cog/src/plugins/SqueakFFIPrims/SqueakFFIPrims.c 2011-07-21 23:04:48 UTC (rev 2469)
@@ -1,9 +1,9 @@
/* Automatically generated by
- VMPluginCodeGenerator VMMaker-oscog.54 uuid: 73c095bd-7fa5-4ef9-b9fc-60378cae64c7
+ VMPluginCodeGenerator VMMaker.oscog-eem.110 uuid: 3a1a55cd-2400-49d1-9252-f056b7d19af2
from
- ReentrantIA32FFIPlugin VMMaker-oscog.54 uuid: 73c095bd-7fa5-4ef9-b9fc-60378cae64c7
+ ThreadedIA32FFIPlugin VMMaker.oscog-eem.110 uuid: 3a1a55cd-2400-49d1-9252-f056b7d19af2
*/
-static char __buildInfo[] = "ReentrantIA32FFIPlugin VMMaker-oscog.54 uuid: 73c095bd-7fa5-4ef9-b9fc-60378cae64c7 " __DATE__ ;
+static char __buildInfo[] = "ThreadedIA32FFIPlugin VMMaker.oscog-eem.110 uuid: 3a1a55cd-2400-49d1-9252-f056b7d19af2 " __DATE__ ;
@@ -53,20 +53,26 @@
# define setsp(ignored) 0
#endif
-#if __APPLE__ && __MACH__ && __i386__
-# define STACK_ALIGN_BYTES 16
-#elif __linux__ && __i386__
-# define STACK_ALIGN_BYTES 16
-#elif defined(__amd64__) || defined(__x86_64__) || defined(__amd64) || defined(__x86_64)
-# define STACK_ALIGN_BYTES 16
-#elif defined(powerpc) || defined(__powerpc__) || defined(_POWER) || defined(__POWERPC__) || defined(__PPC__)
-# define STACK_ALIGN_BYTES 16
-#elif defined(__sparc64__) || defined(__sparcv9__) || defined(__sparc_v9__) /* must preceed 32-bit sparc defs */
-# define STACK_ALIGN_BYTES 16
-#elif defined(sparc) || defined(__sparc__) || defined(__sparclite__)
-# define STACK_ALIGN_BYTES 8
-#else
-# define STACK_ALIGN_BYTES 0
+#if !defined(STACK_ALIGN_BYTES)
+# if __APPLE__ && __MACH__ && __i386__
+# define STACK_ALIGN_BYTES 16
+# elif __linux__ && __i386__
+# define STACK_ALIGN_BYTES 16
+# elif defined(__amd64__) || defined(__x86_64__) || defined(__amd64) || defined(__x86_64)
+# define STACK_ALIGN_BYTES 16
+# elif defined(powerpc) || defined(__powerpc__) || defined(_POWER) || defined(__POWERPC__) || defined(__PPC__)
+# define STACK_ALIGN_BYTES 16
+# elif defined(__sparc64__) || defined(__sparcv9__) || defined(__sparc_v9__) /* must preceed 32-bit sparc defs */
+# define STACK_ALIGN_BYTES 16
+# elif defined(sparc) || defined(__sparc__) || defined(__sparclite__)
+# define STACK_ALIGN_BYTES 8
+# else
+# define STACK_ALIGN_BYTES 0
+# endif
+#endif /* !defined(STACK_ALIGN_BYTES) */
+
+#if !defined(STACK_OFFSET_BYTES)
+# define STACK_OFFSET_BYTES 0
#endif
#if defined(_X86_) || defined(i386) || defined(__i386) || defined(__i386__)
@@ -120,7 +126,7 @@
char *stringArgs[15];
} CalloutState;
-#define ReentrantFFICalloutState CalloutState
+#define ThreadedFFICalloutState CalloutState
@@ -133,7 +139,10 @@
#define ExternalFunctionStackSizeIndex 3
#define FFIAtomicTypeMask 0xF000000
#define FFIAtomicTypeShift 24
+#define FFICallFlagThreaded 0x100
#define FFICallTypeApi 1
+#define FFICallTypeCDecl 0
+#define FFICallTypesMask 0xFF
#define FFIErrorAddressNotFound 13
#define FFIErrorAttemptToPassVoid 14
#define FFIErrorBadAddress 11
@@ -174,6 +183,7 @@
#define PrimErrBadNumArgs 5
#define PrimErrBadReceiver 2
#define PrimErrNoCMemory 10
+#define PrimErrObjectMayMove 14
/*** Function Prototypes ***/
@@ -266,9 +276,9 @@
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
- "SqueakFFIPrims VMMaker-oscog.54 (i)"
+ "SqueakFFIPrims VMMaker.oscog-eem.110 (i)"
#else
- "SqueakFFIPrims VMMaker-oscog.54 (e)"
+ "SqueakFFIPrims VMMaker.oscog-eem.110 (e)"
#endif
;
@@ -612,6 +622,15 @@
}
ptrAddress = ((int) (interpreterProxy->firstIndexableField(valueOop)));
if (!(((calloutState->ffiArgHeader)) & FFIFlagPointer)) {
+
+# if COGMTVM
+ if ((((calloutState->callFlags)) & FFICallFlagThreaded)
+ && (interpreterProxy->isYoung(valueOop))) {
+ return -PrimErrObjectMayMove;
+ }
+
+# endif /* COGMTVM */
+
/* begin ffiPushStructure:ofSize:typeSpec:ofLength:in: */
structSize1 = ((calloutState->ffiArgHeader)) & FFIStructSizeMask;
argSpec1 = (calloutState->ffiArgSpec);
@@ -645,7 +664,7 @@
if ((oop & 1)) {
return FFIErrorIntAsPointer;
}
- if (oop == (interpreterProxy->nilObject())) {
+ if (oop == nilOop) {
/* begin ffiPushPointer:in: */
if ((((calloutState->currentArg)) + 4) > ((calloutState->limit))) {
return FFIErrorCallFrameTooBig;
@@ -754,6 +773,17 @@
}
atomicType2 = FFITypeUnsignedByte;
}
+
+# if COGMTVM
+ if ((((calloutState->callFlags)) & FFICallFlagThreaded)
+ && (((!isAlien)
+ || (isDirectAlien(oop)))
+ && (interpreterProxy->isYoung(oop)))) {
+ return -PrimErrObjectMayMove;
+ }
+
+# endif /* COGMTVM */
+
if ((atomicType2 == FFITypeVoid)
|| ((((usqInt) atomicType2) >> 1) == (((usqInt) FFITypeSignedByte) >> 1))) {
if (isString
@@ -979,6 +1009,17 @@
}
atomicType = FFITypeUnsignedByte;
}
+
+# if COGMTVM
+ if ((((calloutState->callFlags)) & FFICallFlagThreaded)
+ && (((!isAlien)
+ || (isDirectAlien(oop)))
+ && (interpreterProxy->isYoung(oop)))) {
+ return -PrimErrObjectMayMove;
+ }
+
+# endif /* COGMTVM */
+
if ((atomicType == FFITypeVoid)
|| ((((usqInt) atomicType) >> 1) == (((usqInt) FFITypeSignedByte) >> 1))) {
if (isString
@@ -1122,6 +1163,7 @@
double floatRet;
sqInt i;
usqLong intRet;
+ sqInt myThreadIndex;
sqInt oop;
sqInt oop1;
sqInt *ptr;
@@ -1138,6 +1180,14 @@
sqInt typeSpec;
sqInt typeSpec1;
+
+# if COGMTVM
+ if (((calloutState->callFlags)) & FFICallFlagThreaded) {
+ myThreadIndex = interpreterProxy->disownVM(0);
+ }
+
+# endif /* COGMTVM */
+
if ((0 + (cStackAlignment())) > 0) {
setsp((calloutState->argVector));
}
@@ -1154,6 +1204,14 @@
if (isCalleePopsConvention((calloutState->callFlags))) {
setsp((calloutState->argVector));
}
+
+# if COGMTVM
+ if (((calloutState->callFlags)) & FFICallFlagThreaded) {
+ interpreterProxy->ownVM(myThreadIndex);
+ }
+
+# endif /* COGMTVM */
+
if (((calloutState->ffiRetHeader)) & FFIFlagPointer) {
/* begin ffiReturnPointer:ofType:in: */
/* begin ffiReturnType: */
@@ -1203,12 +1261,9 @@
return interpreterProxy->methodReturnValue(retOop1);
}
interpreterProxy->pushRemappableOop(retClass1);
- if (((calloutState->ffiRetHeader)) & FFIFlagStructure) {
- classOop = interpreterProxy->classByteArray();
- }
- else {
- classOop = interpreterProxy->classExternalAddress();
- }
+ classOop = (((calloutState->ffiRetHeader)) & FFIFlagStructure
+ ? interpreterProxy->classByteArray()
+ : interpreterProxy->classExternalAddress());
oop1 = interpreterProxy->instantiateClassindexableSize(classOop, 4);
ptr = interpreterProxy->firstIndexableField(oop1);
ptr[0] = (((sqInt) intRet));
@@ -1286,6 +1341,7 @@
sqInt i;
sqInt i1;
usqLong intRet;
+ sqInt myThreadIndex;
sqInt oop;
sqInt oop1;
sqInt oop2;
@@ -1324,9 +1380,21 @@
&& ((interpreterProxy->slotSizeOf(argTypeArray)) == (nArgs + 1)))) {
return ffiFail(FFIErrorBadArgs);
}
- if (!(1)) {
+
+# if COGMTVM
+ if (!(((flags & FFICallTypesMask) == FFICallTypeCDecl)
+ || ((flags & FFICallTypesMask) == FFICallTypeApi))) {
return ffiFail(FFIErrorCallType);
}
+
+# else /* COGMTVM */
+ if (!((flags == FFICallTypeCDecl)
+ || (flags == FFICallTypeApi))) {
+ return ffiFail(FFIErrorCallType);
+ }
+
+# endif /* COGMTVM */
+
/* begin ffiLoadCalloutAddress: */
/* Lookup the address */
@@ -1407,7 +1475,7 @@
(calloutState->limit = (allocation + stackSize) + 0);
if ((((calloutState->structReturnSize)) > 0)
&& (1
- && (!(returnStructInRegisters((calloutState->structReturnSize)))))) {
+ && (!(returnStructInRegisters((calloutState->structReturnSize)))))) {
/* begin ffiPushPointer:in: */
pointer = (calloutState->limit);
if ((((calloutState->currentArg)) + 4) > ((calloutState->limit))) {
@@ -1430,6 +1498,14 @@
while (((calloutState->stringArgIndex)) > 0) {
free(((calloutState->stringArgs))[(calloutState->stringArgIndex = ((calloutState->stringArgIndex)) - 1)]);
}
+
+# if COGMTVM
+ if (err == (-PrimErrObjectMayMove)) {
+ return PrimErrObjectMayMove;
+ }
+
+# endif /* COGMTVM */
+
return ffiFail(err);
}
}
@@ -1449,6 +1525,14 @@
interpreterProxy->storeIntegerofObjectwithValue(ExternalFunctionStackSizeIndex, externalFunction, stackSize);
}
/* begin ffiCalloutTo:SpecOnStack:in: */
+
+# if COGMTVM
+ if (((calloutState->callFlags)) & FFICallFlagThreaded) {
+ myThreadIndex = interpreterProxy->disownVM(0);
+ }
+
+# endif /* COGMTVM */
+
if ((0 + (cStackAlignment())) > 0) {
setsp((calloutState->argVector));
}
@@ -1465,6 +1549,14 @@
if (isCalleePopsConvention((calloutState->callFlags))) {
setsp((calloutState->argVector));
}
+
+# if COGMTVM
+ if (((calloutState->callFlags)) & FFICallFlagThreaded) {
+ interpreterProxy->ownVM(myThreadIndex);
+ }
+
+# endif /* COGMTVM */
+
if (((calloutState->ffiRetHeader)) & FFIFlagPointer) {
/* begin ffiReturnPointer:ofType:in: */
/* begin ffiReturnType: */
@@ -1517,12 +1609,9 @@
goto l5;
}
interpreterProxy->pushRemappableOop(retClass1);
- if (((calloutState->ffiRetHeader)) & FFIFlagStructure) {
- classOop = interpreterProxy->classByteArray();
- }
- else {
- classOop = interpreterProxy->classExternalAddress();
- }
+ classOop = (((calloutState->ffiRetHeader)) & FFIFlagStructure
+ ? interpreterProxy->classByteArray()
+ : interpreterProxy->classExternalAddress());
oop1 = interpreterProxy->instantiateClassindexableSize(classOop, 4);
ptr1 = interpreterProxy->firstIndexableField(oop1);
ptr1[0] = (((sqInt) intRet));
@@ -2063,6 +2152,15 @@
return 0;
}
if (ptrClass == (interpreterProxy->classByteArray())) {
+
+# if COGMTVM
+ if ((((calloutState->callFlags)) & FFICallFlagThreaded)
+ && (interpreterProxy->isYoung(oop))) {
+ return -PrimErrObjectMayMove;
+ }
+
+# endif /* COGMTVM */
+
ptrAddress = ((int) (interpreterProxy->firstIndexableField(oop)));
/* begin ffiPushPointer:in: */
if ((((calloutState->currentArg)) + 4) > ((calloutState->limit))) {
@@ -2073,6 +2171,16 @@
return 0;
}
if (interpreterProxy->includesBehaviorThatOf(ptrClass, interpreterProxy->classAlien())) {
+
+# if COGMTVM
+ if ((((calloutState->callFlags)) & FFICallFlagThreaded)
+ && ((isDirectAlien(oop))
+ && (interpreterProxy->isYoung(oop)))) {
+ return -PrimErrObjectMayMove;
+ }
+
+# endif /* COGMTVM */
+
ptrAddress = ((longAt(oop + BaseHeaderSize)) > 0
? (oop + BaseHeaderSize) + BytesPerOop
: longAt((oop + BaseHeaderSize) + BytesPerOop));
@@ -2270,6 +2378,15 @@
}
ptrAddress = ((int) (interpreterProxy->firstIndexableField(oop)));
if (!(((calloutState->ffiArgHeader)) & FFIFlagPointer)) {
+
+# if COGMTVM
+ if ((((calloutState->callFlags)) & FFICallFlagThreaded)
+ && (interpreterProxy->isYoung(oop))) {
+ return -PrimErrObjectMayMove;
+ }
+
+# endif /* COGMTVM */
+
/* begin ffiPushStructure:ofSize:typeSpec:ofLength:in: */
structSize1 = ((calloutState->ffiArgHeader)) & FFIStructSizeMask;
argSpec1 = (calloutState->ffiArgSpec);
@@ -2505,12 +2622,9 @@
return interpreterProxy->methodReturnValue(retOop);
}
interpreterProxy->pushRemappableOop(retClass);
- if (((calloutState->ffiRetHeader)) & FFIFlagStructure) {
- classOop = interpreterProxy->classByteArray();
- }
- else {
- classOop = interpreterProxy->classExternalAddress();
- }
+ classOop = (((calloutState->ffiRetHeader)) & FFIFlagStructure
+ ? interpreterProxy->classByteArray()
+ : interpreterProxy->classExternalAddress());
oop = interpreterProxy->instantiateClassindexableSize(classOop, 4);
ptr = interpreterProxy->firstIndexableField(oop);
ptr[0] = (((sqInt) retVal));
@@ -2572,21 +2686,14 @@
}
-/* Currently all target platforms (Mac OS X ppc or x86, linux x86, Win32)
- answer true
- for the two calling conventions, FFICallTypeCDecl FFICallTypeApi, so let's
- not waste
- time by testing for these. The only issue is whether the FFICallTypeApi is
- callee pops
- or not (which itself is of little importance to an alloca-based
- implementation, but does
- save a few instructions if not). Subclasses can still override if
- necessary. */
+/* Check that the calling convention is valid. This test also filters out
+ attempts to do a threaded call in the non-threaded VM/plugin combinatioin. */
static sqInt
ffiSupportsCallingConvention(sqInt aCallingConvention)
{
- return 1;
+ return (aCallingConvention == FFICallTypeCDecl)
+ || (aCallingConvention == FFICallTypeApi);
}
@@ -2755,7 +2862,9 @@
sqInt i1;
usqLong intRet;
sqInt meth;
+ sqInt myThreadIndex;
sqInt nArgs;
+ sqInt nArgs1;
sqInt oop;
sqInt oop1;
sqInt oop2;
@@ -2768,6 +2877,7 @@
sqInt retClass1;
sqInt retOop;
sqInt retOop1;
+ sqInt retryCount;
sqInt retType;
sqInt specLiteral;
sqInt specLiteral1;
@@ -2784,8 +2894,18 @@
interpreterProxy->primitiveFailFor(PrimErrBadMethod); return;
}
externalFunction = interpreterProxy->literalofMethod(0, meth);
+
+# if COGMTVM
+ nArgs = interpreterProxy->methodArgumentCount();
+ retryCount = 0;
+ while (((ffiCallArgArrayOrNilNumArgs(externalFunction, null, nArgs)) == PrimErrObjectMayMove)
+ && (((retryCount += 1)) <= nArgs)) {
+ interpreterProxy->tenuringIncrementalGC();
+ }
+
+# else /* COGMTVM */
/* begin ffiCall:ArgArrayOrNil:NumArgs: */
- nArgs = interpreterProxy->methodArgumentCount();
+ nArgs1 = interpreterProxy->methodArgumentCount();
if (!(interpreterProxy->isKindOfClass(externalFunction, interpreterProxy->classExternalFunction()))) {
ffiFail(FFIErrorNotFunction);
goto l3;
@@ -2800,14 +2920,27 @@
argTypeArray = interpreterProxy->fetchPointerofObject(ExternalFunctionArgTypesIndex, externalFunction);
if (!((interpreterProxy->isArray(argTypeArray))
- && ((interpreterProxy->slotSizeOf(argTypeArray)) == (nArgs + 1)))) {
+ && ((interpreterProxy->slotSizeOf(argTypeArray)) == (nArgs1 + 1)))) {
ffiFail(FFIErrorBadArgs);
goto l3;
}
- if (!(1)) {
+
+# if COGMTVM
+ if (!(((flags & FFICallTypesMask) == FFICallTypeCDecl)
+ || ((flags & FFICallTypesMask) == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l3;
}
+
+# else /* COGMTVM */
+ if (!((flags == FFICallTypeCDecl)
+ || (flags == FFICallTypeApi))) {
+ ffiFail(FFIErrorCallType);
+ goto l3;
+ }
+
+# endif /* COGMTVM */
+
/* begin ffiLoadCalloutAddress: */
/* Lookup the address */
@@ -2890,7 +3023,7 @@
(calloutState->limit = (allocation + stackSize) + 0);
if ((((calloutState->structReturnSize)) > 0)
&& (1
- && (!(returnStructInRegisters((calloutState->structReturnSize)))))) {
+ && (!(returnStructInRegisters((calloutState->structReturnSize)))))) {
/* begin ffiPushPointer:in: */
pointer = (calloutState->limit);
if ((((calloutState->currentArg)) + 4) > ((calloutState->limit))) {
@@ -2900,12 +3033,12 @@
(calloutState->currentArg = ((calloutState->currentArg)) + 4);
l1: /* end ffiPushPointer:in: */;
}
- for (i = 1; i <= nArgs; i += 1) {
+ for (i = 1; i <= nArgs1; i += 1) {
argType = interpreterProxy->fetchPointerofObject(i, argTypeArray);
argSpec = interpreterProxy->fetchPointerofObject(0, argType);
argClass = interpreterProxy->fetchPointerofObject(1, argType);
oop = (null == null
- ? interpreterProxy->stackValue(nArgs - i)
+ ? interpreterProxy->stackValue(nArgs1 - i)
: interpreterProxy->fetchPointerofObject(i - 1, null));
err = ffiArgumentSpecClassin(oop, argSpec, argClass, calloutState);
if (err != 0) {
@@ -2913,6 +3046,14 @@
while (((calloutState->stringArgIndex)) > 0) {
free(((calloutState->stringArgs))[(calloutState->stringArgIndex = ((calloutState->stringArgIndex)) - 1)]);
}
+
+# if COGMTVM
+ if (err == (-PrimErrObjectMayMove)) {
+ goto l3;
+ }
+
+# endif /* COGMTVM */
+
ffiFail(err);
goto l3;
}
@@ -2933,6 +3074,14 @@
interpreterProxy->storeIntegerofObjectwithValue(ExternalFunctionStackSizeIndex, externalFunction, stackSize);
}
/* begin ffiCalloutTo:SpecOnStack:in: */
+
+# if COGMTVM
+ if (((calloutState->callFlags)) & FFICallFlagThreaded) {
+ myThreadIndex = interpreterProxy->disownVM(0);
+ }
+
+# endif /* COGMTVM */
+
if ((0 + (cStackAlignment())) > 0) {
setsp((calloutState->argVector));
}
@@ -2949,6 +3098,14 @@
if (isCalleePopsConvention((calloutState->callFlags))) {
setsp((calloutState->argVector));
}
+
+# if COGMTVM
+ if (((calloutState->callFlags)) & FFICallFlagThreaded) {
+ interpreterProxy->ownVM(myThreadIndex);
+ }
+
+# endif /* COGMTVM */
+
if (((calloutState->ffiRetHeader)) & FFIFlagPointer) {
/* begin ffiReturnPointer:ofType:in: */
/* begin ffiReturnType: */
@@ -3001,12 +3158,9 @@
goto l6;
}
interpreterProxy->pushRemappableOop(retClass1);
- if (((calloutState->ffiRetHeader)) & FFIFlagStructure) {
- classOop = interpreterProxy->classByteArray();
- }
- else {
- classOop = interpreterProxy->classExternalAddress();
- }
+ classOop = (((calloutState->ffiRetHeader)) & FFIFlagStructure
+ ? interpreterProxy->classByteArray()
+ : interpreterProxy->classExternalAddress());
oop1 = interpreterProxy->instantiateClassindexableSize(classOop, 4);
ptr1 = interpreterProxy->firstIndexableField(oop1);
ptr1[0] = (((sqInt) intRet));
@@ -3059,6 +3213,9 @@
free(((calloutState->stringArgs))[(calloutState->stringArgIndex = ((calloutState->stringArgIndex)) - 1)]);
}
l3: /* end ffiCall:ArgArrayOrNil:NumArgs: */;
+
+# endif /* COGMTVM */
+
return;
}
@@ -3094,6 +3251,7 @@
sqInt i;
sqInt i1;
usqLong intRet;
+ sqInt myThreadIndex;
sqInt nArgs;
sqInt oop;
sqInt oop1;
@@ -3107,6 +3265,7 @@
sqInt retClass1;
sqInt retOop;
sqInt retOop1;
+ sqInt retryCount;
sqInt retType;
sqInt specLiteral;
sqInt specLiteral1;
@@ -3121,6 +3280,22 @@
if (!((interpreterProxy->methodArgumentCount()) == 1)) {
interpreterProxy->primitiveFailFor(PrimErrBadNumArgs); return;
}
+
+# if COGMTVM
+ retryCount = 0;
+ while (1) {
+ externalFunction = interpreterProxy->stackValue(1);
+ argArray = interpreterProxy->stackValue(0);
+ if (!(interpreterProxy->isArray(argArray))) {
+ interpreterProxy->primitiveFailFor(PrimErrBadArgument); return;
+ }
+ nArgs = interpreterProxy->slotSizeOf(argArray);
+ if (!(((ffiCallArgArrayOrNilNumArgs(externalFunction, argArray, nArgs)) == PrimErrObjectMayMove)
+ && (((retryCount += 1)) <= nArgs))) break;
+ interpreterProxy->tenuringIncrementalGC();
+ }
+
+# else /* COGMTVM */
externalFunction = interpreterProxy->stackValue(1);
argArray = interpreterProxy->stackValue(0);
if (!(interpreterProxy->isArray(argArray))) {
@@ -3146,10 +3321,23 @@
ffiFail(FFIErrorBadArgs);
goto l3;
}
- if (!(1)) {
+
+# if COGMTVM
+ if (!(((flags & FFICallTypesMask) == FFICallTypeCDecl)
+ || ((flags & FFICallTypesMask) == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l3;
}
+
+# else /* COGMTVM */
+ if (!((flags == FFICallTypeCDecl)
+ || (flags == FFICallTypeApi))) {
+ ffiFail(FFIErrorCallType);
+ goto l3;
+ }
+
+# endif /* COGMTVM */
+
/* begin ffiLoadCalloutAddress: */
/* Lookup the address */
@@ -3232,7 +3420,7 @@
(calloutState->limit = (allocation + stackSize) + 0);
if ((((calloutState->structReturnSize)) > 0)
&& (1
- && (!(returnStructInRegisters((calloutState->structReturnSize)))))) {
+ && (!(returnStructInRegisters((calloutState->structReturnSize)))))) {
/* begin ffiPushPointer:in: */
pointer = (calloutState->limit);
if ((((calloutState->currentArg)) + 4) > ((calloutState->limit))) {
@@ -3255,6 +3443,14 @@
while (((calloutState->stringArgIndex)) > 0) {
free(((calloutState->stringArgs))[(calloutState->stringArgIndex = ((calloutState->stringArgIndex)) - 1)]);
}
+
+# if COGMTVM
+ if (err == (-PrimErrObjectMayMove)) {
+ goto l3;
+ }
+
+# endif /* COGMTVM */
+
ffiFail(err);
goto l3;
}
@@ -3275,6 +3471,14 @@
interpreterProxy->storeIntegerofObjectwithValue(ExternalFunctionStackSizeIndex, externalFunction, stackSize);
}
/* begin ffiCalloutTo:SpecOnStack:in: */
+
+# if COGMTVM
+ if (((calloutState->callFlags)) & FFICallFlagThreaded) {
+ myThreadIndex = interpreterProxy->disownVM(0);
+ }
+
+# endif /* COGMTVM */
+
if ((0 + (cStackAlignment())) > 0) {
setsp((calloutState->argVector));
}
@@ -3291,6 +3495,14 @@
if (isCalleePopsConvention((calloutState->callFlags))) {
setsp((calloutState->argVector));
}
+
+# if COGMTVM
+ if (((calloutState->callFlags)) & FFICallFlagThreaded) {
+ interpreterProxy->ownVM(myThreadIndex);
+ }
+
+# endif /* COGMTVM */
+
if (((calloutState->ffiRetHeader)) & FFIFlagPointer) {
/* begin ffiReturnPointer:ofType:in: */
/* begin ffiReturnType: */
@@ -3343,12 +3555,9 @@
goto l6;
}
interpreterProxy->pushRemappableOop(retClass1);
- if (((calloutState->ffiRetHeader)) & FFIFlagStructure) {
- classOop = interpreterProxy->classByteArray();
- }
- else {
- classOop = interpreterProxy->classExternalAddress();
- }
+ classOop = (((calloutState->ffiRetHeader)) & FFIFlagStructure
+ ? interpreterProxy->classByteArray()
+ : interpreterProxy->classExternalAddress());
oop1 = interpreterProxy->instantiateClassindexableSize(classOop, 4);
ptr1 = interpreterProxy->firstIndexableField(oop1);
ptr1[0] = (((sqInt) intRet));
@@ -3401,6 +3610,9 @@
free(((calloutState->stringArgs))[(calloutState->stringArgIndex = ((calloutState->stringArgIndex)) - 1)]);
}
l3: /* end ffiCall:ArgArrayOrNil:NumArgs: */;
+
+# endif /* COGMTVM */
+
return;
}
@@ -3682,8 +3894,8 @@
}
if (!((byteOffset > 0)
&& ((byteSize == 1)
- || ((byteSize == 2)
- || (byteSize == 4))))) {
+ || ((byteSize == 2)
+ || (byteSize == 4))))) {
return interpreterProxy->primitiveFail();
}
addr = ffiAddressOfstartingAtsize(rcvr, byteOffset, byteSize);
@@ -3746,8 +3958,8 @@
}
if (!((byteOffset > 0)
&& ((byteSize == 1)
- || ((byteSize == 2)
- || (byteSize == 4))))) {
+ || ((byteSize == 2)
+ || (byteSize == 4))))) {
return interpreterProxy->primitiveFail();
}
addr = ffiAddressOfstartingAtsize(rcvr, byteOffset, byteSize);
Property changes on: branches/Cog/unixbuild/mtbld
___________________________________________________________________
Added: svn:ignore
+ *
More information about the Vm-dev
mailing list