Closed Bug 1855301 Opened 2 years ago Closed 2 years ago

Add initial support for fuses.

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
123 Branch
Tracking Status
firefox123 --- fixed

People

(Reporter: mgaudet, Assigned: mgaudet)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [sp3])

Attachments

(8 files, 10 obsolete 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
  • A Fuse: A data structure in memory that asserts some property of the system.
  • A fuse may be popped/invalidated/burnt out; this indicates that the property the fuse was asserting no longer holds.
  • There are two models of Fuse: Guard fuses are used as guards at various points through the engine to allow dynamic choice of a fallback path vs. fast path. A guard is checked explicitly before each action. In constrast, an Invalidating fuse instead performs some cleanup actions which inform various parts of the code that the assumption made no longer holds (e.g invalidating code).

I have patches I will attach that sketch out guard-fuses

Adds the ability to have a specific object kick off a Watchtower callback on property
write to a specific NativeObject.

This also makes the design decision to -also- pop fuses on property change, which
is triggered on the property descriptor change paths.

Depends on D189282

Verify that CacheIR and the fuse agree on the optimizability of Array.prototype[@@iterator]

Depends on D189283

Depends on D189284

Attachment #9355178 - Attachment is obsolete: true
Attachment #9355177 - Attachment is obsolete: true
Attachment #9355176 - Attachment is obsolete: true
Attachment #9355175 - Attachment is obsolete: true
Attachment #9355174 - Attachment is obsolete: true
Attachment #9355173 - Attachment is obsolete: true
Assignee: nobody → mgaudet
Status: NEW → ASSIGNED

A Fuse: A data structure in memory that asserts some property of the system.

  • A fuse may be popped: this indicates that the property the fuse was asserting
    no longer holds.

  • There are two models of Fuse: Guard fuses are used as guards at various
    points through the engine to allow dynamic choice of a fallback path vs. fast
    path. A guard is checked explicitly before each action. In contrast, an
    Invalidating fuse instead performs some cleanup actions which inform
    various parts of the code that the assumption made no longer holds (e.g
    invalidating code).

  • A fuse can be checked easily for validity -- a single load and compare should
    suffice.

This patch only adds support for Realm scoped Guard Fuses.

In order to maintain the invariants required by fuses, Watchtower is enhanced
to support watching for property modification.

A few review notes:

  • This large patch -can- be broken up if desired; it just grew large because I
    got tired of having a wonky bunch of corrections split across three different
    patches.

  • I originally added a number of asserts to ensure that wherever we did a
    setSlot we either correctly watched for changes, or the underlying object
    did not watch for changes. This ended up being a bunch of additions to
    environment object paths; I would prefer to somehow assert that we never flag
    an environment object for watching (at least until we want to try), but I
    can't quite construct that.

This speeds up a microbenchmark like the following by 50%.

function foo(x) {
    var b;
    [b] = x;
    return b;
}
let start = performance.now();
for (var i = 0; i < 200_000; i++) {
    foo([1, 2, 3]);
}
let end = performance.now();
console.log(end - start);

Depends on D194292

Attachment #9355172 - Attachment is obsolete: true
Blocks: 1866158

Also, borrow support here for iterator prototypes in anticipation of adding fuses to ArrayIteratorPrototype

Depends on D195261

Attachment #9364833 - Attachment description: Bug 1855301 - Use a fuse check to speed up destructuring optimization r?jandem → Bug 1855301 - Use a fuse check to speed up destructuring optimization r?jandem,iain
Attachment #9364802 - Attachment description: Bug 1855301 - Add more fuses, and use them to further speed up destructuring optimization r?jandem → Bug 1855301 - Add more fuses, and use them to further speed up destructuring optimization r?jandem,iain
Whiteboard: [sp3]
Attachment #9366542 - Attachment description: Bug 1855301 - Add support for watching for property modification to watchtower r?jandem,iain → WIP: Bug 1855301 - Support observing NativeObject property modification ?jandem,iain
Attachment #9364832 - Attachment is obsolete: true
Attachment #9366543 - Attachment is obsolete: true
Attachment #9366542 - Attachment description: WIP: Bug 1855301 - Support observing NativeObject property modification ?jandem,iain → Bug 1855301 - Support observing NativeObject property modification r?jandem,iain

These fuses will be consumed when we enable fuse based optimization.

Depends on D195265

Current plan is that we'll land this bug as an 'enabling build', without consuming then we'll move forward with consumption in other bugs.

Summary: Explore 'Fuses' as optimization tools → Add initial support for fuses.
Depends on: 1870396
Blocks: sm-runtime
Severity: S3 → N/A

Comment on attachment 9364833 [details]
Bug 1855301 - Use a fuse check to speed up destructuring optimization -- Landing Disabled-by-default r?jandem,iain

Revision D194293 was moved to bug 1870396. Setting attachment 9364833 [details] to obsolete.

Attachment #9364833 - Attachment is obsolete: true
Attachment #9364833 - Attachment description: Bug 1855301 - Use a fuse check to speed up destructuring optimization r?jandem,iain → Bug 1855301 - Use a fuse check to speed up destructuring optimization -- Landing Disabled-by-default r?jandem,iain
Attachment #9364833 - Attachment is obsolete: false
Attachment #9364802 - Attachment is obsolete: true
Blocks: fuse
Pushed by mgaudet@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ced658288757 Add getter for array iterator prototype r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/6f96fe49c54e Support observing NativeObject property modification r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/a5400fe43d70 Setup Array and ArrayIteratorPrototypes with watchtower in anticipation of Fuse support r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/2efe70d66fe4 Introduce Fuses: Runtime Support r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/ba7ca7800429 Introduce Fuses: Code Generation support r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/4937e75feec8 Add more fuses in anticipation of their future use r=iain https://hg.mozilla.org/integration/autoland/rev/e357f23d1600 Use a fuse check to speed up destructuring optimization -- Landing Disabled-by-default r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/f7f45db393fa Fix PBL build for fuses r=iain
Pushed by mgaudet@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8483eb0f6998 Add getter for array iterator prototype r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/56cc0126e3ed Support observing NativeObject property modification r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/339beb959236 Setup Array and ArrayIteratorPrototypes with watchtower in anticipation of Fuse support r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/267bec6e427c Introduce Fuses: Runtime Support r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/7bdb688ff63b Introduce Fuses: Code Generation support r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/2b1d14a12a9c Add more fuses in anticipation of their future use r=iain https://hg.mozilla.org/integration/autoland/rev/96176d302fca Use a fuse check to speed up destructuring optimization -- Landing Disabled-by-default r=jandem,iain https://hg.mozilla.org/integration/autoland/rev/da91b70056f1 Fix PBL build for fuses r=iain

Fixed irksome old clang issue and attempted relanding.

Flags: needinfo?(mgaudet)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: