blob: 3a715ab438fe0940c203f18913da2f2919c4d335 [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
22#include "dlmalloc_space.h"
23#include "image_space.h"
Mathieu Chartier8d562102014-03-12 17:42:10 -070024#include "large_object_space.h"
Ian Rogers1d54e732013-05-02 21:10:01 -070025
26namespace art {
27namespace gc {
28namespace space {
29
30inline ImageSpace* Space::AsImageSpace() {
Mathieu Chartier590fee92013-09-13 13:46:47 -070031 DCHECK(IsImageSpace());
Ian Rogers1d54e732013-05-02 21:10:01 -070032 return down_cast<ImageSpace*>(down_cast<MemMapSpace*>(this));
33}
34
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -070035inline MallocSpace* Space::AsMallocSpace() {
Mathieu Chartier1f3b5352014-02-03 14:00:42 -080036 DCHECK(IsMallocSpace());
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -070037 DCHECK(IsDlMallocSpace() || IsRosAllocSpace());
38 return down_cast<MallocSpace*>(down_cast<MemMapSpace*>(this));
Ian Rogers1d54e732013-05-02 21:10:01 -070039}
40
41inline LargeObjectSpace* Space::AsLargeObjectSpace() {
Mathieu Chartier590fee92013-09-13 13:46:47 -070042 DCHECK(IsLargeObjectSpace());
43 return down_cast<LargeObjectSpace*>(this);
44}
45
46inline ContinuousSpace* Space::AsContinuousSpace() {
47 DCHECK(IsContinuousSpace());
48 return down_cast<ContinuousSpace*>(this);
49}
50
51inline DiscontinuousSpace* Space::AsDiscontinuousSpace() {
52 DCHECK(IsDiscontinuousSpace());
53 return down_cast<DiscontinuousSpace*>(this);
Ian Rogers1d54e732013-05-02 21:10:01 -070054}
55
56} // namespace space
57} // namespace gc
58} // namespace art
59
Brian Carlstromfc0e3212013-07-17 14:40:12 -070060#endif // ART_RUNTIME_GC_SPACE_SPACE_INL_H_