blob: 767c197206779ef3234e5533d3c977561f1a4604 [file] [log] [blame]
Mathieu Chartier83c8ee02014-01-28 14:50:23 -08001/*
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
20// For uint32_t.
21#include <stdint.h>
22// For size_t.
23#include <stdlib.h>
24
25namespace art {
26namespace mirror {
Hiroshi Yamauchi4db74492014-04-22 17:10:48 -070027class Class;
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080028class Object;
Mathieu Chartier407f7022014-02-18 14:37:05 -080029template<class MirrorType> class HeapReference;
Hiroshi Yamauchi4db74492014-04-22 17:10:48 -070030class Reference;
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080031} // namespace mirror
32class StackVisitor;
33
34enum RootType {
35 kRootUnknown = 0,
36 kRootJNIGlobal,
37 kRootJNILocal,
38 kRootJavaFrame,
39 kRootNativeStack,
40 kRootStickyClass,
41 kRootThreadBlock,
42 kRootMonitorUsed,
43 kRootThreadObject,
44 kRootInternedString,
45 kRootDebugger,
46 kRootVMInternal,
47 kRootJNIMonitor,
48};
49
50// Returns the new address of the object, returns root if it has not moved. tid and root_type are
51// only used by hprof.
Mathieu Chartier815873e2014-02-13 18:02:13 -080052typedef void (RootCallback)(mirror::Object** root, void* arg, uint32_t thread_id,
53 RootType root_type);
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080054// A callback for visiting an object in the heap.
55typedef void (ObjectCallback)(mirror::Object* obj, void* arg);
56// A callback used for marking an object, returns the new address of the object if the object moved.
57typedef mirror::Object* (MarkObjectCallback)(mirror::Object* obj, void* arg)
58 __attribute__((warn_unused_result));
59// A callback for verifying roots.
60typedef void (VerifyRootCallback)(const mirror::Object* root, void* arg, size_t vreg,
Mathieu Chartier7bf9f192014-04-04 11:09:41 -070061 const StackVisitor* visitor, RootType root_type);
Mathieu Chartier407f7022014-02-18 14:37:05 -080062
63typedef void (MarkHeapReferenceCallback)(mirror::HeapReference<mirror::Object>* ref, void* arg);
Hiroshi Yamauchi4db74492014-04-22 17:10:48 -070064typedef void (DelayReferenceReferentCallback)(mirror::Class* klass, mirror::Reference* ref, void* arg);
Mathieu Chartier407f7022014-02-18 14:37:05 -080065
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080066// A callback for testing if an object is marked, returns nullptr if not marked, otherwise the new
67// address the object (if the object didn't move, returns the object input parameter).
68typedef mirror::Object* (IsMarkedCallback)(mirror::Object* object, void* arg)
69 __attribute__((warn_unused_result));
Mathieu Chartier3bb57c72014-02-18 11:38:45 -080070typedef void (ProcessMarkStackCallback)(void* arg);
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080071
72} // namespace art
73
74#endif // ART_RUNTIME_OBJECT_CALLBACKS_H_