mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
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:
@@ -41,6 +41,7 @@ realm.scope(() => {
|
|||||||
skipDebugger(CreateDataProperty(debugObj, Value('stopImportant'), stopImportant));
|
skipDebugger(CreateDataProperty(debugObj, Value('stopImportant'), stopImportant));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ask262Debug.startTrace();
|
||||||
realm.evaluateScript(`
|
realm.evaluateScript(`
|
||||||
// Array.prototype.every - should hit sec-array.prototype.every
|
// Array.prototype.every - should hit sec-array.prototype.every
|
||||||
ask262Debug.startImportant();
|
ask262Debug.startImportant();
|
||||||
@@ -50,6 +51,7 @@ realm.evaluateScript(`
|
|||||||
// Proxy creation - should hit sec-proxycreate or similar
|
// Proxy creation - should hit sec-proxycreate or similar
|
||||||
new Proxy({}, {});
|
new Proxy({}, {});
|
||||||
`);
|
`);
|
||||||
|
ask262Debug.stopTrace();
|
||||||
|
|
||||||
// 3. Verify marks were captured
|
// 3. Verify marks were captured
|
||||||
console.log('3. Checking marks...');
|
console.log('3. Checking marks...');
|
||||||
@@ -61,6 +63,18 @@ if (marks.length === 0) {
|
|||||||
process.exit(1);
|
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
|
// 4. Show sample marks
|
||||||
console.log('4. Sample marks:');
|
console.log('4. Sample marks:');
|
||||||
marks.slice(0, 5).forEach((m, i) => {
|
marks.slice(0, 5).forEach((m, i) => {
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ class Ask262Debug {
|
|||||||
/** Whether to mark new entries as important */
|
/** Whether to mark new entries as important */
|
||||||
private _important = false;
|
private _important = false;
|
||||||
|
|
||||||
|
/** Whether capture is enabled (controlled by startTrace/stopTrace) */
|
||||||
|
private _captureEnabled = false;
|
||||||
|
|
||||||
/** Map from deduplication key to index in marks array */
|
/** Map from deduplication key to index in marks array */
|
||||||
private _markIndex = new Map<string, number>();
|
private _markIndex = new Map<string, number>();
|
||||||
|
|
||||||
@@ -47,11 +50,16 @@ class Ask262Debug {
|
|||||||
* Records a mark for spec section entry during execution.
|
* Records a mark for spec section entry during execution.
|
||||||
* Deduplicates based on (sectionIds, file, line) combination.
|
* Deduplicates based on (sectionIds, file, line) combination.
|
||||||
* If duplicate found, merges important flags (OR logic).
|
* 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 sectionIds - Array of ECMAScript spec section IDs
|
||||||
* @param file - Relative file path from engine262/src/
|
* @param file - Relative file path from engine262/src/
|
||||||
* @param line - Line number in source file (1-indexed)
|
* @param line - Line number in source file (1-indexed)
|
||||||
*/
|
*/
|
||||||
mark(sectionIds: string[], file: string, line: number) {
|
mark(sectionIds: string[], file: string, line: number) {
|
||||||
|
if (!this._captureEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const key = this._makeKey(sectionIds, file, line);
|
const key = this._makeKey(sectionIds, file, line);
|
||||||
const existingIndex = this._markIndex.get(key);
|
const existingIndex = this._markIndex.get(key);
|
||||||
|
|
||||||
@@ -75,6 +83,22 @@ class Ask262Debug {
|
|||||||
this.marks.push(newMark);
|
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.
|
* Marks subsequent mark() calls as important.
|
||||||
* Used to annotate interesting execution phases.
|
* Used to annotate interesting execution phases.
|
||||||
|
|||||||
Reference in New Issue
Block a user