Skip to content

Commit

Permalink
feat: add support for v8 version 10+ (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
dios-david authored Dec 7, 2022
1 parent f54c1ef commit 9977181
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,31 @@ const optional = require('optional');

const gc = optional('gc-stats');

const gcTypes = {
0: 'Unknown',
1: 'Scavenge',
2: 'MarkSweepCompact',
3: 'ScavengeAndMarkSweepCompact',
4: 'IncrementalMarking',
8: 'WeakPhantom',
15: 'All',
};
const v8Version = process.versions.v8;
const v8MajorVersion = Number(v8Version.split('.')[0]);

const gcTypes =
v8MajorVersion < 10
? {
// https://github.com/nodejs/node/blob/554fa24916c5c6d052b51c5cee9556b76489b3f7/deps/v8/include/v8.h#L6137-L6144
0: 'Unknown',
1: 'Scavenge',
2: 'MarkSweepCompact',
3: 'ScavengeAndMarkSweepCompact',
4: 'IncrementalMarking',
8: 'WeakPhantom',
15: 'All',
}
: {
// https://github.com/nodejs/node/blob/ccd3a42dd9ea2132111610e667ee338618e3b101/deps/v8/include/v8-callbacks.h#L150-L159
0: 'Unknown',
1: 'Scavenge',
2: 'MinorMarkCompact',
4: 'MarkSweepCompact',
8: 'IncrementalMarking',
16: 'ProcessWeakCallbacks',
31: 'All',
};

const noop = () => {};

Expand Down

0 comments on commit 9977181

Please sign in to comment.