blob: 89712a3cc778577cb826b1b4286ebc464eaec440 [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
Ian Rogers166db042013-07-26 12:05:57 -070017#ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
18#define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
Ian Rogers57b86d42012-03-27 16:05:41 -070019
Ian Rogers848871b2013-08-05 10:56:33 -070020#include <jni.h>
21
22#include "base/macros.h"
Man Cao1aee9002015-07-14 22:31:42 -070023#include "base/mutex.h"
Ian Rogers848871b2013-08-05 10:56:33 -070024#include "offsets.h"
Ian Rogers57b86d42012-03-27 16:05:41 -070025
Ian Rogersdd7624d2014-03-14 17:43:00 -070026#define QUICK_ENTRYPOINT_OFFSET(ptr_size, x) \
27 Thread::QuickEntryPointOffset<ptr_size>(OFFSETOF_MEMBER(QuickEntryPoints, x))
Ian Rogers57b86d42012-03-27 16:05:41 -070028
29namespace art {
Ian Rogers848871b2013-08-05 10:56:33 -070030
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080031namespace mirror {
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080032class Array;
Brian Carlstromea46f952013-07-30 01:26:50 -070033class Class;
Roland Levillain0d5a2812015-11-13 10:07:31 +000034template<class MirrorType> class CompressedReference;
Brian Carlstromea46f952013-07-30 01:26:50 -070035class Object;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080036} // namespace mirror
Ian Rogers848871b2013-08-05 10:56:33 -070037
Mathieu Chartiere401d142015-04-22 13:56:20 -070038class ArtMethod;
Roland Levillain0d5a2812015-11-13 10:07:31 +000039template<class MirrorType> class GcRoot;
Ian Rogers57b86d42012-03-27 16:05:41 -070040class Thread;
41
Ian Rogers166db042013-07-26 12:05:57 -070042// Pointers to functions that are called by quick compiler generated code via thread-local storage.
43struct PACKED(4) QuickEntryPoints {
Andreas Gampe98430592014-07-27 19:44:50 -070044#define ENTRYPOINT_ENUM(name, rettype, ...) rettype ( * p ## name )( __VA_ARGS__ );
45#include "quick_entrypoints_list.h"
46 QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
47#undef QUICK_ENTRYPOINT_LIST
48#undef ENTRYPOINT_ENUM
Ian Rogers57b86d42012-03-27 16:05:41 -070049};
50
Anwar Ghuloum63937db2013-05-24 09:08:32 -070051
Ian Rogers693ff612013-02-01 10:56:12 -080052// JNI entrypoints.
Ian Rogers1eb512d2013-10-18 15:42:20 -070053// TODO: NO_THREAD_SAFETY_ANALYSIS due to different control paths depending on fast JNI.
54extern uint32_t JniMethodStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Igor Murashkin9d4b6da2016-07-29 09:51:58 -070055extern uint32_t JniMethodFastStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -080056extern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -070057 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -080058extern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -070059 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Igor Murashkin9d4b6da2016-07-29 09:51:58 -070060extern void JniMethodFastEnd(uint32_t saved_local_ref_cookie, Thread* self)
61 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -080062extern void JniMethodEndSynchronized(uint32_t saved_local_ref_cookie, jobject locked,
63 Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -070064 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -080065extern mirror::Object* JniMethodEndWithReference(jobject result, uint32_t saved_local_ref_cookie,
66 Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -070067 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -080068
69extern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result,
70 uint32_t saved_local_ref_cookie,
71 jobject locked, Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -070072 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -080073
Hiroshi Yamauchi1cc71eb2015-05-07 10:47:27 -070074extern void ReadBarrierJni(mirror::CompressedReference<mirror::Object>* handle_on_stack,
75 Thread* self)
76 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
77
Roland Levillain0d5a2812015-11-13 10:07:31 +000078
Man Cao1aee9002015-07-14 22:31:42 -070079// Read barrier entrypoints.
Roland Levillain0d5a2812015-11-13 10:07:31 +000080//
81// Compilers for ARM, ARM64, MIPS, MIPS64 can insert a call to these
82// functions directly. For x86 and x86-64, compilers need a wrapper
83// assembly function, to handle mismatch in ABI.
84
Roland Levillain7c1559a2015-12-15 10:55:36 +000085// Mark the heap reference `obj`. This entry point is used by read
86// barrier fast path implementations generated by the compiler to mark
87// an object that is referenced by a field of a gray object.
88extern "C" mirror::Object* artReadBarrierMark(mirror::Object* obj)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070089 REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
Roland Levillain7c1559a2015-12-15 10:55:36 +000090
Roland Levillain0d5a2812015-11-13 10:07:31 +000091// Read barrier entrypoint for heap references.
Roland Levillain7c1559a2015-12-15 10:55:36 +000092// This is the read barrier slow path for instance and static fields
93// and reference type arrays.
94extern "C" mirror::Object* artReadBarrierSlow(mirror::Object* ref,
95 mirror::Object* obj,
Man Cao1aee9002015-07-14 22:31:42 -070096 uint32_t offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070097 REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
Man Cao1aee9002015-07-14 22:31:42 -070098
Roland Levillain0d5a2812015-11-13 10:07:31 +000099// Read barrier entrypoint for GC roots.
100extern "C" mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700101 REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
Roland Levillain0d5a2812015-11-13 10:07:31 +0000102
Ian Rogers57b86d42012-03-27 16:05:41 -0700103} // namespace art
104
Ian Rogers166db042013-07-26 12:05:57 -0700105#endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_