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 #include "vm/code_observers.h" | 5 #include "vm/code_observers.h" |
6 | 6 |
| 7 #include "platform/utils.h" |
7 #include "vm/os.h" | 8 #include "vm/os.h" |
8 | 9 |
9 namespace dart { | 10 namespace dart { |
10 | 11 |
11 intptr_t CodeObservers::observers_length_ = 0; | 12 intptr_t CodeObservers::observers_length_ = 0; |
12 CodeObserver** CodeObservers::observers_ = NULL; | 13 CodeObserver** CodeObservers::observers_ = NULL; |
13 | 14 |
14 | 15 |
15 void CodeObservers::Register(CodeObserver* observer) { | 16 void CodeObservers::Register(CodeObserver* observer) { |
16 observers_length_++; | 17 intptr_t new_length = observers_length_ + 1; |
17 observers_ = reinterpret_cast<CodeObserver**>( | 18 observers_ = Utils::Realloc(observers_, observers_length_, new_length); |
18 realloc(observers_, sizeof(observer) * observers_length_)); | |
19 if (observers_ == NULL) { | 19 if (observers_ == NULL) { |
20 FATAL("failed to grow code observers array"); | 20 FATAL("failed to grow code observers array"); |
21 } | 21 } |
| 22 observers_length_ = new_length; |
22 observers_[observers_length_ - 1] = observer; | 23 observers_[observers_length_ - 1] = observer; |
23 } | 24 } |
24 | 25 |
25 | 26 |
26 void CodeObservers::NotifyAll(const char* name, | 27 void CodeObservers::NotifyAll(const char* name, |
27 uword base, | 28 uword base, |
28 uword prologue_offset, | 29 uword prologue_offset, |
29 uword size, | 30 uword size, |
30 bool optimized) { | 31 bool optimized) { |
31 ASSERT(!AreActive() || (strlen(name) != 0)); | 32 ASSERT(!AreActive() || (strlen(name) != 0)); |
(...skipping 20 matching lines...) Expand all Loading... |
52 free(observers_); | 53 free(observers_); |
53 } | 54 } |
54 | 55 |
55 | 56 |
56 void CodeObservers::InitOnce() { | 57 void CodeObservers::InitOnce() { |
57 OS::RegisterCodeObservers(); | 58 OS::RegisterCodeObservers(); |
58 } | 59 } |
59 | 60 |
60 | 61 |
61 } // namespace dart | 62 } // namespace dart |
OLD | NEW |