Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_GC_SPACE_SPACE_INL_H_ |
| 18 | #define ART_RUNTIME_GC_SPACE_SPACE_INL_H_ |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 19 | |
| 20 | #include "space.h" |
| 21 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 22 | #include "base/casts.h" |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 23 | #include "dlmalloc_space.h" |
| 24 | #include "image_space.h" |
Mathieu Chartier | 8d56210 | 2014-03-12 17:42:10 -0700 | [diff] [blame] | 25 | #include "large_object_space.h" |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 26 | |
| 27 | namespace art { |
| 28 | namespace gc { |
| 29 | namespace space { |
| 30 | |
| 31 | inline ImageSpace* Space::AsImageSpace() { |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 32 | DCHECK(IsImageSpace()); |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 33 | return down_cast<ImageSpace*>(down_cast<MemMapSpace*>(this)); |
| 34 | } |
| 35 | |
Hiroshi Yamauchi | cf58d4a | 2013-09-26 14:21:22 -0700 | [diff] [blame] | 36 | inline MallocSpace* Space::AsMallocSpace() { |
Mathieu Chartier | 1f3b535 | 2014-02-03 14:00:42 -0800 | [diff] [blame] | 37 | DCHECK(IsMallocSpace()); |
Hiroshi Yamauchi | cf58d4a | 2013-09-26 14:21:22 -0700 | [diff] [blame] | 38 | DCHECK(IsDlMallocSpace() || IsRosAllocSpace()); |
| 39 | return down_cast<MallocSpace*>(down_cast<MemMapSpace*>(this)); |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | inline LargeObjectSpace* Space::AsLargeObjectSpace() { |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 43 | DCHECK(IsLargeObjectSpace()); |
| 44 | return down_cast<LargeObjectSpace*>(this); |
| 45 | } |
| 46 | |
| 47 | inline ContinuousSpace* Space::AsContinuousSpace() { |
| 48 | DCHECK(IsContinuousSpace()); |
| 49 | return down_cast<ContinuousSpace*>(this); |
| 50 | } |
| 51 | |
| 52 | inline DiscontinuousSpace* Space::AsDiscontinuousSpace() { |
| 53 | DCHECK(IsDiscontinuousSpace()); |
| 54 | return down_cast<DiscontinuousSpace*>(this); |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | } // namespace space |
| 58 | } // namespace gc |
| 59 | } // namespace art |
| 60 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 61 | #endif // ART_RUNTIME_GC_SPACE_SPACE_INL_H_ |