• adamk's avatar
    More accurately record an end position for default parameters in arrows · e96cbdcd
    adamk authored
    Our previous over-conservative answer caused us to emit hole checks in
    full-codegen when eagerly parsing but not when lazily parsing.
    
    With this patch, we use the positions of the BinaryOperations making up
    the parameter list (which are the positions of the commas) to determine
    the appropriate "end position" for each parameter's initializer. This means
    that we get accurate-enough positions for the initializers in the eager
    parsing step to get the same answers for hole-check-elimination that we
    will later during ParseLazy.
    
    In the included test case, for example:
    
      (function() { ((s = 17, y = s) => s)(); } )();
                            ^2     ^1
    
    The old code would generate a hole check when trying to load
    |s| for assignment to |y| (because it treated the closing parentheses
    pointed to by "^1" as the "initialization position" of |s|).
    
    The new code uses the comma pointed to by "^2" as the initialization
    position of |s|. Since that occurs textually before the load of |s|,
    full-codegen knows it can avoid the hole check.
    
    BUG=v8:4908
    LOG=n
    
    Review URL: https://codereview.chromium.org/1900343002
    
    Cr-Commit-Position: refs/heads/master@{#35678}
    e96cbdcd
parser.cc 249 KB