blob: e3307d87b6f905c3c1cb4c824d3f80ec30fd953d [file] [log] [blame]
Mathieu Chartier4a26f172016-01-26 14:26:18 -08001/*
2 * Copyright (C) 2016 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_IMAGE_INL_H_
18#define ART_RUNTIME_IMAGE_INL_H_
19
20#include "image.h"
21
22namespace art {
23
24template <ReadBarrierOption kReadBarrierOption>
25inline mirror::Object* ImageHeader::GetImageRoot(ImageRoot image_root) const {
26 mirror::ObjectArray<mirror::Object>* image_roots = GetImageRoots<kReadBarrierOption>();
27 return image_roots->Get<kVerifyNone, kReadBarrierOption>(static_cast<int32_t>(image_root));
28}
29
30template <ReadBarrierOption kReadBarrierOption>
31inline mirror::ObjectArray<mirror::Object>* ImageHeader::GetImageRoots() const {
32 // Need a read barrier as it's not visited during root scan.
33 // Pass in the address of the local variable to the read barrier
34 // rather than image_roots_ because it won't move (asserted below)
35 // and it's a const member.
36 mirror::ObjectArray<mirror::Object>* image_roots =
37 reinterpret_cast<mirror::ObjectArray<mirror::Object>*>(image_roots_);
38 mirror::ObjectArray<mirror::Object>* result =
39 ReadBarrier::BarrierForRoot<mirror::ObjectArray<mirror::Object>, kReadBarrierOption>(
40 &image_roots);
41 DCHECK_EQ(image_roots, result);
42 return image_roots;
43}
44
45} // namespace art
46
47#endif // ART_RUNTIME_IMAGE_INL_H_