blob: e40e8eaa37751287d7053685520803042c8cf8ca [file] [log] [blame]
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -07001/*
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_READ_BARRIER_H_
18#define ART_RUNTIME_READ_BARRIER_H_
19
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070020#include "base/mutex.h"
21#include "base/macros.h"
22#include "offsets.h"
23#include "read_barrier_c.h"
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -070024
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070025// This is a C++ (not C) header file, separate from read_barrier_c.h
26// which needs to be a C header file for asm_support.h.
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -070027
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070028namespace art {
29namespace mirror {
30 class Object;
31 template<typename MirrorType> class HeapReference;
32} // namespace mirror
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -070033
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070034class ReadBarrier {
35 public:
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -070036 template <typename MirrorType, ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070037 ALWAYS_INLINE static MirrorType* Barrier(
38 mirror::Object* obj, MemberOffset offset, mirror::HeapReference<MirrorType>* ref_addr)
39 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Hiroshi Yamauchi4cba0d92014-05-21 21:10:23 -070040
41 template <typename MirrorType, ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
42 ALWAYS_INLINE static MirrorType* BarrierForWeakRoot(MirrorType* ref)
43 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070044};
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -070045
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070046} // namespace art
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -070047
48#endif // ART_RUNTIME_READ_BARRIER_H_