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