Closed Bug 1843987 Opened 2 years ago Closed 2 years ago

Automatically tigger concurrent delazification for off-thread compilation if the option is set

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
118 Branch
Tracking Status
firefox118 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(1 file)

Currently the concurrent delazification is triggered from ParseTask.
in order to move the off-thread compilation code to Gecko thread, the DelazifyTask or equivalent needs to be triggered from Gecko thread.

Blocks: sm-meta
Severity: -- → S3
Priority: -- → P3
Severity: S3 → N/A
Depends on: 1845031

Given the concurrent delazification is triggered automatically inside bytecode compiler for on-main-thread compilation,
it's better aligning to it also in off-thread compilation.

Summary: Add public API to trigger concurrent delazification → Automatically tigger concurrent delazification for off-thread compilation if the option is set

The DelazifyTask::runtime field is used in the following places:

  • js::CancelOffThreadDelazify called by JSRuntime::destroyRuntime
  • WaitForAllDelazifyTasks called by CompileGlobalScriptToStencilAndMaybeInstantiate

the query in the latter can be done with ScriptSource, given CompileGlobalScriptToStencilAndMaybeInstantiate triggers the same delazification and it knows the ScriptSource.
the query in the former cannot be done with ScriptSource, given ScriptSource isn't associated with JSRuntime.

So, if we want to cancel delazify task on JSRuntime::destroyRuntime, we'll need to pass JSRuntime pointer via JS::FrontendContext.
but given the script cache is no longer strongly associated with runtime, it's not much necessary to explicitly wait in JSRuntime::destroyRuntime.
Also, given JSRuntime::destroyRuntime purges the cache, the DelazifyTask will soon stop when the current function gets delazified.

https://searchfox.org/mozilla-central/rev/3c7b40d1d74c26a82486f38b5828c3f3a43e05da/js/src/vm/Runtime.cpp#215,228

void JSRuntime::destroyRuntime() {
...
  caches().purgeStencils();

actually, we can just cancel DelazifyTask which has no runtime when a runtime is getting destroyed.

Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Blocks: 1845638
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/cdc989c09e3d Automatically trigger concurrent delazification also for off-thread compilation if the CompileOptions flag is set. r=nbp
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: