BrowserWorks / Waterfox-Classic

The Waterfox Classic repository, for legacy systems and customisation.
https://classic.waterfox.net
Mozilla Public License 2.0
175 stars 34 forks source link

Dynamic imports #121

Open buttercookie42 opened 2 years ago

buttercookie42 commented 2 years ago

I have WIP patches for backporting

buttercookie42 commented 2 years ago

I've been using this for a while in my local build and it mostly seems to work fine, but luckily I've stumbled across one bug introduced by the backporting.

Because unlike the mozilla-central code at the time we're still carrying support for legacy generators, it means that in Waterfox the PackedView struct holding some data related to lazy script parsing was already fully occupying the size of a uint64_t (count the bits).

Adding the parse goal (script vs. module) then consequently meant trying to push 65 bits of data into a 64-bit integer, which of course doesn't work, so the additional bit dropped off the back (strangely enough only in a non-debug build, though). This meant that for any code containing import.meta statements, initial parsing would succeed, but if the rest of the function was lazily parsed only later on, we'd suddenly get a failure because during the second parsing pass we'd have forgotten that we're dealing with module code, so the import.meta statement was suddenly illegal.

This became visible on e.g. https://huggingface.co/spaces/dalle-mini/dalle-mini. I've now fixed up my WIP patches to correct this problem.

buttercookie42 commented 2 years ago

Found and fixed an error introduced during backporting of bug 1518308 in the dynamic module import patches, which partially broke the devtools debugger.