blob: 8e1653ddb9a024db16d0cd252e577ea6eb859e00 [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"
23
Mathieu Chartier4e305412014-02-19 10:54:44 -080024namespace art {
25
26namespace mirror {
27 class Class;
28 class Object;
29} // namespace mirror
30
31// How we want to sanity check the heap's correctness.
32enum VerifyObjectMode {
33 kVerifyObjectModeDisabled, // Heap verification is disabled.
34 kVerifyObjectModeFast, // Sanity heap accesses quickly by using VerifyClassClass.
35 kVerifyObjectModeAll // Sanity heap accesses thoroughly.
36};
37
38enum VerifyObjectFlags {
39 kVerifyNone = 0x0,
40 // Verify self when we are doing an operation.
41 kVerifyThis = 0x1,
42 // Verify reads from objects.
43 kVerifyReads = 0x2,
44 // Verify writes to objects.
45 kVerifyWrites = 0x4,
46 // Verify all things.
47 kVerifyAll = kVerifyThis | kVerifyReads | kVerifyWrites,
48};
49
50static constexpr bool kVerifyStack = kIsDebugBuild;
51static constexpr VerifyObjectFlags kDefaultVerifyFlags = kVerifyNone;
52static constexpr VerifyObjectMode kVerifyObjectSupport =
53 kDefaultVerifyFlags != 0 ? kVerifyObjectModeFast : kVerifyObjectModeDisabled;
54
Ian Rogers22d5e732014-07-15 22:23:51 -070055ALWAYS_INLINE void VerifyObject(mirror::Object* obj) NO_THREAD_SAFETY_ANALYSIS;
Mathieu Chartier4e305412014-02-19 10:54:44 -080056
57// Check that c.getClass() == c.getClass().getClass().
Ian Rogers22d5e732014-07-15 22:23:51 -070058ALWAYS_INLINE bool VerifyClassClass(mirror::Class* c) NO_THREAD_SAFETY_ANALYSIS;
Mathieu Chartier4e305412014-02-19 10:54:44 -080059
60} // namespace art
61
62#endif // ART_RUNTIME_VERIFY_OBJECT_H_