Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.3324
Browse files Browse the repository at this point in the history
Implement SpurSegmentManager>>segmentContainingObj: via binary search
for the benefit of the IGC.

Access Spur oldSpaceSize via totalHeapSizeIncludingBridges.
Have SpurSegmentManager>>totalBytesInSegments do the counting.
Use this in the accessors for total memory size,
SpurSegmentManager>>totalOldSpaceCapacity/totalOldSpaceSize.

Include the receiver when short printing a context, for more information
in the context parts of stack dumps (printCallStack et al).

Have the ImageSegment storage primitive fail with an error code for bad
arguments detected at the outermost level.  Include more failure cases
in SpurMemoryManager>>#storeImageSegmentInto:outPointers:roots:'s comment.

Fix some printf format warnings.
  • Loading branch information
eliotmiranda committed Apr 24, 2023
1 parent 3208ef3 commit ca960de
Show file tree
Hide file tree
Showing 46 changed files with 5,616 additions and 3,582 deletions.
2 changes: 1 addition & 1 deletion src/spur32.cog.lowcode/cogit.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3308 uuid: 9a6ed9b2-78a0-4b41-81e0-6993219f3dc7
CCodeGenerator VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
*/


Expand Down
398 changes: 245 additions & 153 deletions src/spur32.cog.lowcode/cointerp.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/spur32.cog.lowcode/cointerp.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3307 uuid: bea33bb5-98d1-4d1a-8004-40be76e0b94c
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
*/


Expand Down
398 changes: 245 additions & 153 deletions src/spur32.cog.lowcode/gcc3x-cointerp.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/spur32.cog/cogit.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3308 uuid: 9a6ed9b2-78a0-4b41-81e0-6993219f3dc7
CCodeGenerator VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
*/


Expand Down
392 changes: 242 additions & 150 deletions src/spur32.cog/cointerp.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/spur32.cog/cointerp.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3307 uuid: bea33bb5-98d1-4d1a-8004-40be76e0b94c
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
*/


Expand Down
402 changes: 247 additions & 155 deletions src/spur32.cog/cointerpmt.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/spur32.cog/cointerpmt.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3307 uuid: bea33bb5-98d1-4d1a-8004-40be76e0b94c
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
*/


Expand Down
392 changes: 242 additions & 150 deletions src/spur32.cog/gcc3x-cointerp.c

Large diffs are not rendered by default.

402 changes: 247 additions & 155 deletions src/spur32.cog/gcc3x-cointerpmt.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/spur32.sista/cogit.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3308 uuid: 9a6ed9b2-78a0-4b41-81e0-6993219f3dc7
CCodeGenerator VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
*/


Expand Down
388 changes: 240 additions & 148 deletions src/spur32.sista/cointerp.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/spur32.sista/cointerp.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3307 uuid: bea33bb5-98d1-4d1a-8004-40be76e0b94c
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
*/


Expand Down
388 changes: 240 additions & 148 deletions src/spur32.sista/gcc3x-cointerp.c

Large diffs are not rendered by default.

280 changes: 164 additions & 116 deletions src/spur32.stack.lowcode/gcc3x-interp.c

Large diffs are not rendered by default.

280 changes: 164 additions & 116 deletions src/spur32.stack.lowcode/interp.c

Large diffs are not rendered by default.

280 changes: 164 additions & 116 deletions src/spur32.stack/gcc3x-interp.c

Large diffs are not rendered by default.

280 changes: 164 additions & 116 deletions src/spur32.stack/interp.c

Large diffs are not rendered by default.

120 changes: 100 additions & 20 deletions src/spur32.stack/validImage.c
@@ -1,9 +1,9 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3307 uuid: bea33bb5-98d1-4d1a-8004-40be76e0b94c
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
from
ImageLeakChecker VMMaker.oscog-eem.3307 uuid: bea33bb5-98d1-4d1a-8004-40be76e0b94c
ImageLeakChecker VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
*/
static char __buildInfo[] = "ImageLeakChecker VMMaker.oscog-eem.3307 uuid: bea33bb5-98d1-4d1a-8004-40be76e0b94c " __DATE__ ;
static char __buildInfo[] = "ImageLeakChecker VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464 " __DATE__ ;
char *__interpBuildInfo = __buildInfo;


Expand Down Expand Up @@ -538,6 +538,7 @@ static sqInt NoDbgRegParms popObjStack(sqInt objStack);
extern sqInt popRemappableOop(void);
static void NoDbgRegParms postBecomeScanClassTable(sqInt effectsFlags);
extern sqInt primitiveErrorTable(void);
static void NoDbgRegParms printBridgeon(sqInt oop, FILE *aStream);
static void NoDbgRegParms printCantBeObjecton(sqInt oop, FILE *aStream);
static void NoDbgRegParms printForwarderon(sqInt oop, FILE *aStream);
extern void printFreeChunks(void);
Expand Down Expand Up @@ -610,13 +611,15 @@ static sqInt NoDbgRegParms bridgeAt(sqInt segIndex);
static sqInt NoDbgRegParms bridgeFor(SpurSegmentInfo *aSegment);
static void checkSegments(void);
static void collapseSegmentsPostSwizzle(void);
static void computeTotalHeapSizeIncludingBridges(void);
static sqInt NoDbgRegParms isInSegments(usqInt address);
static sqInt NoDbgRegParms isValidSegmentBridge(sqInt objOop);
static SpurSegmentInfo lastSegment(void);
static sqInt NoDbgRegParms readHeapFromImageFiledataBytes(sqImageFile f, sqInt numBytes);
extern SpurSegmentInfo * segmentContainingObj(sqInt objOop);
static sqInt someSegmentContainsPinned(void);
static sqInt NoDbgRegParms swizzleObj(sqInt objOop);
static usqInt totalBytesInSegments(void);
static sqInt totalOldSpaceCapacity(void);
static sqInt NoDbgRegParms addressCouldBeClassObj(sqInt maybeClassObj);
extern sqInt argumentCountOfMethodHeader(sqInt header);
Expand Down Expand Up @@ -732,6 +735,7 @@ _iss sqInt trueObj;
_iss sqInt edenBytes;
_iss usqInt freeOldSpaceStart;
_iss sqInt firstSegmentSize;
_iss usqInt totalHeapSizeIncludingBridges;
_iss sqInt becomeEffectsFlags;
_iss sqInt canSwizzle;
_iss sqInt futureSurvivorStart;
Expand All @@ -747,7 +751,6 @@ _iss sqInt oldHeapBase;
_iss sqInt oldHeapLimit;
_iss char * stackLimit;
_iss sqInt subsequentReport;
_iss usqInt totalHeapSizeIncludingBridges;
_iss sqInt biasForGC;
_iss sqInt fullScreenFlag;
_iss sqInt newFinalization;
Expand Down Expand Up @@ -819,7 +822,6 @@ _iss usqInt objectAfterLastMobileObject;
_iss StackPage * overflowedPage;
_iss sqInt pendingFinalizationSignals;
_iss sqInt preemptionYields;
_iss sqInt preferredPinningSegment;
_iss sqInt previousRememberedSetSize;
_iss sqInt profileMethod;
_iss sqInt profileProcess;
Expand All @@ -843,7 +845,6 @@ _iss sqInt statRootTableOverflows;
_iss sqInt statShrinkMemory;
_iss sqInt statSurvivorCount;
_iss sqInt statTenures;
_iss sqInt sweepIndex;
_iss sqInt tempOop;
_iss sqInt tempOop2;
_iss sqInt tenureCriterion;
Expand Down Expand Up @@ -951,7 +952,7 @@ sqInt extraVMMemory;
sqInt ffiExceptionResponse;
sqInt inIOProcessEvents;
struct VirtualMachine* interpreterProxy;
const char *interpreterVersion = "Open Smalltalk ImageChecker VM [ImageLeakChecker VMMaker.oscog-eem.3307]";
const char *interpreterVersion = "Open Smalltalk ImageChecker VM [ImageLeakChecker VMMaker.oscog-eem.3324]";
sqInt suppressHeartbeatFlag;
char expensiveAsserts = 0;
volatile int sendTrace;
Expand Down Expand Up @@ -2580,7 +2581,7 @@ initializeRememberedSet(void)
else {

/* The Spur32to64BitBootstrap failed to set the type of rememberedSetObj to 64-bit indexability.
This is unimportant except for simulation; rememberedSet is declared as sqInt *, but in to have
This is unimportant except for simulation; rememberedSet is declared as sqInt *, but to have
firstIndexableField: below answer a suitable type the format must be wordIndexableFormat. */
setFormatOfto(obj, wordIndexableFormat());
}
Expand Down Expand Up @@ -3225,6 +3226,7 @@ allocatePinnedSlots(sqInt nSlots)

obj = allocateSlotsForPinningInOldSpacebytesformatclassIndex(nSlots, objectBytesForSlots(nSlots), wordIndexableFormat(), wordSizeClassIndexPun());
if (!(obj == null)) {
assert(isPinned(obj));
/* begin fillObj:numSlots:with: */
assert(oopisLessThan(((obj + BaseHeaderSize) + (nSlots * BytesPerOop)) - 1, addressAfter(obj)));
for (p = (((usqInt)(obj + BaseHeaderSize))); p <= (((usqInt)(((obj + BaseHeaderSize) + (nSlots * BytesPerOop)) - 1))); p += (allocationUnit())) {
Expand Down Expand Up @@ -8455,15 +8457,33 @@ primitiveErrorTable(void)
return fetchPointerofObject(PrimitiveErrorTableIndex, GIV(specialObjectsOop));
}

/* SpurMemoryManager>>#printBridge:on: */
static void NoDbgRegParms
printBridgeon(sqInt oop, FILE *aStream)
{
fprintf(aStream,
"%p is a bridge hdr%d slot size %ul\n",
((void *)oop),
(hasOverflowHeader(oop)
? 16
: 8),
numSlotsOfAny(oop));
}

/* SpurMemoryManager>>#printCantBeObject:on: */
static void NoDbgRegParms
printCantBeObjecton(sqInt oop, FILE *aStream)
{
if (((oop & ((allocationUnit()) - 1)) == 0)
&& ((isInNewSpace(oop))
&& ((!((longAt(oop)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun()))))))) {
printForwarderon(oop, aStream);
return;
if ((oop & ((allocationUnit()) - 1)) == 0) {
if ((isInNewSpace(oop))
&& ((!((longAt(oop)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) {
printForwarderon(oop, aStream);
return;
}
if (oop == (bridgeAt((numSegments()) - 1))) {
printBridgeon(oop, aStream);
return;
}
}
fprintf(aStream,
"%p%s\n",
Expand All @@ -8478,7 +8498,7 @@ static void NoDbgRegParms
printForwarderon(sqInt oop, FILE *aStream)
{
fprintf(aStream,
"%p is a forwarded hdr%d slot size %ud object to %p\n",
"%p is a forwarded hdr%d slot size %ul object to %p\n",
((void *)oop),
(hasOverflowHeader(oop)
? 16
Expand Down Expand Up @@ -10260,13 +10280,21 @@ collapseSegmentsPostSwizzle(void)

GIV(canSwizzle) = 0;
GIV(numSegments) = 1;
computeTotalHeapSizeIncludingBridges();
cascade0 = (&(GIV(segments)[0]));
(cascade0->segStart = oldSpaceStart());
(cascade0->segSize = (GIV(totalHeapSizeIncludingBridges) = (endOfMemory()) - (oldSpaceStart())));
(cascade0->segSize = GIV(totalHeapSizeIncludingBridges));
assert(isSegmentBridge(bridgeAt(0)));
assert((numSlotsOfAny(bridgeAt(0))) == 0);
}

/* SpurSegmentManager>>#computeTotalHeapSizeIncludingBridges */
static void
computeTotalHeapSizeIncludingBridges(void)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
GIV(totalHeapSizeIncludingBridges) = (endOfMemory()) - (oldSpaceStart());
}

/* SpurSegmentManager>>#isInSegments: */
static sqInt NoDbgRegParms
isInSegments(usqInt address)
Expand Down Expand Up @@ -10370,17 +10398,51 @@ readHeapFromImageFiledataBytes(sqImageFile f, sqInt numBytes)
return totalBytesRead;
}


/* Answer the segment containing an object. This is mostly for assert
checking, but
variations on the incremental GC may use it in anger. Binary search is (of
course) marginally slower than linear search for a single segment (e.g. in
a 720k object heap,
67.1ms vs 61.3ms, or 9.5% slower to derive the segment containing every
old space
entity), but usefully faster for many segments (e.g. 92.7ms vs 116ms, or
20% faster
in the same heap extended with enough large arrays to require 11 segments;
and this
is pessimal; there are fewer objects at high addresses since the large
arrays are there). */

/* SpurSegmentManager>>#segmentContainingObj: */
SpurSegmentInfo *
segmentContainingObj(sqInt objOop)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt i;
sqInt high;
sqInt low;
sqInt mid;
SpurSegmentInfo *seg;

for (i = (GIV(numSegments) - 1); i >= 0; i += -1) {
if (objOop >= (((GIV(segments)[i]).segStart))) {
return (&(GIV(segments)[i]));
low = 0;
mid = GIV(numSegments) / 2;
high = GIV(numSegments) - 1;
do {
seg = (&(GIV(segments)[mid]));
if (oopisGreaterThanOrEqualTo(objOop, (seg->segStart))) {
if (mid == high) {
return (oopisLessThan(objOop, segLimit(seg))
? seg
: 0);
}
else {
low = mid;
mid = ((mid + high) + 1) / 2;
}
}
}
else {
high = mid - 1;
mid = (low + mid) / 2;
}
} while(low <= high);
return null;
}

Expand Down Expand Up @@ -10413,10 +10475,28 @@ swizzleObj(sqInt objOop)
return objOop + (((GIV(segments)[0]).swizzle));
}


/* This ``slow'' count is for asserts only. */

/* SpurSegmentManager>>#totalBytesInSegments */
static usqInt
totalBytesInSegments(void)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt i;
usqInt total;

total = 0;
for (i = 0; i < GIV(numSegments); i += 1) {
total += ((GIV(segments)[i]).segSize);
}
return total;
}

/* SpurSegmentManager>>#totalOldSpaceCapacity */
static sqInt
totalOldSpaceCapacity(void)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
assert((totalBytesInSegments()) == GIV(totalHeapSizeIncludingBridges));
return GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (bridgeSize()));
}

Expand Down
2 changes: 1 addition & 1 deletion src/spur64.cog.lowcode/cogit.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.3308 uuid: 9a6ed9b2-78a0-4b41-81e0-6993219f3dc7
CCodeGenerator VMMaker.oscog-eem.3324 uuid: 1377b9b5-9ae2-4164-8ebd-a4ace3630464
*/


Expand Down

0 comments on commit ca960de

Please sign in to comment.