| Carl Shapiro | adc346f | 2010-06-03 23:01:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 _DALVIK_ALLOC_VISIT |
| 18 | #define _DALVIK_ALLOC_VISIT |
| 19 | |
| 20 | #include "Dalvik.h" |
| 21 | |
| Carl Shapiro | 07018e2 | 2010-10-26 21:07:41 -0700 | [diff] [blame] | 22 | typedef enum { |
| 23 | ROOT_UNKNOWN = 0, |
| 24 | ROOT_JNI_GLOBAL, |
| 25 | ROOT_JNI_LOCAL, |
| 26 | ROOT_JAVA_FRAME, |
| 27 | ROOT_NATIVE_STACK, |
| 28 | ROOT_STICKY_CLASS, |
| 29 | ROOT_THREAD_BLOCK, |
| 30 | ROOT_MONITOR_USED, |
| 31 | ROOT_THREAD_OBJECT, |
| 32 | ROOT_INTERNED_STRING, |
| 33 | ROOT_FINALIZING, |
| 34 | ROOT_DEBUGGER, |
| 35 | ROOT_REFERENCE_CLEANUP, |
| 36 | ROOT_VM_INTERNAL, |
| 37 | ROOT_JNI_MONITOR, |
| 38 | } RootType; |
| 39 | |
| Carl Shapiro | ddb0c1c | 2010-07-13 17:36:41 -0700 | [diff] [blame] | 40 | /* |
| 41 | * Callback invoked with the address of a reference and a user |
| 42 | * supplied context argument. |
| 43 | */ |
| 44 | typedef void Visitor(void *addr, void *arg); |
| Carl Shapiro | adc346f | 2010-06-03 23:01:39 -0700 | [diff] [blame] | 45 | |
| Carl Shapiro | ddb0c1c | 2010-07-13 17:36:41 -0700 | [diff] [blame] | 46 | /* |
| Carl Shapiro | 07018e2 | 2010-10-26 21:07:41 -0700 | [diff] [blame] | 47 | * Like a Visitor, but passes root specific information such as the |
| 48 | * containing thread id and the root type. In cases where a root is |
| 49 | * not specific to a thread, 0, an invalid thread id is provided. |
| 50 | */ |
| 51 | typedef void RootVisitor(void *addr, u4 threadId, RootType type, void *arg); |
| 52 | |
| 53 | /* |
| Carl Shapiro | 1fbfcab | 2010-07-22 17:29:23 -0700 | [diff] [blame] | 54 | * Visits references in an object. |
| Carl Shapiro | ddb0c1c | 2010-07-13 17:36:41 -0700 | [diff] [blame] | 55 | */ |
| Carl Shapiro | 056b966 | 2010-06-15 14:40:20 -0700 | [diff] [blame] | 56 | void dvmVisitObject(Visitor *visitor, Object *obj, void *arg); |
| Carl Shapiro | adc346f | 2010-06-03 23:01:39 -0700 | [diff] [blame] | 57 | |
| Carl Shapiro | 1fbfcab | 2010-07-22 17:29:23 -0700 | [diff] [blame] | 58 | /* |
| 59 | * Visits references in the root set. |
| 60 | */ |
| Carl Shapiro | 07018e2 | 2010-10-26 21:07:41 -0700 | [diff] [blame] | 61 | void dvmVisitRoots(RootVisitor *visitor, void *arg); |
| Carl Shapiro | 1fbfcab | 2010-07-22 17:29:23 -0700 | [diff] [blame] | 62 | |
| Carl Shapiro | adc346f | 2010-06-03 23:01:39 -0700 | [diff] [blame] | 63 | #endif /* _DALVIK_ALLOC_VISIT */ |