Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.3380
Browse files Browse the repository at this point in the history
Refactor stack zone initialization to provide an alternate initialization path
through initStackPagesAndContinueInto:with:. This allows e.g. the threaded vm
to allocate the stack zone on a thread other than the first VM thread.

Fix a few more printf warnings in the StackInterpreter.
Fix some pointer type waarnings.

Slang:
Fix a type inference issue with methodDictionaryHash:mask: by making its
return type explicit.

Fully elide assignments of a variable to itself to just a mention of the
variable.

Slang: make the default return type of CogStackPages void. Properly implement
TAssignmentNode>>#hasEffect and hence eliminate the elision of the assignment
hack in TAssignmentNode>>#emitCCodeOn:level:generator:.

Misc:
Filter out unused variables from clusteredVariableNames (which is for access
to interpreter variables from the cogit).
  • Loading branch information
eliotmiranda committed May 24, 2024
1 parent 5dd00dc commit c5bdc5f
Show file tree
Hide file tree
Showing 83 changed files with 2,558 additions and 1,656 deletions.
21 changes: 12 additions & 9 deletions platforms/Cross/vm/sq.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ unsigned int ioMicroMSecs(void);
* Since all OpenSmalltalk VMs are at least STACKVMs, STACKVM is synonymous
* with OpenSmalltalk-VM and Cog VM.
*/
/* Time API, Cog uses 64-bit microseconds fron 1901 as much as possible */

// Alternate stack zone initialization path, e.g. for threaded VMs
void initStackPagesAndContinueIntowith(void (*continuation)(void *), void *);
// Time API, Cog uses 64-bit microseconds fron 1901 as much as possible
void forceInterruptCheckFromHeartbeat(void);
void ioInitTime(void);
usqLong ioUTCMicrosecondsNow(void);
Expand All @@ -138,9 +141,9 @@ sqInt ioLocalSecondsOffset(void);
void ioUpdateVMTimezone(void);
void ioSynchronousCheckForEvents(void);
void checkHighPriorityTickees(usqLong);
# if ITIMER_HEARTBEAT /* Hack; allow heartbeat to avoid */
extern int numAsyncTickees; /* prodHighPriorityThread unless necessary */
# endif /* see platforms/unix/vm/sqUnixHeartbeat.c */
# if ITIMER_HEARTBEAT // Hack; allow heartbeat to avoid
extern int numAsyncTickees; // prodHighPriorityThread unless necessary
# endif // see platforms/unix/vm/sqUnixHeartbeat.c
void ioGetClockLogSizeUsecsIdxMsecsIdx(sqInt*,void**,sqInt*,void**,sqInt*);
void addIdleUsecs(sqInt);

Expand All @@ -162,7 +165,7 @@ extern void reportMinimumUnusedHeadroomOn(FILE *);
extern void ifValidWriteBackStackPointersSaveTo(void *,void *,char **,char **);
extern void dumpPrimTraceLog();
extern void dumpPrimTraceLogOn(FILE *);
#endif /* STACKVM */
#endif // STACKVM
extern void printCallStack(void);
extern void printCallStackOn(FILE *);
extern void printAllStacks(void);
Expand Down Expand Up @@ -271,15 +274,15 @@ int ioOSThreadsEqual(sqOSThread,sqOSThread);
extern sqOSThread ioVMThread;
# define getVMOSThread() ioVMThread
# endif
#endif /* STACKVM || NewspeakVM */
#endif // STACKVM || NewspeakVM

#if STACKVM
/* Event polling via periodic heartbeat thread. */
void ioInitHeartbeat(void);
int ioHeartbeatMilliseconds(void);
void ioSetHeartbeatMilliseconds(int);
unsigned long ioHeartbeatFrequency(int);
#endif /* STACKVM */
#endif // STACKVM

#if COGMTVM
/* COGMTVM is a yet-to-be-released "multi-threaded" VM in the style of Python,
Expand Down Expand Up @@ -356,7 +359,7 @@ void ioTransferTimeslice(void);
# if !defined(ioEventThreadAffinity)
# define ioEventThreadAffinity() -1
#endif
#endif /* COGMTVM */
#endif // COGMTVM

/* Profiling. */
void ioControlProfile(int on, void **vhp, long *nvb, void **ehp, long *neb);
Expand Down Expand Up @@ -641,4 +644,4 @@ sqInt ioFreeModule(void *moduleHandle);
/* The Squeak version from which this interpreter was generated. */
extern const char *interpreterVersion;

#endif /* _SQ_H */
#endif // _SQ_H
4 changes: 2 additions & 2 deletions platforms/iOS/vm/Common/Classes/sqSqueakMainApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ Some of this code was funded via a grant from the European Smalltalk User Group
" x16 %14p x17 %14p x18 %14p x19 %14p\n"
" x20 %14p x21 %14p x22 %14p x23 %14p\n"
" x24 %14p x25 %14p x26 %14p x27 %14p\n"
" x29 %14p fp %14p lr %14p sp %14p\n",
" cpsr 0x%08x\n",
" x28 %14p fp %14p lr %14p sp %14p\n",
" pc %14p cpsr 0x%08x\n",
vr( __x[0]), vr( __x[1]), vr( __x[2]), vr( __x[3]),
vr( __x[4]), vr( __x[5]), vr( __x[6]), vr( __x[7]),
vr( __x[8]), vr( __x[9]), vr(__x[10]), vr(__x[11]),
Expand Down
18 changes: 4 additions & 14 deletions src/plugins/B2DPlugin/B2DPlugin.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.3228 uuid: 02cd75d5-0049-4b27-a5b9-3451af576384
VMPluginCodeGenerator VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3
from
BalloonEnginePlugin VMMaker.oscog-eem.3228 uuid: 02cd75d5-0049-4b27-a5b9-3451af576384
BalloonEnginePlugin VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3
*/
static char __buildInfo[] = "BalloonEnginePlugin VMMaker.oscog-eem.3228 uuid: 02cd75d5-0049-4b27-a5b9-3451af576384 " __DATE__ ;
static char __buildInfo[] = "BalloonEnginePlugin VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3 " __DATE__ ;


#include "config.h"
Expand Down Expand Up @@ -838,7 +838,7 @@ extern
#endif
struct VirtualMachine* interpreterProxy;
static void * loadBBFn;
static const char *moduleName = "B2DPlugin VMMaker.oscog-eem.3228 " INT_EXT;
static const char *moduleName = "B2DPlugin VMMaker.oscog-eem.3380 " INT_EXT;
static int* objBuffer;
static sqInt objUsed;
static unsigned int* spanBuffer;
Expand Down Expand Up @@ -2471,7 +2471,6 @@ computeBeziersplitAt(sqInt index, double param)
goto l1;
}
}
/* leftViaY = */ leftViaY;
l1: /* end assureValue:between:and: */;
/* begin assureValue:between:and: */
if (sharedY > endY) {
Expand All @@ -2494,7 +2493,6 @@ computeBeziersplitAt(sqInt index, double param)
goto l2;
}
}
/* rightViaY = */ rightViaY;
l2: /* end assureValue:between:and: */;
/* begin allocateBezierStackEntry */
if (!(needAvailableSpace(6))) {
Expand Down Expand Up @@ -3219,7 +3217,6 @@ fillBitmapSpanAAfromtoat(sqInt bmFill, sqInt leftX, sqInt rightX, sqInt yValue)
goto l1;
}
else {
/* xp = */ xp;
goto l1;
}
}
Expand All @@ -3235,7 +3232,6 @@ fillBitmapSpanAAfromtoat(sqInt bmFill, sqInt leftX, sqInt rightX, sqInt yValue)
goto l2;
}
else {
/* yp = */ yp;
goto l2;
}
}
Expand Down Expand Up @@ -3340,7 +3336,6 @@ fillBitmapSpanAAfromtoat(sqInt bmFill, sqInt leftX, sqInt rightX, sqInt yValue)
goto l3;
}
else {
/* xp = */ xp;
goto l3;
}
}
Expand All @@ -3356,7 +3351,6 @@ fillBitmapSpanAAfromtoat(sqInt bmFill, sqInt leftX, sqInt rightX, sqInt yValue)
goto l4;
}
else {
/* yp = */ yp;
goto l4;
}
}
Expand Down Expand Up @@ -3462,7 +3456,6 @@ fillBitmapSpanAAfromtoat(sqInt bmFill, sqInt leftX, sqInt rightX, sqInt yValue)
goto l5;
}
else {
/* xp = */ xp;
goto l5;
}
}
Expand All @@ -3478,7 +3471,6 @@ fillBitmapSpanAAfromtoat(sqInt bmFill, sqInt leftX, sqInt rightX, sqInt yValue)
goto l6;
}
else {
/* yp = */ yp;
goto l6;
}
}
Expand Down Expand Up @@ -3697,7 +3689,6 @@ fillBitmapSpanfromtoat(sqInt bmFill, sqInt leftX, sqInt rightX, sqInt yValue)
goto l1;
}
else {
/* xp = */ xp;
goto l1;
}
}
Expand All @@ -3713,7 +3704,6 @@ fillBitmapSpanfromtoat(sqInt bmFill, sqInt leftX, sqInt rightX, sqInt yValue)
goto l2;
}
else {
/* yp = */ yp;
goto l2;
}
}
Expand Down
13 changes: 4 additions & 9 deletions src/plugins/BitBltPlugin/BitBltPlugin.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.3313 uuid: eec7f9f2-1dea-4660-bacc-8f63d29beb2e
SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3
from
BitBltSimulation VMMaker.oscog-eem.3313 uuid: eec7f9f2-1dea-4660-bacc-8f63d29beb2e
BitBltSimulation VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3
*/
static char __buildInfo[] = "BitBltSimulation VMMaker.oscog-eem.3313 uuid: eec7f9f2-1dea-4660-bacc-8f63d29beb2e " __DATE__ ;
static char __buildInfo[] = "BitBltSimulation VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3 " __DATE__ ;


#include "config.h"
Expand Down Expand Up @@ -364,7 +364,7 @@ static int maskTable[33] = {
0, 1, 3, 0, 15, 31, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 65535,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1
};
static const char *moduleName = "BitBltPlugin VMMaker.oscog-eem.3313 " INT_EXT;
static const char *moduleName = "BitBltPlugin VMMaker.oscog-eem.3380 " INT_EXT;
static sqInt noHalftone;
static sqInt noSource;
static sqInt numGCsOnInvocation;
Expand Down Expand Up @@ -4700,11 +4700,9 @@ partitionedRgbComponentAlphadestnBitsnPartitions(unsigned int sourceWord, unsign
v = v & 0xFFFFFF;
goto l1;
}
/* v = */ v;
goto l1;
}
if (v == 0) {
/* v = */ v;
goto l1;
}
d = 32 - nBits;
Expand Down Expand Up @@ -6537,11 +6535,9 @@ rgbComponentAlphawith(sqInt sourceWord, sqInt destinationWord)
v = v & 0xFFFFFF;
goto l1;
}
/* v = */ v;
goto l1;
}
if (v == 0) {
/* v = */ v;
goto l1;
}
d = 32 - destDepth;
Expand Down Expand Up @@ -8184,7 +8180,6 @@ warpPickSmoothPixelsxDeltahyDeltahxDeltavyDeltavsourceMapsmoothingdstShiftInc(sq
}
else {
/* begin rgbMap32To32: */
/* rgb = */ rgb;
}
}
b += rgb & 0xFF;
Expand Down
20 changes: 16 additions & 4 deletions src/plugins/FilePlugin/FilePlugin.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.3371 uuid: caae1504-f28c-4fb4-92c6-fd8c7feb1941
VMPluginCodeGenerator VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3
from
FilePlugin VMMaker.oscog-eem.3371 uuid: caae1504-f28c-4fb4-92c6-fd8c7feb1941
FilePlugin VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3
*/
static char __buildInfo[] = "FilePlugin VMMaker.oscog-eem.3371 uuid: caae1504-f28c-4fb4-92c6-fd8c7feb1941 " __DATE__ ;
static char __buildInfo[] = "FilePlugin VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3 " __DATE__ ;


#include "config.h"
Expand Down Expand Up @@ -208,7 +208,7 @@ extern sqInt trueObject(void);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "FilePlugin VMMaker.oscog-eem.3371 " INT_EXT;
static const char *moduleName = "FilePlugin VMMaker.oscog-eem.3380 " INT_EXT;
static void * sCCPfn;
static void * sCDFfn;
static void * sCDPfn;
Expand Down Expand Up @@ -759,6 +759,12 @@ primitiveDirectoryEntry(void)
sqInt status;
sqInt symlinkFlag;

createDate = 0;
dirFlag = 0;
entryNameSize = 0;
modifiedDate = 0;
posixPermissions = 0;
symlinkFlag = 0;
requestedName = stackValue(0);
pathName = stackValue(1);
if (!(isBytes(pathName))) {
Expand Down Expand Up @@ -883,6 +889,12 @@ primitiveDirectoryLookup(void)
sqInt status;
sqInt symlinkFlag;

createDate = 0;
dirFlag = 0;
entryNameSize = 0;
modifiedDate = 0;
posixPermissions = 0;
symlinkFlag = 0;
index = stackIntegerValue(0);
pathName = stackValue(1);
if (!(isBytes(pathName))) {
Expand Down
16 changes: 4 additions & 12 deletions src/plugins/ScratchPlugin/ScratchPlugin.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.3228 uuid: 02cd75d5-0049-4b27-a5b9-3451af576384
VMPluginCodeGenerator VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3
from
ScratchPlugin VMMaker.oscog-eem.3228 uuid: 02cd75d5-0049-4b27-a5b9-3451af576384
ScratchPlugin VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3
*/
static char __buildInfo[] = "ScratchPlugin VMMaker.oscog-eem.3228 uuid: 02cd75d5-0049-4b27-a5b9-3451af576384 " __DATE__ ;
static char __buildInfo[] = "ScratchPlugin VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3 " __DATE__ ;


#include "config.h"
Expand Down Expand Up @@ -115,7 +115,7 @@ extern sqInt success(sqInt aBoolean);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "ScratchPlugin VMMaker.oscog-eem.3228 " INT_EXT;
static const char *moduleName = "ScratchPlugin VMMaker.oscog-eem.3380 " INT_EXT;


/* ScratchPlugin>>#bitmap:at:putH:s:v: */
Expand Down Expand Up @@ -317,7 +317,6 @@ interpolatedFromxywidthheight(unsigned int *bitmap, sqInt xFixed, sqInt yFixed,
goto l1;
}
if (((bitmap[index + 1]) & 0xFFFFFF) == 0) {
/* topPix = */ topPix;
goto l1;
}
frac1 = 0x400 - xFrac;
Expand Down Expand Up @@ -345,7 +344,6 @@ interpolatedFromxywidthheight(unsigned int *bitmap, sqInt xFixed, sqInt yFixed,
goto l2;
}
if (((bitmap[index + 1]) & 0xFFFFFF) == 0) {
/* bottomPix = */ bottomPix;
goto l2;
}
frac11 = 0x400 - xFrac;
Expand Down Expand Up @@ -989,7 +987,6 @@ primitiveFisheye(void)
goto l3;
}
if (((in[index + 1]) & 0xFFFFFF) == 0) {
/* topPix = */ topPix;
goto l3;
}
frac1 = 0x400 - xFrac;
Expand Down Expand Up @@ -1018,7 +1015,6 @@ primitiveFisheye(void)
goto l4;
}
if (((in[index + 1]) & 0xFFFFFF) == 0) {
/* bottomPix = */ bottomPix;
goto l4;
}
frac11 = 0x400 - xFrac;
Expand Down Expand Up @@ -1528,7 +1524,6 @@ primitiveInterpolate(void)
goto l3;
}
if (((in[index + 1]) & 0xFFFFFF) == 0) {
/* topPix = */ topPix;
goto l3;
}
frac1 = 0x400 - xFrac;
Expand Down Expand Up @@ -1557,7 +1552,6 @@ primitiveInterpolate(void)
goto l2;
}
if (((in[index + 1]) & 0xFFFFFF) == 0) {
/* bottomPix = */ bottomPix;
goto l2;
}
frac11 = 0x400 - xFrac;
Expand Down Expand Up @@ -2400,7 +2394,6 @@ primitiveWhirl(void)
goto l3;
}
if (((in[index + 1]) & 0xFFFFFF) == 0) {
/* topPix = */ topPix;
goto l3;
}
frac1 = 0x400 - xFrac;
Expand Down Expand Up @@ -2429,7 +2422,6 @@ primitiveWhirl(void)
goto l4;
}
if (((in[index + 1]) & 0xFFFFFF) == 0) {
/* bottomPix = */ bottomPix;
goto l4;
}
frac11 = 0x400 - xFrac;
Expand Down
3 changes: 0 additions & 3 deletions src/spur32.cog.lowcode/_variable_order
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
_vmOwner
_stackLimitFromMachineCode
_stackLimit
_stackPointer
_framePointer
Expand All @@ -17,7 +15,6 @@ _newMethod
_instructionPointer
_argumentCount
_nextProfileTick
_nativeSP
_nativeStackPointer
_shadowCallStackPointer
_primTraceLog
2 changes: 1 addition & 1 deletion src/spur32.cog.lowcode/cogit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3375 uuid: f5ac2627-c6fa-4468-b11e-a67fde7fb22a
CCodeGenerator VMMaker.oscog-eem.3380 uuid: c077b429-f897-47ad-92b4-563c161255f3
*/


Expand Down
Loading

0 comments on commit c5bdc5f

Please sign in to comment.