blob: 92c69afa46338f68bb63fbbabac33a8c4d9f9c01 [file] [log] [blame]
Hiroshi Yamauchicf58d4a2013-09-26 14:21:22 -07001/*
2 * Copyright (C) 2013 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_ROSALLOC_SPACE_INL_H_
18#define ART_RUNTIME_GC_SPACE_ROSALLOC_SPACE_INL_H_
19
20#include "rosalloc_space.h"
21#include "thread.h"
22
23namespace art {
24namespace gc {
25namespace space {
26
27inline mirror::Object* RosAllocSpace::AllocNonvirtual(Thread* self, size_t num_bytes,
28 size_t* bytes_allocated) {
29 mirror::Object* obj;
30 obj = AllocWithoutGrowthLocked(self, num_bytes, bytes_allocated);
31 // RosAlloc zeroes memory internally.
32 return obj;
33}
34
35inline mirror::Object* RosAllocSpace::AllocWithoutGrowthLocked(Thread* self, size_t num_bytes,
36 size_t* bytes_allocated) {
37 size_t rosalloc_size = 0;
38 mirror::Object* result = reinterpret_cast<mirror::Object*>(rosalloc_->Alloc(self, num_bytes,
39 &rosalloc_size));
40 if (LIKELY(result != NULL)) {
41 if (kDebugSpaces) {
42 CHECK(Contains(result)) << "Allocation (" << reinterpret_cast<void*>(result)
43 << ") not in bounds of allocation space " << *this;
44 }
45 DCHECK(bytes_allocated != NULL);
46 *bytes_allocated = rosalloc_size;
47 }
48 return result;
49}
50
51} // namespace space
52} // namespace gc
53} // namespace art
54
55#endif // ART_RUNTIME_GC_SPACE_ROSALLOC_SPACE_INL_H_