Skip to content

Commit a1789c5

Browse files
committed
CogVM source as per VMMaker.oscog-eem.3759
Include primitiveContextPreserveTemps as primitive #213. Make StackInterpreter>>marryFrame:SP:, CoInterpreter>>marryFrame:SP:, and the trampolines generated by CogObjectRepresentationForSpur>>genGetActiveContextLarge:inBlock: all agree to capture the non-argument stack (which includes temp vars) as nils, rather than copying potentially stale temp vars, and requiring explcit use of Context>>preserveTemps[:] (primitive #213, primitiveContextPreserveTemps) to capture non-stale temps (N.B. given the closure design this should be required in exceptional circumstances if at all). Refactor pushedReceiverOrClosureOfFrame: & stackPointerIndexForFrame:WithSP: above the new stackPointerIndexForFrame:WithSP:NumArgs: so that StackInterpreter>>marryFrame:SP: accesses frameNumArgs: once rather than twice. Slang: fix ancient type inferrence bug. The final pass of type inferrence must be repeated until a fixed point is reached, otherwise inferrences may be missed. This was demonstrated by primitiveContextPreserveTemps.
1 parent 886523d commit a1789c5

60 files changed

Lines changed: 6657 additions & 1923 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/plugins/JPEGReadWriter2Plugin/JPEGReadWriter2Plugin.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Automatically generated by
2-
SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.3739 uuid: 2d2f2ceb-57d6-4381-b5c9-1a3f4bc795de
3-
(Compiler-ct.529)
2+
SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428
3+
(Compiler-ct.530)
44
from
5-
JPEGReadWriter2Plugin VMMaker.oscog-eem.3739 uuid: 2d2f2ceb-57d6-4381-b5c9-1a3f4bc795de
5+
JPEGReadWriter2Plugin VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428
66
*/
7-
static char __buildInfo[] = "JPEGReadWriter2Plugin VMMaker.oscog-eem.3739 uuid: 2d2f2ceb-57d6-4381-b5c9-1a3f4bc795de " __DATE__ ;
7+
static char __buildInfo[] = "JPEGReadWriter2Plugin VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428 " __DATE__ ;
88

99

1010
#include "config.h"
@@ -124,7 +124,7 @@ extern sqInt trueObject(void);
124124
extern
125125
#endif
126126
struct VirtualMachine* interpreterProxy;
127-
static const char *moduleName = "JPEGReadWriter2Plugin VMMaker.oscog-eem.3739 " INT_EXT;
127+
static const char *moduleName = "JPEGReadWriter2Plugin VMMaker.oscog-eem.3759 " INT_EXT;
128128

129129

130130
/*** Methods ***/
@@ -355,7 +355,7 @@ primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgr(void)
355355
sqInt formDepth;
356356
sqLong formHeight;
357357
sqLong formNativeDepth;
358-
sqInt formPitch;
358+
sqLong formPitch;
359359
sqLong formWidth;
360360
int pixelsPerWord;
361361
sqInt progressiveFlag;

src/spur32.cog.lowcode/cogit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Automatically generated by
2-
CCodeGenerator VMMaker.oscog-eem.3755 uuid: 6a64008e-211d-4917-bce6-105bbefb058b
3-
(Cog-eem.508, Compiler-ct.530)
2+
CCodeGenerator VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428
3+
(Cog-eem.510, Compiler-ct.530)
44
*/
55

66

src/spur32.cog.lowcode/cogitARMv5.c

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Automatically generated by
2-
CCodeGenerator VMMaker.oscog-eem.3755 uuid: 6a64008e-211d-4917-bce6-105bbefb058b
3-
(Cog-eem.508, Compiler-ct.530)
2+
CCodeGenerator VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428
3+
(Cog-eem.510, Compiler-ct.530)
44
from
5-
StackToRegisterMappingCogit VMMaker.oscog-eem.3755 uuid: 6a64008e-211d-4917-bce6-105bbefb058b
5+
StackToRegisterMappingCogit VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428
66
*/
7-
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3755 uuid: 6a64008e-211d-4917-bce6-105bbefb058b " __DATE__ ;
7+
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428 " __DATE__ ;
88
char *__cogitBuildInfo = __buildInfo;
99

1010

@@ -11577,7 +11577,7 @@ static NoDbgRegParms sqInt
1157711577
cPICCompactAndIsNowEmpty(CogMethod *cPIC)
1157811578
{
1157911579
usqInt addressFollowingJump;
11580-
sqInt entryPoint;
11580+
usqInt entryPoint;
1158111581
sqInt i;
1158211582
usqInt jumpTargetAddr;
1158311583
sqInt methods[MaxCPICCases];
@@ -11690,7 +11690,7 @@ cPICHasForwardedClass(CogMethod *cPIC)
1169011690
static NoDbgRegParms sqInt
1169111691
cPICHasFreedTargets(CogMethod *cPIC)
1169211692
{
11693-
sqInt entryPoint;
11693+
usqInt entryPoint;
1169411694
sqInt i;
1169511695
sqInt pc;
1169611696
CogMethod *targetMethod;
@@ -24953,9 +24953,13 @@ generateObjectRepresentationTrampolines(void)
2495324953
}
2495424954

2495524955

24956-
/* Create a trampoline to answer the active context that will
24957-
answer it if a frame is already married, and create it otherwise.
24958-
Assume numArgs is in SendNumArgsReg and ClassReg is free. */
24956+
/* Create a trampoline to answer the active context that will answer it if a
24957+
frame is already married,
24958+
and create it otherwise. Assume numArgs is in SendNumArgsReg and ClassReg
24959+
is free.
24960+
These include machine code implementations of
24961+
CoInterpreter>>#marryFrame:SP:
24962+
*/
2495924963

2496024964
/* CogObjectRepresentationForSpur>>#genGetActiveContextLarge:inBlock: */
2496124965
static NoDbgRegParms sqInt
@@ -25008,7 +25012,7 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock)
2500825012
genoperand(RetN, 0);
2500925013
jmpTarget(jumpSingle, genoperandoperand(Label, (labelCounter += 1), bytecodePC));
2501025014

25011-
/* OK, it doesn't exist; instantiate and initialize it
25015+
/* OK, it doesn't exist; instantiate and initialize it, mimicking CoInterpreter>>#marryFrame:SP:
2501225016
set the hasContext flag; See CoInterpreter class>>initializeFrameIndices */
2501325017

2501425018
/* begin OrCq:R: */
@@ -25326,69 +25330,49 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock)
2532625330
convert back adding 1 ;-) */
2532725331
jmpTarget(exit, genoperandoperand(Label, (labelCounter += 1), bytecodePC));
2532825332

25329-
/* Finally copy the non-argument temps.
25330-
ClassReg := FPReg + FoxMFReceiver.
25331-
SendNumArgsReg := SendNumArgsReg+ReceiverIndex.
25332-
[ClassReg := ClassReg - wordSize.
25333-
backEnd hasLinkRegister
25334-
ifTrue: [SPReg <= ClassReg]
25335-
ifFalse: [SPReg < ClassReg]] whileTrue:
25336-
[receiver[SendNumArgsReg] := *ClassReg.
25337-
SendNumArgsReg := SendNumArgsReg + 1]] */
25333+
/* Now compute number of fields to initialize to nil; set ClassReg to the destination index in the new context...
25334+
destination index is index of first non-arg temp, hence add SendNumArgs and header words to ReceiverIndex + 1 */
25335+
gAddCqRR((ReceiverIndex + 1) + (BaseHeaderSize / BytesPerWord), SendNumArgsReg, ClassReg);
25336+
gSubRRR(SPReg, FPReg, SendNumArgsReg);
2533825337

25339-
/* begin LoadEffectiveAddressMw:r:R: */
25340-
/* begin gen:quickConstant:operand:operand: */
25341-
anInstruction = genoperandoperandoperand(LoadEffectiveAddressMwrR, FoxMFReceiver, FPReg, ClassReg);
25342-
if (usesOutOfLineLiteral(anInstruction)) {
25343-
(anInstruction->dependent = locateLiteral(FoxMFReceiver));
25344-
}
25345-
quickConstant = (ReceiverIndex + 1) + (BaseHeaderSize / BytesPerWord);
25346-
25347-
/* begin AddCq:R: */
25338+
/* begin MoveCq:R: */
2534825339
/* begin gen:quickConstant:operand: */
25349-
anInstruction = genoperandoperand(AddCqR, quickConstant, SendNumArgsReg);
25340+
anInstruction = genoperandoperand(MoveCqR, nilObject(), TempReg);
2535025341
if (usesOutOfLineLiteral(anInstruction)) {
25351-
(anInstruction->dependent = locateLiteral(quickConstant));
25342+
(anInstruction->dependent = locateLiteral(nilObject()));
2535225343
}
2535325344

25354-
/* The receiver has already been set.
25355-
If on a CISC there's a retpc for the trampoline call on top of stack; if on a RISC there isn't. */
25345+
/* ...and loop filling the context's temp slots with nils. N.B. if CISC there is a retpc on the stack */
2535625346

2535725347
/* begin SubCq:R: */
2535825348
/* begin gen:quickConstant:operand: */
25359-
loopHead = genoperandoperand(SubCqR, BytesPerWord, ClassReg);
25349+
loopHead = genoperandoperand(SubCqR, BytesPerWord, SendNumArgsReg);
2536025350
if (usesOutOfLineLiteral(loopHead)) {
2536125351
(loopHead->dependent = locateLiteral(BytesPerWord));
2536225352
}
25353+
quickConstant = (FoxSavedFP - FoxMFReceiver) - BytesPerWord;
2536325354

25364-
/* begin CmpR:R: */
25365-
assert(!(0 /* (ClassReg = SPReg) */));
25366-
genoperandoperand(CmpRR, ClassReg, SPReg);
25367-
exit = genConditionalBranchoperand(JumpAbove, ((sqInt)0));
25368-
25369-
/* begin MoveMw:r:R: */
25370-
/* begin gen:quickConstant:operand:operand: */
25371-
anInstruction = genoperandoperandoperand(MoveMwrR, 0, ClassReg, TempReg);
25355+
/* begin CmpCq:R: */
25356+
/* begin gen:quickConstant:operand: */
25357+
anInstruction = genoperandoperand(CmpCqR, quickConstant, SendNumArgsReg);
2537225358
if (usesOutOfLineLiteral(anInstruction)) {
25373-
(anInstruction->dependent = locateLiteral(0));
25359+
(anInstruction->dependent = locateLiteral(quickConstant));
2537425360
}
25361+
exit = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0));
2537525362

2537625363
/* MoveR:Xwr:R: */
25377-
genoperandoperandoperand(MoveRXwrR, TempReg, SendNumArgsReg, ReceiverResultReg);
25364+
genoperandoperandoperand(MoveRXwrR, TempReg, ClassReg, ReceiverResultReg);
2537825365

2537925366
/* begin AddCq:R: */
2538025367
/* begin gen:quickConstant:operand: */
25381-
anInstruction = genoperandoperand(AddCqR, 1, SendNumArgsReg);
25368+
anInstruction = genoperandoperand(AddCqR, 1, ClassReg);
2538225369
if (usesOutOfLineLiteral(anInstruction)) {
2538325370
(anInstruction->dependent = locateLiteral(1));
2538425371
}
2538525372

2538625373
/* Jump: */
2538725374
genoperand(Jump, ((sqInt)loopHead));
25388-
jmpTarget(exit, genoperandoperand(Label, (labelCounter += 1), bytecodePC));
25389-
25390-
/* RetN: */
25391-
genoperand(RetN, 0);
25375+
jmpTarget(exit, genoperand(RetN, 0));
2539225376
jmpTarget(jumpNeedScavenge, genoperandoperand(Label, (labelCounter += 1), bytecodePC));
2539325377
backEnd;
2539425378

src/spur32.cog.lowcode/cogitIA32.c

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Automatically generated by
2-
CCodeGenerator VMMaker.oscog-eem.3755 uuid: 6a64008e-211d-4917-bce6-105bbefb058b
3-
(Cog-eem.508, Compiler-ct.530)
2+
CCodeGenerator VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428
3+
(Cog-eem.510, Compiler-ct.530)
44
from
5-
StackToRegisterMappingCogit VMMaker.oscog-eem.3755 uuid: 6a64008e-211d-4917-bce6-105bbefb058b
5+
StackToRegisterMappingCogit VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428
66
*/
7-
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3755 uuid: 6a64008e-211d-4917-bce6-105bbefb058b " __DATE__ ;
7+
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3759 uuid: 51653cdb-572e-4dcd-9ed0-a6ce1d4dc428 " __DATE__ ;
88
char *__cogitBuildInfo = __buildInfo;
99

1010

@@ -11349,7 +11349,7 @@ cPICHasForwardedClass(CogMethod *cPIC)
1134911349
static NoDbgRegParms sqInt
1135011350
cPICHasFreedTargets(CogMethod *cPIC)
1135111351
{
11352-
sqInt entryPoint;
11352+
usqInt entryPoint;
1135311353
sqInt i;
1135411354
sqInt pc;
1135511355
CogMethod *targetMethod;
@@ -23214,9 +23214,13 @@ generateObjectRepresentationTrampolines(void)
2321423214
}
2321523215

2321623216

23217-
/* Create a trampoline to answer the active context that will
23218-
answer it if a frame is already married, and create it otherwise.
23219-
Assume numArgs is in SendNumArgsReg and ClassReg is free. */
23217+
/* Create a trampoline to answer the active context that will answer it if a
23218+
frame is already married,
23219+
and create it otherwise. Assume numArgs is in SendNumArgsReg and ClassReg
23220+
is free.
23221+
These include machine code implementations of
23222+
CoInterpreter>>#marryFrame:SP:
23223+
*/
2322023224

2322123225
/* CogObjectRepresentationForSpur>>#genGetActiveContextLarge:inBlock: */
2322223226
static NoDbgRegParms sqInt
@@ -23256,7 +23260,7 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock)
2325623260
genoperand(RetN, 0);
2325723261
jmpTarget(jumpSingle, genoperandoperand(Label, (labelCounter += 1), bytecodePC));
2325823262

23259-
/* OK, it doesn't exist; instantiate and initialize it
23263+
/* OK, it doesn't exist; instantiate and initialize it, mimicking CoInterpreter>>#marryFrame:SP:
2326023264
set the hasContext flag; See CoInterpreter class>>initializeFrameIndices */
2326123265

2326223266
/* #OrCq:R: #gen:quickConstant:operand: #checkQuickConstant:forInstruction: */
@@ -23447,46 +23451,30 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock)
2344723451
convert back adding 1 ;-) */
2344823452
jmpTarget(exit, genoperandoperand(Label, (labelCounter += 1), bytecodePC));
2344923453

23450-
/* Finally copy the non-argument temps.
23451-
ClassReg := FPReg + FoxMFReceiver.
23452-
SendNumArgsReg := SendNumArgsReg+ReceiverIndex.
23453-
[ClassReg := ClassReg - wordSize.
23454-
backEnd hasLinkRegister
23455-
ifTrue: [SPReg <= ClassReg]
23456-
ifFalse: [SPReg < ClassReg]] whileTrue:
23457-
[receiver[SendNumArgsReg] := *ClassReg.
23458-
SendNumArgsReg := SendNumArgsReg + 1]] */
23459-
23460-
/* #LoadEffectiveAddressMw:r:R: #gen:quickConstant:operand:operand: #checkQuickConstant:forInstruction: */
23461-
genoperandoperandoperand(LoadEffectiveAddressMwrR, FoxMFReceiver, FPReg, ClassReg);
23462-
23463-
/* #AddCq:R: #gen:quickConstant:operand: #checkQuickConstant:forInstruction: */
23464-
genoperandoperand(AddCqR, (ReceiverIndex + 1) + (BaseHeaderSize / BytesPerWord), SendNumArgsReg);
23454+
/* Now compute number of fields to initialize to nil; set ClassReg to the destination index in the new context...
23455+
destination index is index of first non-arg temp, hence add SendNumArgs and header words to ReceiverIndex + 1 */
23456+
gAddCqRR((ReceiverIndex + 1) + (BaseHeaderSize / BytesPerWord), SendNumArgsReg, ClassReg);
23457+
gSubRRR(SPReg, FPReg, SendNumArgsReg);
2346523458

23466-
/* The receiver has already been set.
23467-
If on a CISC there's a retpc for the trampoline call on top of stack; if on a RISC there isn't. */
23468-
loopHead = genoperandoperand(SubCqR, BytesPerWord, ClassReg);
23459+
/* #MoveCq:R: #gen:quickConstant:operand: #checkQuickConstant:forInstruction: */
23460+
genoperandoperand(MoveCqR, nilObject(), TempReg);
2346923461

23470-
/* begin CmpR:R: */
23471-
assert(!(0 /* (ClassReg = SPReg) */));
23472-
genoperandoperand(CmpRR, ClassReg, SPReg);
23473-
exit = genConditionalBranchoperand(JumpAboveOrEqual, ((sqInt)0));
23462+
/* ...and loop filling the context's temp slots with nils. N.B. if CISC there is a retpc on the stack */
23463+
loopHead = genoperandoperand(SubCqR, BytesPerWord, SendNumArgsReg);
2347423464

23475-
/* #MoveMw:r:R: #gen:quickConstant:operand:operand: #checkQuickConstant:forInstruction: */
23476-
genoperandoperandoperand(MoveMwrR, 0, ClassReg, TempReg);
23465+
/* #CmpCq:R: #gen:quickConstant:operand: #checkQuickConstant:forInstruction: */
23466+
genoperandoperand(CmpCqR, FoxSavedFP - FoxMFReceiver, SendNumArgsReg);
23467+
exit = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0));
2347723468

2347823469
/* MoveR:Xwr:R: */
23479-
genoperandoperandoperand(MoveRXwrR, TempReg, SendNumArgsReg, ReceiverResultReg);
23470+
genoperandoperandoperand(MoveRXwrR, TempReg, ClassReg, ReceiverResultReg);
2348023471

2348123472
/* #AddCq:R: #gen:quickConstant:operand: #checkQuickConstant:forInstruction: */
23482-
genoperandoperand(AddCqR, 1, SendNumArgsReg);
23473+
genoperandoperand(AddCqR, 1, ClassReg);
2348323474

2348423475
/* Jump: */
2348523476
genoperand(Jump, ((sqInt)loopHead));
23486-
jmpTarget(exit, genoperandoperand(Label, (labelCounter += 1), bytecodePC));
23487-
23488-
/* RetN: */
23489-
genoperand(RetN, 0);
23477+
jmpTarget(exit, genoperand(RetN, 0));
2349023478
jmpTarget(jumpNeedScavenge, genoperandoperand(Label, (labelCounter += 1), bytecodePC));
2349123479

2349223480
/* begin saveRegistersInMask:around: */

0 commit comments

Comments
 (0)