blob: 5657092d8d0839d41c87fe7ce7150757f190bcf2 [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
17#include "callee_save_frame.h"
Ian Rogers7655f292013-07-29 11:07:13 -070018#include "entrypoints/entrypoint_utils.h"
Brian Carlstromea46f952013-07-30 01:26:50 -070019#include "mirror/art_method-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080020#include "mirror/class-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080021#include "mirror/object_array-inl.h"
Ian Rogers4f6ad8a2013-03-18 15:27:28 -070022#include "mirror/object-inl.h"
Ian Rogers57b86d42012-03-27 16:05:41 -070023
24namespace art {
25
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080026#define GENERATE_ENTRYPOINTS_FOR_ALLOCATOR_INST(suffix, suffix2, instrumented_bool, allocator_type) \
27extern "C" mirror::Object* artAllocObjectFromCode ##suffix##suffix2( \
28 uint32_t type_idx, mirror::ArtMethod* method, Thread* self, mirror::ArtMethod** sp) \
29 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
30 FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); \
31 return AllocObjectFromCode<false, instrumented_bool>(type_idx, method, self, allocator_type); \
32} \
Hiroshi Yamauchibe1ca552014-01-15 11:46:48 -080033extern "C" mirror::Object* artAllocObjectFromCodeResolved##suffix##suffix2( \
34 mirror::Class* klass, mirror::ArtMethod* method, Thread* self, mirror::ArtMethod** sp) \
35 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
36 FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); \
37 return AllocObjectFromCodeResolved<instrumented_bool>(klass, method, self, allocator_type); \
38} \
39extern "C" mirror::Object* artAllocObjectFromCodeInitialized##suffix##suffix2( \
40 mirror::Class* klass, mirror::ArtMethod* method, Thread* self, mirror::ArtMethod** sp) \
41 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
42 FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); \
43 return AllocObjectFromCodeInitialized<instrumented_bool>(klass, method, self, allocator_type); \
44} \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080045extern "C" mirror::Object* artAllocObjectFromCodeWithAccessCheck##suffix##suffix2( \
46 uint32_t type_idx, mirror::ArtMethod* method, Thread* self, mirror::ArtMethod** sp) \
47 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
48 FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); \
49 return AllocObjectFromCode<true, instrumented_bool>(type_idx, method, self, allocator_type); \
50} \
51extern "C" mirror::Array* artAllocArrayFromCode##suffix##suffix2( \
52 uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, \
53 mirror::ArtMethod** sp) \
54 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
55 FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); \
56 return AllocArrayFromCode<false, instrumented_bool>(type_idx, method, component_count, self, \
57 allocator_type); \
58} \
59extern "C" mirror::Array* artAllocArrayFromCodeWithAccessCheck##suffix##suffix2( \
60 uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, \
61 mirror::ArtMethod** sp) \
62 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
63 FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); \
64 return AllocArrayFromCode<true, instrumented_bool>(type_idx, method, component_count, self, \
65 allocator_type); \
66} \
67extern "C" mirror::Array* artCheckAndAllocArrayFromCode##suffix##suffix2( \
68 uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, \
69 mirror::ArtMethod** sp) \
70 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
71 FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); \
Hiroshi Yamauchicbbb0802013-11-21 12:42:36 -080072 if (!instrumented_bool) { \
73 return CheckAndAllocArrayFromCode(type_idx, method, component_count, self, false, allocator_type); \
74 } else { \
75 return CheckAndAllocArrayFromCodeInstrumented(type_idx, method, component_count, self, false, allocator_type); \
76 } \
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080077} \
78extern "C" mirror::Array* artCheckAndAllocArrayFromCodeWithAccessCheck##suffix##suffix2( \
79 uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, \
80 mirror::ArtMethod** sp) \
81 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { \
82 FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); \
Hiroshi Yamauchicbbb0802013-11-21 12:42:36 -080083 if (!instrumented_bool) { \
84 return CheckAndAllocArrayFromCode(type_idx, method, component_count, self, true, allocator_type); \
85 } else { \
86 return CheckAndAllocArrayFromCodeInstrumented(type_idx, method, component_count, self, true, allocator_type); \
87 } \
Ian Rogers57b86d42012-03-27 16:05:41 -070088}
89
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080090#define GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(suffix, allocator_type) \
91 GENERATE_ENTRYPOINTS_FOR_ALLOCATOR_INST(suffix, Instrumented, true, allocator_type) \
92 GENERATE_ENTRYPOINTS_FOR_ALLOCATOR_INST(suffix, , false, allocator_type)
Ian Rogers57b86d42012-03-27 16:05:41 -070093
Mathieu Chartiere6da9af2013-12-16 11:54:42 -080094GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(DlMalloc, gc::kAllocatorTypeDlMalloc)
95GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(RosAlloc, gc::kAllocatorTypeRosAlloc)
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080096GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(BumpPointer, gc::kAllocatorTypeBumpPointer)
Mathieu Chartier692fafd2013-11-29 17:24:40 -080097GENERATE_ENTRYPOINTS_FOR_ALLOCATOR(TLAB, gc::kAllocatorTypeTLAB)
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -070098
Ian Rogers57b86d42012-03-27 16:05:41 -070099} // namespace art