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

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

Issue 2912903002: Reapply "Fix misoptimization of 'is' test"" (Closed)
Patch Set: Remove change to TestCidsInstr::Canonicalize and improve printer Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/constant_propagator.h" 10 #include "vm/constant_propagator.h"
(...skipping 2718 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 const Object& constant_value = value()->BoundConstant(); 2729 const Object& constant_value = value()->BoundConstant();
2730 if (constant_value.IsSmi() && 2730 if (constant_value.IsSmi() &&
2731 cids_.Contains(Smi::Cast(constant_value).Value())) { 2731 cids_.Contains(Smi::Cast(constant_value).Value())) {
2732 return NULL; 2732 return NULL;
2733 } 2733 }
2734 } 2734 }
2735 return this; 2735 return this;
2736 } 2736 }
2737 2737
2738 2738
2739 TestCidsInstr::TestCidsInstr(TokenPosition token_pos,
2740 Token::Kind kind,
2741 Value* value,
2742 const ZoneGrowableArray<intptr_t>& cid_results,
2743 intptr_t deopt_id)
2744 : TemplateComparison(token_pos, kind, deopt_id),
2745 cid_results_(cid_results),
2746 licm_hoisted_(false) {
2747 ASSERT((kind == Token::kIS) || (kind == Token::kISNOT));
2748 SetInputAt(0, value);
2749 set_operation_cid(kObjectCid);
2750 #ifdef DEBUG
2751 ASSERT(cid_results[0] == kSmiCid);
2752 if (deopt_id == Thread::kNoDeoptId) {
2753 // The entry for Smi can be special, but all other entries have
2754 // to match in the no-deopt case.
2755 for (intptr_t i = 4; i < cid_results.length(); i += 2) {
2756 ASSERT(cid_results[i + 1] == cid_results[3]);
2757 }
2758 }
2759 #endif
2760 }
2761
2762
2739 Definition* TestCidsInstr::Canonicalize(FlowGraph* flow_graph) { 2763 Definition* TestCidsInstr::Canonicalize(FlowGraph* flow_graph) {
2740 CompileType* in_type = left()->Type(); 2764 CompileType* in_type = left()->Type();
2741 intptr_t cid = in_type->ToCid(); 2765 intptr_t cid = in_type->ToCid();
2742 if (cid == kDynamicCid) return this; 2766 if (cid == kDynamicCid) return this;
2743 2767
2744 const ZoneGrowableArray<intptr_t>& data = cid_results(); 2768 const ZoneGrowableArray<intptr_t>& data = cid_results();
2745 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0; 2769 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0;
2746 for (intptr_t i = 0; i < data.length(); i += 2) { 2770 for (intptr_t i = 0; i < data.length(); i += 2) {
2747 if (data[i] == cid) { 2771 if (data[i] == cid) {
2748 return (data[i + 1] == true_result) 2772 return (data[i + 1] == true_result)
2749 ? flow_graph->GetConstant(Bool::True()) 2773 ? flow_graph->GetConstant(Bool::True())
2750 : flow_graph->GetConstant(Bool::False()); 2774 : flow_graph->GetConstant(Bool::False());
2751 } 2775 }
2752 } 2776 }
2753 2777
2754 // TODO(sra): Handle misses if the instruction is not deoptimizing. 2778 if (!CanDeoptimize()) {
2779 ASSERT(deopt_id() == Thread::kNoDeoptId);
2780 return (data[data.length() - 1] == true_result)
2781 ? flow_graph->GetConstant(Bool::False())
2782 : flow_graph->GetConstant(Bool::True());
2783 }
2784
2755 // TODO(sra): Handle nullable input, possibly canonicalizing to a compare 2785 // TODO(sra): Handle nullable input, possibly canonicalizing to a compare
2756 // against `null`. 2786 // against `null`.
2757 return this; 2787 return this;
2758 } 2788 }
2759 2789
2760 2790
2761 Instruction* GuardFieldClassInstr::Canonicalize(FlowGraph* flow_graph) { 2791 Instruction* GuardFieldClassInstr::Canonicalize(FlowGraph* flow_graph) {
2762 if (field().guarded_cid() == kDynamicCid) { 2792 if (field().guarded_cid() == kDynamicCid) {
2763 return NULL; // Nothing to guard. 2793 return NULL; // Nothing to guard.
2764 } 2794 }
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after
4331 "native function '%s' (%" Pd " arguments) cannot be found", 4361 "native function '%s' (%" Pd " arguments) cannot be found",
4332 native_name().ToCString(), function().NumParameters()); 4362 native_name().ToCString(), function().NumParameters());
4333 } 4363 }
4334 set_is_auto_scope(auto_setup_scope); 4364 set_is_auto_scope(auto_setup_scope);
4335 set_native_c_function(native_function); 4365 set_native_c_function(native_function);
4336 } 4366 }
4337 4367
4338 #undef __ 4368 #undef __
4339 4369
4340 } // namespace dart 4370 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698