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

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

Issue 722793002: Revert "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
804 void Definition::ReplaceWith(Definition* other, 792 void Definition::ReplaceWith(Definition* other,
805 ForwardInstructionIterator* iterator) { 793 ForwardInstructionIterator* iterator) {
806 // Record other's input uses. 794 // Record other's input uses.
807 for (intptr_t i = other->InputCount() - 1; i >= 0; --i) { 795 for (intptr_t i = other->InputCount() - 1; i >= 0; --i) {
808 Value* input = other->InputAt(i); 796 Value* input = other->InputAt(i);
809 input->definition()->AddInputUse(input); 797 input->definition()->AddInputUse(input);
810 } 798 }
811 // Take other's environment from this definition. 799 // Take other's environment from this definition.
812 ASSERT(other->env() == NULL); 800 ASSERT(other->env() == NULL);
813 other->SetEnvironment(env()); 801 other->SetEnvironment(env());
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 } 1987 }
2000 1988
2001 return replacement; 1989 return replacement;
2002 } 1990 }
2003 1991
2004 return this; 1992 return this;
2005 } 1993 }
2006 1994
2007 1995
2008 Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) { 1996 Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) {
2009 if (!HasUses() && !CanDeoptimize()) return NULL; 1997 if (!HasUses()) return NULL;
2010 1998
2011 // Fold away Unbox<rep>(Box<rep>(v)). 1999 // Fold away Unbox<rep>(Box<rep>(v)).
2012 BoxInstr* box_defn = value()->definition()->AsBox(); 2000 BoxInstr* box_defn = value()->definition()->AsBox();
2013 if ((box_defn != NULL) && 2001 if ((box_defn != NULL) &&
2014 (box_defn->from_representation() == representation())) { 2002 (box_defn->from_representation() == representation())) {
2015 return box_defn->value()->definition(); 2003 return box_defn->value()->definition();
2016 } 2004 }
2017 2005
2018 if ((representation() == kUnboxedDouble) && value()->BindsToConstant()) { 2006 if ((representation() == kUnboxedDouble) && value()->BindsToConstant()) {
2019 UnboxedConstantInstr* uc = NULL; 2007 UnboxedConstantInstr* uc = NULL;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 Isolate* isolate = flow_graph->isolate(); 2243 Isolate* isolate = flow_graph->isolate();
2256 // Only handle strict-compares. 2244 // Only handle strict-compares.
2257 if (comparison()->IsStrictCompare()) { 2245 if (comparison()->IsStrictCompare()) {
2258 bool negated = false; 2246 bool negated = false;
2259 Definition* replacement = 2247 Definition* replacement =
2260 CanonicalizeStrictCompare(comparison()->AsStrictCompare(), &negated); 2248 CanonicalizeStrictCompare(comparison()->AsStrictCompare(), &negated);
2261 if (replacement == comparison()) { 2249 if (replacement == comparison()) {
2262 return this; 2250 return this;
2263 } 2251 }
2264 ComparisonInstr* comp = replacement->AsComparison(); 2252 ComparisonInstr* comp = replacement->AsComparison();
2265 if ((comp == NULL) || 2253 if ((comp == NULL) || comp->CanDeoptimize()) {
2266 comp->CanDeoptimize() ||
2267 comp->HasUnmatchedInputRepresentations()) {
2268 return this; 2254 return this;
2269 } 2255 }
2270 2256
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
2271 // Replace the comparison if the replacement is used at this branch, 2266 // Replace the comparison if the replacement is used at this branch,
2272 // and has exactly one use. 2267 // and has exactly one use.
2273 Value* use = comp->input_use_list(); 2268 Value* use = comp->input_use_list();
2274 if ((use->instruction() == this) && comp->HasOnlyUse(use)) { 2269 if ((use->instruction() == this) && comp->HasOnlyUse(use)) {
2275 if (negated) { 2270 if (negated) {
2276 comp->NegateComparison(); 2271 comp->NegateComparison();
2277 } 2272 }
2278 RemoveEnvironment(); 2273 RemoveEnvironment();
2279 flow_graph->CopyDeoptTarget(this, comp); 2274 flow_graph->CopyDeoptTarget(this, comp);
2280 // Unlink environment from the comparison since it is copied to the 2275 // Unlink environment from the comparison since it is copied to the
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 case Token::kTRUNCDIV: return 0; 3365 case Token::kTRUNCDIV: return 0;
3371 case Token::kMOD: return 1; 3366 case Token::kMOD: return 1;
3372 default: UNIMPLEMENTED(); return -1; 3367 default: UNIMPLEMENTED(); return -1;
3373 } 3368 }
3374 } 3369 }
3375 3370
3376 3371
3377 #undef __ 3372 #undef __
3378 3373
3379 } // namespace dart 3374 } // 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