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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 24239003: Fix range checks for typed data in native code and the optimizer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 27650)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -2649,10 +2649,19 @@
call->deopt_id());
InsertBefore(call, len_in_bytes, call->env(), Definition::kValue);
- // Check byte_index < len_in_bytes.
+ // Check byte_index + num_bytes < len_in_bytes.
Ivan Posva 2013/09/20 17:20:30 Where is the check that byte_index is positive?
siva 2013/09/20 22:03:45 We have been using the name 'element_size_in_bytes
Florian Schneider 2013/09/23 11:02:26 Changed to access_size.
Florian Schneider 2013/09/23 11:02:26 Good catch. Changed into two checks using CheckArr
+ ConstantInstr* num_bytes =
+ flow_graph()->GetConstant(Smi::Handle(Smi::New(
+ FlowGraphCompiler::ElementSizeFor(view_cid) - 1)));
+ BinarySmiOpInstr* adjusted_index =
+ new BinarySmiOpInstr(Token::kADD,
+ new Value(byte_index),
+ new Value(num_bytes),
+ call->deopt_id());
+ InsertBefore(call, adjusted_index, call->env(), Definition::kValue);
InsertBefore(call,
new CheckArrayBoundInstr(new Value(len_in_bytes),
- new Value(byte_index),
+ new Value(adjusted_index),
call->deopt_id()),
call->env(),
Definition::kEffect);

Powered by Google App Engine
This is Rietveld 408576698