blob: 02a63f6e73aa49710c6bde1081820196353caaca [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"
24
25namespace art {
26namespace gc {
27namespace space {
28
29inline ImageSpace* Space::AsImageSpace() {
Mathieu Chartier590fee92013-09-13 13:46:47 -070030 DCHECK(IsImageSpace());
Ian Rogers1d54e732013-05-02 21:10:01 -070031 return down_cast<ImageSpace*>(down_cast<MemMapSpace*>(this));
32}
33
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -070034inline MallocSpace* Space::AsMallocSpace() {
Mathieu Chartier1f3b5352014-02-03 14:00:42 -080035 DCHECK(IsMallocSpace());
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -070036 DCHECK(IsDlMallocSpace() || IsRosAllocSpace());
37 return down_cast<MallocSpace*>(down_cast<MemMapSpace*>(this));
Ian Rogers1d54e732013-05-02 21:10:01 -070038}
39
40inline LargeObjectSpace* Space::AsLargeObjectSpace() {
Mathieu Chartier590fee92013-09-13 13:46:47 -070041 DCHECK(IsLargeObjectSpace());
42 return down_cast<LargeObjectSpace*>(this);
43}
44
45inline ContinuousSpace* Space::AsContinuousSpace() {
46 DCHECK(IsContinuousSpace());
47 return down_cast<ContinuousSpace*>(this);
48}
49
50inline DiscontinuousSpace* Space::AsDiscontinuousSpace() {
51 DCHECK(IsDiscontinuousSpace());
52 return down_cast<DiscontinuousSpace*>(this);
Ian Rogers1d54e732013-05-02 21:10:01 -070053}
54
55} // namespace space
56} // namespace gc
57} // namespace art
58
Brian Carlstromfc0e3212013-07-17 14:40:12 -070059#endif // ART_RUNTIME_GC_SPACE_SPACE_INL_H_