157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers/* 257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * Copyright (C) 2012 The Android Open Source Project 357b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * 457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * Licensed under the Apache License, Version 2.0 (the "License"); 557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * you may not use this file except in compliance with the License. 657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * You may obtain a copy of the License at 757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * 857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * http://www.apache.org/licenses/LICENSE-2.0 957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * 1057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * Unless required by applicable law or agreed to in writing, software 1157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * distributed under the License is distributed on an "AS IS" BASIS, 1257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1357b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * See the License for the specific language governing permissions and 1457b86d47b66322693a070185fadfb43cb9c12eabIan Rogers * limitations under the License. 1557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers */ 1657b86d47b66322693a070185fadfb43cb9c12eabIan Rogers 17166db04e259ca51838c311891598664deeed85adIan Rogers#ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ 18166db04e259ca51838c311891598664deeed85adIan Rogers#define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ 1957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers 20848871b4d8481229c32e0d048a9856e5a9a17ef9Ian Rogers#include <jni.h> 21848871b4d8481229c32e0d048a9856e5a9a17ef9Ian Rogers 22848871b4d8481229c32e0d048a9856e5a9a17ef9Ian Rogers#include "base/macros.h" 231aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao#include "base/mutex.h" 24848871b4d8481229c32e0d048a9856e5a9a17ef9Ian Rogers#include "offsets.h" 2557b86d47b66322693a070185fadfb43cb9c12eabIan Rogers 26dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers#define QUICK_ENTRYPOINT_OFFSET(ptr_size, x) \ 27dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers Thread::QuickEntryPointOffset<ptr_size>(OFFSETOF_MEMBER(QuickEntryPoints, x)) 2857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers 2957b86d47b66322693a070185fadfb43cb9c12eabIan Rogersnamespace art { 30848871b4d8481229c32e0d048a9856e5a9a17ef9Ian Rogers 312dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogersnamespace mirror { 321cc7dbabd03e0a6c09d68161417a21bd6f9df371Andreas Gampeclass Array; 33ea46f950e7a51585db293cd7f047de190a482414Brian Carlstromclass Class; 340d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillaintemplate<class MirrorType> class CompressedReference; 35ea46f950e7a51585db293cd7f047de190a482414Brian Carlstromclass Object; 362dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers} // namespace mirror 37848871b4d8481229c32e0d048a9856e5a9a17ef9Ian Rogers 38e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartierclass ArtMethod; 390d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillaintemplate<class MirrorType> class GcRoot; 4057b86d47b66322693a070185fadfb43cb9c12eabIan Rogersclass Thread; 4157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers 42166db04e259ca51838c311891598664deeed85adIan Rogers// Pointers to functions that are called by quick compiler generated code via thread-local storage. 43166db04e259ca51838c311891598664deeed85adIan Rogersstruct PACKED(4) QuickEntryPoints { 44984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#define ENTRYPOINT_ENUM(name, rettype, ...) rettype ( * p ## name )( __VA_ARGS__ ); 45984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#include "quick_entrypoints_list.h" 46984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM) 47984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#undef QUICK_ENTRYPOINT_LIST 48984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#undef ENTRYPOINT_ENUM 4957b86d47b66322693a070185fadfb43cb9c12eabIan Rogers}; 5057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers 5163937db1cec24d065e2b4cdb7a41809528b5085bAnwar Ghuloum 52693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogers// JNI entrypoints. 531eb512d33f94d1dd7ea38263307ba0f7a0dfa653Ian Rogers// TODO: NO_THREAD_SAFETY_ANALYSIS due to different control paths depending on fast JNI. 541eb512d33f94d1dd7ea38263307ba0f7a0dfa653Ian Rogersextern uint32_t JniMethodStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; 55693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogersextern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self) 561eb512d33f94d1dd7ea38263307ba0f7a0dfa653Ian Rogers NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; 57693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogersextern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self) 581eb512d33f94d1dd7ea38263307ba0f7a0dfa653Ian Rogers NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; 59693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogersextern void JniMethodEndSynchronized(uint32_t saved_local_ref_cookie, jobject locked, 60693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogers Thread* self) 611eb512d33f94d1dd7ea38263307ba0f7a0dfa653Ian Rogers NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; 62693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogersextern mirror::Object* JniMethodEndWithReference(jobject result, uint32_t saved_local_ref_cookie, 63693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogers Thread* self) 641eb512d33f94d1dd7ea38263307ba0f7a0dfa653Ian Rogers NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; 65693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogers 66693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogersextern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result, 67693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogers uint32_t saved_local_ref_cookie, 68693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogers jobject locked, Thread* self) 691eb512d33f94d1dd7ea38263307ba0f7a0dfa653Ian Rogers NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; 70693ff61274cd2c9b8eb7e68c370f84a911b8ca52Ian Rogers 711cc71ebf333ca323ae0e130fefbce4593e385c10Hiroshi Yamauchiextern void ReadBarrierJni(mirror::CompressedReference<mirror::Object>* handle_on_stack, 721cc71ebf333ca323ae0e130fefbce4593e385c10Hiroshi Yamauchi Thread* self) 731cc71ebf333ca323ae0e130fefbce4593e385c10Hiroshi Yamauchi NO_THREAD_SAFETY_ANALYSIS HOT_ATTR; 741cc71ebf333ca323ae0e130fefbce4593e385c10Hiroshi Yamauchi 750d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain 761aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao// Read barrier entrypoints. 770d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain// 780d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain// Compilers for ARM, ARM64, MIPS, MIPS64 can insert a call to these 790d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain// functions directly. For x86 and x86-64, compilers need a wrapper 800d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain// assembly function, to handle mismatch in ABI. 810d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain 827c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillain// Mark the heap reference `obj`. This entry point is used by read 837c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillain// barrier fast path implementations generated by the compiler to mark 847c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillain// an object that is referenced by a field of a gray object. 857c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillainextern "C" mirror::Object* artReadBarrierMark(mirror::Object* obj) 867c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillain SHARED_REQUIRES(Locks::mutator_lock_) HOT_ATTR; 877c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillain 880d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain// Read barrier entrypoint for heap references. 897c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillain// This is the read barrier slow path for instance and static fields 907c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillain// and reference type arrays. 917c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillainextern "C" mirror::Object* artReadBarrierSlow(mirror::Object* ref, 927c1559a06041c9c299d5ab514d54b2102f204a84Roland Levillain mirror::Object* obj, 931aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao uint32_t offset) 941aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao SHARED_REQUIRES(Locks::mutator_lock_) HOT_ATTR; 951aee900d5a0b3a8d78725a7551356bda0d8554e1Man Cao 960d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain// Read barrier entrypoint for GC roots. 970d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillainextern "C" mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root) 980d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain SHARED_REQUIRES(Locks::mutator_lock_) HOT_ATTR; 990d5a281c671444bfa75d63caf1427a8c0e6e1177Roland Levillain 10057b86d47b66322693a070185fadfb43cb9c12eabIan Rogers} // namespace art 10157b86d47b66322693a070185fadfb43cb9c12eabIan Rogers 102166db04e259ca51838c311891598664deeed85adIan Rogers#endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ 103