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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 11098009: Implement SmiToInt and DoubleToInt. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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.h » ('j') | runtime/vm/intermediate_language_ia32.cc » ('J')
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 13385)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -887,7 +887,7 @@
ASSERT(call->HasICData());
const ICData& ic_data = *call->ic_data();
if ((ic_data.NumberOfChecks() == 0) || !ic_data.HasOneTarget()) {
- // No type feedback collected.
+ // No type feedback collected or multiple targets found.
return false;
}
Function& target = Function::Handle();
@@ -914,6 +914,31 @@
return true;
}
+ if ((recognized_kind == MethodRecognizer::kIntegerToInteger) &&
+ (class_ids[0] == kSmiCid)) {
+ // TODO(srdjan): implement also for BigInt and Mint.
+ InsertBefore(call,
+ new CheckSmiInstr(call->ArgumentAt(0)->value()->Copy(),
+ call->deopt_id()),
+ call->env(),
+ Definition::kEffect);
+ IntegerToIntegerInstr* int2int_instr =
+ new IntegerToIntegerInstr(call->ArgumentAt(0)->value(), call, kSmiCid);
+ call->ReplaceWith(int2int_instr, current_iterator());
Florian Schneider 2012/10/09 11:13:58 Since IntegerToInteger itself is a nop, I think yo
srdjan 2012/10/09 21:23:04 Done.
+ RemovePushArguments(call);
+ return true;
+ }
+
+ if ((recognized_kind == MethodRecognizer::kDoubleToInteger) &&
+ (class_ids[0] == kDoubleCid)) {
+ AddCheckClass(call, call->ArgumentAt(0)->value()->Copy());
+ DoubleToIntegerInstr* d2int_instr = new DoubleToIntegerInstr(call);
+ call->ReplaceWith(d2int_instr, current_iterator());
+ // Pushed arguments are not removed because DoubleToInt is implemented
+ // as a call.
+ return true;
+ }
+
if (recognized_kind == MethodRecognizer::kStringBaseIsEmpty) {
if (!ic_data.HasOneTarget()) {
// Target is not only StringBase_get_length.
@@ -927,6 +952,8 @@
}
+// Tries to optimize instance call by replacing it with a faster instruction
+// (e.g, binary op, field load, ..).
void FlowGraphOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
if (instr->HasICData() && (instr->ic_data()->NumberOfChecks() > 0)) {
const Token::Kind op_kind = instr->token_kind();
@@ -3049,6 +3076,23 @@
}
+void ConstantPropagator::VisitIntegerToInteger(IntegerToIntegerInstr* instr) {
+ const Object& value = instr->value()->definition()->constant_value();
+ if (IsNonConstant(value)) {
+ SetValue(instr, non_constant_);
+ } else if (IsConstant(value)) {
+ // TODO(kmillikin): Handle conversion.
+ SetValue(instr, non_constant_);
+ }
+}
+
+
+void ConstantPropagator::VisitDoubleToInteger(DoubleToIntegerInstr* instr) {
+ // TODO(kmillikin): Handle conversion.
+ SetValue(instr, non_constant_);
+}
+
+
void ConstantPropagator::VisitConstant(ConstantInstr* instr) {
SetValue(instr, instr->value());
}
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | runtime/vm/intermediate_language_ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698