Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -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 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ |
| 18 | #define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 19 | |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 20 | #include <jni.h> |
| 21 | |
Andreas Gampe | 7fbc4a5 | 2018-11-28 08:26:47 -0800 | [diff] [blame] | 22 | #include "base/locks.h" |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 23 | #include "base/macros.h" |
Nicolas Geoffray | 4e92c3c | 2017-05-08 09:34:26 +0100 | [diff] [blame] | 24 | #include "deoptimization_kind.h" |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 25 | #include "offsets.h" |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 26 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 27 | #define QUICK_ENTRYPOINT_OFFSET(ptr_size, x) \ |
| 28 | Thread::QuickEntryPointOffset<ptr_size>(OFFSETOF_MEMBER(QuickEntryPoints, x)) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 29 | |
| 30 | namespace art { |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 31 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 32 | namespace mirror { |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 33 | class Array; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 34 | class Class; |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 35 | template<class MirrorType> class CompressedReference; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 36 | class Object; |
Vladimir Marko | 552a134 | 2017-10-31 10:56:47 +0000 | [diff] [blame] | 37 | class String; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 38 | } // namespace mirror |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 39 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 40 | class ArtMethod; |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 41 | template<class MirrorType> class GcRoot; |
Roland Levillain | ad0777d | 2018-02-12 20:00:18 +0000 | [diff] [blame] | 42 | template<class MirrorType> class StackReference; |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 43 | class Thread; |
| 44 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 45 | // Pointers to functions that are called by quick compiler generated code via thread-local storage. |
| 46 | struct PACKED(4) QuickEntryPoints { |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 47 | #define ENTRYPOINT_ENUM(name, rettype, ...) rettype ( * p ## name )( __VA_ARGS__ ); |
| 48 | #include "quick_entrypoints_list.h" |
| 49 | QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM) |
| 50 | #undef QUICK_ENTRYPOINT_LIST |
| 51 | #undef ENTRYPOINT_ENUM |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
Anwar Ghuloum | 63937db | 2013-05-24 09:08:32 -0700 | [diff] [blame] | 54 | |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 55 | // JNI entrypoints. |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 56 | // TODO: NO_THREAD_SAFETY_ANALYSIS due to different control paths depending on fast JNI. |
| 57 | extern uint32_t JniMethodStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 58 | extern uint32_t JniMethodFastStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 59 | extern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self) |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 60 | NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 61 | extern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self) |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 62 | NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 63 | extern void JniMethodFastEnd(uint32_t saved_local_ref_cookie, Thread* self) |
| 64 | NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 65 | extern void JniMethodEndSynchronized(uint32_t saved_local_ref_cookie, jobject locked, |
| 66 | Thread* self) |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 67 | NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 68 | extern mirror::Object* JniMethodEndWithReference(jobject result, uint32_t saved_local_ref_cookie, |
| 69 | Thread* self) |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 70 | NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
Igor Murashkin | af1e299 | 2016-10-12 17:44:50 -0700 | [diff] [blame] | 71 | extern mirror::Object* JniMethodFastEndWithReference(jobject result, |
| 72 | uint32_t saved_local_ref_cookie, |
| 73 | Thread* self) |
| 74 | NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
| 75 | |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 76 | |
| 77 | extern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result, |
| 78 | uint32_t saved_local_ref_cookie, |
| 79 | jobject locked, Thread* self) |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 80 | NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 81 | |
Vladimir Marko | 552a134 | 2017-10-31 10:56:47 +0000 | [diff] [blame] | 82 | extern "C" mirror::String* artStringBuilderAppend(uint32_t format, |
| 83 | const uint32_t* args, |
| 84 | Thread* self) |
| 85 | REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR; |
| 86 | |
Hiroshi Yamauchi | 1cc71eb | 2015-05-07 10:47:27 -0700 | [diff] [blame] | 87 | extern void ReadBarrierJni(mirror::CompressedReference<mirror::Object>* handle_on_stack, |
| 88 | Thread* self) |
| 89 | NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; |
| 90 | |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 91 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 92 | // Read barrier entrypoints. |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 93 | // |
| 94 | // Compilers for ARM, ARM64, MIPS, MIPS64 can insert a call to these |
| 95 | // functions directly. For x86 and x86-64, compilers need a wrapper |
| 96 | // assembly function, to handle mismatch in ABI. |
| 97 | |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 98 | // Mark the heap reference `obj`. This entry point is used by read |
| 99 | // barrier fast path implementations generated by the compiler to mark |
| 100 | // an object that is referenced by a field of a gray object. |
| 101 | extern "C" mirror::Object* artReadBarrierMark(mirror::Object* obj) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 102 | REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR; |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 103 | |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 104 | // Read barrier entrypoint for heap references. |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 105 | // This is the read barrier slow path for instance and static fields |
| 106 | // and reference type arrays. |
| 107 | extern "C" mirror::Object* artReadBarrierSlow(mirror::Object* ref, |
| 108 | mirror::Object* obj, |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 109 | uint32_t offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 110 | REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR; |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 111 | |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 112 | // Read barrier entrypoint for GC roots. |
| 113 | extern "C" mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 114 | REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR; |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 115 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 116 | } // namespace art |
| 117 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 118 | #endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ |