Hiroshi Yamauchi | 800ac2d | 2014-04-02 17:32:54 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | namespace art { |
| 25 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 26 | template <typename MirrorType, ReadBarrierOption kReadBarrierOption> |
Hiroshi Yamauchi | 800ac2d | 2014-04-02 17:32:54 -0700 | [diff] [blame] | 27 | inline MirrorType* ReadBarrier::Barrier( |
| 28 | mirror::Object* obj, MemberOffset offset, mirror::HeapReference<MirrorType>* ref_addr) { |
| 29 | // Unused for now. |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 30 | UNUSED(obj, offset, ref_addr); |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 31 | const bool with_read_barrier = kReadBarrierOption == kWithReadBarrier; |
| 32 | if (with_read_barrier && kUseBakerReadBarrier) { |
Hiroshi Yamauchi | 800ac2d | 2014-04-02 17:32:54 -0700 | [diff] [blame] | 33 | // To be implemented. |
| 34 | return ref_addr->AsMirrorPtr(); |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 35 | } else if (with_read_barrier && kUseBrooksReadBarrier) { |
Hiroshi Yamauchi | 800ac2d | 2014-04-02 17:32:54 -0700 | [diff] [blame] | 36 | // To be implemented. |
| 37 | return ref_addr->AsMirrorPtr(); |
| 38 | } else { |
| 39 | // No read barrier. |
| 40 | return ref_addr->AsMirrorPtr(); |
| 41 | } |
| 42 | } |
| 43 | |
Hiroshi Yamauchi | 4cba0d9 | 2014-05-21 21:10:23 -0700 | [diff] [blame] | 44 | template <typename MirrorType, ReadBarrierOption kReadBarrierOption> |
Hiroshi Yamauchi | a91a4bc | 2014-06-13 16:44:55 -0700 | [diff] [blame] | 45 | inline MirrorType* ReadBarrier::BarrierForRoot(MirrorType** root) { |
| 46 | MirrorType* ref = *root; |
Hiroshi Yamauchi | 4cba0d9 | 2014-05-21 21:10:23 -0700 | [diff] [blame] | 47 | const bool with_read_barrier = kReadBarrierOption == kWithReadBarrier; |
| 48 | if (with_read_barrier && kUseBakerReadBarrier) { |
| 49 | // To be implemented. |
| 50 | return ref; |
| 51 | } else if (with_read_barrier && kUseBrooksReadBarrier) { |
| 52 | // To be implemented. |
| 53 | return ref; |
| 54 | } else { |
| 55 | return ref; |
| 56 | } |
| 57 | } |
| 58 | |
Hiroshi Yamauchi | 800ac2d | 2014-04-02 17:32:54 -0700 | [diff] [blame] | 59 | } // namespace art |
| 60 | |
| 61 | #endif // ART_RUNTIME_READ_BARRIER_INL_H_ |