blob: e252b7bb83d8d33d55baf2f7d2bdcab2ab356fee [file] [log] [blame]
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -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_INL_H_
18#define ART_RUNTIME_READ_BARRIER_INL_H_
19
20#include "read_barrier.h"
21
22#include "mirror/object_reference.h"
23
24namespace art {
25
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -070026template <typename MirrorType, ReadBarrierOption kReadBarrierOption>
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070027inline MirrorType* ReadBarrier::Barrier(
28 mirror::Object* obj, MemberOffset offset, mirror::HeapReference<MirrorType>* ref_addr) {
29 // Unused for now.
30 UNUSED(obj);
31 UNUSED(offset);
32 UNUSED(ref_addr);
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -070033 const bool with_read_barrier = kReadBarrierOption == kWithReadBarrier;
34 if (with_read_barrier && kUseBakerReadBarrier) {
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070035 // To be implemented.
36 return ref_addr->AsMirrorPtr();
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -070037 } else if (with_read_barrier && kUseBrooksReadBarrier) {
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070038 // To be implemented.
39 return ref_addr->AsMirrorPtr();
40 } else {
41 // No read barrier.
42 return ref_addr->AsMirrorPtr();
43 }
44}
45
Hiroshi Yamauchi4cba0d92014-05-21 21:10:23 -070046template <typename MirrorType, ReadBarrierOption kReadBarrierOption>
Hiroshi Yamauchi1bd48722014-05-23 19:58:15 -070047inline MirrorType* ReadBarrier::BarrierForWeakRoot(MirrorType** weak_root) {
48 MirrorType* ref = *weak_root;
Hiroshi Yamauchi4cba0d92014-05-21 21:10:23 -070049 const bool with_read_barrier = kReadBarrierOption == kWithReadBarrier;
50 if (with_read_barrier && kUseBakerReadBarrier) {
51 // To be implemented.
52 return ref;
53 } else if (with_read_barrier && kUseBrooksReadBarrier) {
54 // To be implemented.
55 return ref;
56 } else {
57 return ref;
58 }
59}
60
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070061} // namespace art
62
63#endif // ART_RUNTIME_READ_BARRIER_INL_H_