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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 11855007: Optimize stores to Uint8List. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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/intermediate_language.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 16956)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -548,8 +548,19 @@
switch (class_id) {
case kArrayCid:
case kGrowableObjectArrayCid:
- // Acceptable store index classes.
+ if (ArgIsAlwaysSmi(*call->ic_data(), 2)) {
+ value_check = call->ic_data()->AsUnaryClassChecksForArgNr(2);
+ }
break;
+ case kUint8ArrayCid:
+ // Check that value is always smi.
+ value_check = call->ic_data()->AsUnaryClassChecksForArgNr(2);
+ if ((value_check.NumberOfChecks() != 1) ||
+ (value_check.GetReceiverClassIdAt(0) != kSmiCid)) {
+ return false;
+ }
+ break;
+
case kFloat32ArrayCid:
case kFloat64ArrayCid: {
// Check that value is always double.
@@ -592,13 +603,16 @@
type_args = new Value(load_type_args);
break;
}
+ case kUint8ArrayCid:
case kFloat32ArrayCid:
case kFloat64ArrayCid: {
ConstantInstr* null_constant = new ConstantInstr(Object::ZoneHandle());
InsertBefore(call, null_constant, NULL, Definition::kValue);
instantiator = new Value(null_constant);
type_args = new Value(null_constant);
- ASSERT(value_type.IsDoubleType());
+ ASSERT((class_id != kUint8ArrayCid) || value_type.IsIntType());
+ ASSERT((class_id != kFloat32ArrayCid && class_id != kFloat64ArrayCid) ||
+ value_type.IsDoubleType());
ASSERT(value_type.IsInstantiated());
break;
}
@@ -622,21 +636,24 @@
Value* value = call->ArgumentAt(2)->value();
// Check if store barrier is needed.
bool needs_store_barrier = true;
- if ((class_id == kFloat32ArrayCid) || (class_id == kFloat64ArrayCid)) {
- ASSERT(!value_check.IsNull());
- InsertBefore(call,
- new CheckClassInstr(value->Copy(),
- call->deopt_id(),
- value_check),
- call->env(),
- Definition::kEffect);
- needs_store_barrier = false;
- } else if (ArgIsAlwaysSmi(*call->ic_data(), 2)) {
- InsertBefore(call,
- new CheckSmiInstr(value->Copy(), call->deopt_id()),
- call->env(),
- Definition::kEffect);
- needs_store_barrier = false;
+ if (!value_check.IsNull()) {
+ ASSERT(value_check.NumberOfChecks() == 1);
+ if (value_check.GetReceiverClassIdAt(0) == kSmiCid) {
+ InsertBefore(call,
+ new CheckSmiInstr(value->Copy(), call->deopt_id()),
+ call->env(),
+ Definition::kEffect);
+ needs_store_barrier = false;
+ } else {
+ ASSERT(value_check.GetReceiverClassIdAt(0) == kDoubleCid);
+ InsertBefore(call,
+ new CheckClassInstr(value->Copy(),
+ call->deopt_id(),
+ value_check),
+ call->env(),
+ Definition::kEffect);
+ needs_store_barrier = false;
+ }
}
Definition* array_op =
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698