| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef RUNTIME_VM_CHA_H_ | 5 #ifndef RUNTIME_VM_CHA_H_ |
| 6 #define RUNTIME_VM_CHA_H_ | 6 #define RUNTIME_VM_CHA_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
| 10 #include "vm/thread.h" | 10 #include "vm/thread.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class Class; | 14 class Class; |
| 15 class Function; | 15 class Function; |
| 16 template <typename T> class ZoneGrowableArray; | 16 template <typename T> |
| 17 class ZoneGrowableArray; |
| 17 class String; | 18 class String; |
| 18 | 19 |
| 19 class CHA : public StackResource { | 20 class CHA : public StackResource { |
| 20 public: | 21 public: |
| 21 explicit CHA(Thread* thread) | 22 explicit CHA(Thread* thread) |
| 22 : StackResource(thread), | 23 : StackResource(thread), |
| 23 thread_(thread), | 24 thread_(thread), |
| 24 guarded_classes_(thread->zone(), 1), | 25 guarded_classes_(thread->zone(), 1), |
| 25 previous_(thread->cha()) { | 26 previous_(thread->cha()) { |
| 26 thread->set_cha(this); | 27 thread->set_cha(this); |
| 27 } | 28 } |
| 28 | 29 |
| 29 ~CHA() { | 30 ~CHA() { |
| 30 ASSERT(thread_->cha() == this); | 31 ASSERT(thread_->cha() == this); |
| 31 thread_->set_cha(previous_); | 32 thread_->set_cha(previous_); |
| 32 } | 33 } |
| 33 | 34 |
| 34 // Returns true if the class has subclasses. | 35 // Returns true if the class has subclasses. |
| 35 static bool HasSubclasses(const Class& cls); | 36 static bool HasSubclasses(const Class& cls); |
| 36 bool HasSubclasses(intptr_t cid) const; | 37 bool HasSubclasses(intptr_t cid) const; |
| 37 | 38 |
| 38 // Collect the concrete subclasses of 'cls' into 'class_ids'. Return true if | 39 // Collect the concrete subclasses of 'cls' into 'class_ids'. Return true if |
| 39 // the result is valid (may be invalid because we don't track the subclasses | 40 // the result is valid (may be invalid because we don't track the subclasses |
| 40 // of classes allocated in the VM isolate or class Object). | 41 // of classes allocated in the VM isolate or class Object). |
| 41 bool ConcreteSubclasses(const Class& cls, GrowableArray<intptr_t> *class_ids); | 42 bool ConcreteSubclasses(const Class& cls, GrowableArray<intptr_t>* class_ids); |
| 42 | 43 |
| 43 // Return true if the class is implemented by some other class. | 44 // Return true if the class is implemented by some other class. |
| 44 static bool IsImplemented(const Class& cls); | 45 static bool IsImplemented(const Class& cls); |
| 45 | 46 |
| 46 // Returns true if any subclass of 'cls' contains the function. | 47 // Returns true if any subclass of 'cls' contains the function. |
| 47 // If no override was found subclass_count would contain total count of | 48 // If no override was found subclass_count would contain total count of |
| 48 // finalized subclasses that CHA looked at. | 49 // finalized subclasses that CHA looked at. |
| 49 // This count will be used to validate CHA decision before installing | 50 // This count will be used to validate CHA decision before installing |
| 50 // optimized code compiled in background. | 51 // optimized code compiled in background. |
| 51 bool HasOverride(const Class& cls, | 52 bool HasOverride(const Class& cls, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 79 intptr_t subclass_count; | 80 intptr_t subclass_count; |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 GrowableArray<GuardedClassInfo> guarded_classes_; | 83 GrowableArray<GuardedClassInfo> guarded_classes_; |
| 83 CHA* previous_; | 84 CHA* previous_; |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 } // namespace dart | 87 } // namespace dart |
| 87 | 88 |
| 88 #endif // RUNTIME_VM_CHA_H_ | 89 #endif // RUNTIME_VM_CHA_H_ |
| OLD | NEW |