Closed Bug 1670238 Opened 4 years ago Closed 4 years ago

Reduce amount of script compile needed for line-based breakpoints in JS debugger

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: tcampbell, Assigned: arai)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

In Bug 1623761 we now avoid delazifying the entire debuggee realm when a findScripts({line, ...}) query is made and instead delazify in a targeted way. This bug is about improving the precision of this to reduce compiles further.

The root issue is that end-line is not known for lazy scripts and so we must compile the script to accurately compute line number filters. At the same time, there are other fields in SourceExtent that are known even for lazy scripts that could be used to further avoid delazifications that will not match.

An example of how this might be achieved is to track the maximum sourceStart we observe of any BaseScript who's initial line number is greater than target line number. This could then be used to avoid compiling lazy scripts that have a larger sourceStart.
(EDIT: I think I have the start/end stuff completely backwards here. Just more indication that care should be taken...)

Some edge cases to consider:

  • multiple functions on target line
  • functions that start before but match, and then end after but match
  • class constructors have a toString range of whole class
  • functions in arguments function f(a = (() => 0)) {}
  • functions in computed property names let o = { [(() => "a")()]() {} };

Careful asserts are probably needed to detect changes in our underlying assumptions since bugs here usually just translate into intermittent debugger problems for users.

Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Depends on: 1670510

Each script for target source has a SourceExtent that represents the source
start as both an offset and a line/column value. We use these mappings to
compute a lower-bound on the source offset of a target line when performing
findScripts. This lower bound lets us quickly eliminate candidate scripts
without needing to compile their bytecode and inspect SrcNotes.

Depends on D93177

Attachment #9181195 - Attachment is obsolete: true

The result of this change is that findScripts will delazify at most 1 non-matching script which is a nice improvement.

Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1bd440c12538
Do not delazify if sourceEnd is definitely before the specified line in findScript. r=arai
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: