Skip to content

Commit 38c5b8d

Browse files
committed
CogVM source as per VMMaker.oscog-eem.3681
Fix the AndreasSystemProfiler misattribution bug, which is caused by the tally being sampled. The fix requires that runProfileProcess zero nextProfileTick while profiling. The fix also requires that primitiveProfileStart does not nil the samples (profileProcess and profileMethod). Since checkProfileTickPostPrimitive: is always invoked with newMethod, remove the argument and access newMethod directly.
1 parent a14bd86 commit 38c5b8d

35 files changed

+629
-1057
lines changed

src/spur32.cog.lowcode/cointerp.c

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Automatically generated by
2-
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3680 uuid: a9ad06c5-1c8d-4efc-b2a6-1516f7d64803
2+
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3681 uuid: 84bd780d-3a40-4927-9642-e7af19ce89b5
33
(Cog-eem.504, * Compiler-nice.525)
44
from
5-
CoInterpreter VMMaker.oscog-eem.3680 uuid: a9ad06c5-1c8d-4efc-b2a6-1516f7d64803
5+
CoInterpreter VMMaker.oscog-eem.3681 uuid: 84bd780d-3a40-4927-9642-e7af19ce89b5
66
*/
7-
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3680 uuid: a9ad06c5-1c8d-4efc-b2a6-1516f7d64803 " __DATE__ ;
7+
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3681 uuid: 84bd780d-3a40-4927-9642-e7af19ce89b5 " __DATE__ ;
88
char *__interpBuildInfo = __buildInfo;
99

1010

@@ -454,7 +454,7 @@ extern sqInt checkIfCFramePointerInUse(void);
454454
extern int checkingLongRunningPrimitives(void);
455455
#endif /* LRPCheck */
456456
static NoDbgRegParms sqInt checkOkayFields(sqInt oop);
457-
static NoDbgRegParms NeverInline void checkProfileTickPostPrimitive(sqInt aPrimitiveMethod);
457+
static NeverInline void checkProfileTickPostPrimitive(void);
458458
static NoDbgRegParms sqInt cogMethodHasRealNonProfilingPrimitive(CogMethod *cogMethod);
459459
extern sqInt cogMethodHasTooManyLiterals(CogMethod *aCogMethod);
460460
extern CogMethod * cogMethodOf(sqInt aMethodOop);
@@ -1831,8 +1831,8 @@ _iss sqInt mournQueue;
18311831
_iss sqInt classTableIndex;
18321832
_iss usqInt lastMobileObject;
18331833
_iss sqInt profileProcess;
1834-
_iss sqInt profileMethod;
18351834
_iss sqInt profileSemaphore;
1835+
_iss sqInt profileMethod;
18361836
_iss sqInt remapBufferCount;
18371837
_iss sqInt becomeEffectsFlags;
18381838
_iss sqInt numRememberedEphemerons;
@@ -2700,7 +2700,7 @@ sqInt debugCallbackReturns;
27002700
sqInt suppressHeartbeatFlag;
27012701
sqInt cannotDeferDisplayUpdates;
27022702
sqInt checkedPluginName;
2703-
const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3680]";
2703+
const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3681]";
27042704
const char * leakCheckFlagsMeanings[] = {
27052705
"1: check full GC", "2: check new space GC", "4: check incremental GC", "8: check become",
27062706
"16: check image segment", "32: check free space", "64: check shorten", "128: check prim call",
@@ -6091,7 +6091,7 @@ l6:;
60916091
/* Don't fail if primitive has done something radical, e.g. perform:
60926092
If we are profiling, take accurate primitive measures */
60936093
if (GIV(nextProfileTick) > 0) {
6094-
checkProfileTickPostPrimitive(GIV(newMethod));
6094+
checkProfileTickPostPrimitive();
60956095
}
60966096
succeeded = !GIV(primFailCode);
60976097
if (GIV(instructionPointer) == (ceReturnToInterpreterPC())) {
@@ -27191,7 +27191,7 @@ ceActivateFailingPrimitiveMethod(sqInt aPrimitiveMethod)
2719127191
primitiveFunctionPointer = functionPointerForCompiledMethodprimitiveIndexprimitivePropertyFlagsInto(aPrimitiveMethod, (primitiveIndexOf(aPrimitiveMethod)), null);
2719227192
retryPrimitiveOnFailure();
2719327193
if (GIV(nextProfileTick) > 0) {
27194-
checkProfileTickPostPrimitive(aPrimitiveMethod);
27194+
checkProfileTickPostPrimitive();
2719527195
}
2719627196
if (!GIV(primFailCode)) {
2719727197
result = longAt(GIV(stackPointer));
@@ -29397,9 +29397,9 @@ checkOkayFields(sqInt oop)
2939729397
the next check
2939829398
*/
2939929399

29400-
/* CoInterpreter>>#checkProfileTickPostPrimitive: */
29401-
static NoDbgRegParms NeverInline void
29402-
checkProfileTickPostPrimitive(sqInt aPrimitiveMethod)
29400+
/* CoInterpreter>>#checkProfileTickPostPrimitive */
29401+
static NeverInline void
29402+
checkProfileTickPostPrimitive(void)
2940329403
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
2940429404
sqInt objOop;
2940529405

@@ -29417,7 +29417,7 @@ checkProfileTickPostPrimitive(sqInt aPrimitiveMethod)
2941729417
GIV(profileMethod) = null;
2941829418
}
2941929419
else {
29420-
GIV(profileMethod) = aPrimitiveMethod;
29420+
GIV(profileMethod) = GIV(newMethod);
2942129421

2942229422
/* begin zeroNextProfileTick */
2942329423
GIV(nextProfileTick) = 0;
@@ -31767,7 +31767,7 @@ interpretMethodFromMachineCode(void)
3176731767
/* Don't fail if primitive has done something radical, e.g. perform:
3176831768
If we are profiling, take accurate primitive measures */
3176931769
if (GIV(nextProfileTick) > 0) {
31770-
checkProfileTickPostPrimitive(GIV(newMethod));
31770+
checkProfileTickPostPrimitive();
3177131771
}
3177231772

3177331773
/* successful */
@@ -38288,7 +38288,7 @@ primitiveEnterCriticalSection(void)
3828838288

3828938289
/* begin forProcessPrimitiveReturnToExecutivePostContextSwitch: */
3829038290
if (GIV(nextProfileTick) > 0) {
38291-
checkProfileTickPostPrimitive(GIV(newMethod));
38291+
checkProfileTickPostPrimitive();
3829238292
}
3829338293
returnToExecutivepostContextSwitch(inInterpreter, 1);
3829438294
}
@@ -38345,7 +38345,7 @@ primitiveExitCriticalSection(void)
3834538345
if (resumepreemptedYieldingIffrom(owningProcess, GIV(preemptionYields), CSExitCriticalSection)) {
3834638346
/* begin forProcessPrimitiveReturnToExecutivePostContextSwitch: */
3834738347
if (GIV(nextProfileTick) > 0) {
38348-
checkProfileTickPostPrimitive(GIV(newMethod));
38348+
checkProfileTickPostPrimitive();
3834938349
}
3835038350
returnToExecutivepostContextSwitch(inInterpreter, 1);
3835138351
}
@@ -39141,7 +39141,7 @@ primitiveResume(void)
3914139141
if (resumepreemptedYieldingIffrom(proc, GIV(preemptionYields), CSResume)) {
3914239142
/* begin forProcessPrimitiveReturnToExecutivePostContextSwitch: */
3914339143
if (GIV(nextProfileTick) > 0) {
39144-
checkProfileTickPostPrimitive(GIV(newMethod));
39144+
checkProfileTickPostPrimitive();
3914539145
}
3914639146
returnToExecutivepostContextSwitch(inInterpreter, 1);
3914739147
}
@@ -39166,7 +39166,7 @@ primitiveSignal(void)
3916639166
if (synchronousSignal(longAt(GIV(stackPointer)))) {
3916739167
/* begin forProcessPrimitiveReturnToExecutivePostContextSwitch: */
3916839168
if (GIV(nextProfileTick) > 0) {
39169-
checkProfileTickPostPrimitive(GIV(newMethod));
39169+
checkProfileTickPostPrimitive();
3917039170
}
3917139171
returnToExecutivepostContextSwitch(inInterpreter, 1);
3917239172
}
@@ -39254,7 +39254,7 @@ primitiveSuspend(void)
3925439254

3925539255
/* begin forProcessPrimitiveReturnToExecutivePostContextSwitch: */
3925639256
if (GIV(nextProfileTick) > 0) {
39257-
checkProfileTickPostPrimitive(GIV(newMethod));
39257+
checkProfileTickPostPrimitive();
3925839258
}
3925939259
returnToExecutivepostContextSwitch(inInterpreter, 1);
3926039260
return;
@@ -39329,7 +39329,7 @@ primitiveSuspendBackingUpV1(void)
3932939329

3933039330
/* begin forProcessPrimitiveReturnToExecutivePostContextSwitch: */
3933139331
if (GIV(nextProfileTick) > 0) {
39332-
checkProfileTickPostPrimitive(GIV(newMethod));
39332+
checkProfileTickPostPrimitive();
3933339333
}
3933439334
returnToExecutivepostContextSwitch(inInterpreter, 1);
3933539335
return;
@@ -39408,7 +39408,7 @@ primitiveSuspendBackingUpV2(void)
3940839408

3940939409
/* begin forProcessPrimitiveReturnToExecutivePostContextSwitch: */
3941039410
if (GIV(nextProfileTick) > 0) {
39411-
checkProfileTickPostPrimitive(GIV(newMethod));
39411+
checkProfileTickPostPrimitive();
3941239412
}
3941339413
returnToExecutivepostContextSwitch(inInterpreter, 1);
3941439414
return;
@@ -40361,7 +40361,7 @@ primitiveWait(void)
4036140361

4036240362
/* begin forProcessPrimitiveReturnToExecutivePostContextSwitch: */
4036340363
if (GIV(nextProfileTick) > 0) {
40364-
checkProfileTickPostPrimitive(GIV(newMethod));
40364+
checkProfileTickPostPrimitive();
4036540365
}
4036640366
returnToExecutivepostContextSwitch(inInterpreter, 1);
4036740367
}
@@ -40413,7 +40413,7 @@ primitiveYield(void)
4041340413

4041440414
/* begin forProcessPrimitiveReturnToExecutivePostContextSwitch: */
4041540415
if (GIV(nextProfileTick) > 0) {
40416-
checkProfileTickPostPrimitive(GIV(newMethod));
40416+
checkProfileTickPostPrimitive();
4041740417
}
4041840418
returnToExecutivepostContextSwitch(inInterpreter, 1);
4041940419
}
@@ -51279,7 +51279,6 @@ primitiveProfileStart(void)
5127951279
deltaTicks = longAt(GIV(stackPointer));
5128051280
if ((deltaTicks & 1)) {
5128151281
GIV(deferProfileCheckForVNCS) = 0;
51282-
GIV(profileProcess) = (GIV(profileMethod) = null);
5128351282
deltaTicks = (deltaTicks >> 1);
5128451283
GIV(nextProfileTick) = (deltaTicks > 0
5128551284
? (ioHighResClock()) + deltaTicks
@@ -77780,7 +77779,7 @@ bridgeFor(SpurSegmentInfo *aSegment)
7778077779
static NoDbgRegParms void
7778177780
bridgeFromto(SpurSegmentInfo *aSegment, SpurSegmentInfo *nextSegmentOrNil)
7778277781
{
77783-
sqInt bridgeSpan;
77782+
int bridgeSpan;
7778477783
sqInt clifton;
7778577784
usqInt segEnd;
7778677785

@@ -82468,13 +82467,14 @@ static sqInt
8246882467
getErrorObjectFromPrimFailCode(void)
8246982468
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
8247082469
sqInt classIndex;
82471-
sqInt clone;
82472-
sqInt errObj;
82470+
usqInt clone;
82471+
usqInt errObj;
8247382472
sqInt i;
8247482473
usqInt newObj;
8247582474
usqInt numBytes;
8247682475
usqInt numSlots;
8247782476
usqInt numSlotsUsqInt;
82477+
sqInt objOop;
8247882478
sqInt table;
8247982479
sqInt valuePointer;
8248082480

@@ -82486,12 +82486,13 @@ getErrorObjectFromPrimFailCode(void)
8248682486
? longAt((void *)(table - BaseHeaderSize))
8248782487
: numSlots)))) {
8248882488
/* begin followField:ofObject: */
82489-
errObj = longAt((void *)((table + BaseHeaderSize) + ((((usqInt)((GIV(primFailCode) - 1)) << (shiftForWord()))))));
82489+
objOop = longAt((void *)((table + BaseHeaderSize) + ((((usqInt)((GIV(primFailCode) - 1)) << (shiftForWord()))))));
8249082490
if (/* isOopForwarded: */
82491-
((!(errObj & (tagMask()))))
82492-
&& ((!((longAt((void *)(errObj))) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) {
82493-
errObj = fixFollowedFieldofObjectwithInitialValue(GIV(primFailCode) - 1, table, errObj);
82491+
((!(objOop & (tagMask()))))
82492+
&& ((!((longAt((void *)(objOop))) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) {
82493+
objOop = fixFollowedFieldofObjectwithInitialValue(GIV(primFailCode) - 1, table, objOop);
8249482494
}
82495+
errObj = objOop;
8249582496

8249682497
/* If there's a clonable object in the table at that index,
8249782498
answer a clone of the error object with the second slot set to the value of secondaryErrorCode. */
@@ -90442,7 +90443,7 @@ slowPrimitiveResponse(void)
9044290443
/* Don't fail if primitive has done something radical, e.g. perform:
9044390444
If we are profiling, take accurate primitive measures */
9044490445
if (GIV(nextProfileTick) > 0) {
90445-
checkProfileTickPostPrimitive(GIV(newMethod));
90446+
checkProfileTickPostPrimitive();
9044690447
}
9044790448
return !GIV(primFailCode);
9044890449
}

src/spur32.cog.lowcode/cointerp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Automatically generated by
2-
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3680 uuid: a9ad06c5-1c8d-4efc-b2a6-1516f7d64803
2+
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3681 uuid: 84bd780d-3a40-4927-9642-e7af19ce89b5
33
(Cog-eem.504, * Compiler-nice.525)
44
*/
55

0 commit comments

Comments
 (0)