| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | |
| Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 17 | #include "entrypoints/entrypoint_utils-inl.h" |
| Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 18 | #include "mirror/art_method-inl.h" |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 19 | #include "mirror/object-inl.h" |
| 20 | |
| 21 | namespace art { |
| 22 | |
| Mathieu Chartier | e6da9af | 2013-12-16 11:54:42 -0800 | [diff] [blame] | 23 | static constexpr gc::AllocatorType kPortableAllocatorType = |
| 24 | gc::kUseRosAlloc ? gc::kAllocatorTypeRosAlloc : gc::kAllocatorTypeDlMalloc; |
| 25 | |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 26 | extern "C" mirror::Object* art_portable_alloc_object_from_code(uint32_t type_idx, |
| Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 27 | mirror::ArtMethod* referrer, |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 28 | Thread* thread) |
| 29 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| Mathieu Chartier | e6da9af | 2013-12-16 11:54:42 -0800 | [diff] [blame] | 30 | return AllocObjectFromCode<false, true>(type_idx, referrer, thread, kPortableAllocatorType); |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | extern "C" mirror::Object* art_portable_alloc_object_from_code_with_access_check(uint32_t type_idx, |
| Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 34 | mirror::ArtMethod* referrer, |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 35 | Thread* thread) |
| 36 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| Mathieu Chartier | e6da9af | 2013-12-16 11:54:42 -0800 | [diff] [blame] | 37 | return AllocObjectFromCode<true, true>(type_idx, referrer, thread, kPortableAllocatorType); |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | extern "C" mirror::Object* art_portable_alloc_array_from_code(uint32_t type_idx, |
| Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 41 | mirror::ArtMethod* referrer, |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 42 | uint32_t length, |
| 43 | Thread* self) |
| 44 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 45 | return AllocArrayFromCode<false, true>(type_idx, referrer, length, self, |
| Mathieu Chartier | e6da9af | 2013-12-16 11:54:42 -0800 | [diff] [blame] | 46 | kPortableAllocatorType); |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | extern "C" mirror::Object* art_portable_alloc_array_from_code_with_access_check(uint32_t type_idx, |
| Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 50 | mirror::ArtMethod* referrer, |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 51 | uint32_t length, |
| 52 | Thread* self) |
| 53 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 54 | return AllocArrayFromCode<true, true>(type_idx, referrer, length, self, |
| Mathieu Chartier | e6da9af | 2013-12-16 11:54:42 -0800 | [diff] [blame] | 55 | kPortableAllocatorType); |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code(uint32_t type_idx, |
| Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 59 | mirror::ArtMethod* referrer, |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 60 | uint32_t length, |
| 61 | Thread* thread) |
| 62 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| Hiroshi Yamauchi | cbbb080 | 2013-11-21 12:42:36 -0800 | [diff] [blame] | 63 | return CheckAndAllocArrayFromCodeInstrumented(type_idx, referrer, length, thread, false, |
| Mathieu Chartier | e6da9af | 2013-12-16 11:54:42 -0800 | [diff] [blame] | 64 | kPortableAllocatorType); |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code_with_access_check(uint32_t type_idx, |
| Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 68 | mirror::ArtMethod* referrer, |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 69 | uint32_t length, |
| 70 | Thread* thread) |
| 71 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| Hiroshi Yamauchi | cbbb080 | 2013-11-21 12:42:36 -0800 | [diff] [blame] | 72 | return CheckAndAllocArrayFromCodeInstrumented(type_idx, referrer, length, thread, true, |
| Mathieu Chartier | e6da9af | 2013-12-16 11:54:42 -0800 | [diff] [blame] | 73 | kPortableAllocatorType); |
| Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | } // namespace art |