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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 490573003: Small improvements in array code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/il_printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 39516)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -3808,17 +3808,20 @@
*cursor = flow_graph()->AppendTo(*cursor, len_in_bytes, call->env(),
FlowGraph::kValue);
- ConstantInstr* length_adjustment =
- flow_graph()->GetConstant(Smi::Handle(I, Smi::New(
- Instance::ElementSizeFor(view_cid) - 1)));
// adjusted_length = len_in_bytes - (element_size - 1).
- BinarySmiOpInstr* adjusted_length =
- new(I) BinarySmiOpInstr(Token::kSUB,
- new(I) Value(len_in_bytes),
- new(I) Value(length_adjustment),
- call->deopt_id(), call->token_pos());
- *cursor = flow_graph()->AppendTo(*cursor, adjusted_length, call->env(),
- FlowGraph::kValue);
+ Definition* adjusted_length = len_in_bytes;
+ intptr_t adjustment = Instance::ElementSizeFor(view_cid) - 1;
+ if (adjustment > 0) {
+ ConstantInstr* length_adjustment =
+ flow_graph()->GetConstant(Smi::Handle(I, Smi::New(adjustment)));
+ adjusted_length =
+ new(I) BinarySmiOpInstr(Token::kSUB,
+ new(I) Value(len_in_bytes),
+ new(I) Value(length_adjustment),
+ call->deopt_id(), call->token_pos());
+ *cursor = flow_graph()->AppendTo(*cursor, adjusted_length, call->env(),
+ FlowGraph::kValue);
+ }
// Check adjusted_length > 0.
ConstantInstr* zero =
« no previous file with comments | « no previous file | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698