Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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" |
Andreas Gampe | e179456 | 2014-11-04 22:26:32 -0800 | [diff] [blame] | 21 | #include "entrypoints/quick/quick_alloc_entrypoints.h" |
| 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" |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 24 | #include "entrypoints/quick/quick_entrypoints.h" |
| 25 | #include "entrypoints/entrypoint_utils.h" |
| 26 | #include "entrypoints/math_entrypoints.h" |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 27 | #include "entrypoints/runtime_asm_entrypoints.h" |
| 28 | #include "interpreter/interpreter.h" |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 29 | |
| 30 | namespace art { |
| 31 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [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); |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [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*); |
| 53 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg12(mirror::Object*); |
| 54 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg13(mirror::Object*); |
| 55 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg14(mirror::Object*); |
| 56 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg15(mirror::Object*); |
| 57 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg16(mirror::Object*); |
| 58 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg17(mirror::Object*); |
| 59 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg18(mirror::Object*); |
| 60 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg19(mirror::Object*); |
| 61 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg20(mirror::Object*); |
| 62 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg21(mirror::Object*); |
| 63 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg22(mirror::Object*); |
| 64 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg22(mirror::Object*); |
| 65 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg23(mirror::Object*); |
| 66 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg24(mirror::Object*); |
| 67 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg25(mirror::Object*); |
| 68 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg26(mirror::Object*); |
| 69 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg27(mirror::Object*); |
| 70 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg28(mirror::Object*); |
| 71 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg29(mirror::Object*); |
| 72 | |
Mathieu Chartier | fe814e8 | 2016-11-09 14:32:49 -0800 | [diff] [blame] | 73 | void UpdateReadBarrierEntrypoints(QuickEntryPoints* qpoints, bool is_marking) { |
| 74 | // ARM64 is the architecture with the largest number of core |
| 75 | // registers (32) that supports the read barrier configuration. |
| 76 | // Because registers 30 (LR) and 31 (SP/XZR) cannot be used to pass |
| 77 | // arguments, only define ReadBarrierMarkRegX entrypoints for the |
| 78 | // first 30 registers. This limitation is not a problem on other |
| 79 | // supported architectures (ARM, x86 and x86-64) either, as they |
| 80 | // have less core registers (resp. 16, 8 and 16). (We may have to |
| 81 | // revise that design choice if read barrier support is added for |
| 82 | // MIPS and/or MIPS64.) |
| 83 | qpoints->pReadBarrierMarkReg00 = is_marking ? art_quick_read_barrier_mark_reg00 : nullptr; |
| 84 | qpoints->pReadBarrierMarkReg01 = is_marking ? art_quick_read_barrier_mark_reg01 : nullptr; |
| 85 | qpoints->pReadBarrierMarkReg02 = is_marking ? art_quick_read_barrier_mark_reg02 : nullptr; |
| 86 | qpoints->pReadBarrierMarkReg03 = is_marking ? art_quick_read_barrier_mark_reg03 : nullptr; |
| 87 | qpoints->pReadBarrierMarkReg04 = is_marking ? art_quick_read_barrier_mark_reg04 : nullptr; |
| 88 | qpoints->pReadBarrierMarkReg05 = is_marking ? art_quick_read_barrier_mark_reg05 : nullptr; |
| 89 | qpoints->pReadBarrierMarkReg06 = is_marking ? art_quick_read_barrier_mark_reg06 : nullptr; |
| 90 | qpoints->pReadBarrierMarkReg07 = is_marking ? art_quick_read_barrier_mark_reg07 : nullptr; |
| 91 | qpoints->pReadBarrierMarkReg08 = is_marking ? art_quick_read_barrier_mark_reg08 : nullptr; |
| 92 | qpoints->pReadBarrierMarkReg09 = is_marking ? art_quick_read_barrier_mark_reg09 : nullptr; |
| 93 | qpoints->pReadBarrierMarkReg10 = is_marking ? art_quick_read_barrier_mark_reg10 : nullptr; |
| 94 | qpoints->pReadBarrierMarkReg11 = is_marking ? art_quick_read_barrier_mark_reg11 : nullptr; |
| 95 | qpoints->pReadBarrierMarkReg12 = is_marking ? art_quick_read_barrier_mark_reg12 : nullptr; |
| 96 | qpoints->pReadBarrierMarkReg13 = is_marking ? art_quick_read_barrier_mark_reg13 : nullptr; |
| 97 | qpoints->pReadBarrierMarkReg14 = is_marking ? art_quick_read_barrier_mark_reg14 : nullptr; |
| 98 | qpoints->pReadBarrierMarkReg15 = is_marking ? art_quick_read_barrier_mark_reg15 : nullptr; |
| 99 | qpoints->pReadBarrierMarkReg17 = is_marking ? art_quick_read_barrier_mark_reg17 : nullptr; |
| 100 | qpoints->pReadBarrierMarkReg18 = is_marking ? art_quick_read_barrier_mark_reg18 : nullptr; |
| 101 | qpoints->pReadBarrierMarkReg19 = is_marking ? art_quick_read_barrier_mark_reg19 : nullptr; |
| 102 | qpoints->pReadBarrierMarkReg20 = is_marking ? art_quick_read_barrier_mark_reg20 : nullptr; |
| 103 | qpoints->pReadBarrierMarkReg21 = is_marking ? art_quick_read_barrier_mark_reg21 : nullptr; |
| 104 | qpoints->pReadBarrierMarkReg22 = is_marking ? art_quick_read_barrier_mark_reg22 : nullptr; |
| 105 | qpoints->pReadBarrierMarkReg23 = is_marking ? art_quick_read_barrier_mark_reg23 : nullptr; |
| 106 | qpoints->pReadBarrierMarkReg24 = is_marking ? art_quick_read_barrier_mark_reg24 : nullptr; |
| 107 | qpoints->pReadBarrierMarkReg25 = is_marking ? art_quick_read_barrier_mark_reg25 : nullptr; |
| 108 | qpoints->pReadBarrierMarkReg26 = is_marking ? art_quick_read_barrier_mark_reg26 : nullptr; |
| 109 | qpoints->pReadBarrierMarkReg27 = is_marking ? art_quick_read_barrier_mark_reg27 : nullptr; |
| 110 | qpoints->pReadBarrierMarkReg28 = is_marking ? art_quick_read_barrier_mark_reg28 : nullptr; |
| 111 | qpoints->pReadBarrierMarkReg29 = is_marking ? art_quick_read_barrier_mark_reg29 : nullptr; |
| 112 | } |
| 113 | |
Andreas Gampe | 3cfa4d0 | 2015-10-06 17:04:01 -0700 | [diff] [blame] | 114 | void InitEntryPoints(JniEntryPoints* jpoints, QuickEntryPoints* qpoints) { |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 115 | DefaultInitEntryPoints(jpoints, qpoints); |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 116 | |
| 117 | // Cast |
Mathieu Chartier | 9fd8c60 | 2016-11-14 14:38:53 -0800 | [diff] [blame] | 118 | qpoints->pInstanceofNonTrivial = artInstanceOfFromCode; |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 119 | qpoints->pCheckInstanceOf = art_quick_check_instance_of; |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 120 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 121 | // Math |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 122 | // TODO null entrypoints not needed for ARM64 - generate inline. |
Zheng Xu | 0210d11 | 2014-06-17 12:25:48 +0800 | [diff] [blame] | 123 | qpoints->pCmpgDouble = nullptr; |
| 124 | qpoints->pCmpgFloat = nullptr; |
| 125 | qpoints->pCmplDouble = nullptr; |
| 126 | qpoints->pCmplFloat = nullptr; |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 127 | qpoints->pFmod = fmod; |
Zheng Xu | 0210d11 | 2014-06-17 12:25:48 +0800 | [diff] [blame] | 128 | qpoints->pL2d = nullptr; |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 129 | qpoints->pFmodf = fmodf; |
Zheng Xu | 0210d11 | 2014-06-17 12:25:48 +0800 | [diff] [blame] | 130 | qpoints->pL2f = nullptr; |
| 131 | qpoints->pD2iz = nullptr; |
| 132 | qpoints->pF2iz = nullptr; |
| 133 | qpoints->pIdivmod = nullptr; |
| 134 | qpoints->pD2l = nullptr; |
| 135 | qpoints->pF2l = nullptr; |
| 136 | qpoints->pLdiv = nullptr; |
| 137 | qpoints->pLmod = nullptr; |
| 138 | qpoints->pLmul = nullptr; |
| 139 | qpoints->pShlLong = nullptr; |
| 140 | qpoints->pShrLong = nullptr; |
| 141 | qpoints->pUshrLong = nullptr; |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 142 | |
Anton Kirilov | 02fc24e | 2016-01-20 16:48:19 +0000 | [diff] [blame] | 143 | // More math. |
| 144 | qpoints->pCos = cos; |
| 145 | qpoints->pSin = sin; |
| 146 | qpoints->pAcos = acos; |
| 147 | qpoints->pAsin = asin; |
| 148 | qpoints->pAtan = atan; |
| 149 | qpoints->pAtan2 = atan2; |
| 150 | qpoints->pCbrt = cbrt; |
| 151 | qpoints->pCosh = cosh; |
| 152 | qpoints->pExp = exp; |
| 153 | qpoints->pExpm1 = expm1; |
| 154 | qpoints->pHypot = hypot; |
| 155 | qpoints->pLog = log; |
| 156 | qpoints->pLog10 = log10; |
| 157 | qpoints->pNextAfter = nextafter; |
| 158 | qpoints->pSinh = sinh; |
| 159 | qpoints->pTan = tan; |
| 160 | qpoints->pTanh = tanh; |
| 161 | |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 162 | // Intrinsics |
| 163 | qpoints->pIndexOf = art_quick_indexof; |
Scott Wakeling | 1f36f41 | 2016-04-21 11:13:45 +0100 | [diff] [blame] | 164 | // The ARM64 StringCompareTo intrinsic does not call the runtime. |
| 165 | qpoints->pStringCompareTo = nullptr; |
Serban Constantinescu | 9bd88b0 | 2015-04-22 16:24:46 +0100 | [diff] [blame] | 166 | qpoints->pMemcpy = memcpy; |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 167 | |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 168 | // Read barrier. |
Hiroshi Yamauchi | 1cc71eb | 2015-05-07 10:47:27 -0700 | [diff] [blame] | 169 | qpoints->pReadBarrierJni = ReadBarrierJni; |
Mathieu Chartier | 36c2271 | 2016-08-12 13:19:44 -0700 | [diff] [blame] | 170 | qpoints->pReadBarrierMarkReg16 = nullptr; // IP0 is used as a temp by the asm stub. |
Mathieu Chartier | fe814e8 | 2016-11-09 14:32:49 -0800 | [diff] [blame] | 171 | UpdateReadBarrierEntrypoints(qpoints, /*is_marking*/ false); |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 172 | qpoints->pReadBarrierSlow = artReadBarrierSlow; |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 173 | qpoints->pReadBarrierForRootSlow = artReadBarrierForRootSlow; |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | } // namespace art |