| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // TODO(fschneider): Make sure ic_data are sorted to hit more cases. | 145 // TODO(fschneider): Make sure ic_data are sorted to hit more cases. |
| 146 if (unary_checks().GetReceiverClassIdAt(i) != | 146 if (unary_checks().GetReceiverClassIdAt(i) != |
| 147 other_check->unary_checks().GetReceiverClassIdAt(i)) { | 147 other_check->unary_checks().GetReceiverClassIdAt(i)) { |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 return true; | 151 return true; |
| 152 } | 152 } |
| 153 | 153 |
| 154 | 154 |
| 155 bool CheckClassInstr::IsImmutableClassId(intptr_t cid) { |
| 156 switch (cid) { |
| 157 case kOneByteStringCid: |
| 158 case kTwoByteStringCid: |
| 159 return false; |
| 160 default: |
| 161 return true; |
| 162 } |
| 163 } |
| 164 |
| 165 |
| 166 static bool AreAllChecksImmutable(const ICData& checks) { |
| 167 const intptr_t len = checks.NumberOfChecks(); |
| 168 for (intptr_t i = 0; i < len; i++) { |
| 169 if (checks.IsUsedAt(i)) { |
| 170 if (!CheckClassInstr::IsImmutableClassId( |
| 171 checks.GetReceiverClassIdAt(i))) { |
| 172 return false; |
| 173 } |
| 174 } |
| 175 } |
| 176 return true; |
| 177 } |
| 178 |
| 179 |
| 155 EffectSet CheckClassInstr::Dependencies() const { | 180 EffectSet CheckClassInstr::Dependencies() const { |
| 156 // Externalization of strings via the API can change the class-id. | 181 // Externalization of strings via the API can change the class-id. |
| 157 const bool externalizable = | 182 return !AreAllChecksImmutable(unary_checks()) ? |
| 158 unary_checks().HasReceiverClassId(kOneByteStringCid) || | 183 EffectSet::Externalization() : EffectSet::None(); |
| 159 unary_checks().HasReceiverClassId(kTwoByteStringCid); | |
| 160 return externalizable ? EffectSet::Externalization() : EffectSet::None(); | |
| 161 } | 184 } |
| 162 | 185 |
| 163 | 186 |
| 164 EffectSet CheckClassIdInstr::Dependencies() const { | 187 EffectSet CheckClassIdInstr::Dependencies() const { |
| 165 // Externalization of strings via the API can change the class-id. | 188 // Externalization of strings via the API can change the class-id. |
| 166 const bool externalizable = | 189 return !CheckClassInstr::IsImmutableClassId(cid_) ? |
| 167 cid_ == kOneByteStringCid || cid_ == kTwoByteStringCid; | 190 EffectSet::Externalization() : EffectSet::None(); |
| 168 return externalizable ? EffectSet::Externalization() : EffectSet::None(); | |
| 169 } | 191 } |
| 170 | 192 |
| 171 | 193 |
| 172 bool CheckClassInstr::IsNullCheck() const { | 194 bool CheckClassInstr::IsNullCheck() const { |
| 173 if (unary_checks().NumberOfChecks() != 1) { | 195 if (unary_checks().NumberOfChecks() != 1) { |
| 174 return false; | 196 return false; |
| 175 } | 197 } |
| 176 CompileType* in_type = value()->Type(); | 198 CompileType* in_type = value()->Type(); |
| 177 const intptr_t cid = unary_checks().GetCidAt(0); | 199 const intptr_t cid = unary_checks().GetCidAt(0); |
| 178 // Performance check: use CheckSmiInstr instead. | 200 // Performance check: use CheckSmiInstr instead. |
| (...skipping 3289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3468 case Token::kTRUNCDIV: return 0; | 3490 case Token::kTRUNCDIV: return 0; |
| 3469 case Token::kMOD: return 1; | 3491 case Token::kMOD: return 1; |
| 3470 default: UNIMPLEMENTED(); return -1; | 3492 default: UNIMPLEMENTED(); return -1; |
| 3471 } | 3493 } |
| 3472 } | 3494 } |
| 3473 | 3495 |
| 3474 | 3496 |
| 3475 #undef __ | 3497 #undef __ |
| 3476 | 3498 |
| 3477 } // namespace dart | 3499 } // namespace dart |
| OLD | NEW |