Open Bug 1521120 Opened 6 years ago Updated 2 years ago

LoadInfo, Principal and CSP deserialization code takes `const` arguments making it difficult to avoid copies when deserializing

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

Tracking Status
firefox66 --- affected

People

(Reporter: Gijs, Unassigned)

References

(Depends on 1 open bug)

Details

It'd be better if we had more efficient implementations, but esp. the LoadInfoArgsToLoadInfo implementation is not trivial. :froydnj also said that improving this will likely take ipdl changes.

See Also: → 1519074

The reason this requires IPDL changes is twofold:

  • our IPC actor Recv* methods take IPDL-defined structs by const&, e.g.:

https://searchfox.org/mozilla-central/source/__GENERATED__/ipc/ipdl/PNeckoParent.cpp#2116

which basically requires propagating const& all over the place, even though those references should really be &&, since the objects are newly constructed on the stack and won't be used after our actor implementation consumes them.

  • one we do the first thing, we should probably consider how to generate move constructors for IPDL structs. People may not use them right away, but they will probably want to eventually... (this part may not actually block the work here)

Once that's all done, then we can go about rewriting PrincipalInfoToPrincipal, LoadInfoArgsToLoadInfo, etc. with versions that take && and/or turn them into giant templated monstrosities so we don't have to write both the const& and && versions out by hand.

Depends on: 1479930

We already have move constructors for IPDL structs, and devirtualization (bug 1512990) should allow ergonomic Recv-by-move, because the autogenerated code can just std::move everything and the argument types can be anything initializable by T&&. So maybe this bug should depend on that instead of bug 1479930.

Send-by-move is harder and probably doesn't matter for this, since it's going to be copied during serialization anyway.

Priority: -- → P3
Depends on: 1529942

I looked at this some this morning. The plan was to:

  • Make everything that takes const OptionalLoadInfoArgs& taken OptionalLoadInfoArgs&& instead.
  • Make LoadInfoArgsToLoadInfo pass T&& into its callees, where appropriate.
  • Modify callees as necessary to consume T&& rather than const T&, particularly for PrincipalInfo args. PrincipalInfo is an interesting case, because we do need to keep the const PrincipalInfo& conversion around for various reasons.

I ran into some actor implementations that need to be devirtualized (PWebrtcProxyChannel, particularly), and a few other issues. I'll try to fix those next week.

As mentioned before, Devirtualization should make this much easier to do :-), and that's landed now.

Depends on: 1530347
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.