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

Issue 10867012: Add a smi-check instruction for arithmetic smi operations. (Closed)

Created:
8 years, 4 months ago by Florian Schneider
Modified:
8 years, 4 months ago
Reviewers:
srdjan
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Add a smi-check instruction for arithmetic smi operations. The flowgraph optimizer inserts smi checks for the inputs of arithmetic smi operations: PushArgument v0 PushArgument v1 v2 <- InstanceCall(+, v0, v1) IC[1: Smi, Smi] becomes CheckSmi(v0) CheckSmi(v1) v2 <- BinarySmiOp(+, v0, v1) Each input operand is checked separately. This avoids using a temp register for a combined smi check. It also allows us to easily eliminate the checks for left and right input separately. There are two ways to eliminate smi checks: 1. By common subexpression elimination: if the value checked is already checked for smi-ness before. 2. By class-id propagation: If the input value is guaranteed to be a smi. Committed: https://code.google.com/p/dart/source/detail?r=11216

Patch Set 1 #

Total comments: 10

Patch Set 2 : addressed comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+223 lines, -110 lines) Patch
M runtime/vm/code_generator.h View 1 chunk +2 lines, -1 line 0 comments Download
M runtime/vm/flow_graph_optimizer.cc View 6 chunks +37 lines, -15 lines 0 comments Download
M runtime/vm/il_printer.cc View 1 chunk +10 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language.h View 1 7 chunks +48 lines, -5 lines 0 comments Download
M runtime/vm/intermediate_language.cc View 1 4 chunks +65 lines, -45 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 6 chunks +31 lines, -22 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 6 chunks +30 lines, -22 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Florian Schneider
8 years, 4 months ago (2012-08-22 14:43:09 UTC) #1
srdjan
LGTM https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/flow_graph_optimizer.cc File runtime/vm/flow_graph_optimizer.cc (right): https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/flow_graph_optimizer.cc#newcode342 runtime/vm/flow_graph_optimizer.cc:342: instr->env()->Copy()); Some binary ops will now not be ...
8 years, 4 months ago (2012-08-22 15:56:51 UTC) #2
Florian Schneider
8 years, 4 months ago (2012-08-23 07:53:15 UTC) #3
https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/flow_graph_...
File runtime/vm/flow_graph_optimizer.cc (right):

https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/flow_graph_...
runtime/vm/flow_graph_optimizer.cc:342: instr->env()->Copy());
On 2012/08/22 15:56:51, srdjan wrote:
> Some binary ops will now not be able to deoptimize (AND, OR, ...). Shall we
> clear environment for those?

Done. Yes, I forgot to return the right value in CanDeoptimize for &, |, ^
operations. When CanDeoptimize is false, the register allocator removes
environments automatically.

https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/intermediat...
File runtime/vm/intermediate_language.cc (right):

https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/intermediat...
runtime/vm/intermediate_language.cc:1089: return (value()->ResultCid() ==
kSmiCid) ?  NULL : instr;
On 2012/08/22 15:56:51, srdjan wrote:
> This is too early to eliminate all checks as FlowGraphOptimizer runs before
the
> type propagation (and type propagation needs to run after some nodes have been
> replaced). You should have another check in CheckSmiComp::EmitNative.
> 
> Maybe we need another pass after type propagation that will eliminate all
> checks?

Already done. TryReplace is called by the pass OptimizeComputations which is
invoked after FlowGraphTypePropagator.

https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/intermediat...
File runtime/vm/intermediate_language.h (right):

https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/intermediat...
runtime/vm/intermediate_language.h:157: // By default return its input parameter
(no replacement).
On 2012/08/22 15:56:51, srdjan wrote:
> 'its input parameter' is not that clear to me. I thought it is the
computation's
> input parameter being returned.

I changed the comment. The old behaviour was that a NULL return value menas that
nothing changes. Now NULL means that the instructions will be removed.

https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/intermediat...
File runtime/vm/intermediate_language_ia32.cc (right):

https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/intermediat...
runtime/vm/intermediate_language_ia32.cc:1469: // Can't deoptimize. Arguments
are already checked for smi.
On 2012/08/22 15:56:51, srdjan wrote:
> How can we say that this computation cannot deoptimize
> (Computation::CanDeoptimize) ? Different computation for the bit operations? A
> flag in BinarySmiOpComp?

Done. Changed CanDeoptimize accordingly.

https://chromiumcodereview.appspot.com/10867012/diff/1/runtime/vm/intermediat...
runtime/vm/intermediate_language_ia32.cc:2194: void
CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) {
On 2012/08/22 15:56:51, srdjan wrote:
> You want to check here if we can skip Smi check.

Done. OptimizeComputations should eliminate all redundant checks.

Powered by Google App Engine
This is Rietveld 408576698