blob: d8c1c402b960df08822ac29779ecdf3f2dfe2cb3 [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
Mathieu Chartier8ab7e782014-05-19 16:55:27 -070020// For ostream.
21#include <ostream>
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080022// For uint32_t.
23#include <stdint.h>
24// For size_t.
25#include <stdlib.h>
26
27namespace art {
28namespace mirror {
Hiroshi Yamauchi4db74492014-04-22 17:10:48 -070029class Class;
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080030class Object;
Mathieu Chartier407f7022014-02-18 14:37:05 -080031template<class MirrorType> class HeapReference;
Hiroshi Yamauchi4db74492014-04-22 17:10:48 -070032class Reference;
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080033} // namespace mirror
34class StackVisitor;
35
36enum RootType {
37 kRootUnknown = 0,
38 kRootJNIGlobal,
39 kRootJNILocal,
40 kRootJavaFrame,
41 kRootNativeStack,
42 kRootStickyClass,
43 kRootThreadBlock,
44 kRootMonitorUsed,
45 kRootThreadObject,
46 kRootInternedString,
47 kRootDebugger,
48 kRootVMInternal,
49 kRootJNIMonitor,
50};
Mathieu Chartier8ab7e782014-05-19 16:55:27 -070051std::ostream& operator<<(std::ostream& os, const RootType& root_type);
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080052
53// Returns the new address of the object, returns root if it has not moved. tid and root_type are
54// only used by hprof.
Mathieu Chartier815873e2014-02-13 18:02:13 -080055typedef void (RootCallback)(mirror::Object** root, void* arg, uint32_t thread_id,
56 RootType root_type);
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080057// A callback for visiting an object in the heap.
58typedef void (ObjectCallback)(mirror::Object* obj, void* arg);
59// A callback used for marking an object, returns the new address of the object if the object moved.
60typedef mirror::Object* (MarkObjectCallback)(mirror::Object* obj, void* arg)
61 __attribute__((warn_unused_result));
62// A callback for verifying roots.
63typedef void (VerifyRootCallback)(const mirror::Object* root, void* arg, size_t vreg,
Mathieu Chartier7bf9f192014-04-04 11:09:41 -070064 const StackVisitor* visitor, RootType root_type);
Mathieu Chartier407f7022014-02-18 14:37:05 -080065
66typedef void (MarkHeapReferenceCallback)(mirror::HeapReference<mirror::Object>* ref, void* arg);
Hiroshi Yamauchi4db74492014-04-22 17:10:48 -070067typedef void (DelayReferenceReferentCallback)(mirror::Class* klass, mirror::Reference* ref, void* arg);
Mathieu Chartier407f7022014-02-18 14:37:05 -080068
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080069// A callback for testing if an object is marked, returns nullptr if not marked, otherwise the new
70// address the object (if the object didn't move, returns the object input parameter).
71typedef mirror::Object* (IsMarkedCallback)(mirror::Object* object, void* arg)
72 __attribute__((warn_unused_result));
Mathieu Chartier308351a2014-06-15 12:39:02 -070073
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.
76typedef bool (IsHeapReferenceMarkedCallback)(mirror::HeapReference<mirror::Object>* object,
77 void* arg) __attribute__((warn_unused_result));
Mathieu Chartier3bb57c72014-02-18 11:38:45 -080078typedef void (ProcessMarkStackCallback)(void* arg);
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080079
80} // namespace art
81
82#endif // ART_RUNTIME_OBJECT_CALLBACKS_H_