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

Issue 7992005: Block scoped const variables. (Closed)

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

Description

Block scoped const variables. This implements block scoped 'const' declared variables in harmony mode. They have a temporal dead zone semantics similar to 'let' bindings, i.e. accessing uninitialized 'const' bindings in throws a ReferenceError. As for 'let' bindings, the semantics of 'const' bindings in global scope is not correctly implemented yet. Furthermore assignments to 'const's are silently ignored. Another CL will introduce treatment of those assignments as early errors. Committed: http://code.google.com/p/v8/source/detail?r=9764

Patch Set 1 #

Patch Set 2 : Rebased. #

Total comments: 2

Patch Set 3 : Removed redundant code. #

Total comments: 7

Patch Set 4 : Comments, function variable mode, preparser. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+395 lines, -111 lines) Patch
M src/arm/full-codegen-arm.cc View 1 2 3 10 chunks +27 lines, -12 lines 0 comments Download
M src/ast.h View 1 2 1 chunk +4 lines, -1 line 0 comments Download
M src/contexts.h View 1 2 1 chunk +30 lines, -11 lines 0 comments Download
M src/contexts.cc View 1 2 3 4 chunks +10 lines, -3 lines 0 comments Download
M src/full-codegen.cc View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M src/hydrogen.cc View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M src/ia32/full-codegen-ia32.cc View 1 2 3 10 chunks +28 lines, -13 lines 0 comments Download
M src/messages.js View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/objects.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/parser.h View 1 2 2 chunks +3 lines, -1 line 0 comments Download
M src/parser.cc View 1 2 14 chunks +63 lines, -24 lines 0 comments Download
M src/preparser.cc View 1 2 3 3 chunks +26 lines, -3 lines 0 comments Download
M src/runtime.cc View 1 2 3 1 chunk +20 lines, -7 lines 0 comments Download
M src/scopeinfo.cc View 1 2 2 chunks +11 lines, -3 lines 0 comments Download
M src/scopes.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/scopes.cc View 1 2 3 chunks +7 lines, -4 lines 0 comments Download
M src/token.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/v8globals.h View 1 2 1 chunk +5 lines, -3 lines 0 comments Download
M src/variables.h View 1 1 chunk +9 lines, -0 lines 0 comments Download
M src/variables.cc View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 1 2 3 10 chunks +30 lines, -14 lines 0 comments Download
M test/mjsunit/harmony/block-conflicts.js View 1 1 chunk +5 lines, -0 lines 0 comments Download
M test/mjsunit/harmony/block-let-declaration.js View 1 3 chunks +30 lines, -2 lines 0 comments Download
M test/mjsunit/harmony/block-let-semantics.js View 1 4 chunks +27 lines, -1 line 0 comments Download
M test/mjsunit/harmony/block-scoping.js View 1 9 chunks +50 lines, -4 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
Steven
PTAL.
9 years, 3 months ago (2011-09-22 15:00:08 UTC) #1
Steven
Rebased this to tip of tree. Could you please take a look.
9 years, 2 months ago (2011-10-17 13:05:26 UTC) #2
fschneider
Almost there. You probably do need to add a bailout in the hydrogen-compiler, don't you? ...
9 years, 2 months ago (2011-10-21 09:19:40 UTC) #3
Steven
Added a bailout to hydrogen. Sorry also rebased in between somewhere. Please take another look. ...
9 years, 2 months ago (2011-10-24 09:37:55 UTC) #4
fschneider
LGTM with a few minor comments. http://codereview.chromium.org/7992005/diff/23028/src/contexts.cc File src/contexts.cc (right): http://codereview.chromium.org/7992005/diff/23028/src/contexts.cc#newcode204 src/contexts.cc:204: *binding_flags = mode ...
9 years, 2 months ago (2011-10-24 12:58:13 UTC) #5
Steven
Sorry I forgot to remove redundant code from the preparser. Can you please take a ...
9 years, 2 months ago (2011-10-24 14:05:18 UTC) #6
fschneider
9 years, 2 months ago (2011-10-24 15:33:43 UTC) #7
Still LGTM.

http://codereview.chromium.org/7992005/diff/23028/src/ia32/full-codegen-ia32.cc
File src/ia32/full-codegen-ia32.cc (right):

http://codereview.chromium.org/7992005/diff/23028/src/ia32/full-codegen-ia32....
src/ia32/full-codegen-ia32.cc:714: bool binding_needs_init =
Yes, passing a declaration object would be the right way, but it's fine to leave
it as is for this change.

On 2011/10/24 14:05:18, Steven wrote:
> Unfortunately for DYNAMIC_GLOBAL variables we can only get the mode used in
the
> declaration from the declaration object and not from the variable itself. It
> does for example occur with eval('var foo;') in global scope. We can't pass
the
> declaration because it is also used for the function variable of a named
> function expression, which doesn't have a declaration object. I will leave
> cleaning this up for another hypothetical CL.
> On 2011/10/24 12:58:13, fschneider wrote:
> > EmitDeclaration is used in two places. Is it possible to use
> > variable->binding_needs_init() instead here?
>

Powered by Google App Engine
This is Rietveld 408576698