summaryrefslogtreecommitdiff
path: root/deps/v8/tools/logreader.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/tools/logreader.mjs')
-rw-r--r--deps/v8/tools/logreader.mjs27
1 files changed, 24 insertions, 3 deletions
diff --git a/deps/v8/tools/logreader.mjs b/deps/v8/tools/logreader.mjs
index e4d8b4d057..339017c488 100644
--- a/deps/v8/tools/logreader.mjs
+++ b/deps/v8/tools/logreader.mjs
@@ -35,6 +35,16 @@
export function parseString(field) { return field };
export const parseVarArgs = 'parse-var-args';
+// Checks fields for numbers that are not safe integers. Returns true if any are
+// found.
+function containsUnsafeInts(fields) {
+ for (let i = 0; i < fields.length; i++) {
+ let field = fields[i];
+ if ('number' == typeof(field) && !Number.isSafeInteger(field)) return true;
+ }
+ return false;
+}
+
/**
* Base class for processing log files.
*
@@ -44,7 +54,7 @@ export const parseVarArgs = 'parse-var-args';
* @constructor
*/
export class LogReader {
- constructor(timedRange=false, pairwiseTimedRange=false) {
+ constructor(timedRange=false, pairwiseTimedRange=false, useBigInt=false) {
this.dispatchTable_ = new Map();
this.timedRange_ = timedRange;
this.pairwiseTimedRange_ = pairwiseTimedRange;
@@ -54,6 +64,11 @@ export class LogReader {
// Variables for tracking of 'current-time' log entries:
this.hasSeenTimerMarker_ = false;
this.logLinesSinceLastTimerMarker_ = [];
+ // Flag to parse all numeric fields as BigInt to avoid arithmetic errors
+ // caused by memory addresses being greater than MAX_SAFE_INTEGER
+ this.useBigInt = useBigInt;
+ this.parseFrame = useBigInt ? BigInt : parseInt;
+ this.hasSeenUnsafeIntegers = false;
}
/**
@@ -180,11 +195,11 @@ export class LogReader {
const firstChar = frame[0];
if (firstChar === '+' || firstChar === '-') {
// An offset from the previous frame.
- prevFrame += parseInt(frame, 16);
+ prevFrame += this.parseFrame(frame);
fullStack.push(prevFrame);
// Filter out possible 'overflow' string.
} else if (firstChar !== 'o') {
- fullStack.push(parseInt(frame, 16));
+ fullStack.push(this.parseFrame(frame));
} else {
console.error(`Dropping unknown tick frame: ${frame}`);
}
@@ -216,6 +231,12 @@ export class LogReader {
parsedFields[i] = parser(fields[1 + i]);
}
}
+ if (!this.useBigInt) {
+ if (!this.hasSeenUnsafeIntegers && containsUnsafeInts(parsedFields)) {
+ console.warn(`Log line containts unsafe integers: ${fields}`);
+ this.hasSeenUnsafeIntegers = true;
+ }
+ }
// Run the processor.
await dispatch.processor(...parsedFields);
}