Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.3411
Browse files Browse the repository at this point in the history
StackInterpreter: add a guard to the two perform:withArguments: primitives
that finds recursive arrays. Use perform: to avoid inlining executeNewMethod
and slowPrimitiveResponse.

Eliminate most noInlineFoo methods using the perform: style. It's much nicer.

ThreaddFFIPlugin: tweak-simplify ffiCall:ArgArrayOrNil:NumArgs:.

Slang:
Avoid creating arg assignments for unused arguments. This shaves
lots of bogus expressions from the inlining of the null
InLineLiteralsManager>>#checkQuickConstant:forInstruction:.

Have TSendNode check for effectless if-then-else's in its hasEffect method.
  • Loading branch information
eliotmiranda committed Jul 24, 2024
1 parent 35802c0 commit d0a638f
Show file tree
Hide file tree
Showing 72 changed files with 37,415 additions and 34,425 deletions.
10 changes: 4 additions & 6 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.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2
VMPluginCodeGenerator VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8
from
BalloonEnginePlugin VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2
BalloonEnginePlugin VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8
*/
static char __buildInfo[] = "BalloonEnginePlugin VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2 " __DATE__ ;
static char __buildInfo[] = "BalloonEnginePlugin VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8 " __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.3408 " INT_EXT;
static const char *moduleName = "B2DPlugin VMMaker.oscog-eem.3411 " INT_EXT;
static int* objBuffer;
static sqInt objUsed;
static unsigned int* spanBuffer;
Expand Down Expand Up @@ -13525,7 +13525,6 @@ stepToNextLine(void)

/* begin stepToNextLineIn:at: */
line = aetBuffer[workBuffer[GWAETStart]];
workBuffer[GWCurrentY];
x = (objBuffer[line + GEXValue]) + (objBuffer[line + GLXIncrement]);
err = (objBuffer[line + GLError]) + (objBuffer[line + GLErrorAdjUp]);
if (err > 0) {
Expand Down Expand Up @@ -13703,7 +13702,6 @@ stepToNextWideLine(void)

/* begin stepToNextWideLineIn:at: */
line = aetBuffer[workBuffer[GWAETStart]];
workBuffer[GWCurrentY];
yEntry = (objBuffer[line + GLWideEntry]) + 1;
yExit = (objBuffer[line + GLWideExit]) + 1;
/* begin obj:at:put: */
Expand Down
30 changes: 18 additions & 12 deletions src/plugins/Klatt/Klatt.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2
VMPluginCodeGenerator VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8
from
KlattSynthesizerPlugin VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2
KlattSynthesizerPlugin VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8
*/
static char __buildInfo[] = "KlattSynthesizerPlugin VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2 " __DATE__ ;
static char __buildInfo[] = "KlattSynthesizerPlugin VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8 " __DATE__ ;


#include "config.h"
Expand Down Expand Up @@ -201,7 +201,7 @@ extern sqInt success(sqInt aBoolean);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "Klatt VMMaker.oscog-eem.3408 " INT_EXT;
static const char *moduleName = "Klatt VMMaker.oscog-eem.3411 " INT_EXT;
static sqInt nmod;
static sqInt nopen;
static sqInt nper;
Expand Down Expand Up @@ -334,6 +334,7 @@ antiResonatorfrequencybandwidth(sqInt index, float freq, float bw)
resonators[(index * 5) - 4] = b;
/* begin resonatorC:put: */
resonators[(index * 5) - 3] = c;
return;
}

/* KlattSynthesizerPlugin>>#antiResonator:value: */
Expand Down Expand Up @@ -1383,7 +1384,7 @@ primitiveSynthesizeFrameIntoStartingAt(void)
/* begin glottalSource */
if (t0 == 0) {
voice = 0;
goto l25;
goto l39;
}
if (nper < nopen) {
x0 = (a1 * x1) + (a2 * x2);
Expand Down Expand Up @@ -1543,7 +1544,7 @@ primitiveSynthesizeFrameIntoStartingAt(void)
}
nper += 1;
voice = x0;
l25: /* end glottalSource */;
l39: /* end glottalSource */;

/* Add turbulence during glottal open phase.
Use random rather than noise because noise is low-passed. */
Expand All @@ -1565,7 +1566,7 @@ primitiveSynthesizeFrameIntoStartingAt(void)
/* begin cascadeBranch: */
if (!(cascade > 0)) {
out = 0.0;
goto l17;
goto l18;
}
/* begin antiResonator:value: */
answer8 = (((resonatorA(Rnz)) * glotout) + ((resonatorB(Rnz)) * ((p18 = resonatorP1(Rnz))))) + ((resonatorC(Rnz)) * (resonatorP2(Rnz)));
Expand Down Expand Up @@ -1688,7 +1689,7 @@ primitiveSynthesizeFrameIntoStartingAt(void)
out1 = answer7;
}
out = out1;
l17: /* end cascadeBranch: */;
l18: /* end cascadeBranch: */;

/* Source is voicing plus aspiration. */
source = parGlotout;
Expand Down Expand Up @@ -1837,6 +1838,7 @@ resonatorfrequencybandwidth(sqInt index, float freq, float bw)
resonators[(index * 5) - 4] = b;
/* begin resonatorC:put: */
resonators[(index * 5) - 3] = c;
return;
}


Expand All @@ -1853,6 +1855,7 @@ resonatorfrequencybandwidthgain(sqInt index, float freq, float bw, float gain)
/* begin resonatorA:put: */
aFloat = (resonatorA(index)) * gain;
resonators[(index * 5) - 5] = aFloat;
return;
}

/* KlattSynthesizerPlugin>>#resonator:value: */
Expand Down Expand Up @@ -1997,6 +2000,7 @@ rorark(float roNumber, float raNumber, float rkNumber)
if (!(s0 == 0.0)) {
x1 = (x1 / s0) * 10000.0;
}
return;
}

/* KlattSynthesizerPlugin>>#saveTo: */
Expand Down Expand Up @@ -2212,6 +2216,7 @@ setCurrentFrame(float *aKlattFrame)
/* begin resonatorA:put: */
aFloat10 = (resonatorA(R6fp)) * ampF6F;
resonators[(R6fp * 5) - 5] = aFloat10;
return;
}


Expand Down Expand Up @@ -2546,7 +2551,7 @@ synthesizeFrameintostartingAt(float *aKlattFrame, short *buffer, sqInt startInde
/* begin glottalSource */
if (t0 == 0) {
voice = 0;
goto l25;
goto l39;
}
if (nper < nopen) {
x0 = (a1 * x1) + (a2 * x2);
Expand Down Expand Up @@ -2706,7 +2711,7 @@ synthesizeFrameintostartingAt(float *aKlattFrame, short *buffer, sqInt startInde
}
nper += 1;
voice = x0;
l25: /* end glottalSource */;
l39: /* end glottalSource */;

/* Add turbulence during glottal open phase.
Use random rather than noise because noise is low-passed. */
Expand All @@ -2728,7 +2733,7 @@ synthesizeFrameintostartingAt(float *aKlattFrame, short *buffer, sqInt startInde
/* begin cascadeBranch: */
if (!(cascade > 0)) {
out = 0.0;
goto l17;
goto l18;
}
/* begin antiResonator:value: */
answer8 = (((resonatorA(Rnz)) * glotout) + ((resonatorB(Rnz)) * ((p18 = resonatorP1(Rnz))))) + ((resonatorC(Rnz)) * (resonatorP2(Rnz)));
Expand Down Expand Up @@ -2851,7 +2856,7 @@ synthesizeFrameintostartingAt(float *aKlattFrame, short *buffer, sqInt startInde
out1 = answer7;
}
out = out1;
l17: /* end cascadeBranch: */;
l18: /* end cascadeBranch: */;

/* Source is voicing plus aspiration. */
source = parGlotout;
Expand Down Expand Up @@ -3070,6 +3075,7 @@ voicedPitchSynchronousReset(void)
x1 = 0;
}
}
return;
}

/* KlattSynthesizerPlugin>>#zeroQphi:cosphi:sinphi:rphid: */
Expand Down
54 changes: 17 additions & 37 deletions src/plugins/SqueakFFIPrims/ARM32FFIPlugin.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2
VMPluginCodeGenerator VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8
from
ThreadedARM32FFIPlugin VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2
ThreadedARM32FFIPlugin VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8
*/
static char __buildInfo[] = "ThreadedARM32FFIPlugin VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2 " __DATE__ ;
static char __buildInfo[] = "ThreadedARM32FFIPlugin VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8 " __DATE__ ;


#include "config.h"
Expand Down Expand Up @@ -177,7 +177,7 @@ static char __buildInfo[] = "ThreadedARM32FFIPlugin VMMaker.oscog-eem.3408 uuid:
#define MaxNumArgs 15
#define NumFloatRegArgs 16
#define NumIntRegArgs 4
#define PluginVersionInfo " VMMaker.oscog-eem.3408"
#define PluginVersionInfo " VMMaker.oscog-eem.3411"

typedef struct {
char *argVector;
Expand Down Expand Up @@ -529,7 +529,7 @@ extern sqInt trueObject(void);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "ARM32FFIPlugin VMMaker.oscog-eem.3408 " INT_EXT;
static const char *moduleName = "ARM32FFIPlugin VMMaker.oscog-eem.3411 " INT_EXT;


/*** Macros ***/
Expand Down Expand Up @@ -1379,8 +1379,6 @@ ffiArgumentSpecClassin(sqInt oop, sqInt argSpec, sqInt argClass, CalloutState *c
}
/* begin ffiPushStructure:ofSize:typeSpec:ofLength:in: */
structSize = ((calloutState->ffiArgHeader)) & FFIStructSizeMask;
((sqInt *) ((calloutState->ffiArgSpec)));
(calloutState->ffiArgSpecSize);
availableRegisterSpace = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * 4;
stackPartSize = structSize;
if (availableRegisterSpace > 0) {
Expand Down Expand Up @@ -1434,8 +1432,6 @@ ffiArgumentSpecClassin(sqInt oop, sqInt argSpec, sqInt argClass, CalloutState *c
# endif // COGMTVM
/* begin ffiPushStructure:ofSize:typeSpec:ofLength:in: */
structSize1 = ((calloutState->ffiArgHeader)) & FFIStructSizeMask;
((sqInt *) ((calloutState->ffiArgSpec)));
(calloutState->ffiArgSpecSize);
availableRegisterSpace1 = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * 4;
stackPartSize1 = structSize1;
if (availableRegisterSpace1 > 0) {
Expand Down Expand Up @@ -2596,8 +2592,6 @@ ffiPushStructureContentsOfin(sqInt oop, CalloutState *calloutState)
}
/* begin ffiPushStructure:ofSize:typeSpec:ofLength:in: */
structSize = ((calloutState->ffiArgHeader)) & FFIStructSizeMask;
((sqInt *) ((calloutState->ffiArgSpec)));
(calloutState->ffiArgSpecSize);
availableRegisterSpace = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * 4;
stackPartSize = structSize;
if (availableRegisterSpace > 0) {
Expand Down Expand Up @@ -2651,8 +2645,6 @@ ffiPushStructureContentsOfin(sqInt oop, CalloutState *calloutState)
# endif // COGMTVM
/* begin ffiPushStructure:ofSize:typeSpec:ofLength:in: */
structSize1 = ((calloutState->ffiArgHeader)) & FFIStructSizeMask;
((sqInt *) ((calloutState->ffiArgSpec)));
(calloutState->ffiArgSpecSize);
availableRegisterSpace1 = (NumIntRegArgs - ((calloutState->integerRegisterIndex))) * 4;
stackPartSize1 = structSize1;
if (availableRegisterSpace1 > 0) {
Expand Down Expand Up @@ -3147,21 +3139,15 @@ primitiveCallout(void)
ffiFail(FFIErrorBadArgs);
goto l10;
}
# if COGMTVM
if (!(((flags & FFICallTypesMask) == FFICallTypeCDecl)
|| ((flags & FFICallTypesMask) == FFICallTypeApi))) {
if (!((((COGMTVM
? flags & FFICallTypesMask
: flags)) == FFICallTypeCDecl)
|| (((COGMTVM
? flags & FFICallTypesMask
: flags)) == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l10;
}
# else // COGMTVM

/* not masking causes threaded calls to fail, which is as they should if the plugin is not threaded. */
if (!((flags == FFICallTypeCDecl)
|| (flags == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l10;
}
# endif // COGMTVM
requiredStackSize = (externalFunctionInstSize > ExternalFunctionStackSizeIndex
? fetchIntegerofObject(ExternalFunctionStackSizeIndex, externalFunction)
: -1);
Expand Down Expand Up @@ -3625,21 +3611,15 @@ primitiveCalloutWithArgs(void)
ffiFail(FFIErrorBadArgs);
goto l10;
}
# if COGMTVM
if (!(((flags & FFICallTypesMask) == FFICallTypeCDecl)
|| ((flags & FFICallTypesMask) == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l10;
}
# else // COGMTVM

/* not masking causes threaded calls to fail, which is as they should if the plugin is not threaded. */
if (!((flags == FFICallTypeCDecl)
|| (flags == FFICallTypeApi))) {
if (!((((COGMTVM
? flags & FFICallTypesMask
: flags)) == FFICallTypeCDecl)
|| (((COGMTVM
? flags & FFICallTypesMask
: flags)) == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l10;
}
# endif // COGMTVM
requiredStackSize = (externalFunctionInstSize > ExternalFunctionStackSizeIndex
? fetchIntegerofObject(ExternalFunctionStackSizeIndex, externalFunction)
: -1);
Expand Down
46 changes: 17 additions & 29 deletions src/plugins/SqueakFFIPrims/ARM64AppleFFIPlugin.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2
VMPluginCodeGenerator VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8
from
ThreadedARM64AppleFFIPlugin VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2
ThreadedARM64AppleFFIPlugin VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8
*/
static char __buildInfo[] = "ThreadedARM64AppleFFIPlugin VMMaker.oscog-eem.3408 uuid: 99ace54d-4adf-4a36-9064-0f4fe0bbaae2 " __DATE__ ;
static char __buildInfo[] = "ThreadedARM64AppleFFIPlugin VMMaker.oscog-eem.3411 uuid: 428bd5d0-2901-4512-9766-0ee5e923cde8 " __DATE__ ;


#include "config.h"
Expand Down Expand Up @@ -177,7 +177,7 @@ static char __buildInfo[] = "ThreadedARM64AppleFFIPlugin VMMaker.oscog-eem.3408
#define MaxNumArgs 15
#define NumFloatRegArgs 8
#define NumIntRegArgs 8
#define PluginVersionInfo " VMMaker.oscog-eem.3408"
#define PluginVersionInfo " VMMaker.oscog-eem.3411"

typedef struct {
char *argVector;
Expand Down Expand Up @@ -551,7 +551,7 @@ extern sqInt trueObject(void);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "ARM64AppleFFIPlugin VMMaker.oscog-eem.3408 " INT_EXT;
static const char *moduleName = "ARM64AppleFFIPlugin VMMaker.oscog-eem.3411 " INT_EXT;


/*** Macros ***/
Expand Down Expand Up @@ -3563,21 +3563,15 @@ primitiveCallout(void)
ffiFail(FFIErrorBadArgs);
goto l10;
}
# if COGMTVM
if (!(((flags & FFICallTypesMask) == FFICallTypeCDecl)
|| ((flags & FFICallTypesMask) == FFICallTypeApi))) {
if (!((((COGMTVM
? flags & FFICallTypesMask
: flags)) == FFICallTypeCDecl)
|| (((COGMTVM
? flags & FFICallTypesMask
: flags)) == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l10;
}
# else // COGMTVM

/* not masking causes threaded calls to fail, which is as they should if the plugin is not threaded. */
if (!((flags == FFICallTypeCDecl)
|| (flags == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l10;
}
# endif // COGMTVM
requiredStackSize = (externalFunctionInstSize > ExternalFunctionStackSizeIndex
? fetchIntegerofObject(ExternalFunctionStackSizeIndex, externalFunction)
: -1);
Expand Down Expand Up @@ -4055,21 +4049,15 @@ primitiveCalloutWithArgs(void)
ffiFail(FFIErrorBadArgs);
goto l10;
}
# if COGMTVM
if (!(((flags & FFICallTypesMask) == FFICallTypeCDecl)
|| ((flags & FFICallTypesMask) == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l10;
}
# else // COGMTVM

/* not masking causes threaded calls to fail, which is as they should if the plugin is not threaded. */
if (!((flags == FFICallTypeCDecl)
|| (flags == FFICallTypeApi))) {
if (!((((COGMTVM
? flags & FFICallTypesMask
: flags)) == FFICallTypeCDecl)
|| (((COGMTVM
? flags & FFICallTypesMask
: flags)) == FFICallTypeApi))) {
ffiFail(FFIErrorCallType);
goto l10;
}
# endif // COGMTVM
requiredStackSize = (externalFunctionInstSize > ExternalFunctionStackSizeIndex
? fetchIntegerofObject(ExternalFunctionStackSizeIndex, externalFunction)
: -1);
Expand Down
Loading

0 comments on commit d0a638f

Please sign in to comment.