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

Issue 7904008: Introduce with scope and rework variable resolution. (Closed)

Created:
9 years, 3 months ago by Steven
Modified:
9 years, 2 months ago
CC:
v8-dev
Visibility:
Public.

Description

Introduce with scope and rework variable resolution. Committed: http://code.google.com/p/v8/source/detail?r=9650

Patch Set 1 #

Total comments: 36

Patch Set 2 : Addressed comments and improved the code. #

Patch Set 3 : Addressed new comments. #

Patch Set 4 : Removed tracking of 'with' from parser and variable proxies. #

Total comments: 12

Patch Set 5 : Latest version. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+257 lines, -269 lines) Patch
M src/arm/full-codegen-arm.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M src/ast.h View 1 2 3 2 chunks +0 lines, -3 lines 0 comments Download
M src/ast.cc View 1 2 3 2 chunks +0 lines, -3 lines 0 comments Download
M src/contexts.h View 1 1 chunk +1 line, -2 lines 0 comments Download
M src/contexts.cc View 1 2 chunks +6 lines, -10 lines 0 comments Download
M src/ia32/full-codegen-ia32.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M src/mips/full-codegen-mips.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M src/parser.h View 1 2 3 5 chunks +4 lines, -3 lines 0 comments Download
M src/parser.cc View 1 2 3 4 18 chunks +46 lines, -41 lines 0 comments Download
M src/scopes.h View 1 2 3 4 11 chunks +64 lines, -14 lines 0 comments Download
M src/scopes.cc View 1 2 3 4 15 chunks +128 lines, -189 lines 0 comments Download
M src/variables.h View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 1 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 7 (0 generated)
Steven
PTAL.
9 years, 3 months ago (2011-09-15 08:44:05 UTC) #1
Kevin Millikin (Chromium)
I have a few comments. It's great to clean this up. The existing code is ...
9 years, 3 months ago (2011-09-15 09:38:13 UTC) #2
Steven
http://codereview.chromium.org/7904008/diff/1/src/parser.cc File src/parser.cc (right): http://codereview.chromium.org/7904008/diff/1/src/parser.cc#newcode2083 src/parser.cc:2083: Scope* saved_scope = top_scope_; On 2011/09/15 09:38:13, Kevin Millikin ...
9 years, 3 months ago (2011-09-15 19:54:06 UTC) #3
Kevin Millikin (Chromium)
I haven't taken a close look at the latest changes yet. http://codereview.chromium.org/7904008/diff/1/src/scopes.cc File src/scopes.cc (right): ...
9 years, 3 months ago (2011-09-16 05:23:21 UTC) #4
Steven
PTAL again. http://codereview.chromium.org/7904008/diff/1/src/scopes.cc File src/scopes.cc (right): http://codereview.chromium.org/7904008/diff/1/src/scopes.cc#newcode828 src/scopes.cc:828: (*var)->MarkAsAccessedFromInnerScope(); Sure, done. On 2011/09/16 05:23:21, Kevin ...
9 years, 3 months ago (2011-09-16 10:48:14 UTC) #5
Kevin Millikin (Chromium)
This is a very nice cleanup. I have a few comments below. You should take ...
9 years, 3 months ago (2011-09-16 12:58:19 UTC) #6
Steven
9 years, 3 months ago (2011-09-16 18:29:51 UTC) #7
Will land this on Monday.

http://codereview.chromium.org/7904008/diff/9011/src/parser.cc
File src/parser.cc (right):

http://codereview.chromium.org/7904008/diff/9011/src/parser.cc#newcode467
src/parser.cc:467: // These scopes are not kept around after parsing or
referenced by syntax trees
There is PreParser::Scope that remotely corresponds to LexicalScope, but these
classes are unrelated in terms of their implementation, so the preparser doesn't
need to be mentioned here.
Moreover the only important piece of information is the stack-allocation. I will
keep that and remove the rest.
On 2011/09/16 12:58:19, Kevin Millikin wrote:
> Does the preparser still use these guys?  If not we should get rid of that
part
> of the comment.

http://codereview.chromium.org/7904008/diff/9011/src/scopes.cc
File src/scopes.cc (right):

http://codereview.chromium.org/7904008/diff/9011/src/scopes.cc#newcode302
src/scopes.cc:302: ASSERT(is_function_scope() ||
On 2011/09/16 12:58:19, Kevin Millikin wrote:
> I don't think this ASSERT is necessary any more.

Done.

http://codereview.chromium.org/7904008/diff/9011/src/scopes.cc#newcode807
src/scopes.cc:807: *var = LocalLookup(name);
Yeah, after all me too.
On 2011/09/16 12:58:19, Kevin Millikin wrote:
> For some reason I prefer returning the variable and having the lookup kind be
> the output parameter.  Just saying.

http://codereview.chromium.org/7904008/diff/9011/src/scopes.cc#newcode823
src/scopes.cc:823: if (function_ != NULL &&
function_->name().is_identical_to(name)) {
Unfortunately we can't. The function name is still in an 'implicit' outer scope
and might be shadowed by eval introduced variables, i.e. something like
function y( eval("var y = 1;"); return y; )
Thus the lookup for the y reference should produce BOUND_EVAL_SHADOWED. But if
we let LocalLookup do this check it will be BOUND.

Yes it is fishy that the function name of the SerializedScopeInfo is checked.
Removing it does not break any tests, but I left it in there for another cleanup
CL. It is for example used in another fishy function Scope::Lookup which in turn
is used in the parser to detect direct 'eval' calls.
On 2011/09/16 12:58:19, Kevin Millikin wrote:
> I wonder if we could make Scope::LocalLookup check the function name after
> checking the variable map, and get rid of this here.
> 
> It seems like it Scope::LocalLookup already does that for scopes backed by a
> ScopeInfo.  That seems fishy, even if it's not an actual bug.

http://codereview.chromium.org/7904008/diff/9011/src/scopes.cc#newcode838
src/scopes.cc:838: return DYNAMIC_LOOKUP;
On 2011/09/16 12:58:19, Kevin Millikin wrote:
> And I'd prefer setting var to NULL (or returning NULL if you take the
suggestion
> above) in the cases where it's meaningless/should not be used/will not be
used.

Done.

http://codereview.chromium.org/7904008/diff/9011/src/scopes.h
File src/scopes.h (right):

http://codereview.chromium.org/7904008/diff/9011/src/scopes.h#newcode417
src/scopes.h:417: enum LookupResult {
Used BindingKind for lack of a better name.
On 2011/09/16 12:58:19, Kevin Millikin wrote:
> This sounds like a silly request, but: we already have a type LookupResult
(for
> property lookups) that's used extensively.  Since C++ tools generally stink,
it
> might be easiest to choose some different name so it's easy to find each of
> them.
> 
> BindingKind?  Something else?

Powered by Google App Engine
This is Rietveld 408576698