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

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 721773003: Suppress canonicalization of Unbox() instruction that can deoptimize. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cpu.h" 8 #include "vm/cpu.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_allocator.h" 10 #include "vm/flow_graph_allocator.h"
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 if (curr == this) return true; 782 if (curr == this) return true;
783 } 783 }
784 784
785 return false; 785 return false;
786 } 786 }
787 787
788 return dom_block->Dominates(block); 788 return dom_block->Dominates(block);
789 } 789 }
790 790
791 791
792 bool Instruction::HasUnmatchedInputRepresentations() const {
793 for (intptr_t i = 0; i < InputCount(); i++) {
794 Definition* input = InputAt(i)->definition();
795 if (RequiredInputRepresentation(i) != input->representation()) {
796 return true;
797 }
798 }
799
800 return false;
801 }
802
803
792 void Definition::ReplaceWith(Definition* other, 804 void Definition::ReplaceWith(Definition* other,
793 ForwardInstructionIterator* iterator) { 805 ForwardInstructionIterator* iterator) {
794 // Record other's input uses. 806 // Record other's input uses.
795 for (intptr_t i = other->InputCount() - 1; i >= 0; --i) { 807 for (intptr_t i = other->InputCount() - 1; i >= 0; --i) {
796 Value* input = other->InputAt(i); 808 Value* input = other->InputAt(i);
797 input->definition()->AddInputUse(input); 809 input->definition()->AddInputUse(input);
798 } 810 }
799 // Take other's environment from this definition. 811 // Take other's environment from this definition.
800 ASSERT(other->env() == NULL); 812 ASSERT(other->env() == NULL);
801 other->SetEnvironment(env()); 813 other->SetEnvironment(env());
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 } 1999 }
1988 2000
1989 return replacement; 2001 return replacement;
1990 } 2002 }
1991 2003
1992 return this; 2004 return this;
1993 } 2005 }
1994 2006
1995 2007
1996 Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) { 2008 Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) {
1997 if (!HasUses()) return NULL; 2009 if (!HasUses() && !CanDeoptimize()) return NULL;
1998 2010
1999 // Fold away Unbox<rep>(Box<rep>(v)). 2011 // Fold away Unbox<rep>(Box<rep>(v)).
2000 BoxInstr* box_defn = value()->definition()->AsBox(); 2012 BoxInstr* box_defn = value()->definition()->AsBox();
2001 if ((box_defn != NULL) && 2013 if ((box_defn != NULL) &&
2002 (box_defn->from_representation() == representation())) { 2014 (box_defn->from_representation() == representation())) {
2003 return box_defn->value()->definition(); 2015 return box_defn->value()->definition();
2004 } 2016 }
2005 2017
2006 if ((representation() == kUnboxedDouble) && value()->BindsToConstant()) { 2018 if ((representation() == kUnboxedDouble) && value()->BindsToConstant()) {
2007 UnboxedConstantInstr* uc = NULL; 2019 UnboxedConstantInstr* uc = NULL;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2243 Isolate* isolate = flow_graph->isolate(); 2255 Isolate* isolate = flow_graph->isolate();
2244 // Only handle strict-compares. 2256 // Only handle strict-compares.
2245 if (comparison()->IsStrictCompare()) { 2257 if (comparison()->IsStrictCompare()) {
2246 bool negated = false; 2258 bool negated = false;
2247 Definition* replacement = 2259 Definition* replacement =
2248 CanonicalizeStrictCompare(comparison()->AsStrictCompare(), &negated); 2260 CanonicalizeStrictCompare(comparison()->AsStrictCompare(), &negated);
2249 if (replacement == comparison()) { 2261 if (replacement == comparison()) {
2250 return this; 2262 return this;
2251 } 2263 }
2252 ComparisonInstr* comp = replacement->AsComparison(); 2264 ComparisonInstr* comp = replacement->AsComparison();
2253 if ((comp == NULL) || comp->CanDeoptimize()) { 2265 if ((comp == NULL) ||
2266 comp->CanDeoptimize() ||
2267 comp->HasUnmatchedInputRepresentations()) {
2254 return this; 2268 return this;
2255 } 2269 }
2256 2270
2257 // Assert that the comparison is not serving as a pending deoptimization
2258 // target for conversions.
2259 for (intptr_t i = 0; i < comp->InputCount(); i++) {
2260 if (comp->RequiredInputRepresentation(i) !=
2261 comp->InputAt(i)->definition()->representation()) {
2262 return this;
2263 }
2264 }
2265
2266 // Replace the comparison if the replacement is used at this branch, 2271 // Replace the comparison if the replacement is used at this branch,
2267 // and has exactly one use. 2272 // and has exactly one use.
2268 Value* use = comp->input_use_list(); 2273 Value* use = comp->input_use_list();
2269 if ((use->instruction() == this) && comp->HasOnlyUse(use)) { 2274 if ((use->instruction() == this) && comp->HasOnlyUse(use)) {
2270 if (negated) { 2275 if (negated) {
2271 comp->NegateComparison(); 2276 comp->NegateComparison();
2272 } 2277 }
2273 RemoveEnvironment(); 2278 RemoveEnvironment();
2274 flow_graph->CopyDeoptTarget(this, comp); 2279 flow_graph->CopyDeoptTarget(this, comp);
2275 // Unlink environment from the comparison since it is copied to the 2280 // Unlink environment from the comparison since it is copied to the
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
3365 case Token::kTRUNCDIV: return 0; 3370 case Token::kTRUNCDIV: return 0;
3366 case Token::kMOD: return 1; 3371 case Token::kMOD: return 1;
3367 default: UNIMPLEMENTED(); return -1; 3372 default: UNIMPLEMENTED(); return -1;
3368 } 3373 }
3369 } 3374 }
3370 3375
3371 3376
3372 #undef __ 3377 #undef __
3373 3378
3374 } // namespace dart 3379 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | tests/language/vm/canonicalization_preserves_deopt_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698