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

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

Issue 1058793003: A CheckClass instruction that compares against a null class only can be optimized to check instance… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
« 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/constant_propagator.h" 8 #include "vm/constant_propagator.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 185
186 186
187 EffectSet CheckClassIdInstr::Dependencies() const { 187 EffectSet CheckClassIdInstr::Dependencies() const {
188 // Externalization of strings via the API can change the class-id. 188 // Externalization of strings via the API can change the class-id.
189 return !CheckClassInstr::IsImmutableClassId(cid_) ? 189 return !CheckClassInstr::IsImmutableClassId(cid_) ?
190 EffectSet::Externalization() : EffectSet::None(); 190 EffectSet::Externalization() : EffectSet::None();
191 } 191 }
192 192
193 193
194 bool CheckClassInstr::IsNullCheck() const { 194 bool CheckClassInstr::DeoptIfNull() const {
195 if (unary_checks().NumberOfChecks() != 1) { 195 if (unary_checks().NumberOfChecks() != 1) {
196 return false; 196 return false;
197 } 197 }
198 CompileType* in_type = value()->Type(); 198 CompileType* in_type = value()->Type();
199 const intptr_t cid = unary_checks().GetCidAt(0); 199 const intptr_t cid = unary_checks().GetCidAt(0);
200 // Performance check: use CheckSmiInstr instead. 200 // Performance check: use CheckSmiInstr instead.
201 ASSERT(cid != kSmiCid); 201 ASSERT(cid != kSmiCid);
202 return in_type->is_nullable() && (in_type->ToNullableCid() == cid); 202 return in_type->is_nullable() && (in_type->ToNullableCid() == cid);
203 } 203 }
204 204
205 205
206 // Null object is a singleton of null-class (except for some sentinel,
207 // transitional temporaries). Instead of checking against the null class only
208 // we can check against null instance instead.
209 bool CheckClassInstr::DeoptIfNotNull() const {
210 if (unary_checks().NumberOfChecks() != 1) {
211 return false;
212 }
213 const intptr_t cid = unary_checks().GetCidAt(0);
214 return cid == kNullCid;
215 }
216
217
218
206 bool CheckClassInstr::IsDenseSwitch() const { 219 bool CheckClassInstr::IsDenseSwitch() const {
207 if (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) return false; 220 if (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) return false;
208 if (cids_.length() > 2 && 221 if (cids_.length() > 2 &&
209 cids_[cids_.length() - 1] - cids_[0] < kBitsPerWord) { 222 cids_[cids_.length() - 1] - cids_[0] < kBitsPerWord) {
210 return true; 223 return true;
211 } 224 }
212 return false; 225 return false;
213 } 226 }
214 227
215 228
(...skipping 3371 matching lines...) Expand 10 before | Expand all | Expand 10 after
3587 case Token::kTRUNCDIV: return 0; 3600 case Token::kTRUNCDIV: return 0;
3588 case Token::kMOD: return 1; 3601 case Token::kMOD: return 1;
3589 default: UNIMPLEMENTED(); return -1; 3602 default: UNIMPLEMENTED(); return -1;
3590 } 3603 }
3591 } 3604 }
3592 3605
3593 3606
3594 #undef __ 3607 #undef __
3595 3608
3596 } // namespace dart 3609 } // 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