blob: fa129afd391dbcc374166bee12e4d530dd94e4cd [file] [log] [blame]
Ian Rogers57b86d42012-03-27 16:05:41 -07001/*
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
Mathieu Chartierd8891782014-03-02 13:28:37 -080017#include "entrypoints/quick/quick_alloc_entrypoints.h"
18
Ian Rogers57b86d42012-03-27 16:05:41 -070019#include "callee_save_frame.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070020#include "entrypoints/entrypoint_utils-inl.h"
Brian Carlstromea46f952013-07-30 01:26:50 -070021#include "mirror/art_method-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080022#include "mirror/class-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080023#include "mirror/object_array-inl.h"
Ian Rogers4f6ad8a2013-03-18 15:27:28 -070024#include "mirror/object-inl.h"
Ian Rogers57b86d42012-03-27 16:05:41 -070025
26namespace art {
27
Hiroshi Yamauchieb1e9292014-08-06 12:41:15 -070028static constexpr bool kUseTlabFastPath = true;
29
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080030#define GENERATE_ENTRYPOINTS_FOR_ALLOCATOR_INST(suffix, suffix2, instrumented_bool, allocator_type) \
31extern "C" mirror::Object* artAllocObjectFromCode ##suffix##suffix2( \
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070032 uint32_t type_idx, mirror::ArtMethod* method, Thread* self) \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080033 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070034 ScopedQuickEntrypointChecks sqec(self); \
Hiroshi Yamauchieb1e9292014-08-06 12:41:15 -070035 if (kUseTlabFastPath && !instrumented_bool && allocator_type == gc::kAllocatorTypeTLAB) { \
Andreas Gampe05d2ab22014-08-06 16:27:52 -070036 mirror::Class* klass = method->GetDexCacheResolvedType<false>(type_idx); \
Hiroshi Yamauchieb1e9292014-08-06 12:41:15 -070037 if (LIKELY(klass != nullptr && klass->IsInitialized() && !klass->IsFinalizable())) { \
38 size_t byte_count = klass->GetObjectSize(); \
39 byte_count = RoundUp(byte_count, gc::space::BumpPointerSpace::kAlignment); \
40 mirror::Object* obj; \
41 if (LIKELY(byte_count < self->TlabSize())) { \
42 obj = self->AllocTlab(byte_count); \
43 DCHECK(obj != nullptr) << "AllocTlab can't fail"; \
44 obj->SetClass(klass); \
45 if (kUseBakerOrBrooksReadBarrier) { \
46 if (kUseBrooksReadBarrier) { \
47 obj->SetReadBarrierPointer(obj); \
48 } \
49 obj->AssertReadBarrierPointer(); \
50 } \
51 QuasiAtomic::ThreadFenceForConstructor(); \
52 return obj; \
53 } \
54 } \
55 } \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080056 return AllocObjectFromCode<false, instrumented_bool>(type_idx, method, self, allocator_type); \
57} \
Hiroshi Yamauchibe1ca552014-01-15 11:46:48 -080058extern "C" mirror::Object* artAllocObjectFromCodeResolved##suffix##suffix2( \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070059 mirror::Class* klass, mirror::ArtMethod* method, Thread* self) \
Hiroshi Yamauchibe1ca552014-01-15 11:46:48 -080060 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070061 UNUSED(method); \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070062 ScopedQuickEntrypointChecks sqec(self); \
Hiroshi Yamauchieb1e9292014-08-06 12:41:15 -070063 if (kUseTlabFastPath && !instrumented_bool && allocator_type == gc::kAllocatorTypeTLAB) { \
64 if (LIKELY(klass->IsInitialized())) { \
65 size_t byte_count = klass->GetObjectSize(); \
66 byte_count = RoundUp(byte_count, gc::space::BumpPointerSpace::kAlignment); \
67 mirror::Object* obj; \
68 if (LIKELY(byte_count < self->TlabSize())) { \
69 obj = self->AllocTlab(byte_count); \
70 DCHECK(obj != nullptr) << "AllocTlab can't fail"; \
71 obj->SetClass(klass); \
72 if (kUseBakerOrBrooksReadBarrier) { \
73 if (kUseBrooksReadBarrier) { \
74 obj->SetReadBarrierPointer(obj); \
75 } \
76 obj->AssertReadBarrierPointer(); \
77 } \
78 QuasiAtomic::ThreadFenceForConstructor(); \
79 return obj; \
80 } \
81 } \
82 } \
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070083 return AllocObjectFromCodeResolved<instrumented_bool>(klass, self, allocator_type); \
Hiroshi Yamauchibe1ca552014-01-15 11:46:48 -080084} \
85extern "C" mirror::Object* artAllocObjectFromCodeInitialized##suffix##suffix2( \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070086 mirror::Class* klass, mirror::ArtMethod* method, Thread* self) \
Hiroshi Yamauchibe1ca552014-01-15 11:46:48 -080087 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070088 UNUSED(method); \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070089 ScopedQuickEntrypointChecks sqec(self); \
Hiroshi Yamauchieb1e9292014-08-06 12:41:15 -070090 if (kUseTlabFastPath && !instrumented_bool && allocator_type == gc::kAllocatorTypeTLAB) { \
91 size_t byte_count = klass->GetObjectSize(); \
92 byte_count = RoundUp(byte_count, gc::space::BumpPointerSpace::kAlignment); \
93 mirror::Object* obj; \
94 if (LIKELY(byte_count < self->TlabSize())) { \
95 obj = self->AllocTlab(byte_count); \
96 DCHECK(obj != nullptr) << "AllocTlab can't fail"; \
97 obj->SetClass(klass); \
98 if (kUseBakerOrBrooksReadBarrier) { \
99 if (kUseBrooksReadBarrier) { \
100 obj->SetReadBarrierPointer(obj); \
101 } \
102 obj->AssertReadBarrierPointer(); \
103 } \
104 QuasiAtomic::ThreadFenceForConstructor(); \
105 return obj; \
106 } \
107 } \
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700108 return AllocObjectFromCodeInitialized<instrumented_bool>(klass, self, allocator_type); \
Hiroshi Yamauchibe1ca552014-01-15 11:46:48 -0800109} \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800110extern "C" mirror::Object* artAllocObjectFromCodeWithAccessCheck##suffix##suffix2( \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700111 uint32_t type_idx, mirror::ArtMethod* method, Thread* self) \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800112 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700113 ScopedQuickEntrypointChecks sqec(self); \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800114 return AllocObjectFromCode<true, instrumented_bool>(type_idx, method, self, allocator_type); \
115} \
116extern "C" mirror::Array* artAllocArrayFromCode##suffix##suffix2( \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800117 uint32_t type_idx, int32_t component_count, mirror::ArtMethod* method, Thread* self) \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800118 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700119 ScopedQuickEntrypointChecks sqec(self); \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800120 return AllocArrayFromCode<false, instrumented_bool>(type_idx, component_count, method, self, \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800121 allocator_type); \
122} \
Hiroshi Yamauchibb8f0ab2014-01-27 16:50:29 -0800123extern "C" mirror::Array* artAllocArrayFromCodeResolved##suffix##suffix2( \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800124 mirror::Class* klass, int32_t component_count, mirror::ArtMethod* method, Thread* self) \
Hiroshi Yamauchibb8f0ab2014-01-27 16:50:29 -0800125 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700126 ScopedQuickEntrypointChecks sqec(self); \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800127 return AllocArrayFromCodeResolved<false, instrumented_bool>(klass, component_count, method, self, \
Hiroshi Yamauchibb8f0ab2014-01-27 16:50:29 -0800128 allocator_type); \
129} \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800130extern "C" mirror::Array* artAllocArrayFromCodeWithAccessCheck##suffix##suffix2( \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800131 uint32_t type_idx, int32_t component_count, mirror::ArtMethod* method, Thread* self) \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800132 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700133 ScopedQuickEntrypointChecks sqec(self); \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800134 return AllocArrayFromCode<true, instrumented_bool>(type_idx, component_count, method, self, \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800135 allocator_type); \
136} \
137extern "C" mirror::Array* artCheckAndAllocArrayFromCode##suffix##suffix2( \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800138 uint32_t type_idx, int32_t component_count, mirror::ArtMethod* method, Thread* self) \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800139 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700140 ScopedQuickEntrypointChecks sqec(self); \
Hiroshi Yamauchicbbb0802013-11-21 12:42:36 -0800141 if (!instrumented_bool) { \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800142 return CheckAndAllocArrayFromCode(type_idx, component_count, method, self, false, allocator_type); \
Hiroshi Yamauchicbbb0802013-11-21 12:42:36 -0800143 } else { \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800144 return CheckAndAllocArrayFromCodeInstrumented(type_idx, component_count, method, self, false, allocator_type); \
Hiroshi Yamauchicbbb0802013-11-21 12:42:36 -0800145 } \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800146} \
147extern "C" mirror::Array* artCheckAndAllocArrayFromCodeWithAccessCheck##suffix##suffix2( \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800148 uint32_t type_idx, int32_t component_count, mirror::ArtMethod* method, Thread* self) \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800149 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700150 ScopedQuickEntrypointChecks sqec(self); \
Hiroshi Yamauchicbbb0802013-11-21 12:42:36 -0800151 if (!instrumented_bool) { \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800152 return CheckAndAllocArrayFromCode(type_idx, component_count, method, self, true, allocator_type); \
Hiroshi Yamauchicbbb0802013-11-21 12:42:36 -0800153 } else { \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800154 return CheckAndAllocArrayFromCodeInstrumented(type_idx, component_count, method, self, true, allocator_type); \
Hiroshi Yamauchicbbb0802013-11-21 12:42:36 -0800155 } \
Jeff Hao848f70a2014-01-15 13:49:50 -0800156} \
157extern "C" mirror::String* artAllocStringFromBytesFromCode##suffix##suffix2( \
158 mirror::ByteArray* byte_array, int32_t high, int32_t offset, int32_t byte_count, \
159 Thread* self) \
160 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
161 ScopedQuickEntrypointChecks sqec(self); \
162 StackHandleScope<1> hs(self); \
163 Handle<mirror::ByteArray> handle_array(hs.NewHandle(byte_array)); \
164 return mirror::String::AllocFromByteArray<instrumented_bool>(self, byte_count, handle_array, \
165 offset, high, allocator_type); \
166} \
167extern "C" mirror::String* artAllocStringFromCharsFromCode##suffix##suffix2( \
168 int32_t offset, int32_t char_count, mirror::CharArray* char_array, Thread* self) \
169 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
170 StackHandleScope<1> hs(self); \
171 Handle<mirror::CharArray> handle_array(hs.NewHandle(char_array)); \
172 return mirror::String::AllocFromCharArray<instrumented_bool>(self, char_count, handle_array, \
173 offset, allocator_type); \
174} \
175extern "C" mirror::String* artAllocStringFromStringFromCode##suffix##suffix2( \
176 mirror::String* string, Thread* self) \
177 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
178 StackHandleScope<1> hs(self); \
179 Handle<mirror::String> handle_string(hs.NewHandle(string)); \
180 return mirror::String::AllocFromString<instrumented_bool>(self, handle_string->GetLength(), \
181 handle_string, 0, allocator_type); \
Ian Rogers57b86d42012-03-27 16:05:41 -0700182}
183
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800184#define GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(suffix, allocator_type) \
185 GENERATE_ENTRYPOINTS_FOR_ALLOCATOR_INST(suffix, Instrumented, true, allocator_type) \
186 GENERATE_ENTRYPOINTS_FOR_ALLOCATOR_INST(suffix, , false, allocator_type)
Ian Rogers57b86d42012-03-27 16:05:41 -0700187
Mathieu Chartiere6da9af2013-12-16 11:54:42 -0800188GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(DlMalloc, gc::kAllocatorTypeDlMalloc)
189GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(RosAlloc, gc::kAllocatorTypeRosAlloc)
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800190GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(BumpPointer, gc::kAllocatorTypeBumpPointer)
Mathieu Chartier692fafd2013-11-29 17:24:40 -0800191GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(TLAB, gc::kAllocatorTypeTLAB)
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800192GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(Region, gc::kAllocatorTypeRegion)
193GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(RegionTLAB, gc::kAllocatorTypeRegionTLAB)
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700194
Mathieu Chartierd8891782014-03-02 13:28:37 -0800195#define GENERATE_ENTRYPOINTS(suffix) \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800196extern "C" void* art_quick_alloc_array##suffix(uint32_t, int32_t, mirror::ArtMethod* ref); \
197extern "C" void* art_quick_alloc_array_resolved##suffix(mirror::Class* klass, int32_t, mirror::ArtMethod* ref); \
198extern "C" void* art_quick_alloc_array_with_access_check##suffix(uint32_t, int32_t, mirror::ArtMethod* ref); \
199extern "C" void* art_quick_alloc_object##suffix(uint32_t type_idx, mirror::ArtMethod* ref); \
200extern "C" void* art_quick_alloc_object_resolved##suffix(mirror::Class* klass, mirror::ArtMethod* ref); \
201extern "C" void* art_quick_alloc_object_initialized##suffix(mirror::Class* klass, mirror::ArtMethod* ref); \
202extern "C" void* art_quick_alloc_object_with_access_check##suffix(uint32_t type_idx, mirror::ArtMethod* ref); \
203extern "C" void* art_quick_check_and_alloc_array##suffix(uint32_t, int32_t, mirror::ArtMethod* ref); \
204extern "C" void* art_quick_check_and_alloc_array_with_access_check##suffix(uint32_t, int32_t, mirror::ArtMethod* ref); \
Jeff Hao848f70a2014-01-15 13:49:50 -0800205extern "C" void* art_quick_alloc_string_from_bytes##suffix(void*, int32_t, int32_t, int32_t); \
206extern "C" void* art_quick_alloc_string_from_chars##suffix(int32_t, int32_t, void*); \
207extern "C" void* art_quick_alloc_string_from_string##suffix(void*); \
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800208extern "C" void* art_quick_alloc_array##suffix##_instrumented(uint32_t, int32_t, mirror::ArtMethod* ref); \
209extern "C" void* art_quick_alloc_array_resolved##suffix##_instrumented(mirror::Class* klass, int32_t, mirror::ArtMethod* ref); \
210extern "C" void* art_quick_alloc_array_with_access_check##suffix##_instrumented(uint32_t, int32_t, mirror::ArtMethod* ref); \
211extern "C" void* art_quick_alloc_object##suffix##_instrumented(uint32_t type_idx, mirror::ArtMethod* ref); \
212extern "C" void* art_quick_alloc_object_resolved##suffix##_instrumented(mirror::Class* klass, mirror::ArtMethod* ref); \
213extern "C" void* art_quick_alloc_object_initialized##suffix##_instrumented(mirror::Class* klass, mirror::ArtMethod* ref); \
214extern "C" void* art_quick_alloc_object_with_access_check##suffix##_instrumented(uint32_t type_idx, mirror::ArtMethod* ref); \
215extern "C" void* art_quick_check_and_alloc_array##suffix##_instrumented(uint32_t, int32_t, mirror::ArtMethod* ref); \
216extern "C" void* art_quick_check_and_alloc_array_with_access_check##suffix##_instrumented(uint32_t, int32_t, mirror::ArtMethod* ref); \
Jeff Hao848f70a2014-01-15 13:49:50 -0800217extern "C" void* art_quick_alloc_string_from_bytes##suffix##_instrumented(void*, int32_t, int32_t, int32_t); \
218extern "C" void* art_quick_alloc_string_from_chars##suffix##_instrumented(int32_t, int32_t, void*); \
219extern "C" void* art_quick_alloc_string_from_string##suffix##_instrumented(void*); \
Mathieu Chartierd8891782014-03-02 13:28:37 -0800220void SetQuickAllocEntryPoints##suffix(QuickEntryPoints* qpoints, bool instrumented) { \
221 if (instrumented) { \
222 qpoints->pAllocArray = art_quick_alloc_array##suffix##_instrumented; \
223 qpoints->pAllocArrayResolved = art_quick_alloc_array_resolved##suffix##_instrumented; \
224 qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check##suffix##_instrumented; \
225 qpoints->pAllocObject = art_quick_alloc_object##suffix##_instrumented; \
226 qpoints->pAllocObjectResolved = art_quick_alloc_object_resolved##suffix##_instrumented; \
227 qpoints->pAllocObjectInitialized = art_quick_alloc_object_initialized##suffix##_instrumented; \
228 qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check##suffix##_instrumented; \
229 qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array##suffix##_instrumented; \
230 qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check##suffix##_instrumented; \
Jeff Hao848f70a2014-01-15 13:49:50 -0800231 qpoints->pAllocStringFromBytes = art_quick_alloc_string_from_bytes##suffix##_instrumented; \
232 qpoints->pAllocStringFromChars = art_quick_alloc_string_from_chars##suffix##_instrumented; \
233 qpoints->pAllocStringFromString = art_quick_alloc_string_from_string##suffix##_instrumented; \
Mathieu Chartierd8891782014-03-02 13:28:37 -0800234 } else { \
235 qpoints->pAllocArray = art_quick_alloc_array##suffix; \
236 qpoints->pAllocArrayResolved = art_quick_alloc_array_resolved##suffix; \
237 qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check##suffix; \
238 qpoints->pAllocObject = art_quick_alloc_object##suffix; \
239 qpoints->pAllocObjectResolved = art_quick_alloc_object_resolved##suffix; \
240 qpoints->pAllocObjectInitialized = art_quick_alloc_object_initialized##suffix; \
241 qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check##suffix; \
242 qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array##suffix; \
243 qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check##suffix; \
Jeff Hao848f70a2014-01-15 13:49:50 -0800244 qpoints->pAllocStringFromBytes = art_quick_alloc_string_from_bytes##suffix; \
245 qpoints->pAllocStringFromChars = art_quick_alloc_string_from_chars##suffix; \
246 qpoints->pAllocStringFromString = art_quick_alloc_string_from_string##suffix; \
Mathieu Chartierd8891782014-03-02 13:28:37 -0800247 } \
248}
249
250// Generate the entrypoint functions.
Ian Rogersc3ccc102014-06-25 11:52:14 -0700251#if !defined(__APPLE__) || !defined(__LP64__)
Andreas Gampec8ccf682014-09-29 20:07:43 -0700252GENERATE_ENTRYPOINTS(_dlmalloc)
253GENERATE_ENTRYPOINTS(_rosalloc)
254GENERATE_ENTRYPOINTS(_bump_pointer)
255GENERATE_ENTRYPOINTS(_tlab)
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800256GENERATE_ENTRYPOINTS(_region)
257GENERATE_ENTRYPOINTS(_region_tlab)
Ian Rogersc3ccc102014-06-25 11:52:14 -0700258#endif
Mathieu Chartierd8891782014-03-02 13:28:37 -0800259
260static bool entry_points_instrumented = false;
261static gc::AllocatorType entry_points_allocator = gc::kAllocatorTypeDlMalloc;
262
263void SetQuickAllocEntryPointsAllocator(gc::AllocatorType allocator) {
264 entry_points_allocator = allocator;
265}
266
267void SetQuickAllocEntryPointsInstrumented(bool instrumented) {
268 entry_points_instrumented = instrumented;
269}
270
271void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints) {
Andreas Gampe48cc32c2015-04-07 02:53:04 +0000272#if !defined(__APPLE__) || !defined(__LP64__)
Ian Rogersde2db522014-11-04 14:43:18 -0800273 switch (entry_points_allocator) {
Mathieu Chartierd8891782014-03-02 13:28:37 -0800274 case gc::kAllocatorTypeDlMalloc: {
275 SetQuickAllocEntryPoints_dlmalloc(qpoints, entry_points_instrumented);
Ian Rogers7dc9c812014-11-04 15:10:55 -0800276 return;
Mathieu Chartierd8891782014-03-02 13:28:37 -0800277 }
278 case gc::kAllocatorTypeRosAlloc: {
279 SetQuickAllocEntryPoints_rosalloc(qpoints, entry_points_instrumented);
Ian Rogers7dc9c812014-11-04 15:10:55 -0800280 return;
Mathieu Chartierd8891782014-03-02 13:28:37 -0800281 }
282 case gc::kAllocatorTypeBumpPointer: {
283 CHECK(kMovingCollector);
284 SetQuickAllocEntryPoints_bump_pointer(qpoints, entry_points_instrumented);
Ian Rogers7dc9c812014-11-04 15:10:55 -0800285 return;
Mathieu Chartierd8891782014-03-02 13:28:37 -0800286 }
287 case gc::kAllocatorTypeTLAB: {
288 CHECK(kMovingCollector);
289 SetQuickAllocEntryPoints_tlab(qpoints, entry_points_instrumented);
Ian Rogers7dc9c812014-11-04 15:10:55 -0800290 return;
Mathieu Chartierd8891782014-03-02 13:28:37 -0800291 }
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800292 case gc::kAllocatorTypeRegion: {
293 CHECK(kMovingCollector);
294 SetQuickAllocEntryPoints_region(qpoints, entry_points_instrumented);
295 return;
296 }
297 case gc::kAllocatorTypeRegionTLAB: {
298 CHECK(kMovingCollector);
299 SetQuickAllocEntryPoints_region_tlab(qpoints, entry_points_instrumented);
300 return;
301 }
Andreas Gampe48cc32c2015-04-07 02:53:04 +0000302 default:
303 break;
Mathieu Chartierd8891782014-03-02 13:28:37 -0800304 }
Andreas Gampe48cc32c2015-04-07 02:53:04 +0000305#else
306 UNUSED(qpoints);
307#endif
308 UNIMPLEMENTED(FATAL);
Ian Rogersde2db522014-11-04 14:43:18 -0800309 UNREACHABLE();
Mathieu Chartierd8891782014-03-02 13:28:37 -0800310}
311
Ian Rogers57b86d42012-03-27 16:05:41 -0700312} // namespace art