Skip to content

Commit f649ff7

Browse files
dckckriskowal
authored andcommitted
feat(xsnap): meter garbageCollectionCount
1 parent 5a35842 commit f649ff7

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

packages/xsnap/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/** The version identifier for our meter type.
44
* TODO Bump this whenever there's a change to metering semantics.
55
*/
6-
export const METER_TYPE = 'xs-meter-3';
6+
export const METER_TYPE = 'xs-meter-4';
77

88
export const ExitCode = {
99
E_UNKNOWN_ERROR: -1,

packages/xsnap/src/xsnap.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1400,13 +1400,15 @@ static char* fxReadNetStringError(int code)
14001400

14011401
static int fxWriteOkay(FILE* outStream, xsUnsignedValue meterIndex, txMachine *the, char* buf, size_t length)
14021402
{
1403-
char fmt[] = ".{\"compute\":%u,\"allocate\":%u,\"allocateChunksCalls\":%u,\"allocateSlotsCalls\":%u}\1";
1403+
char fmt[] = ".{\"compute\":%u,\"allocate\":%u,\"allocateChunksCalls\":%u,\"allocateSlotsCalls\":%u,\"garbageCollectionCount\":%u}\1";
14041404
char numeral64[] = "12345678901234567890"; // big enough for 64bit numeral
14051405
char prefix[8 + sizeof fmt + 4 * sizeof numeral64];
14061406
// TODO: fxCollect counter
14071407
// Prepend the meter usage to the reply.
14081408
snprintf(prefix, sizeof(prefix) - 1, fmt,
1409-
meterIndex, the->allocatedSpace, the->allocateChunksCallCount, the->allocateSlotsCallCount);
1409+
meterIndex, the->allocatedSpace,
1410+
the->allocateChunksCallCount, the->allocateSlotsCallCount,
1411+
the->garbageCollectionCount);
14101412
return fxWriteNetString(outStream, prefix, buf, length);
14111413
}
14121414

packages/xsnap/src/xsnap.h

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
txSize allocatedSpace; \
7272
txUnsigned allocateChunksCallCount; \
7373
txUnsigned allocateSlotsCallCount; \
74+
txUnsigned garbageCollectionCount; \
7475
int promiseJobs; \
7576
void* timerJobs; \
7677
void* waiterCondition; \

packages/xsnap/test/test-xsnap.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,15 @@ test('meter details', async t => {
521521
meterUsage: { meterType, ...meters },
522522
} = result;
523523
t.log(meters);
524-
t.is(meterType, 'xs-meter-3');
524+
t.is(meterType, 'xs-meter-4');
525525
const { entries, fromEntries } = Object;
526526
t.deepEqual(
527527
{
528528
compute: 'number',
529529
allocate: 'number',
530530
allocateChunksCalls: 'number',
531531
allocateSlotsCalls: 'number',
532+
garbageCollectionCount: 'number',
532533
},
533534
fromEntries(entries(meters).map(([p, v]) => [p, typeof v])),
534535
);

0 commit comments

Comments
 (0)