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

Issue 11265047: Implement const expressions for local variables (Closed)

Created:
8 years, 1 month ago by hausner
Modified:
8 years, 1 month ago
Reviewers:
siva
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Implement const expressions for local variables Committed: https://code.google.com/p/dart/source/detail?r=14716

Patch Set 1 #

Patch Set 2 : #

Total comments: 12

Patch Set 3 : #

Patch Set 4 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+173 lines, -9 lines) Patch
M runtime/vm/ast.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/ast.cc View 1 2 1 chunk +8 lines, -0 lines 0 comments Download
M runtime/vm/object.h View 1 2 1 chunk +7 lines, -1 line 0 comments Download
M runtime/vm/object.cc View 1 2 2 chunks +24 lines, -0 lines 0 comments Download
M runtime/vm/parser.cc View 1 2 3 chunks +12 lines, -1 line 0 comments Download
M runtime/vm/raw_object.h View 1 2 1 chunk +5 lines, -1 line 0 comments Download
M runtime/vm/scopes.h View 1 2 3 chunks +17 lines, -0 lines 0 comments Download
M runtime/vm/scopes.cc View 1 2 3 chunks +19 lines, -5 lines 0 comments Download
A tests/language/const_locals_test.dart View 1 2 1 chunk +32 lines, -0 lines 0 comments Download
A tests/language/const_nested_test.dart View 1 2 1 chunk +44 lines, -0 lines 0 comments Download
M tests/language/language.status View 1 2 3 2 chunks +2 lines, -1 line 0 comments Download
M tests/language/language_dart2js.status View 1 2 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
hausner
8 years, 1 month ago (2012-11-08 01:15:02 UTC) #1
siva
LGTM with one question regarding closures. http://codereview.chromium.org/11265047/diff/7001/runtime/vm/scopes.h File runtime/vm/scopes.h (right): http://codereview.chromium.org/11265047/diff/7001/runtime/vm/scopes.h#newcode81 runtime/vm/scopes.h:81: const_value_ = &value; ...
8 years, 1 month ago (2012-11-08 20:30:01 UTC) #2
hausner
8 years, 1 month ago (2012-11-09 00:10:21 UTC) #3
Addressed comments and questions. Also added support for closurized const
variables.

Feel free to take another look.

http://codereview.chromium.org/11265047/diff/7001/runtime/vm/scopes.h
File runtime/vm/scopes.h (right):

http://codereview.chromium.org/11265047/diff/7001/runtime/vm/scopes.h#newcode81
runtime/vm/scopes.h:81: const_value_ = &value;
Local variable objects and scopes are only alive during the compilation of a
single function. Thus, the pointer to the Zone handle goes away with the zone.

Similarly, we already store a reference to a zone handle for the variable's name
and type. I didn't want to use a reference to a handle, but a pointer instead,
because I don't want to allocate a handle for each non-const variable.
 
On 2012/11/08 20:30:01, siva wrote:
> 'value' is zone allocated and stored here. Will this
> always be available. I am wondering of a case where
> we return a closure and compilation of the closure
> happens much later, the original zone could have
> been destroyed and is not available anymore.

http://codereview.chromium.org/11265047/diff/7001/tests/language/const_locals...
File tests/language/const_locals_test.dart (right):

http://codereview.chromium.org/11265047/diff/7001/tests/language/const_locals...
tests/language/const_locals_test.dart:17: const MASK = (1 << (MAX - MIN + 1)) -
1;
On 2012/11/08 20:30:01, siva wrote:
> const MASK = (1 << (MAX - MIN + 1)) - 1;  // 65535.

Done.

http://codereview.chromium.org/11265047/diff/7001/tests/language/const_locals...
tests/language/const_locals_test.dart:27: Expect.isTrue(cf2 === cf3);
On 2012/11/08 20:30:01, siva wrote:
> Expect.isFalse(cf2 === cf1);

Done.

http://codereview.chromium.org/11265047/diff/7001/tests/language/const_nested...
File tests/language/const_nested_test.dart (right):

http://codereview.chromium.org/11265047/diff/7001/tests/language/const_nested...
tests/language/const_nested_test.dart:17: const MASK = (1 << (MAX - MIN + 1)) -
1;
On 2012/11/08 20:30:01, siva wrote:
> const MASK = (1 << (MAX - MIN + 1)) - 1;  // 65535.

Done.

http://codereview.chromium.org/11265047/diff/7001/tests/language/const_nested...
tests/language/const_nested_test.dart:29: Expect.isTrue(cf2 === cf3);
On 2012/11/08 20:30:01, siva wrote:
> Expect.isFalse(cf2 === cf1);

Done.

http://codereview.chromium.org/11265047/diff/7001/tests/language/const_nested...
tests/language/const_nested_test.dart:31: foo();
On 2012/11/08 20:30:01, siva wrote:
> foo() should be returned as a closure and invoked outside of main.

Done.

Powered by Google App Engine
This is Rietveld 408576698