| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/precompiler.h" | 5 #include "vm/precompiler.h" |
| 6 | 6 |
| 7 #include "vm/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/branch_optimizer.h" | 10 #include "vm/branch_optimizer.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 238 } |
| 239 | 239 |
| 240 | 240 |
| 241 bool TypeRangeCache::InstanceOfHasClassRange(const AbstractType& type, | 241 bool TypeRangeCache::InstanceOfHasClassRange(const AbstractType& type, |
| 242 intptr_t* lower_limit, | 242 intptr_t* lower_limit, |
| 243 intptr_t* upper_limit) { | 243 intptr_t* upper_limit) { |
| 244 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); | 244 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); |
| 245 | 245 |
| 246 if (!type.IsInstantiated()) return false; | 246 if (!type.IsInstantiated()) return false; |
| 247 if (type.IsFunctionType()) return false; | 247 if (type.IsFunctionType()) return false; |
| 248 if (type.IsDartFunctionType()) return false; |
| 248 | 249 |
| 249 Zone* zone = thread_->zone(); | 250 Zone* zone = thread_->zone(); |
| 250 const TypeArguments& type_arguments = | 251 const TypeArguments& type_arguments = |
| 251 TypeArguments::Handle(zone, type.arguments()); | 252 TypeArguments::Handle(zone, type.arguments()); |
| 252 if (!type_arguments.IsNull() && | 253 if (!type_arguments.IsNull() && |
| 253 !type_arguments.IsRaw(0, type_arguments.Length())) | 254 !type_arguments.IsRaw(0, type_arguments.Length())) |
| 254 return false; | 255 return false; |
| 255 | 256 |
| 256 | 257 |
| 257 intptr_t type_cid = type.type_class_id(); | 258 intptr_t type_cid = type.type_class_id(); |
| 258 if (lower_limits_[type_cid] == kNotContiguous) return false; | 259 if (lower_limits_[type_cid] == kNotContiguous) return false; |
| 259 if (lower_limits_[type_cid] != kNotComputed) { | 260 if (lower_limits_[type_cid] != kNotComputed) { |
| 260 *lower_limit = lower_limits_[type_cid]; | 261 *lower_limit = lower_limits_[type_cid]; |
| 261 *upper_limit = upper_limits_[type_cid]; | 262 *upper_limit = upper_limits_[type_cid]; |
| 262 return true; | 263 return true; |
| 263 } | 264 } |
| 264 | 265 |
| 265 | 266 |
| 266 *lower_limit = -1; | 267 *lower_limit = -1; |
| 267 *upper_limit = -1; | 268 *upper_limit = -1; |
| 268 intptr_t last_matching_cid = -1; | 269 intptr_t last_matching_cid = -1; |
| 269 | 270 |
| 270 ClassTable* table = thread_->isolate()->class_table(); | 271 ClassTable* table = thread_->isolate()->class_table(); |
| 271 Class& cls = Class::Handle(zone); | 272 Class& cls = Class::Handle(zone); |
| 272 AbstractType& cls_type = AbstractType::Handle(zone); | 273 AbstractType& cls_type = AbstractType::Handle(zone); |
| 273 for (intptr_t cid = kInstanceCid; cid < table->NumCids(); cid++) { | 274 for (intptr_t cid = kInstanceCid; cid < table->NumCids(); cid++) { |
| 275 // Create local zone because deep hierarchies may allocate lots of handles |
| 276 // within one iteration of this loop. |
| 277 StackZone stack_zone(thread_); |
| 278 HANDLESCOPE(thread_); |
| 279 |
| 274 if (!table->HasValidClassAt(cid)) continue; | 280 if (!table->HasValidClassAt(cid)) continue; |
| 275 if (cid == kVoidCid) continue; | 281 if (cid == kVoidCid) continue; |
| 276 if (cid == kDynamicCid) continue; | 282 if (cid == kDynamicCid) continue; |
| 277 if (cid == kNullCid) continue; // Instance is not at Bottom like Null type. | 283 if (cid == kNullCid) continue; // Instance is not at Bottom like Null type. |
| 278 cls = table->At(cid); | 284 cls = table->At(cid); |
| 279 if (cls.is_abstract()) continue; | 285 if (cls.is_abstract()) continue; |
| 280 if (cls.is_patch()) continue; | 286 if (cls.is_patch()) continue; |
| 281 if (cls.IsTopLevel()) continue; | 287 if (cls.IsTopLevel()) continue; |
| 282 | 288 |
| 283 cls_type = cls.RareType(); | 289 cls_type = cls.RareType(); |
| 284 if (cls_type.IsSubtypeOf(type, NULL, NULL, Heap::kOld)) { | 290 if (cls_type.IsSubtypeOf(type, NULL, NULL, Heap::kNew)) { |
| 285 last_matching_cid = cid; | 291 last_matching_cid = cid; |
| 286 if (*lower_limit == -1) { | 292 if (*lower_limit == -1) { |
| 287 // Found beginning of range. | 293 // Found beginning of range. |
| 288 *lower_limit = cid; | 294 *lower_limit = cid; |
| 289 } else if (*upper_limit == -1) { | 295 } else if (*upper_limit == -1) { |
| 290 // Expanding range. | 296 // Expanding range. |
| 291 } else { | 297 } else { |
| 292 // Found a second range. | 298 // Found a second range. |
| 293 lower_limits_[type_cid] = kNotContiguous; | 299 lower_limits_[type_cid] = kNotContiguous; |
| 294 return false; | 300 return false; |
| (...skipping 3361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3656 | 3662 |
| 3657 ASSERT(FLAG_precompiled_mode); | 3663 ASSERT(FLAG_precompiled_mode); |
| 3658 const bool optimized = function.IsOptimizable(); // False for natives. | 3664 const bool optimized = function.IsOptimizable(); // False for natives. |
| 3659 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3665 DartPrecompilationPipeline pipeline(zone, field_type_map); |
| 3660 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); | 3666 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); |
| 3661 } | 3667 } |
| 3662 | 3668 |
| 3663 #endif // DART_PRECOMPILER | 3669 #endif // DART_PRECOMPILER |
| 3664 | 3670 |
| 3665 } // namespace dart | 3671 } // namespace dart |
| OLD | NEW |