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

Issue 9595017: Refactor constant part. (Closed)

Created:
8 years, 9 months ago by floitsch
Modified:
8 years, 9 months ago
Reviewers:
kasperl
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Refactor constant part. The Ssa backend now uses the CompileTimeConstantHandler's Constants. Committed: https://code.google.com/p/dart/source/detail?r=4958

Patch Set 1 #

Total comments: 20

Patch Set 2 : Address comments. #

Patch Set 3 : More comment addressing. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+262 lines, -410 lines) Patch
M frog/leg/compile_time_constants.dart View 1 17 chunks +37 lines, -41 lines 0 comments Download
M frog/leg/compiler.dart View 1 5 chunks +5 lines, -5 lines 0 comments Download
M frog/leg/emitter.dart View 1 6 chunks +8 lines, -8 lines 0 comments Download
M frog/leg/ssa/builder.dart View 1 2 13 chunks +29 lines, -35 lines 0 comments Download
M frog/leg/ssa/codegen.dart View 1 2 chunks +13 lines, -29 lines 0 comments Download
M frog/leg/ssa/nodes.dart View 1 2 37 chunks +123 lines, -244 lines 0 comments Download
M frog/leg/ssa/optimize.dart View 1 2 4 chunks +29 lines, -40 lines 0 comments Download
M frog/leg/ssa/tracer.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M frog/leg/tree/nodes.dart View 1 chunk +0 lines, -2 lines 0 comments Download
M tests/co19/co19-leg.status View 3 chunks +0 lines, -3 lines 0 comments Download
M tests/language/language-leg.status View 1 chunk +0 lines, -1 line 0 comments Download
A tests/language/src/CompileTimeConstant9Test.dart View 1 chunk +16 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
floitsch
8 years, 9 months ago (2012-03-05 12:45:12 UTC) #1
kasperl
LGTM! https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/compile_time_constants.dart File frog/leg/compile_time_constants.dart (right): https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/compile_time_constants.dart#newcode23 frog/leg/compile_time_constants.dart:23: bool isTrue() { This smells like you should ...
8 years, 9 months ago (2012-03-05 13:53:16 UTC) #2
floitsch
8 years, 9 months ago (2012-03-05 15:43:24 UTC) #3
https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/compile_time_c...
File frog/leg/compile_time_constants.dart (right):

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/compile_time_c...
frog/leg/compile_time_constants.dart:23: bool isTrue() {
On 2012/03/05 13:53:16, kasperl wrote:
> This smells like you should have two separate BoolConstants: TrueConstant and
> FalseConstant.

I will do that when I introduce caching for the common constants.

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/compile_time_c...
frog/leg/compile_time_constants.dart:44: Constant binaryFold(String op, Constant
other) {
On 2012/03/05 13:53:16, kasperl wrote:
> It sort of rubs me the wrong way to use a string for the operation here.

will fix in another CL.

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/compile_time_c...
frog/leg/compile_time_constants.dart:58: // the VM.
On 2012/03/05 13:53:16, kasperl wrote:
> Did you file this as a bug? Update comment with bug number.

bug is gone.

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/builder.dart
File frog/leg/ssa/builder.dart (right):

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/builder.da...
frog/leg/ssa/builder.dart:1300: // See if we can constant-fold right away. This
avoids rewrites later on.
On 2012/03/05 13:53:16, kasperl wrote:
> Nice. I wonder if there's anyway of avoiding to create the "wrong" HConstant
in
> the first place? It would require you to not visit the node.receiver and to be
> able to get a Constant from the syntax tree somehow.

We could, but I'm not sure it wins us that much. Also note that we avoid more
than just -<number>:
var x = 99;
var y = -x;  will correctly be folded here.

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/builder.da...
frog/leg/ssa/builder.dart:1320: void visitBinary(HInstruction left, Operator op,
HInstruction right) {
On 2012/03/05 13:53:16, kasperl wrote:
> Maybe think about if it would be possible to constant fold in the caller of
this
> method too (like you do for unary sends).

Of course I thought about it :)
Currently it is kind of annoying with the =,++,... mixed in. But I will continue
thinking about it.

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/codegen.dart
File frog/leg/ssa/codegen.dart (right):

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/codegen.da...
frog/leg/ssa/codegen.dart:644: CompileTimeConstantHandler handler =
compiler.compileTimeConstantHandler;
On 2012/03/05 13:53:16, kasperl wrote:
> Maybe compiler.compileTimeConstantHandler should be renamed?
compiler.constants?

renamed to constantHandler.

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/nodes.dart
File frog/leg/ssa/nodes.dart (right):

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/nodes.dart...
frog/leg/ssa/nodes.dart:151: HType mapConstantTypeToSsaType(Constant constant) {
On 2012/03/05 13:53:16, kasperl wrote:
> static?

Done.

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/nodes.dart...
frog/leg/ssa/nodes.dart:921: bool isNullConstant() => false;
On 2012/03/05 13:53:16, kasperl wrote:
> I know it doesn't read as well, but I think I'd prefer these to be
> isConstantNull, etc. Somehow that just seems more consistent to me.

Done.

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/nodes.dart...
frog/leg/ssa/nodes.dart:1188: return graph.addNewConstant(new
IntConstant(string.length));
On 2012/03/05 13:53:16, kasperl wrote:
> Maybe keeping a few helpers around (graph.addNewConstantInt) for these cases
> wouldn't hurt?

Done.

https://chromiumcodereview.appspot.com/9595017/diff/1/frog/leg/ssa/nodes.dart...
frog/leg/ssa/nodes.dart:1382: String operationAsString() => "+";
On 2012/03/05 13:53:16, kasperl wrote:
> These operationAsString seem a bit broken. I wonder how much work it would be
to
> introduce const objects for operations?

will think about it in another CL.

Powered by Google App Engine
This is Rietveld 408576698