Closed Bug 1623761 Opened 9 months ago Closed 2 months ago

Remove Debugger::QueryScript::delazifyScripts()


(Core :: JavaScript Engine, task, P3)




83 Branch
Tracking Status
firefox83 --- fixed


(Reporter: tcampbell, Assigned: tcampbell)




(3 files)

Due to syntax parsing, we may have js::BaseScript instances without full
bytecode. (Previously these had a distinct type called js::LazyScript). A
syntax-parsed script doesn't not have all the information that the Debugger
would normally like to query (such as detailed line-number info). Instead, for
these queries the Debugger first calls QueryScript::delazifyScripts[1] to fully
compile all BaseScript in a given Realm.

This compilation is a blunt operation that we would like to avoid if possible.
Instead of forcing compilation first, we should be able to do it as we go by
calling JSFunction::getOrCreateScript().

The specific examples we need to handle are in [2]. It is important to note
that we cannot call getOrCreateScript() while under IterateScripts so these
will need to be done in two phases. First, collect the best results using the
current system, then (if necessary) iterate over the vector expanding inner
functions and updating results.


Depends on: 1623763
Blocks: 1623763
No longer depends on: 1623763
Blocks: 1623766
Assignee: nobody → tcampbell

Instead of tracking the innermost script under the CellIter, collect the
results as though innermost was not specified and then do the filtering at
the end. This allows us to modify how line-matching works in later patches.
The tradeoff is that enclosing functions get collected in a vector
temporarily this is a very small cost compared to everything else that
happens in findScripts. Note that the "innermost" query is only used in
tests now.

Depends on D93036

Querying a specific line number in the Debugger requires candidate scripts to
have bytecode in order to known the ending line number. Previously we would
delazify all scripts in a Realm before performing such queries. In this patch
we instead gather partial matches during the CellIter<BaseScript> visit and
do post-processing to delazify recursively if it may contain matches. This
system does no more compilations than before and since we visit every script
in the gc::Zone regardless, there is no additional impact.

In this new system we use the CellIter to collect all scripts that have been
exposed to script that are partial query matches. This includes scripts with
bytecode and lazy scripts with non-lazy parents. This handles cases where
enclosing scripts (such as in an eval) are GC'd but inner functions remain

After the CellIter completes, we take the lazy scripts that are partial
matches, delazify them, and check if they still match with full information.
There inner lazy functions can then be recursively added to the work queue.
This gives the same results as before but without Realm-wide impact.

Depends on D93037

Blocks: 1670238
Pushed by
Use field initializers in Debugger::QueryScript code. r=arai
Simplify Debugger::QueryScript::findScripts handling of "innermost". r=arai
Avoid global delazification for Debugger findScripts "line" queries. r=arai
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 83 Branch
You need to log in before you can comment on or make changes to this bug.