blob: ac0f67bd696c77cb40d4f78204968d964321837d [file] [log] [blame]
Hiroshi Yamauchi3c2856e2013-11-22 13:42:53 -08001/*
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_ALLOCATOR_ROSALLOC_INL_H_
18#define ART_RUNTIME_GC_ALLOCATOR_ROSALLOC_INL_H_
19
20#include "rosalloc.h"
21
22namespace art {
23namespace gc {
24namespace allocator {
25
26inline ALWAYS_INLINE void* RosAlloc::Alloc(Thread* self, size_t size, size_t* bytes_allocated) {
27 if (UNLIKELY(size > kLargeSizeThreshold)) {
28 return AllocLargeObject(self, size, bytes_allocated);
29 }
30 void* m = AllocFromRun(self, size, bytes_allocated);
31 // Check if the returned memory is really all zero.
Mathieu Chartier73d1e172014-04-11 17:53:48 -070032 if (kCheckZeroMemory && m != nullptr) {
Hiroshi Yamauchi3c2856e2013-11-22 13:42:53 -080033 byte* bytes = reinterpret_cast<byte*>(m);
34 for (size_t i = 0; i < size; ++i) {
35 DCHECK_EQ(bytes[i], 0);
36 }
37 }
38 return m;
39}
40
41} // namespace allocator
42} // namespace gc
43} // namespace art
44
45#endif // ART_RUNTIME_GC_ALLOCATOR_ROSALLOC_INL_H_