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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 562203005: Inline toDouble calls on mints (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index cb830facc3e216001f3378de60c0c940a6df96fd..c43cd2619b26aef2aef6911f3f42292777d38736 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -638,21 +638,12 @@ void FlowGraphOptimizer::InsertConversion(Representation from,
converted = new UnboxUint32Instr(use->CopyWithType(), deopt_id);
} else if (from == kUnboxedMint && to == kUnboxedDouble) {
ASSERT(CanUnboxDouble());
- // Convert by boxing/unboxing.
- // TODO(fschneider): Implement direct unboxed mint-to-double conversion.
- BoxIntegerInstr* boxed =
- new(I) BoxIntegerInstr(use->CopyWithType());
- use->BindTo(boxed);
- InsertBefore(insert_before, boxed, NULL, FlowGraph::kValue);
-
const intptr_t deopt_id = (deopt_target != NULL) ?
deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId;
- converted = new(I) UnboxDoubleInstr(new(I) Value(boxed), deopt_id);
-
+ converted = new MintToDoubleInstr(use->CopyWithType(), deopt_id);
} else if ((from == kUnboxedDouble) && (to == kTagged)) {
ASSERT(CanUnboxDouble());
converted = new(I) BoxDoubleInstr(use->CopyWithType());
-
} else if ((from == kTagged) && (to == kUnboxedDouble)) {
ASSERT(CanUnboxDouble());
ASSERT((deopt_target != NULL) ||
@@ -3051,14 +3042,21 @@ bool FlowGraphOptimizer::TryInlineInstanceMethod(InstanceCallInstr* call) {
if (CanUnboxDouble() &&
(recognized_kind == MethodRecognizer::kIntegerToDouble) &&
- (ic_data.NumberOfChecks() == 1) &&
- (class_ids[0] == kSmiCid)) {
- AddReceiverCheck(call);
- ReplaceCall(call,
- new(I) SmiToDoubleInstr(
- new(I) Value(call->ArgumentAt(0)),
- call->token_pos()));
- return true;
+ (ic_data.NumberOfChecks() == 1)) {
+ if (class_ids[0] == kSmiCid) {
+ AddReceiverCheck(call);
+ ReplaceCall(call,
+ new(I) SmiToDoubleInstr(
+ new(I) Value(call->ArgumentAt(0)),
+ call->token_pos()));
+ return true;
+ } else if (class_ids[0] == kMintCid) {
+ AddReceiverCheck(call);
+ ReplaceCall(call,
+ new(I) MintToDoubleInstr(new(I) Value(call->ArgumentAt(0)),
+ call->deopt_id()));
+ return true;
+ }
}
if (class_ids[0] == kDoubleCid) {
@@ -4502,23 +4500,6 @@ void FlowGraphOptimizer::VisitStaticCall(StaticCallInstr* call) {
recognized_kind,
call->token_pos());
ReplaceCall(call, invoke);
- } else if (recognized_kind == MethodRecognizer::kDoubleFromInteger) {
- if (call->HasICData() && (call->ic_data()->NumberOfChecks() == 1)) {
Cutch 2014/09/16 16:04:11 This code had two problems: 1) DoubleFromInteger
Florian Schneider 2014/09/17 11:15:32 Good catch. Double.fromInteger is called in a lot
Cutch 2014/09/18 16:39:49 Done.
- const ICData& ic_data = *call->ic_data();
- if (CanUnboxDouble() && ArgIsAlways(kSmiCid, ic_data, 0)) {
- Definition* arg = call->ArgumentAt(0);
- InsertBefore(call,
- new(I) CheckSmiInstr(
- new(I) Value(arg),
- call->deopt_id(),
- call->token_pos()),
- call->env(),
- FlowGraph::kEffect);
- ReplaceCall(call,
- new(I) SmiToDoubleInstr(new(I) Value(arg),
- call->token_pos()));
- }
- }
} else if (call->function().IsFactory()) {
const Class& function_class =
Class::Handle(I, call->function().Owner());
@@ -8483,6 +8464,17 @@ void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) {
}
+void ConstantPropagator::VisitMintToDouble(MintToDoubleInstr* instr) {
+ const Object& value = instr->value()->definition()->constant_value();
+ if (IsConstant(value) && value.IsInteger()) {
+ SetValue(instr, Double::Handle(I,
+ Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld)));
+ } else if (IsNonConstant(value)) {
+ SetValue(instr, non_constant_);
+ }
+}
+
+
void ConstantPropagator::VisitInt32ToDouble(Int32ToDoubleInstr* instr) {
const Object& value = instr->value()->definition()->constant_value();
if (IsConstant(value) && value.IsInteger()) {

Powered by Google App Engine
This is Rietveld 408576698