Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_RUNTIME_OBJECT_CALLBACKS_H_ |
| 18 | #define ART_RUNTIME_OBJECT_CALLBACKS_H_ |
| 19 | |
Mathieu Chartier | 8ab7e78 | 2014-05-19 16:55:27 -0700 | [diff] [blame] | 20 | // For ostream. |
| 21 | #include <ostream> |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 22 | // For uint32_t. |
| 23 | #include <stdint.h> |
| 24 | // For size_t. |
| 25 | #include <stdlib.h> |
| 26 | |
Mathieu Chartier | 4c13a3f | 2014-07-14 14:57:16 -0700 | [diff] [blame] | 27 | #include "base/macros.h" |
| 28 | |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 29 | namespace art { |
| 30 | namespace mirror { |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 31 | class Class; |
| 32 | class Object; |
| 33 | template<class MirrorType> class HeapReference; |
| 34 | class Reference; |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 35 | } // namespace mirror |
| 36 | class StackVisitor; |
| 37 | |
| 38 | enum RootType { |
| 39 | kRootUnknown = 0, |
| 40 | kRootJNIGlobal, |
| 41 | kRootJNILocal, |
| 42 | kRootJavaFrame, |
| 43 | kRootNativeStack, |
| 44 | kRootStickyClass, |
| 45 | kRootThreadBlock, |
| 46 | kRootMonitorUsed, |
| 47 | kRootThreadObject, |
| 48 | kRootInternedString, |
| 49 | kRootDebugger, |
| 50 | kRootVMInternal, |
| 51 | kRootJNIMonitor, |
| 52 | }; |
Mathieu Chartier | 8ab7e78 | 2014-05-19 16:55:27 -0700 | [diff] [blame] | 53 | std::ostream& operator<<(std::ostream& os, const RootType& root_type); |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 54 | |
| 55 | // Returns the new address of the object, returns root if it has not moved. tid and root_type are |
| 56 | // only used by hprof. |
Mathieu Chartier | 815873e | 2014-02-13 18:02:13 -0800 | [diff] [blame] | 57 | typedef void (RootCallback)(mirror::Object** root, void* arg, uint32_t thread_id, |
| 58 | RootType root_type); |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 59 | // A callback for visiting an object in the heap. |
| 60 | typedef void (ObjectCallback)(mirror::Object* obj, void* arg); |
| 61 | // A callback used for marking an object, returns the new address of the object if the object moved. |
Mathieu Chartier | 4c13a3f | 2014-07-14 14:57:16 -0700 | [diff] [blame] | 62 | typedef mirror::Object* (MarkObjectCallback)(mirror::Object* obj, void* arg) WARN_UNUSED; |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 63 | // A callback for verifying roots. |
| 64 | typedef void (VerifyRootCallback)(const mirror::Object* root, void* arg, size_t vreg, |
Mathieu Chartier | 7bf9f19 | 2014-04-04 11:09:41 -0700 | [diff] [blame] | 65 | const StackVisitor* visitor, RootType root_type); |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 66 | |
| 67 | typedef void (MarkHeapReferenceCallback)(mirror::HeapReference<mirror::Object>* ref, void* arg); |
Hiroshi Yamauchi | 4db7449 | 2014-04-22 17:10:48 -0700 | [diff] [blame] | 68 | typedef void (DelayReferenceReferentCallback)(mirror::Class* klass, mirror::Reference* ref, void* arg); |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 69 | |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 70 | // A callback for testing if an object is marked, returns nullptr if not marked, otherwise the new |
| 71 | // address the object (if the object didn't move, returns the object input parameter). |
Mathieu Chartier | 4c13a3f | 2014-07-14 14:57:16 -0700 | [diff] [blame] | 72 | typedef mirror::Object* (IsMarkedCallback)(mirror::Object* object, void* arg) WARN_UNUSED; |
Mathieu Chartier | 308351a | 2014-06-15 12:39:02 -0700 | [diff] [blame] | 73 | |
| 74 | // Returns true if the object in the heap reference is marked, if it is marked and has moved the |
| 75 | // callback updates the heap reference contain the new value. |
| 76 | typedef bool (IsHeapReferenceMarkedCallback)(mirror::HeapReference<mirror::Object>* object, |
Mathieu Chartier | 4c13a3f | 2014-07-14 14:57:16 -0700 | [diff] [blame] | 77 | void* arg) WARN_UNUSED; |
Mathieu Chartier | 3bb57c7 | 2014-02-18 11:38:45 -0800 | [diff] [blame] | 78 | typedef void (ProcessMarkStackCallback)(void* arg); |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 79 | |
| 80 | } // namespace art |
| 81 | |
| 82 | #endif // ART_RUNTIME_OBJECT_CALLBACKS_H_ |