blob: de72d3a18f7ac54a564691aa1e8e2c30898a2bc6 [file] [log] [blame]
Ian Rogers7655f292013-07-29 11:07:13 -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
Vladimir Marko3a21e382016-09-02 12:38:38 +010017#include <math.h>
18#include <string.h>
19
Mingyao Yang98d1cc82014-05-15 17:02:16 -070020#include "entrypoints/jni/jni_entrypoints.h"
Mathieu Chartierd8891782014-03-02 13:28:37 -080021#include "entrypoints/quick/quick_alloc_entrypoints.h"
Andreas Gampee1794562014-11-04 22:26:32 -080022#include "entrypoints/quick/quick_default_externs.h"
Andreas Gampec7ed09b2016-04-25 20:08:55 -070023#include "entrypoints/quick/quick_default_init_entrypoints.h"
Ian Rogers7655f292013-07-29 11:07:13 -070024#include "entrypoints/quick/quick_entrypoints.h"
25#include "entrypoints/entrypoint_utils.h"
26#include "entrypoints/math_entrypoints.h"
Andreas Gampee1794562014-11-04 22:26:32 -080027#include "entrypoints/runtime_asm_entrypoints.h"
Ian Rogers6f3dbba2014-10-14 17:41:57 -070028#include "interpreter/interpreter.h"
Ian Rogers7655f292013-07-29 11:07:13 -070029
30namespace art {
31
Ian Rogers7655f292013-07-29 11:07:13 -070032// Cast entrypoints.
Mathieu Chartier9fd8c602016-11-14 14:38:53 -080033extern "C" size_t artInstanceOfFromCode(mirror::Object* obj, mirror::Class* ref_class);
Ian Rogers7655f292013-07-29 11:07:13 -070034
Roland Levillain02b75802016-07-13 11:54:35 +010035// Read barrier entrypoints.
36// art_quick_read_barrier_mark_regX uses an non-standard calling
37// convention: it expects its input in register X and returns its
Roland Levillain4359e612016-07-20 11:32:19 +010038// result in that same register, and saves and restores all
39// caller-save registers.
40extern "C" mirror::Object* art_quick_read_barrier_mark_reg00(mirror::Object*);
Roland Levillain02b75802016-07-13 11:54:35 +010041extern "C" mirror::Object* art_quick_read_barrier_mark_reg01(mirror::Object*);
42extern "C" mirror::Object* art_quick_read_barrier_mark_reg02(mirror::Object*);
43extern "C" mirror::Object* art_quick_read_barrier_mark_reg03(mirror::Object*);
44extern "C" mirror::Object* art_quick_read_barrier_mark_reg04(mirror::Object*);
45extern "C" mirror::Object* art_quick_read_barrier_mark_reg05(mirror::Object*);
46extern "C" mirror::Object* art_quick_read_barrier_mark_reg06(mirror::Object*);
47extern "C" mirror::Object* art_quick_read_barrier_mark_reg07(mirror::Object*);
48extern "C" mirror::Object* art_quick_read_barrier_mark_reg08(mirror::Object*);
49extern "C" mirror::Object* art_quick_read_barrier_mark_reg09(mirror::Object*);
50extern "C" mirror::Object* art_quick_read_barrier_mark_reg10(mirror::Object*);
51extern "C" mirror::Object* art_quick_read_barrier_mark_reg11(mirror::Object*);
52extern "C" mirror::Object* art_quick_read_barrier_mark_reg12(mirror::Object*);
Ian Rogers7655f292013-07-29 11:07:13 -070053
Zheng Xu5667fdb2014-10-23 18:29:55 +080054// Used by soft float.
Ian Rogers7655f292013-07-29 11:07:13 -070055// Single-precision FP arithmetics.
Zheng Xu5667fdb2014-10-23 18:29:55 +080056extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
Ian Rogers7655f292013-07-29 11:07:13 -070057// Double-precision FP arithmetics.
Zheng Xu5667fdb2014-10-23 18:29:55 +080058extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
59
60// Used by hard float.
Zheng Xu5667fdb2014-10-23 18:29:55 +080061extern "C" float art_quick_fmodf(float a, float b); // REM_FLOAT[_2ADDR]
62extern "C" double art_quick_fmod(double a, double b); // REM_DOUBLE[_2ADDR]
Ian Rogers7655f292013-07-29 11:07:13 -070063
64// Integer arithmetics.
65extern "C" int __aeabi_idivmod(int32_t, int32_t); // [DIV|REM]_INT[_2ADDR|_LIT8|_LIT16]
66
67// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
68extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t);
Andreas Gampe277ccbd2014-11-03 21:36:10 -080069
Mathieu Chartierfe814e82016-11-09 14:32:49 -080070void UpdateReadBarrierEntrypoints(QuickEntryPoints* qpoints, bool is_marking) {
71 qpoints->pReadBarrierMarkReg00 = is_marking ? art_quick_read_barrier_mark_reg00 : nullptr;
72 qpoints->pReadBarrierMarkReg01 = is_marking ? art_quick_read_barrier_mark_reg01 : nullptr;
73 qpoints->pReadBarrierMarkReg02 = is_marking ? art_quick_read_barrier_mark_reg02 : nullptr;
74 qpoints->pReadBarrierMarkReg03 = is_marking ? art_quick_read_barrier_mark_reg03 : nullptr;
75 qpoints->pReadBarrierMarkReg04 = is_marking ? art_quick_read_barrier_mark_reg04 : nullptr;
76 qpoints->pReadBarrierMarkReg05 = is_marking ? art_quick_read_barrier_mark_reg05 : nullptr;
77 qpoints->pReadBarrierMarkReg06 = is_marking ? art_quick_read_barrier_mark_reg06 : nullptr;
78 qpoints->pReadBarrierMarkReg07 = is_marking ? art_quick_read_barrier_mark_reg07 : nullptr;
79 qpoints->pReadBarrierMarkReg08 = is_marking ? art_quick_read_barrier_mark_reg08 : nullptr;
80 qpoints->pReadBarrierMarkReg09 = is_marking ? art_quick_read_barrier_mark_reg09 : nullptr;
81 qpoints->pReadBarrierMarkReg10 = is_marking ? art_quick_read_barrier_mark_reg10 : nullptr;
82 qpoints->pReadBarrierMarkReg11 = is_marking ? art_quick_read_barrier_mark_reg11 : nullptr;
83}
84
Andreas Gampe3cfa4d02015-10-06 17:04:01 -070085void InitEntryPoints(JniEntryPoints* jpoints, QuickEntryPoints* qpoints) {
Andreas Gampec7ed09b2016-04-25 20:08:55 -070086 DefaultInitEntryPoints(jpoints, qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -070087
88 // Cast
Mathieu Chartier6beced42016-11-15 15:51:31 -080089 qpoints->pInstanceofNonTrivial = artInstanceOfFromCode;
Mathieu Chartierb99f4d62016-11-07 16:17:26 -080090 qpoints->pCheckInstanceOf = art_quick_check_instance_of;
Ian Rogers7655f292013-07-29 11:07:13 -070091
Ian Rogers7655f292013-07-29 11:07:13 -070092 // Math
Ian Rogers7655f292013-07-29 11:07:13 -070093 qpoints->pIdivmod = __aeabi_idivmod;
Ian Rogers7655f292013-07-29 11:07:13 -070094 qpoints->pLdiv = __aeabi_ldivmod;
Ian Rogersa9a82542013-10-04 11:17:26 -070095 qpoints->pLmod = __aeabi_ldivmod; // result returned in r2:r3
Ian Rogers7655f292013-07-29 11:07:13 -070096 qpoints->pLmul = art_quick_mul_long;
97 qpoints->pShlLong = art_quick_shl_long;
98 qpoints->pShrLong = art_quick_shr_long;
99 qpoints->pUshrLong = art_quick_ushr_long;
Zheng Xu5667fdb2014-10-23 18:29:55 +0800100 if (kArm32QuickCodeUseSoftFloat) {
101 qpoints->pFmod = fmod;
102 qpoints->pFmodf = fmodf;
103 qpoints->pD2l = art_d2l;
104 qpoints->pF2l = art_f2l;
Roland Levillain5b3ee562015-04-14 16:02:41 +0100105 qpoints->pL2f = art_l2f;
Zheng Xu5667fdb2014-10-23 18:29:55 +0800106 } else {
107 qpoints->pFmod = art_quick_fmod;
108 qpoints->pFmodf = art_quick_fmodf;
109 qpoints->pD2l = art_quick_d2l;
110 qpoints->pF2l = art_quick_f2l;
Roland Levillain5b3ee562015-04-14 16:02:41 +0100111 qpoints->pL2f = art_quick_l2f;
Zheng Xu5667fdb2014-10-23 18:29:55 +0800112 }
Ian Rogers7655f292013-07-29 11:07:13 -0700113
Anton Kirilovd70dc9d2016-02-04 14:59:04 +0000114 // More math.
115 qpoints->pCos = cos;
116 qpoints->pSin = sin;
117 qpoints->pAcos = acos;
118 qpoints->pAsin = asin;
119 qpoints->pAtan = atan;
120 qpoints->pAtan2 = atan2;
121 qpoints->pCbrt = cbrt;
122 qpoints->pCosh = cosh;
123 qpoints->pExp = exp;
124 qpoints->pExpm1 = expm1;
125 qpoints->pHypot = hypot;
126 qpoints->pLog = log;
127 qpoints->pLog10 = log10;
128 qpoints->pNextAfter = nextafter;
129 qpoints->pSinh = sinh;
130 qpoints->pTan = tan;
131 qpoints->pTanh = tanh;
132
Ian Rogers7655f292013-07-29 11:07:13 -0700133 // Intrinsics
134 qpoints->pIndexOf = art_quick_indexof;
Scott Wakelingc25cbf12016-04-18 09:00:11 +0100135 // The ARM StringCompareTo intrinsic does not call the runtime.
136 qpoints->pStringCompareTo = nullptr;
Ian Rogers7655f292013-07-29 11:07:13 -0700137 qpoints->pMemcpy = memcpy;
138
Roland Levillain0d5a2812015-11-13 10:07:31 +0000139 // Read barrier.
Hiroshi Yamauchi1cc71eb2015-05-07 10:47:27 -0700140 qpoints->pReadBarrierJni = ReadBarrierJni;
Mathieu Chartierfe814e82016-11-09 14:32:49 -0800141 UpdateReadBarrierEntrypoints(qpoints, /*is_marking*/ false);
Mathieu Chartier36c22712016-08-12 13:19:44 -0700142 qpoints->pReadBarrierMarkReg12 = nullptr; // Cannot use register 12 (IP) to pass arguments.
Roland Levillain02b75802016-07-13 11:54:35 +0100143 qpoints->pReadBarrierMarkReg13 = nullptr; // Cannot use register 13 (SP) to pass arguments.
144 qpoints->pReadBarrierMarkReg14 = nullptr; // Cannot use register 14 (LR) to pass arguments.
145 qpoints->pReadBarrierMarkReg15 = nullptr; // Cannot use register 15 (PC) to pass arguments.
146 // ARM has only 16 core registers.
147 qpoints->pReadBarrierMarkReg16 = nullptr;
148 qpoints->pReadBarrierMarkReg17 = nullptr;
149 qpoints->pReadBarrierMarkReg18 = nullptr;
150 qpoints->pReadBarrierMarkReg19 = nullptr;
151 qpoints->pReadBarrierMarkReg20 = nullptr;
152 qpoints->pReadBarrierMarkReg21 = nullptr;
153 qpoints->pReadBarrierMarkReg22 = nullptr;
154 qpoints->pReadBarrierMarkReg23 = nullptr;
155 qpoints->pReadBarrierMarkReg24 = nullptr;
156 qpoints->pReadBarrierMarkReg25 = nullptr;
157 qpoints->pReadBarrierMarkReg26 = nullptr;
158 qpoints->pReadBarrierMarkReg27 = nullptr;
159 qpoints->pReadBarrierMarkReg28 = nullptr;
160 qpoints->pReadBarrierMarkReg29 = nullptr;
Man Cao1aee9002015-07-14 22:31:42 -0700161 qpoints->pReadBarrierSlow = artReadBarrierSlow;
Roland Levillain0d5a2812015-11-13 10:07:31 +0000162 qpoints->pReadBarrierForRootSlow = artReadBarrierForRootSlow;
Andreas Gampec8ccf682014-09-29 20:07:43 -0700163}
Ian Rogers7655f292013-07-29 11:07:13 -0700164
165} // namespace art