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

Issue 669155: Add an assigned variables analysis.... (Closed)

Created:
10 years, 9 months ago by fschneider
Modified:
9 years, 6 months ago
CC:
v8-dev
Visibility:
Public.

Description

Add an assigned variables analysis. This change adds a pass over the AST that computes the set of assigned variables for locals and parameters for each expression. The result of this analysis is used to for two purposes: 1. Recognize variables that are trivial subexpressions. A left sub-expression of a binary operation is trivial if it is a local variable or a parameter and it is not assigned in the right sub-expression. In the case of a trivial left sub-expression we evaluate the right first. Currently only binary operations and compare operations are considered when finding trivial left sub-expressions. 2. Recogize certain simple for-loops with a constant trip count where the loop variable is always within smi range. If the loop count variable is not assigned in the body of the loop (except in the update expression the for-loop). This allows omitting smi checks on operation using the loop count variable. Committed: http://code.google.com/p/v8/source/detail?r=4087

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 42

Patch Set 4 : '' #

Patch Set 5 : '' #

Patch Set 6 : '' #

Patch Set 7 : '' #

Total comments: 26

Patch Set 8 : '' #

Total comments: 16

Patch Set 9 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+699 lines, -88 lines) Patch
M src/ast.h View 1 2 3 4 5 6 7 8 11 chunks +32 lines, -3 lines 0 comments Download
M src/ast.cc View 1 2 3 4 5 6 7 1 chunk +15 lines, -1 line 0 comments Download
M src/compiler.cc View 1 2 3 4 5 6 7 8 2 chunks +18 lines, -0 lines 0 comments Download
M src/data-flow.h View 1 2 3 4 5 6 7 8 2 chunks +35 lines, -1 line 0 comments Download
M src/data-flow.cc View 1 2 3 4 5 6 7 8 2 chunks +440 lines, -0 lines 0 comments Download
M src/ia32/codegen-ia32.cc View 1 2 3 4 5 6 7 8 6 chunks +131 lines, -78 lines 0 comments Download
M src/ia32/macro-assembler-ia32.h View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
M src/ia32/macro-assembler-ia32.cc View 1 2 3 4 1 chunk +6 lines, -0 lines 0 comments Download
M src/ia32/virtual-frame-ia32.h View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -0 lines 0 comments Download
M src/ia32/virtual-frame-ia32.cc View 1 2 3 4 5 6 7 8 1 chunk +10 lines, -4 lines 0 comments Download
M src/scopes.h View 4 5 6 7 8 1 chunk +0 lines, -1 line 0 comments Download
M src/virtual-frame-inl.h View 1 2 3 4 5 6 7 8 1 chunk +6 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
fschneider
Ready for first round of review. I tried to reduce the number of bit-vector copies ...
10 years, 9 months ago (2010-03-05 14:06:34 UTC) #1
Kevin Millikin (Chromium)
First round of comments on the assigned variables visitor. I think you can simply accumulate ...
10 years, 9 months ago (2010-03-08 10:55:32 UTC) #2
fschneider
Uploaded new version with comments addressed. I'm still processing expressions left-to-right (and saving the intermediate ...
10 years, 9 months ago (2010-03-08 17:26:47 UTC) #3
Kevin Millikin (Chromium)
http://codereview.chromium.org/669155/diff/32/1032 File src/data-flow.cc (right): http://codereview.chromium.org/669155/diff/32/1032#newcode714 src/data-flow.cc:714: Visit(stmt->condition()); On 2010/03/08 17:26:47, fschneider wrote: > I could ...
10 years, 9 months ago (2010-03-09 06:03:47 UTC) #4
fschneider
http://codereview.chromium.org/669155/diff/32/1032 File src/data-flow.cc (right): http://codereview.chromium.org/669155/diff/32/1032#newcode714 src/data-flow.cc:714: Visit(stmt->condition()); On 2010/03/09 06:03:47, Kevin Millikin wrote: > On ...
10 years, 9 months ago (2010-03-10 11:52:23 UTC) #5
Kevin Millikin (Chromium)
http://codereview.chromium.org/669155/diff/25001/11009 File src/ast.h (right): http://codereview.chromium.org/669155/diff/25001/11009#newcode128 src/ast.h:128: virtual Block* AsBlock() { return NULL; } Is this ...
10 years, 9 months ago (2010-03-10 14:37:06 UTC) #6
fschneider
Thanks. I addressed the comments. I also added marking trivial receivers of property stores in ...
10 years, 9 months ago (2010-03-10 15:47:48 UTC) #7
Kevin Millikin (Chromium)
I think you should remove Scope::num_stack_variables. Other than that, there are some suggestions and LGTM. ...
10 years, 9 months ago (2010-03-10 16:41:14 UTC) #8
fschneider
10 years, 9 months ago (2010-03-10 17:15:24 UTC) #9
http://codereview.chromium.org/669155/diff/35001/9010
File src/compiler.cc (right):

http://codereview.chromium.org/669155/diff/35001/9010#newcode82
src/compiler.cc:82: if (function->scope()->num_stack_variables() > 0) {
On 2010/03/10 16:41:14, Kevin Millikin wrote:
> Could we get rid of num_stack_variables and use
> 
> if (function->scope()->num_parameters() > 0 ||
>     function->scope()->num_stack_slots() > 0) { ... }

Done.

http://codereview.chromium.org/669155/diff/35001/9002
File src/data-flow.cc (right):

http://codereview.chromium.org/669155/diff/35001/9002#newcode1178
src/data-flow.cc:1178: void
AssignedVariablesAnalyzer::RecordAssignedVar(Variable* var) {
On 2010/03/10 16:41:14, Kevin Millikin wrote:
> It might make more sense to require var to be non-NULL and check for it at the
> call sites.

Done.

http://codereview.chromium.org/669155/diff/35001/9002#newcode1185
src/data-flow.cc:1185: void
AssignedVariablesAnalyzer::ComputeTrivialExpression(Expression* expr) {
On 2010/03/10 16:41:14, Kevin Millikin wrote:
> It doesn't really Compute.  Maybe "MarkIfTrivial"?

Done.

http://codereview.chromium.org/669155/diff/35001/9002#newcode1189
src/data-flow.cc:1189: !var->is_this() &&
On 2010/03/10 16:41:14, Kevin Millikin wrote:
> You could remove the special case for this in VariableProxy::IsTrivial, and
have
> 
> if (var != NULL &&
>     var->IsStackAllocated() &&
>     (var->is_this() || !av_.Contains(BitIndex(var)))) {
>   ....
> }

Done.

http://codereview.chromium.org/669155/diff/35001/9002#newcode1423
src/data-flow.cc:1423: RecordAssignedVar(var);
On 2010/03/10 16:41:14, Kevin Millikin wrote:
> Then you'd have
> 
> if (var != NULL) RecordAssignedVar(var);
> 
> here.

Done.

http://codereview.chromium.org/669155/diff/35001/9002#newcode1425
src/data-flow.cc:1425: ProcessExpression(expr->value());
On 2010/03/10 16:41:14, Kevin Millikin wrote:
> It doesn't make any difference, but since the assignment to var happens after
> the evaluation of expr->value(), it might make sense to have
> 
> ProcessExpression(expr->value());
> RecordAssignedVar(var)...

Done.

http://codereview.chromium.org/669155/diff/35001/9006
File src/ia32/virtual-frame-ia32.cc (right):

http://codereview.chromium.org/669155/diff/35001/9006#newcode1174
src/ia32/virtual-frame-ia32.cc:1174: if (proxy != NULL) {
On 2010/03/10 16:41:14, Kevin Millikin wrote:
> I don't think there needs to be a special case for parameter -1:
> 
> if (proxy != NULL) {
>   Slot* slot = proxy->var()->slot();
>   ASSERT(slot != NULL);
>   if (slot->type() == Slot::LOCAL) {
>     PushLocalAt(slot->index());
>     return;
>   }
>   if (slot->type() == Slot::PARAMETER) {
>     PushParameterAt(slot->index());
>     return;
>   }

Done.

http://codereview.chromium.org/669155/diff/35001/9008
File src/ia32/virtual-frame-ia32.h (right):

http://codereview.chromium.org/669155/diff/35001/9008#newcode426
src/ia32/virtual-frame-ia32.h:426: inline void SetTypeLocalAt(int index,
NumberInfo info);
On 2010/03/10 16:41:14, Kevin Millikin wrote:
> Maybe SetTypeForLocalAt?

Done.

Powered by Google App Engine
This is Rietveld 408576698