[Vm-dev] [commit][2717] CogVM source as per VMMaker.oscog-eem.284.
commits at squeakvm.org
commits at squeakvm.org
Thu Apr 11 00:17:12 UTC 2013
Revision: 2717
Author: eliot
Date: 2013-04-10 17:17:11 -0700 (Wed, 10 Apr 2013)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.284.
Add Callback LIFO ordering support to the new-style Callback return primitives
to the IA32ABI Aline plugins. Fix some compiler warnings there-in.
Improve the debug message printing in sqUnixExternalPrims.c so it prints line
numbers.
Modified Paths:
--------------
branches/Cog/nscogsrc/plugins/IA32ABI/IA32ABI.c
branches/Cog/platforms/unix/vm/sqUnixExternalPrims.c
branches/Cog/src/plugins/IA32ABI/IA32ABI.c
Property Changed:
----------------
branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
Modified: branches/Cog/nscogsrc/plugins/IA32ABI/IA32ABI.c
===================================================================
--- branches/Cog/nscogsrc/plugins/IA32ABI/IA32ABI.c 2013-04-07 12:00:29 UTC (rev 2716)
+++ branches/Cog/nscogsrc/plugins/IA32ABI/IA32ABI.c 2013-04-11 00:17:11 UTC (rev 2717)
@@ -1,9 +1,9 @@
/* Automatically generated by
- VMPluginCodeGenerator VMMaker.oscog-eem.235 uuid: 954df856-3f83-498c-9735-6cd3777ba9c7
+ VMPluginCodeGenerator VMMaker.oscog-eem.284 uuid: 4f939b96-e07b-4888-9880-d2e9465edbe3
from
- NewsqueakIA32ABIPlugin VMMaker.oscog-eem.235 uuid: 954df856-3f83-498c-9735-6cd3777ba9c7
+ NewsqueakIA32ABIPlugin VMMaker.oscog-eem.284 uuid: 4f939b96-e07b-4888-9880-d2e9465edbe3
*/
-static char __buildInfo[] = "NewsqueakIA32ABIPlugin VMMaker.oscog-eem.235 uuid: 954df856-3f83-498c-9735-6cd3777ba9c7 " __DATE__ ;
+static char __buildInfo[] = "NewsqueakIA32ABIPlugin VMMaker.oscog-eem.284 uuid: 4f939b96-e07b-4888-9880-d2e9465edbe3 " __DATE__ ;
@@ -134,6 +134,7 @@
static sqInt (*classLargePositiveInteger)(void);
static sqInt (*classSemaphore)(void);
static sqInt (*failed)(void);
+static sqInt (*falseObject)(void);
static sqInt (*fetchClassOf)(sqInt oop);
static void * (*firstIndexableField)(sqInt oop);
static double (*floatValueOf)(sqInt oop);
@@ -178,6 +179,7 @@
extern sqInt classLargePositiveInteger(void);
extern sqInt classSemaphore(void);
extern sqInt failed(void);
+extern sqInt falseObject(void);
extern sqInt fetchClassOf(sqInt oop);
extern void * firstIndexableField(sqInt oop);
extern double floatValueOf(sqInt oop);
@@ -222,9 +224,9 @@
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
- "IA32ABI VMMaker.oscog-eem.235 (i)"
+ "IA32ABI VMMaker.oscog-eem.284 (i)"
#else
- "IA32ABI VMMaker.oscog-eem.235 (e)"
+ "IA32ABI VMMaker.oscog-eem.284 (e)"
#endif
;
@@ -910,7 +912,7 @@
EXPORT(sqInt)
primInLibraryFindSymbol(void)
{
- sqInt address;
+ void *address;
sqInt functionName;
sqInt libraryProxy;
@@ -926,7 +928,7 @@
|| (address == 0)) {
return primitiveFailFor(PrimErrNotFound);
}
- methodReturnValue(positive32BitIntegerFor(address));
+ methodReturnValue(positive32BitIntegerFor(((usqInt)address)));
}
@@ -938,7 +940,7 @@
EXPORT(sqInt)
primLoadLibrary(void)
{
- sqInt libraryHandle;
+ void *libraryHandle;
sqInt libraryName;
libraryName = stackValue(0);
@@ -949,7 +951,7 @@
if (libraryHandle == 0) {
return primitiveFailFor(PrimErrNotFound);
}
- methodReturnValue(positive32BitIntegerFor(libraryHandle));
+ methodReturnValue(positive32BitIntegerFor(((usqInt)libraryHandle)));
}
@@ -977,28 +979,57 @@
/* Return a result from a callback to the callback's callee. The primitive
- has a signature of the form:
+ has a signature of either of the forms:
result <VMCallbackContext32/64>
primReturnAs: returnTypeCode <Integer>
FromContext: callbackContext <Context>
+ result <VMCallbackContext32/64>
+ primSignal: aSemaphore <Semaphore>
+ andReturnAs: returnTypeCode <Integer>
+ FromContext: callbackContext <Context>
<primitive: 'primReturnAsFromContextThrough' error: errorCode module:
- 'IA32ABI'> */
+ 'IA32ABI'>. If of the second form answer false if this is not the most
+ recent callback, and signal aSemaphore
+ if it is, so as to implement LIFO ordering of callbacks. */
EXPORT(sqInt)
primReturnAsFromContextThrough(void)
{
- if (!(returnAsThroughCallbackContext(stackValue(1), ((VMCallbackContext *) (startOfData(stackValue(2)))), stackValue(0)))) {
+ sqInt isMostRecent;
+ VMCallbackContext *vmCallbackContext;
+
+ if ((methodArgumentCount()) == 3) {
+ vmCallbackContext = ((VMCallbackContext *) (startOfData(stackValue(3))));
+ isMostRecent = vmCallbackContext == (getMostRecentCallbackContext());
+ if (!isMostRecent) {
+ return methodReturnValue(falseObject());
+ }
+ if (!((fetchClassOf(stackValue(2))) == (classSemaphore()))) {
+ return primitiveFailFor(PrimErrBadArgument);
+ }
+ while (!(signalNoResume(stackValue(2)))) {
+ }
+ }
+ else {
+ vmCallbackContext = ((VMCallbackContext *) (startOfData(stackValue(2))));
+ }
+ if (!(returnAsThroughCallbackContext(stackValue(1), vmCallbackContext, stackValue(0)))) {
return primitiveFailFor(PrimErrBadArgument);
}
}
/* Return a result from a callback to the callback's callee. The primitive
- has a signature of the form:
+ has a signature of either of the forms:
result <FFICallbackResult> primReturnFromContext: callbackContext
- <Context> through: jmpBuf <Integer>
- <primitive: 'primReturnFromContextThrough' error: errorCode module:
- 'IA32ABI'> */
+ <MethodContext> through: jmpBuf <Integer>
+ result <FFICallbackResult> primSignal: aSemaphore <Semaphore>
+ andReturnFromContext: callbackContext <MethodContext> through: jmpBuf
+ <Integer> <primitive: 'primReturnFromContextThrough' error: errorCode
+ module: 'IA32ABI'>.
+ If of the second form answer true if this is not the most recent callback,
+ and signal aSemaphore
+ if it is, so as to implement LIFO ordering of callbacks. */
EXPORT(sqInt)
primReturnFromContextThrough(void)
@@ -1973,6 +2004,7 @@
classLargePositiveInteger = interpreterProxy->classLargePositiveInteger;
classSemaphore = interpreterProxy->classSemaphore;
failed = interpreterProxy->failed;
+ falseObject = interpreterProxy->falseObject;
fetchClassOf = interpreterProxy->fetchClassOf;
firstIndexableField = interpreterProxy->firstIndexableField;
floatValueOf = interpreterProxy->floatValueOf;
Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
___________________________________________________________________
Modified: checkindate
- Thu Apr 4 11:39:26 PDT 2013
+ Wed Apr 10 17:15:30 PDT 2013
Modified: branches/Cog/platforms/unix/vm/sqUnixExternalPrims.c
===================================================================
--- branches/Cog/platforms/unix/vm/sqUnixExternalPrims.c 2013-04-07 12:00:29 UTC (rev 2716)
+++ branches/Cog/platforms/unix/vm/sqUnixExternalPrims.c 2013-04-11 00:17:11 UTC (rev 2717)
@@ -36,6 +36,7 @@
#include "sq.h" /* sqUnixConfig.h */
#include "sqAssert.h"
+#include "sqUnixMain.h"
#if (DEBUG)
# define DPRINTF(ARGS) fprintf ARGS
@@ -133,11 +134,13 @@
#endif
-static void *tryLoadModule(char *in, char *name)
+static void *
+tryLoadModule(char *in, char *name)
{
char path[PATH_MAX], *out= path;
void *handle= 0;
int c;
+ DPRINTF((stderr, __FILE__ " %d tryLoadModule(%s,%s)\n", __LINE__, in, name));
while ((c= *in++) && ':' != c) { /* copy next plugin path to path[] */
switch (c) {
case '%':
@@ -160,7 +163,7 @@
}
sprintf(out, "/" MODULE_PREFIX "%s" MODULE_SUFFIX, name);
handle= dlopen(path, RTLD_NOW | RTLD_GLOBAL);
- DPRINTF((stderr, "tryLoading(%s) = %p\n", path, handle));
+ DPRINTF((stderr, __FILE__ " %d tryLoading dlopen(%s) = %p\n", __LINE__, path, handle));
if (!handle) {
struct stat buf;
if ((0 == stat(path, &buf)) && ! S_ISDIR(buf.st_mode))
@@ -176,13 +179,14 @@
char *dir= squeakPlugins;
void *handle= 0;
+ DPRINTF((stderr, __FILE__ " %d ioLoadModule(%s)\n", __LINE__, pluginName));
if ((0 == pluginName) || ('\0' == pluginName[0])) { /* find module in main program */
handle= dlopen(0, RTLD_NOW | RTLD_GLOBAL);
if (handle == 0) {
- fprintf(stderr, "ioLoadModule(<intrinsic>): %s\n", dlerror());
+ fprintf(stderr, __FILE__ " %d ioLoadModule dlopen(<intrinsic>): %s\n", __LINE__, dlerror());
}
else {
- DPRINTF((stderr, "loaded: <intrinsic>\n"));
+ DPRINTF((stderr, __FILE__ " %d ioLoadModule loaded: <intrinsic>\n", __LINE__));
}
return handle;
}
@@ -205,7 +209,7 @@
# endif
handle= dlopen(path, RTLD_NOW | RTLD_GLOBAL);
- DPRINTF((stderr, "ioLoadModule(%s) = %p\n", path, handle));
+ DPRINTF((stderr, __FILE__ " %d ioLoadModule dlopen(%s) = %p%s\n", __LINE__, path, handle, handle ? "" : dlerror()));
return handle;
}
@@ -215,7 +219,8 @@
/* Attempt to load the shared library named by the concatenation of prefix,
* moduleName and suffix. Answer the new module entry, or 0 if the shared
- * library could not be loaded.
+ * library could not be loaded. Try all combinations of prefixes and suffixes,
+ * including no prefix or suffix.
*/
static void *
tryLoading(char *dirName, char *moduleName)
@@ -225,6 +230,7 @@
void *handle= 0;
char **prefix= 0, **suffix= 0;
+ DPRINTF((stderr, __FILE__ " %d tryLoadModule(%s,%s)\n", __LINE__, dirName, moduleName));
for (prefix= prefixes; *prefix; ++prefix)
for (suffix= suffixes; *suffix; ++suffix) {
char libName[NAME_MAX + 32]; /* headroom for prefix/suffix */
@@ -234,10 +240,10 @@
assert(n >= 0 && n < NAME_MAX + 32);
if (!stat(libName, &buf)) {
if (S_ISDIR(buf.st_mode))
- DPRINTF((stderr, "ignoring directory: %s\n", libName));
+ DPRINTF((stderr, __FILE__ " %d ignoring directory: %s\n", __LINE__, libName));
else {
- DPRINTF((stderr, "tryLoading %s\n", libName));
handle= dlopen(libName, RTLD_NOW | RTLD_GLOBAL);
+ DPRINTF((stderr, __FILE__ " %d tryLoading dlopen(%s) = %p\n", __LINE__, libName, handle));
if (handle == 0) {
if (!sqIgnorePluginErrors)
fprintf(stderr, "ioLoadModule(%s):\n %s\n", libName, dlerror());
@@ -291,10 +297,10 @@
if (!pluginName || !*pluginName) {
if (!(handle= dlopen(0, RTLD_NOW | RTLD_GLOBAL))) {
- fprintf(stderr, "ioLoadModule(<intrinsic>): %s\n", dlerror());
+ fprintf(stderr, __FILE__ " %d ioLoadModule(<intrinsic>): %s\n", __LINE__, dlerror());
return 0;
}
- DPRINTF((stderr, "loaded: <intrinsic>\n"));
+ DPRINTF((stderr, __FILE__ " %d ioLoadModule loaded: <intrinsic>\n", __LINE__));
return handle;
}
@@ -311,8 +317,8 @@
*out++= c;
}
*out= '\0';
- DPRINTF((stderr, "ioLoadModule plugins = %s\n path = %s\n",
- squeakPlugins, path));
+ DPRINTF((stderr, "%s %d ioLoadModule plugins = %s path = %s\n",
+ __FILE__, __LINE__, squeakPlugins, path));
if ((handle= tryLoading("", path)))
return handle;
if (!(out > path && *(out - 1) == '/')) {
Modified: branches/Cog/src/plugins/IA32ABI/IA32ABI.c
===================================================================
--- branches/Cog/src/plugins/IA32ABI/IA32ABI.c 2013-04-07 12:00:29 UTC (rev 2716)
+++ branches/Cog/src/plugins/IA32ABI/IA32ABI.c 2013-04-11 00:17:11 UTC (rev 2717)
@@ -1,9 +1,9 @@
/* Automatically generated by
- VMPluginCodeGenerator VMMaker.oscog-eem.235 uuid: 954df856-3f83-498c-9735-6cd3777ba9c7
+ VMPluginCodeGenerator VMMaker.oscog-eem.284 uuid: 4f939b96-e07b-4888-9880-d2e9465edbe3
from
- IA32ABIPlugin VMMaker.oscog-eem.235 uuid: 954df856-3f83-498c-9735-6cd3777ba9c7
+ IA32ABIPlugin VMMaker.oscog-eem.284 uuid: 4f939b96-e07b-4888-9880-d2e9465edbe3
*/
-static char __buildInfo[] = "IA32ABIPlugin VMMaker.oscog-eem.235 uuid: 954df856-3f83-498c-9735-6cd3777ba9c7 " __DATE__ ;
+static char __buildInfo[] = "IA32ABIPlugin VMMaker.oscog-eem.284 uuid: 4f939b96-e07b-4888-9880-d2e9465edbe3 " __DATE__ ;
@@ -132,6 +132,7 @@
static sqInt (*classLargePositiveInteger)(void);
static sqInt (*classSemaphore)(void);
static sqInt (*failed)(void);
+static sqInt (*falseObject)(void);
static sqInt (*fetchClassOf)(sqInt oop);
static void * (*firstIndexableField)(sqInt oop);
static double (*floatValueOf)(sqInt oop);
@@ -175,6 +176,7 @@
extern sqInt classLargePositiveInteger(void);
extern sqInt classSemaphore(void);
extern sqInt failed(void);
+extern sqInt falseObject(void);
extern sqInt fetchClassOf(sqInt oop);
extern void * firstIndexableField(sqInt oop);
extern double floatValueOf(sqInt oop);
@@ -218,9 +220,9 @@
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
- "IA32ABI VMMaker.oscog-eem.235 (i)"
+ "IA32ABI VMMaker.oscog-eem.284 (i)"
#else
- "IA32ABI VMMaker.oscog-eem.235 (e)"
+ "IA32ABI VMMaker.oscog-eem.284 (e)"
#endif
;
@@ -888,7 +890,7 @@
EXPORT(sqInt)
primInLibraryFindSymbol(void)
{
- sqInt address;
+ void *address;
sqInt functionName;
sqInt libraryProxy;
@@ -904,7 +906,7 @@
|| (address == 0)) {
return primitiveFailFor(PrimErrNotFound);
}
- methodReturnValue(positive32BitIntegerFor(address));
+ methodReturnValue(positive32BitIntegerFor(((usqInt)address)));
}
@@ -916,7 +918,7 @@
EXPORT(sqInt)
primLoadLibrary(void)
{
- sqInt libraryHandle;
+ void *libraryHandle;
sqInt libraryName;
libraryName = stackValue(0);
@@ -927,7 +929,7 @@
if (libraryHandle == 0) {
return primitiveFailFor(PrimErrNotFound);
}
- methodReturnValue(positive32BitIntegerFor(libraryHandle));
+ methodReturnValue(positive32BitIntegerFor(((usqInt)libraryHandle)));
}
@@ -955,28 +957,57 @@
/* Return a result from a callback to the callback's callee. The primitive
- has a signature of the form:
+ has a signature of either of the forms:
result <VMCallbackContext32/64>
primReturnAs: returnTypeCode <Integer>
FromContext: callbackContext <Context>
+ result <VMCallbackContext32/64>
+ primSignal: aSemaphore <Semaphore>
+ andReturnAs: returnTypeCode <Integer>
+ FromContext: callbackContext <Context>
<primitive: 'primReturnAsFromContextThrough' error: errorCode module:
- 'IA32ABI'> */
+ 'IA32ABI'>. If of the second form answer false if this is not the most
+ recent callback, and signal aSemaphore
+ if it is, so as to implement LIFO ordering of callbacks. */
EXPORT(sqInt)
primReturnAsFromContextThrough(void)
{
- if (!(returnAsThroughCallbackContext(stackValue(1), ((VMCallbackContext *) (startOfData(stackValue(2)))), stackValue(0)))) {
+ sqInt isMostRecent;
+ VMCallbackContext *vmCallbackContext;
+
+ if ((methodArgumentCount()) == 3) {
+ vmCallbackContext = ((VMCallbackContext *) (startOfData(stackValue(3))));
+ isMostRecent = vmCallbackContext == (getMostRecentCallbackContext());
+ if (!isMostRecent) {
+ return methodReturnValue(falseObject());
+ }
+ if (!((fetchClassOf(stackValue(2))) == (classSemaphore()))) {
+ return primitiveFailFor(PrimErrBadArgument);
+ }
+ while (!(signalNoResume(stackValue(2)))) {
+ }
+ }
+ else {
+ vmCallbackContext = ((VMCallbackContext *) (startOfData(stackValue(2))));
+ }
+ if (!(returnAsThroughCallbackContext(stackValue(1), vmCallbackContext, stackValue(0)))) {
return primitiveFailFor(PrimErrBadArgument);
}
}
/* Return a result from a callback to the callback's callee. The primitive
- has a signature of the form:
+ has a signature of either of the forms:
result <FFICallbackResult> primReturnFromContext: callbackContext
- <Context> through: jmpBuf <Integer>
- <primitive: 'primReturnFromContextThrough' error: errorCode module:
- 'IA32ABI'> */
+ <MethodContext> through: jmpBuf <Integer>
+ result <FFICallbackResult> primSignal: aSemaphore <Semaphore>
+ andReturnFromContext: callbackContext <MethodContext> through: jmpBuf
+ <Integer> <primitive: 'primReturnFromContextThrough' error: errorCode
+ module: 'IA32ABI'>.
+ If of the second form answer true if this is not the most recent callback,
+ and signal aSemaphore
+ if it is, so as to implement LIFO ordering of callbacks. */
EXPORT(sqInt)
primReturnFromContextThrough(void)
@@ -1924,6 +1955,7 @@
classLargePositiveInteger = interpreterProxy->classLargePositiveInteger;
classSemaphore = interpreterProxy->classSemaphore;
failed = interpreterProxy->failed;
+ falseObject = interpreterProxy->falseObject;
fetchClassOf = interpreterProxy->fetchClassOf;
firstIndexableField = interpreterProxy->firstIndexableField;
floatValueOf = interpreterProxy->floatValueOf;
More information about the Vm-dev
mailing list