Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -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 | |
Vladimir Marko | 3a21e38 | 2016-09-02 12:38:38 +0100 | [diff] [blame] | 17 | #include <math.h> |
| 18 | #include <string.h> |
| 19 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 20 | #include "entrypoints/jni/jni_entrypoints.h" |
Mathieu Chartier | d889178 | 2014-03-02 13:28:37 -0800 | [diff] [blame] | 21 | #include "entrypoints/quick/quick_alloc_entrypoints.h" |
Andreas Gampe | e179456 | 2014-11-04 22:26:32 -0800 | [diff] [blame] | 22 | #include "entrypoints/quick/quick_default_externs.h" |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 23 | #include "entrypoints/quick/quick_default_init_entrypoints.h" |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 24 | #include "entrypoints/quick/quick_entrypoints.h" |
| 25 | #include "entrypoints/entrypoint_utils.h" |
| 26 | #include "entrypoints/math_entrypoints.h" |
Andreas Gampe | e179456 | 2014-11-04 22:26:32 -0800 | [diff] [blame] | 27 | #include "entrypoints/runtime_asm_entrypoints.h" |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 28 | #include "interpreter/interpreter.h" |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 29 | |
| 30 | namespace art { |
| 31 | |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 32 | // Cast entrypoints. |
Mathieu Chartier | 9fd8c60 | 2016-11-14 14:38:53 -0800 | [diff] [blame] | 33 | extern "C" size_t artInstanceOfFromCode(mirror::Object* obj, mirror::Class* ref_class); |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 34 | |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 35 | // 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 Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 38 | // result in that same register, and saves and restores all |
| 39 | // caller-save registers. |
| 40 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg00(mirror::Object*); |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 41 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg01(mirror::Object*); |
| 42 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg02(mirror::Object*); |
| 43 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg03(mirror::Object*); |
| 44 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg04(mirror::Object*); |
| 45 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg05(mirror::Object*); |
| 46 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg06(mirror::Object*); |
| 47 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg07(mirror::Object*); |
| 48 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg08(mirror::Object*); |
| 49 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg09(mirror::Object*); |
| 50 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg10(mirror::Object*); |
| 51 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg11(mirror::Object*); |
| 52 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg12(mirror::Object*); |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 53 | |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 54 | // Used by soft float. |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 55 | // Single-precision FP arithmetics. |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 56 | extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR] |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 57 | // Double-precision FP arithmetics. |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 58 | extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR] |
| 59 | |
| 60 | // Used by hard float. |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 61 | extern "C" float art_quick_fmodf(float a, float b); // REM_FLOAT[_2ADDR] |
| 62 | extern "C" double art_quick_fmod(double a, double b); // REM_DOUBLE[_2ADDR] |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 63 | |
| 64 | // Integer arithmetics. |
| 65 | extern "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] |
| 68 | extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t); |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 69 | |
Mathieu Chartier | fe814e8 | 2016-11-09 14:32:49 -0800 | [diff] [blame] | 70 | void 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 Gampe | 3cfa4d0 | 2015-10-06 17:04:01 -0700 | [diff] [blame] | 85 | void InitEntryPoints(JniEntryPoints* jpoints, QuickEntryPoints* qpoints) { |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 86 | DefaultInitEntryPoints(jpoints, qpoints); |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 87 | |
| 88 | // Cast |
Mathieu Chartier | 6beced4 | 2016-11-15 15:51:31 -0800 | [diff] [blame] | 89 | qpoints->pInstanceofNonTrivial = artInstanceOfFromCode; |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 90 | qpoints->pCheckInstanceOf = art_quick_check_instance_of; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 91 | |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 92 | // Math |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 93 | qpoints->pIdivmod = __aeabi_idivmod; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 94 | qpoints->pLdiv = __aeabi_ldivmod; |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 95 | qpoints->pLmod = __aeabi_ldivmod; // result returned in r2:r3 |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 96 | 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 Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 100 | if (kArm32QuickCodeUseSoftFloat) { |
| 101 | qpoints->pFmod = fmod; |
| 102 | qpoints->pFmodf = fmodf; |
| 103 | qpoints->pD2l = art_d2l; |
| 104 | qpoints->pF2l = art_f2l; |
Roland Levillain | 5b3ee56 | 2015-04-14 16:02:41 +0100 | [diff] [blame] | 105 | qpoints->pL2f = art_l2f; |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 106 | } 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 Levillain | 5b3ee56 | 2015-04-14 16:02:41 +0100 | [diff] [blame] | 111 | qpoints->pL2f = art_quick_l2f; |
Zheng Xu | 5667fdb | 2014-10-23 18:29:55 +0800 | [diff] [blame] | 112 | } |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 113 | |
Anton Kirilov | d70dc9d | 2016-02-04 14:59:04 +0000 | [diff] [blame] | 114 | // 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 Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 133 | // Intrinsics |
| 134 | qpoints->pIndexOf = art_quick_indexof; |
Scott Wakeling | c25cbf1 | 2016-04-18 09:00:11 +0100 | [diff] [blame] | 135 | // The ARM StringCompareTo intrinsic does not call the runtime. |
| 136 | qpoints->pStringCompareTo = nullptr; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 137 | qpoints->pMemcpy = memcpy; |
| 138 | |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 139 | // Read barrier. |
Hiroshi Yamauchi | 1cc71eb | 2015-05-07 10:47:27 -0700 | [diff] [blame] | 140 | qpoints->pReadBarrierJni = ReadBarrierJni; |
Mathieu Chartier | fe814e8 | 2016-11-09 14:32:49 -0800 | [diff] [blame] | 141 | UpdateReadBarrierEntrypoints(qpoints, /*is_marking*/ false); |
Mathieu Chartier | 36c2271 | 2016-08-12 13:19:44 -0700 | [diff] [blame] | 142 | qpoints->pReadBarrierMarkReg12 = nullptr; // Cannot use register 12 (IP) to pass arguments. |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 143 | 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 Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 161 | qpoints->pReadBarrierSlow = artReadBarrierSlow; |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 162 | qpoints->pReadBarrierForRootSlow = artReadBarrierForRootSlow; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 163 | } |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 164 | |
| 165 | } // namespace art |