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

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

Issue 2904543002: Fix misoptimization of 'is' test (Closed)
Patch Set: Feedback from Slava, do same optimization on AOT and JIT Created 3 years, 7 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 2715 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 const Object& constant_value = value()->BoundConstant(); 2726 const Object& constant_value = value()->BoundConstant();
2727 if (constant_value.IsSmi() && 2727 if (constant_value.IsSmi() &&
2728 cids_.Contains(Smi::Cast(constant_value).Value())) { 2728 cids_.Contains(Smi::Cast(constant_value).Value())) {
2729 return NULL; 2729 return NULL;
2730 } 2730 }
2731 } 2731 }
2732 return this; 2732 return this;
2733 } 2733 }
2734 2734
2735 2735
2736 TestCidsInstr::TestCidsInstr(TokenPosition token_pos,
2737 Token::Kind kind,
2738 Value* value,
2739 const ZoneGrowableArray<intptr_t>& cid_results,
2740 intptr_t deopt_id)
2741 : TemplateComparison(token_pos, kind, deopt_id),
2742 cid_results_(cid_results),
2743 licm_hoisted_(false) {
2744 ASSERT((kind == Token::kIS) || (kind == Token::kISNOT));
2745 SetInputAt(0, value);
2746 set_operation_cid(kObjectCid);
2747 #ifdef DEBUG
2748 ASSERT(cid_results[0] == kSmiCid);
2749 if (deopt_id == Thread::kNoDeoptId) {
2750 // The entry for Smi can be special, but all other entries have
2751 // to match in the no-deopt case.
2752 for (intptr_t i = 4; i < cid_results.length(); i += 2) {
2753 ASSERT(cid_results[i + 1] == cid_results[3]);
2754 }
2755 }
2756 #endif
2757 }
2758
2759
2736 Definition* TestCidsInstr::Canonicalize(FlowGraph* flow_graph) { 2760 Definition* TestCidsInstr::Canonicalize(FlowGraph* flow_graph) {
2737 CompileType* in_type = left()->Type(); 2761 CompileType* in_type = left()->Type();
2738 intptr_t cid = in_type->ToCid(); 2762 intptr_t cid = in_type->ToCid();
2739 if (cid == kDynamicCid) return this; 2763 if (cid == kDynamicCid) return this;
2740 2764
2741 const ZoneGrowableArray<intptr_t>& data = cid_results(); 2765 const ZoneGrowableArray<intptr_t>& data = cid_results();
2742 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0; 2766 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0;
2743 for (intptr_t i = 0; i < data.length(); i += 2) { 2767 for (intptr_t i = 0; i < data.length(); i += 2) {
2744 if (data[i] == cid) { 2768 if (data[i] == cid) {
2745 return (data[i + 1] == true_result) 2769 return (data[i + 1] == true_result)
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after
4327 "native function '%s' (%" Pd " arguments) cannot be found", 4351 "native function '%s' (%" Pd " arguments) cannot be found",
4328 native_name().ToCString(), function().NumParameters()); 4352 native_name().ToCString(), function().NumParameters());
4329 } 4353 }
4330 set_is_auto_scope(auto_setup_scope); 4354 set_is_auto_scope(auto_setup_scope);
4331 set_native_c_function(native_function); 4355 set_native_c_function(native_function);
4332 } 4356 }
4333 4357
4334 #undef __ 4358 #undef __
4335 4359
4336 } // namespace dart 4360 } // 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