Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
code_observers.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_CODE_OBSERVERS_H_
6#define RUNTIME_VM_CODE_OBSERVERS_H_
7
8#include "vm/allocation.h"
9#include "vm/globals.h"
10
11#include "include/dart_api.h"
12
13#if !defined(PRODUCT)
14namespace dart {
15
16class CodeComments;
17
18// Object observing code creation events. Used by external profilers and
19// debuggers to map address ranges to function names.
21 public:
23
24 virtual ~CodeObserver() {}
25
26 // Returns true if this observer is active and should be notified
27 // about newly created code objects.
28 virtual bool IsActive() const = 0;
29
30 // Notify code observer about a newly created code object with the
31 // given properties.
32 virtual void Notify(const char* name,
33 uword base,
34 uword prologue_offset,
35 uword size,
36 bool optimized,
37 const CodeComments* comments) = 0;
38
39 private:
41};
42
43class Mutex;
44
45class CodeObservers : public AllStatic {
46 public:
47 static void Init();
48
49 static void RegisterExternal(Dart_CodeObserver observer);
50
51 static void Register(CodeObserver* observer);
52
53 // Notify all active code observers about a newly created code object.
54 static void NotifyAll(const char* name,
55 uword base,
56 uword prologue_offset,
57 uword size,
58 bool optimized,
59 const CodeComments* comments);
60
61 // Returns true if there is at least one active code observer.
62 static bool AreActive();
63
64 static void Cleanup();
65
66 static Mutex* mutex() { return mutex_; }
67
68 private:
69 static Mutex* mutex_;
70 static intptr_t observers_length_;
71 static CodeObserver** observers_;
72};
73
74} // namespace dart
75#endif // !defined(PRODUCT)
76
77#endif // RUNTIME_VM_CODE_OBSERVERS_H_
virtual bool IsActive() const =0
virtual void Notify(const char *name, uword base, uword prologue_offset, uword size, bool optimized, const CodeComments *comments)=0
static Mutex * mutex()
static void Cleanup()
static void RegisterExternal(Dart_CodeObserver observer)
static void NotifyAll(const char *name, uword base, uword prologue_offset, uword size, bool optimized, const CodeComments *comments)
static bool AreActive()
const char *const name
uintptr_t uword
Definition globals.h:501
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581