Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(768)

Issue 1292753007: [es6] Parameter scopes for sloppy eval (Closed)

Created:
5 years, 4 months ago by rossberg
Modified:
5 years, 3 months ago
CC:
caitpott88_gmail.com, Paweł Hajdan Jr., v8-dev
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[es6] Parameter scopes for sloppy eval 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 Committed: https://crrev.com/365fd7bc351705e4fb181741829f89e580549daf Cr-Commit-Position: refs/heads/master@{#30295}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Rebase #

Patch Set 3 : Comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+451 lines, -116 lines) Patch
M include/v8.h View 1 1 chunk +1 line, -1 line 0 comments Download
M src/bootstrapper.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M src/compiler/ast-graph-builder.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M src/contexts.h View 1 3 chunks +11 lines, -3 lines 0 comments Download
M src/contexts.cc View 1 2 7 chunks +62 lines, -19 lines 0 comments Download
M src/debug/debug-scopes.h View 1 chunk +3 lines, -0 lines 0 comments Download
M src/debug/debug-scopes.cc View 1 13 chunks +71 lines, -51 lines 0 comments Download
M src/factory.h View 1 1 chunk +5 lines, -0 lines 0 comments Download
M src/factory.cc View 1 2 1 chunk +13 lines, -0 lines 0 comments Download
M src/full-codegen/full-codegen.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/hydrogen.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M src/objects.h View 1 6 chunks +39 lines, -2 lines 0 comments Download
M src/objects.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M src/objects-debug.cc View 1 1 chunk +8 lines, -0 lines 0 comments Download
M src/objects-inl.h View 1 1 chunk +5 lines, -0 lines 0 comments Download
M src/objects-printer.cc View 1 1 chunk +9 lines, -0 lines 0 comments Download
M src/parser.h View 1 2 chunks +2 lines, -1 line 0 comments Download
M src/parser.cc View 1 6 chunks +37 lines, -8 lines 0 comments Download
M src/pattern-rewriter.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/runtime/runtime-object.cc View 1 2 chunks +2 lines, -4 lines 0 comments Download
M src/runtime/runtime-scopes.cc View 1 4 chunks +19 lines, -7 lines 0 comments Download
M src/scopeinfo.cc View 1 4 chunks +9 lines, -0 lines 0 comments Download
M src/scopes.h View 2 chunks +4 lines, -1 line 0 comments Download
M src/scopes.cc View 1 7 chunks +16 lines, -10 lines 0 comments Download
M test/mjsunit/harmony/default-parameters.js View 3 chunks +127 lines, -2 lines 0 comments Download

Messages

Total messages: 15 (2 generated)
rossberg
5 years, 4 months ago (2015-08-19 16:10:23 UTC) #1
Yang
On 2015/08/19 16:10:23, rossberg wrote: Very confused. In the example, is the 'x' in the ...
5 years, 4 months ago (2015-08-20 09:08:56 UTC) #2
Yang
On 2015/08/20 09:08:56, Yang wrote: > On 2015/08/19 16:10:23, rossberg wrote: > > Very confused. ...
5 years, 4 months ago (2015-08-20 09:09:22 UTC) #3
Yang
On 2015/08/20 09:09:22, Yang wrote: > On 2015/08/20 09:08:56, Yang wrote: > > On 2015/08/19 ...
5 years, 4 months ago (2015-08-20 09:17:08 UTC) #4
Michael Starzinger
LGTM on compiler, full-codegen, objects and contexts. Didn't look at the rest. https://codereview.chromium.org/1292753007/diff/1/src/contexts.cc File src/contexts.cc ...
5 years, 4 months ago (2015-08-20 10:30:00 UTC) #5
Dan Ehrenberg
lgtm Such a weird spec, but your implementation makes sense. I can't think of a ...
5 years, 4 months ago (2015-08-20 21:24:48 UTC) #6
rossberg
On 2015/08/20 21:24:48, Dan Ehrenberg wrote: > Such a weird spec, but your implementation makes ...
5 years, 4 months ago (2015-08-21 09:53:37 UTC) #7
rossberg
https://codereview.chromium.org/1292753007/diff/1/src/contexts.cc File src/contexts.cc (right): https://codereview.chromium.org/1292753007/diff/1/src/contexts.cc#newcode65 src/contexts.cc:65: return ext->IsSloppyBlockWithEvalContextExtension() On 2015/08/20 10:30:00, Michael Starzinger wrote: > ...
5 years, 4 months ago (2015-08-21 10:00:40 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1292753007/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1292753007/40001
5 years, 4 months ago (2015-08-21 10:00:53 UTC) #11
commit-bot: I haz the power
Committed patchset #3 (id:40001)
5 years, 4 months ago (2015-08-21 10:58:40 UTC) #12
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/365fd7bc351705e4fb181741829f89e580549daf Cr-Commit-Position: refs/heads/master@{#30295}
5 years, 4 months ago (2015-08-21 10:58:54 UTC) #13
ruv
On 2015/08/19 16:10:23, rossberg wrote: > - In the parser, if a function has a ...
5 years, 3 months ago (2015-09-02 12:22:32 UTC) #14
rossberg
5 years, 3 months ago (2015-09-02 14:43:43 UTC) #15
Message was sent while issue was closed.
On 2015/09/02 12:22:32, ruv wrote:
> On 2015/08/19 16:10:23, rossberg wrote:
> > - 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. 
> 
> Could you please clarify, does the engine take into account that in strict
mode
> such eval doesn't introduce new variables into the surrounding scope?   So, in
> such case no need to allow possible dynamic var bindings.

Yes, strict cannot contain a "sloppy direct eval". (Though do-expressions may be
another source of vars in the future, even in strict mode.)

Powered by Google App Engine
This is Rietveld 408576698