| 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 VM_CHA_H_ | 5 #ifndef VM_CHA_H_ |
| 6 #define VM_CHA_H_ | 6 #define 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 | 11 |
| 11 namespace dart { | 12 namespace dart { |
| 12 | 13 |
| 13 class Class; | 14 class Class; |
| 14 class Function; | 15 class Function; |
| 15 template <typename T> class ZoneGrowableArray; | 16 template <typename T> class ZoneGrowableArray; |
| 16 class String; | 17 class String; |
| 17 | 18 |
| 18 class CHA : public StackResource { | 19 class CHA : public StackResource { |
| 19 public: | 20 public: |
| 20 explicit CHA(Isolate* isolate) | 21 explicit CHA(Thread* thread) |
| 21 : StackResource(isolate), | 22 : StackResource(thread->isolate()), |
| 22 isolate_(isolate), | 23 thread_(thread), |
| 23 leaf_classes_(isolate, 1), | 24 leaf_classes_(thread->zone(), 1), |
| 24 previous_(isolate->cha()) { | 25 previous_(thread->cha()) { |
| 25 isolate->set_cha(this); | 26 thread->set_cha(this); |
| 26 } | 27 } |
| 27 | 28 |
| 28 ~CHA() { | 29 ~CHA() { |
| 29 ASSERT(isolate_->cha() == this); | 30 ASSERT(thread_->cha() == this); |
| 30 isolate_->set_cha(previous_); | 31 thread_->set_cha(previous_); |
| 31 } | 32 } |
| 32 | 33 |
| 33 // Returns true if the class has subclasses. | 34 // Returns true if the class has subclasses. |
| 34 // Updates set of leaf classes that we register optimized code with for lazy | 35 // Updates set of leaf classes that we register optimized code with for lazy |
| 35 // deoptimization. | 36 // deoptimization. |
| 36 bool HasSubclasses(const Class& cls); | 37 bool HasSubclasses(const Class& cls); |
| 37 bool HasSubclasses(intptr_t cid); | 38 bool HasSubclasses(intptr_t cid); |
| 38 | 39 |
| 39 // Return true if the class is implemented by some other class. | 40 // Return true if the class is implemented by some other class. |
| 40 // Updates set of leaf classes that we register optimized code with for lazy | 41 // Updates set of leaf classes that we register optimized code with for lazy |
| 41 // deoptimization. | 42 // deoptimization. |
| 42 bool IsImplemented(const Class& cls); | 43 bool IsImplemented(const Class& cls); |
| 43 | 44 |
| 44 // Returns true if any subclass of 'cls' contains the function. | 45 // Returns true if any subclass of 'cls' contains the function. |
| 45 // Updates set of leaf classes that we register optimized code with for lazy | 46 // Updates set of leaf classes that we register optimized code with for lazy |
| 46 // deoptimization. | 47 // deoptimization. |
| 47 bool HasOverride(const Class& cls, const String& function_name); | 48 bool HasOverride(const Class& cls, const String& function_name); |
| 48 | 49 |
| 49 const GrowableArray<Class*>& leaf_classes() const { | 50 const GrowableArray<Class*>& leaf_classes() const { |
| 50 return leaf_classes_; | 51 return leaf_classes_; |
| 51 } | 52 } |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 void AddToLeafClasses(const Class& cls); | 55 void AddToLeafClasses(const Class& cls); |
| 55 | 56 |
| 56 Isolate* isolate_; | 57 Thread* thread_; |
| 57 GrowableArray<Class*> leaf_classes_; | 58 GrowableArray<Class*> leaf_classes_; |
| 58 CHA* previous_; | 59 CHA* previous_; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 } // namespace dart | 62 } // namespace dart |
| 62 | 63 |
| 63 #endif // VM_CHA_H_ | 64 #endif // VM_CHA_H_ |
| OLD | NEW |