OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_VERIFIER_H_ | 5 #ifndef VM_VERIFIER_H_ |
6 #define VM_VERIFIER_H_ | 6 #define VM_VERIFIER_H_ |
7 | 7 |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/handles.h" |
10 #include "vm/visitor.h" | 11 #include "vm/visitor.h" |
11 | 12 |
12 namespace dart { | 13 namespace dart { |
13 | 14 |
14 DECLARE_FLAG(bool, verify_on_transition); | 15 DECLARE_FLAG(bool, verify_on_transition); |
15 | 16 |
16 #define VERIFY_ON_TRANSITION \ | 17 #define VERIFY_ON_TRANSITION \ |
17 if (FLAG_verify_on_transition) { \ | 18 if (FLAG_verify_on_transition) { \ |
18 VerifyPointersVisitor::VerifyPointers(); \ | 19 VerifyPointersVisitor::VerifyPointers(); \ |
19 Isolate::Current()->heap()->Verify(); \ | 20 Isolate::Current()->heap()->Verify(); \ |
20 } \ | 21 } \ |
21 | 22 |
22 | 23 |
23 // Forward declarations. | 24 // Forward declarations. |
24 class RawObject; | 25 class RawObject; |
25 | 26 |
26 // A sample object pointer visitor implementation which verifies that | 27 // A sample object pointer visitor implementation which verifies that |
27 // the pointers visited are contained in the isolate heap. | 28 // the pointers visited are contained in the isolate heap. |
28 class VerifyPointersVisitor : public ObjectPointerVisitor { | 29 class VerifyPointersVisitor : public ObjectPointerVisitor { |
29 public: | 30 public: |
30 VerifyPointersVisitor() {} | 31 VerifyPointersVisitor() {} |
31 | 32 |
32 virtual void VisitPointers(RawObject** first, RawObject** last); | 33 virtual void VisitPointers(RawObject** first, RawObject** last); |
33 | 34 |
34 static void VerifyPointers(); | 35 static void VerifyPointers(); |
| 36 |
| 37 private: |
| 38 DISALLOW_COPY_AND_ASSIGN(VerifyPointersVisitor); |
| 39 }; |
| 40 |
| 41 class VerifyWeakPointersVisitor : public HandleVisitor { |
| 42 public: |
| 43 explicit VerifyWeakPointersVisitor(VerifyPointersVisitor* visitor) |
| 44 : visitor_(visitor) { |
| 45 } |
| 46 |
| 47 virtual void VisitHandle(uword addr); |
| 48 |
| 49 private: |
| 50 ObjectPointerVisitor* visitor_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(VerifyWeakPointersVisitor); |
35 }; | 53 }; |
36 | 54 |
37 } // namespace dart | 55 } // namespace dart |
38 | 56 |
39 #endif // VM_VERIFIER_H_ | 57 #endif // VM_VERIFIER_H_ |
OLD | NEW |