Closed Bug 1907151 Opened 4 months ago Closed 4 months ago

Improve lazy tiering

Categories

(Core :: JavaScript: WebAssembly, task, P1)

task

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox130 --- fixed

People

(Reporter: rhunt, Assigned: rhunt)

References

(Blocks 1 open bug)

Details

Attachments

(11 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Fix the first low hanging fruit to improve lazy tiering.

FeatureUsage is moved from CodeMetadata to ModuleMetadata. This removes
one of the places where we mutate CodeMetadata while compiling a tier
of code, which prevents us from making CodeMetadata truly immutable
for tier2.

Changes ModuleMetadata to create an manage the inner CodeMetadata.

We can get the FuncType* from just the typeIndex, and the pointer
makes serializing this class difficult. Drop it.

We previously did not have FuncDesc available on Code/Instance,
leading to a bunch of ad-hoc ways of getting the same info,
such as FuncExport/Import having a typeIndex, or debugFuncTypeIndices,
or numFuncs. This commit switches them to use FuncDesc and serializes
it.

Now that we have FuncDesc, we don't need FuncImport/Export::typeIndex around anymore.

ModuleGenerator mutates CodeMetadata during initialize() and finishModule(),
and these make it difficult to make CodeMetadata immutable for tier2.

We can fix the mutation done by initialize() by adding a ModuleMetadata::
prepareForCompilation() method which all compilers use.

The mutation in finishModule() is trickier, but most of it can be fixed
by having CompileArgs be saved on ModuleMetadata.

The remaining mutation is harmless for making tier2 use an immutable
metadata because it only happens duing ModuleGenerator::finishModule,
which doesn't run on tier2. So we change that mutation to acquire its
mutable CodeMetadata from the mutable ModuleMetadata passed by param.

Once this is all done, we can finally have ModuleGenerator only need
an immutable CodeMetadata for intializing and compiling functions.

Now that we ModuleGenerator can use the CodeMetadata from the original
tier-1 compile, use that instead of recreating one.

CompileArgs live on ModuleMetadata/CodeMetadata now, so ModuleGenerator can
just grab it from that instead.

Use the bytecode offset from CodeRange to skip in the code section
to exactly the function that we're compiling for tier2.

Note: this requires a hack to OpIter to skip the checks that all bytes
are consumed. The reason is that CodeRange doesn't have a function
body length to use. This is fixed in a later commit that adds a
FuncDefRange.

ModuleGenerator used to compile the shared stubs every time it was
initialized to compile a complete tier. This is wasteful, because it
would be thrown away when compiling tier2. However, we need the shared
stubs link data for serializing tier2, making fixing this tricky.

This commit reworks serialization so that the LinkData that we
serialize comes from wasm::Code. This lets tier1 put the shared
stubs link data into wasm::Code, then have the tier2 compile
pull it out when it's time to serialize.

With that in place, we can now skip compiling shared stubs when
we're not in tier1.

Depends on D215698

Add a FuncDefRange to CodeMetadata that tracks the begin/length bytecode
offsets for every function defined in a module.

This lets us drop the equivalent info from CodeRange, shrinking that struct.

We can then use this for lazy compilation, and in the future for inlining.

Depends on D216220

No longer blocks: 1905716
Depends on: 1905716
Blocks: 1907557
Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/649cfd2e8c96 wasm: Move FeatureUsage onto ModuleMetadata. r=jseward https://hg.mozilla.org/integration/autoland/rev/19ce9e92c773 wasm: ModuleMetadata strongly owns CodeMetadata. r=jseward https://hg.mozilla.org/integration/autoland/rev/9ced3a801124 wasm: Drop FuncType* from FuncDesc to make it POD. r=jseward https://hg.mozilla.org/integration/autoland/rev/ce088784c1e1 wasm: Serialize FuncDesc, replace ad-hoc old users. r=jseward https://hg.mozilla.org/integration/autoland/rev/9d606119b727 wasm: Remove typeIndex from FuncImport and FuncExport. r=jseward https://hg.mozilla.org/integration/autoland/rev/a7d8d2c13b31 wasm: Remove most remaining mutation of CodeMetadata from ModuleGenerator. r=jseward https://hg.mozilla.org/integration/autoland/rev/f7f2d95f3e49 wasm: Don't recreate ModuleMetadata for tier2. r=jseward https://hg.mozilla.org/integration/autoland/rev/931ce01840a3 wasm: Remove CompileArgs from ModuleGenerator constructor. r=jseward https://hg.mozilla.org/integration/autoland/rev/d57a1961c6fa wasm: Only decode the function that is being re-compiled for tier2. r=jseward https://hg.mozilla.org/integration/autoland/rev/67a952c44d89 wasm: Only generate shared stubs when compiling tier 1. r=jseward https://hg.mozilla.org/integration/autoland/rev/e77dd6f34a82 wasm: Add FuncDefRange for tracking function bytecode ranges. r=jseward https://hg.mozilla.org/integration/autoland/rev/53fa71987ba0 apply code formatting via Lando
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: