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_CODE_OBSERVERS_H_ | 5 #ifndef VM_CODE_OBSERVERS_H_ |
6 #define VM_CODE_OBSERVERS_H_ | 6 #define VM_CODE_OBSERVERS_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #include "vm/allocation.h" |
9 | 10 |
10 namespace dart { | 11 namespace dart { |
11 | 12 |
12 // Object observing code creation events. Used by external profilers and | 13 // Object observing code creation events. Used by external profilers and |
13 // debuggers to map address ranges to function names. | 14 // debuggers to map address ranges to function names. |
14 class CodeObserver { | 15 class CodeObserver { |
15 public: | 16 public: |
| 17 CodeObserver() { } |
| 18 |
16 virtual ~CodeObserver() { } | 19 virtual ~CodeObserver() { } |
17 | 20 |
18 // Returns true if this observer is active and should be notified | 21 // Returns true if this observer is active and should be notified |
19 // about newly created code objects. | 22 // about newly created code objects. |
20 virtual bool IsActive() const = 0; | 23 virtual bool IsActive() const = 0; |
21 | 24 |
22 // Notify code observer about a newly created code object with the | 25 // Notify code observer about a newly created code object with the |
23 // given properties. | 26 // given properties. |
24 virtual void Notify(const char* name, | 27 virtual void Notify(const char* name, |
25 uword base, | 28 uword base, |
26 uword prologue_offset, | 29 uword prologue_offset, |
27 uword size, | 30 uword size, |
28 bool optimized) = 0; | 31 bool optimized) = 0; |
| 32 |
| 33 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(CodeObserver); |
29 }; | 35 }; |
30 | 36 |
31 | 37 |
32 class CodeObservers { | 38 class CodeObservers : public AllStatic { |
33 public: | 39 public: |
34 static void InitOnce(); | 40 static void InitOnce(); |
35 | 41 |
36 static void Register(CodeObserver* observer); | 42 static void Register(CodeObserver* observer); |
37 | 43 |
38 // Notify all active code observers about a newly created code object. | 44 // Notify all active code observers about a newly created code object. |
39 static void NotifyAll(const char* name, | 45 static void NotifyAll(const char* name, |
40 uword base, | 46 uword base, |
41 uword prologue_offset, | 47 uword prologue_offset, |
42 uword size, | 48 uword size, |
43 bool optimized); | 49 bool optimized); |
44 | 50 |
45 // Returns true if there is at least one active code observer. | 51 // Returns true if there is at least one active code observer. |
46 static bool AreActive(); | 52 static bool AreActive(); |
47 | 53 |
| 54 static void DeleteAll(); |
| 55 |
48 private: | 56 private: |
49 static intptr_t observers_length_; | 57 static intptr_t observers_length_; |
50 static CodeObserver** observers_; | 58 static CodeObserver** observers_; |
51 }; | 59 }; |
52 | 60 |
53 | 61 |
54 } // namespace dart | 62 } // namespace dart |
55 | 63 |
56 #endif // VM_CODE_OBSERVERS_H_ | 64 #endif // VM_CODE_OBSERVERS_H_ |
OLD | NEW |