diff --git a/engine262/lib-src/node/verify-ask262-debug.mts b/engine262/lib-src/node/verify-ask262-debug.mts index d25c3f1..7db4c64 100644 --- a/engine262/lib-src/node/verify-ask262-debug.mts +++ b/engine262/lib-src/node/verify-ask262-debug.mts @@ -41,6 +41,7 @@ realm.scope(() => { skipDebugger(CreateDataProperty(debugObj, Value('stopImportant'), stopImportant)); }); +ask262Debug.startTrace(); realm.evaluateScript(` // Array.prototype.every - should hit sec-array.prototype.every ask262Debug.startImportant(); @@ -50,6 +51,7 @@ realm.evaluateScript(` // Proxy creation - should hit sec-proxycreate or similar new Proxy({}, {}); `); +ask262Debug.stopTrace(); // 3. Verify marks were captured console.log('3. Checking marks...'); @@ -61,6 +63,18 @@ if (marks.length === 0) { process.exit(1); } +// 3a. Assert that Array.prototype.every section is found and marked important +const everyMark = marks.find((m) => m.sectionIds.some((id) => id.includes('array.prototype.every'))); +if (!everyMark) { + console.error('FAIL: sec-array.prototype.every not found in marks'); + process.exit(1); +} +if (!everyMark.important) { + console.error('FAIL: sec-array.prototype.every found but not marked as important'); + process.exit(1); +} +console.log(' ✓ Found sec-array.prototype.every (marked as important)\n'); + // 4. Show sample marks console.log('4. Sample marks:'); marks.slice(0, 5).forEach((m, i) => { diff --git a/engine262/src/ask262-debug.mts b/engine262/src/ask262-debug.mts index a5ecc3b..eaacbad 100644 --- a/engine262/src/ask262-debug.mts +++ b/engine262/src/ask262-debug.mts @@ -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(); @@ -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.