Closed Bug 1449220 Opened 6 years ago Closed 6 years ago

ModuleBuilder import/export lookup uses linear search

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: jonco, Assigned: jonco)

Details

Attachments

(1 file)

When creating module metadata we maintain vectors of import and export entry objects which we search using linear search in a couple of places.  This happens to check whether an export is re-exporting an import and when we hit a new export statement the parser to check for duplicate exported names.  This leads to N^2 behaviour and is bound to cause problems for large modules.
Patch to use hash tables for import / entry lookup in ModuleBuilder.  importEntries_ uses a map as we have to lookup an object by name.  For exports there is not always a name (in the case of |export *|) so I added a separate set for exported names.  I removed importedBoundNames_ which was unused.

I also had to update a test that assumed importEntries would be present in a certain order.
Attachment #8962754 - Flags: review?(jorendorff)
Priority: -- → P2
Attachment #8962754 - Flags: review?(jorendorff) → review+
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/627599ba1f3b
Use hash tables for looking up imports and exports when building module metadata r=jorendorff
https://hg.mozilla.org/mozilla-central/rev/627599ba1f3b
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: