OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |