blob: 384e56f7f4352186897dbfd2eb15904edda88bcb [file] [log] [blame]
Mathieu Chartier4e305412014-02-19 10:54:44 -08001/*
2 * Copyright (C) 2014 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_VERIFY_OBJECT_H_
18#define ART_RUNTIME_VERIFY_OBJECT_H_
19
Mathieu Chartier4e305412014-02-19 10:54:44 -080020#include <stdint.h>
21
Ian Rogers719d1a32014-03-06 12:13:39 -080022#include "base/macros.h"
Mathieu Chartiera058fdf2016-10-06 15:13:58 -070023#include "obj_ptr.h"
Ian Rogers719d1a32014-03-06 12:13:39 -080024
Mathieu Chartier4e305412014-02-19 10:54:44 -080025namespace art {
26
27namespace mirror {
28 class Class;
29 class Object;
30} // namespace mirror
31
32// How we want to sanity check the heap's correctness.
33enum VerifyObjectMode {
34 kVerifyObjectModeDisabled, // Heap verification is disabled.
35 kVerifyObjectModeFast, // Sanity heap accesses quickly by using VerifyClassClass.
36 kVerifyObjectModeAll // Sanity heap accesses thoroughly.
37};
38
39enum VerifyObjectFlags {
40 kVerifyNone = 0x0,
41 // Verify self when we are doing an operation.
42 kVerifyThis = 0x1,
43 // Verify reads from objects.
44 kVerifyReads = 0x2,
45 // Verify writes to objects.
46 kVerifyWrites = 0x4,
47 // Verify all things.
48 kVerifyAll = kVerifyThis | kVerifyReads | kVerifyWrites,
49};
50
51static constexpr bool kVerifyStack = kIsDebugBuild;
52static constexpr VerifyObjectFlags kDefaultVerifyFlags = kVerifyNone;
53static constexpr VerifyObjectMode kVerifyObjectSupport =
54 kDefaultVerifyFlags != 0 ? kVerifyObjectModeFast : kVerifyObjectModeDisabled;
55
Mathieu Chartiera058fdf2016-10-06 15:13:58 -070056ALWAYS_INLINE void VerifyObject(ObjPtr<mirror::Object> obj) NO_THREAD_SAFETY_ANALYSIS;
Mathieu Chartier4e305412014-02-19 10:54:44 -080057
58// Check that c.getClass() == c.getClass().getClass().
Mathieu Chartiera058fdf2016-10-06 15:13:58 -070059ALWAYS_INLINE bool VerifyClassClass(ObjPtr<mirror::Class> c) NO_THREAD_SAFETY_ANALYSIS;
Mathieu Chartier4e305412014-02-19 10:54:44 -080060
61} // namespace art
62
63#endif // ART_RUNTIME_VERIFY_OBJECT_H_