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