Skip to content

fix(runtime): apply source maps to CPU profiler output#32634

Merged
bartlomieju merged 3 commits intodenoland:mainfrom
bartlomieju:fix/cpu-prof-source-maps
Mar 15, 2026
Merged

fix(runtime): apply source maps to CPU profiler output#32634
bartlomieju merged 3 commits intodenoland:mainfrom
bartlomieju:fix/cpu-prof-source-maps

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

  • Apply source maps to CPU profile call frames before writing, so --cpu-prof reports original TypeScript line/column numbers instead of transpiled JavaScript positions
  • Reuses the existing SourceMapper infrastructure from deno_core (same one used for error stack traces)
  • Exports SourceMapper and SourceMapApplication from deno_core and adds a JsRuntime::source_mapper() accessor

Closes #32626

Test plan

  • Added spec test tests/specs/cpu_prof/source_map/ that profiles a TypeScript file and verifies the output has .ts URLs with valid source-mapped line numbers
  • Existing CPU profiler tests continue to pass
  • Manually verified with a TypeScript file containing const enum (which gets erased during transpilation) — line numbers correctly point to original .ts source positions

🤖 Generated with Claude Code

The `--cpu-prof` flag was reporting transpiled JavaScript line numbers
instead of original TypeScript source positions. This applies source maps
to the profile's call frames before writing, reusing the existing
SourceMapper infrastructure from deno_core.

Closes denoland#32626

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

LGTM

bartlomieju and others added 2 commits March 15, 2026 14:31
Main refactored runtime/cpu_profiler.rs into runtime/cpu_profiler/ module
directory. Applied the source map changes from this PR to the new mod.rs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju enabled auto-merge (squash) March 15, 2026 15:06
@bartlomieju bartlomieju merged commit 24bc84e into denoland:main Mar 15, 2026
112 checks passed
@bartlomieju bartlomieju deleted the fix/cpu-prof-source-maps branch March 15, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--cpu-prof wrong line numbers

2 participants