• Daniel Clark's avatar
    Plumb import assertions through SourceTextModuleDescriptor's ModuleRequestMap · ea0ccc7e
    Daniel Clark authored
    This change plumbs import assertions from SourceTextModuleDescriptor's
    ModuleRequestMap into SourceTextModuleInfo via a new ModuleRequest
    type, where previously there had been only the specifier.
    
    SourceTextModuleDescriptor::module_map now deduplicates module requests
    using the specifier and the import assertions.  Continuing to use the
    specifier alone would cause a loss of information in the event that
    a module imports from the same specifier multiple times using different
    sets of assertions.  Failing to deduplicate at all would result in
    multiple requests for statements like `import {a,b,c} from "foo.js"`,
    which would be a potential performance issue.  See design doc at
    https://docs.google.com/document/d/1yuXgNHSbTAPubT1Mg0JXp5uTrfirkvO1g5cHHCe-LmY
    for more detail on this decision.
    
    v8::internal::ModuleRequest holds the assertions as an array of the form
    [key1, value1, position1, key2, value2, assertion2, ...].  However the
    parser still needs to use a map, since duplicate assertion keys need to
    be detected at parse time.  A follow-up  change will ensure that
    assertions are sorted using a proper lexicographic sort.
    
    Bug: v8:10958
    Change-Id: Iff13fb9a37d58fc1622cd3cce78925ad2b7a14bb
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2493060
    Commit-Queue: Dan Clark <daniec@microsoft.com>
    Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
    Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#71066}
    ea0ccc7e
parser.cc 137 KB