1/*
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
17#ifndef ART_RUNTIME_GC_SPACE_SPACE_INL_H_
18#define ART_RUNTIME_GC_SPACE_SPACE_INL_H_
19
20#include "space.h"
21
22#include "base/casts.h"
23#include "dlmalloc_space.h"
24#include "image_space.h"
25#include "large_object_space.h"
26
27namespace art {
28namespace gc {
29namespace space {
30
31inline ImageSpace* Space::AsImageSpace() {
32  DCHECK(IsImageSpace());
33  return down_cast<ImageSpace*>(down_cast<MemMapSpace*>(this));
34}
35
36inline MallocSpace* Space::AsMallocSpace() {
37  DCHECK(IsMallocSpace());
38  DCHECK(IsDlMallocSpace() || IsRosAllocSpace());
39  return down_cast<MallocSpace*>(down_cast<MemMapSpace*>(this));
40}
41
42inline LargeObjectSpace* Space::AsLargeObjectSpace() {
43  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);
55}
56
57}  // namespace space
58}  // namespace gc
59}  // namespace art
60
61#endif  // ART_RUNTIME_GC_SPACE_SPACE_INL_H_
62