blob: 3ea68cf9ca00cf4d5f421f4006351eabc9684e57 [file] [log] [blame]
Ian Rogers1d54e732013-05-02 21:10:01 -07001/*
2 * Copyright (C) 2011 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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_GC_SPACE_SPACE_INL_H_
18#define ART_RUNTIME_GC_SPACE_SPACE_INL_H_
Ian Rogers1d54e732013-05-02 21:10:01 -070019
20#include "space.h"
21
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070022#include "base/casts.h"
Ian Rogers1d54e732013-05-02 21:10:01 -070023#include "dlmalloc_space.h"
24#include "image_space.h"
Mathieu Chartier8d562102014-03-12 17:42:10 -070025#include "large_object_space.h"
Ian Rogers1d54e732013-05-02 21:10:01 -070026
27namespace art {
28namespace gc {
29namespace space {
30
31inline ImageSpace* Space::AsImageSpace() {
Mathieu Chartier590fee92013-09-13 13:46:47 -070032 DCHECK(IsImageSpace());
Ian Rogers1d54e732013-05-02 21:10:01 -070033 return down_cast<ImageSpace*>(down_cast<MemMapSpace*>(this));
34}
35
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -070036inline MallocSpace* Space::AsMallocSpace() {
Mathieu Chartier1f3b5352014-02-03 14:00:42 -080037 DCHECK(IsMallocSpace());
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -070038 DCHECK(IsDlMallocSpace() || IsRosAllocSpace());
39 return down_cast<MallocSpace*>(down_cast<MemMapSpace*>(this));
Ian Rogers1d54e732013-05-02 21:10:01 -070040}
41
42inline LargeObjectSpace* Space::AsLargeObjectSpace() {
Mathieu Chartier590fee92013-09-13 13:46:47 -070043 DCHECK(IsLargeObjectSpace());
44 return down_cast<LargeObjectSpace*>(this);
45}
46
47inline ContinuousSpace* Space::AsContinuousSpace() {
48 DCHECK(IsContinuousSpace());
49 return down_cast<ContinuousSpace*>(this);
50}
51
52inline DiscontinuousSpace* Space::AsDiscontinuousSpace() {
53 DCHECK(IsDiscontinuousSpace());
54 return down_cast<DiscontinuousSpace*>(this);
Ian Rogers1d54e732013-05-02 21:10:01 -070055}
56
57} // namespace space
58} // namespace gc
59} // namespace art
60
Brian Carlstromfc0e3212013-07-17 14:40:12 -070061#endif // ART_RUNTIME_GC_SPACE_SPACE_INL_H_