Skip to content

feat: assign auto-incremented ids to anonynous functions to identify them in vm trace#4754

Open
ashddev wants to merge 1 commit intoboa-dev:mainfrom
ashddev:feature/4742-id-anonymous-funcs-in-vm-trace
Open

feat: assign auto-incremented ids to anonynous functions to identify them in vm trace#4754
ashddev wants to merge 1 commit intoboa-dev:mainfrom
ashddev:feature/4742-id-anonymous-funcs-in-vm-trace

Conversation

@ashddev
Copy link

@ashddev ashddev commented Feb 27, 2026

This Pull Request closes #4742

It changes the following:

  • Adds an empty anon_debug_id to CodeBlocks.
  • Assigns IDs to anonymous function codeblocks when their frame is pushed onto the call stack.
  • Displays anonymous function IDs in the compiled output and call frame titles during tracing.

This is my first contribution to Boa, and I’m happy to make any changes based on feedback :)

@ashddev ashddev requested a review from a team as a code owner February 27, 2026 21:41
@github-actions
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 52,862 52,862 0
Passed 49,504 49,504 0
Ignored 2,262 2,262 0
Failed 1,096 1,096 0
Panics 0 0 0
Conformance 93.65% 93.65% 0.00%

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice contribution! We can simplify this a bit more with a thread local counter.

Comment on lines +183 to +184
#[cfg(feature = "trace")]
anon_debug_id: Cell::new(None),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say for simplicitly's sake, we can just assign a incremental ID to every CodeBlock on the same thread. We do something very similar in Context:

thread_local! {
static CANNOT_BLOCK_COUNTER: Cell<u64> = const { Cell::new(0) };
}

CANNOT_BLOCK_COUNTER.set(CANNOT_BLOCK_COUNTER.get() + 1);

Since any CodeBlock can be executed by any Context but CodeBlock's cannot be sent between threads, a thread local counter should be enough for this purpose.

@jedel1043 jedel1043 added enhancement New feature or request vm Issues and PRs related to the Boa Virtual Machine. labels Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request vm Issues and PRs related to the Boa Virtual Machine.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make anonymous functions identifiable in VM trace

2 participants