• rossberg's avatar
    [es6] Parameter scopes for sloppy eval · 365fd7bc
    rossberg authored
    This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
    
      let x = 1;
      function f(g = () => x) {
        var y
        eval("var x = 2")
        return g() + x  // f() = 3
      }
    
    we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
    
    - Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
    
    - When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
    
    - While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
    
    - Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
    
    - Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
    
    - In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
    
    - In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
    
    - ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
    
    - Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
    
    - While at it, refactor and unify some respective code in the debugger.
    
    Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
    
    @mstarzinger: Please review the changes to contexts.
    @yangguo: Please have a look at the debugger stuff.
    
    R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
    BUG=v8:811,v8:2160
    LOG=N
    
    Review URL: https://codereview.chromium.org/1292753007
    
    Cr-Commit-Position: refs/heads/master@{#30295}
    365fd7bc
Name
Last commit
Last update
..
regress Loading commit data...
array-concat.js Loading commit data...
array-copywithin.js Loading commit data...
array-fill.js Loading commit data...
array-find.js Loading commit data...
array-findindex.js Loading commit data...
array-from.js Loading commit data...
array-includes-to-object-sloppy.js Loading commit data...
array-includes-to-object-strict.js Loading commit data...
array-includes.js Loading commit data...
array-of.js Loading commit data...
arrow-functions-lexical-arguments.js Loading commit data...
arrow-functions-this.js Loading commit data...
arrow-functions.js Loading commit data...
arrow-rest-params.js Loading commit data...
atomics.js Loading commit data...
block-conflicts-sloppy.js Loading commit data...
block-const-assign-sloppy.js Loading commit data...
block-for-sloppy.js Loading commit data...
block-lazy-compile.js Loading commit data...
block-leave-sloppy.js Loading commit data...
block-let-crankshaft-sloppy.js Loading commit data...
block-let-declaration-sloppy.js Loading commit data...
block-let-semantics-sloppy.js Loading commit data...
block-scope-class.js Loading commit data...
block-scoping-sloppy.js Loading commit data...
block-scoping-top-level-sloppy.js Loading commit data...
classes-derived-return-type.js Loading commit data...
dataview-accessors.js Loading commit data...
default-parameters-debug.js Loading commit data...
default-parameters.js Loading commit data...
destructuring-parameters-literalcount-nolazy.js Loading commit data...
destructuring-parameters-literalcount.js Loading commit data...
destructuring.js Loading commit data...
futex.js Loading commit data...
module-linking.js Loading commit data...
module-parsing-eval.js Loading commit data...
module-recompile.js Loading commit data...
module-resolution.js Loading commit data...
modules.js Loading commit data...
new-target.js Loading commit data...
object-assign.js Loading commit data...
object-literals-super.js Loading commit data...
private.js Loading commit data...
proxies-example-membrane.js Loading commit data...
proxies-for.js Loading commit data...
proxies-function.js Loading commit data...
proxies-hash.js Loading commit data...
proxies-json.js Loading commit data...
proxies-symbols.js Loading commit data...
proxies-with-unscopables.js Loading commit data...
proxies-with.js Loading commit data...
proxies.js Loading commit data...
reflect-apply.js Loading commit data...
reflect-construct.js Loading commit data...
regexp-flags.js Loading commit data...
regexp-sticky.js Loading commit data...
rest-params-lazy-parsing.js Loading commit data...
rest-params.js Loading commit data...
set-prototype-of.js Loading commit data...
sharedarraybuffer.js Loading commit data...
simd.js Loading commit data...
spread-array.js Loading commit data...
spread-call-new-class.js Loading commit data...
spread-call-new.js Loading commit data...
spread-call-super-property.js Loading commit data...
spread-call.js Loading commit data...
super.js Loading commit data...
typed-array-includes.js Loading commit data...
unicode-escapes-in-regexps.js Loading commit data...