feat: add startTrace/stopTrace to control mark capture

Implemented a capture flag in `Ask262Debug` to enable/disable marking.
- Added `_captureEnabled` property and related logic in `mark()`.
- Introduced `startTrace()` and `stopTrace()` methods to toggle capture.
- Updated verification script to start tracing, run tests, stop tracing, and assert that the `Array.prototype.every` section is captured and marked important.
This commit is contained in:
2026-04-08 16:03:09 +05:30
parent b73035a4d3
commit aa9c875006
2 changed files with 38 additions and 0 deletions
+24
View File
@@ -29,6 +29,9 @@ class Ask262Debug {
/** Whether to mark new entries as important */
private _important = false;
/** Whether capture is enabled (controlled by startTrace/stopTrace) */
private _captureEnabled = false;
/** Map from deduplication key to index in marks array */
private _markIndex = new Map<string, number>();
@@ -47,11 +50,16 @@ class Ask262Debug {
* Records a mark for spec section entry during execution.
* Deduplicates based on (sectionIds, file, line) combination.
* If duplicate found, merges important flags (OR logic).
* Only captures if tracing is enabled (via startTrace()).
* @param sectionIds - Array of ECMAScript spec section IDs
* @param file - Relative file path from engine262/src/
* @param line - Line number in source file (1-indexed)
*/
mark(sectionIds: string[], file: string, line: number) {
if (!this._captureEnabled) {
return;
}
const key = this._makeKey(sectionIds, file, line);
const existingIndex = this._markIndex.get(key);
@@ -75,6 +83,22 @@ class Ask262Debug {
this.marks.push(newMark);
}
/**
* Enables capture of marks during execution.
* Marks will be recorded until stopTrace() is called.
*/
startTrace() {
this._captureEnabled = true;
}
/**
* Disables capture of marks during execution.
* Marks will be ignored until startTrace() is called again.
*/
stopTrace() {
this._captureEnabled = false;
}
/**
* Marks subsequent mark() calls as important.
* Used to annotate interesting execution phases.