blob: 6add107cb761f3be4625f18f59848719ee70c402 [file] [log] [blame]
Stuart Monteithb95a5342014-03-12 13:32:32 +00001/*
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 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"
Andreas Gampee1794562014-11-04 22:26:32 -080021#include "entrypoints/quick/quick_alloc_entrypoints.h"
22#include "entrypoints/quick/quick_default_externs.h"
Andreas Gampec7ed09b2016-04-25 20:08:55 -070023#include "entrypoints/quick/quick_default_init_entrypoints.h"
Stuart Monteithb95a5342014-03-12 13:32:32 +000024#include "entrypoints/quick/quick_entrypoints.h"
25#include "entrypoints/entrypoint_utils.h"
26#include "entrypoints/math_entrypoints.h"
Ian Rogers6f3dbba2014-10-14 17:41:57 -070027#include "entrypoints/runtime_asm_entrypoints.h"
28#include "interpreter/interpreter.h"
Stuart Monteithb95a5342014-03-12 13:32:32 +000029
30namespace art {
31
Stuart Monteithb95a5342014-03-12 13:32:32 +000032// Cast entrypoints.
Mathieu Chartier9fd8c602016-11-14 14:38:53 -080033extern "C" size_t artInstanceOfFromCode(mirror::Object* obj, mirror::Class* ref_class);
Stuart Monteithb95a5342014-03-12 13:32:32 +000034
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*);
53extern "C" mirror::Object* art_quick_read_barrier_mark_reg12(mirror::Object*);
54extern "C" mirror::Object* art_quick_read_barrier_mark_reg13(mirror::Object*);
55extern "C" mirror::Object* art_quick_read_barrier_mark_reg14(mirror::Object*);
56extern "C" mirror::Object* art_quick_read_barrier_mark_reg15(mirror::Object*);
57extern "C" mirror::Object* art_quick_read_barrier_mark_reg16(mirror::Object*);
58extern "C" mirror::Object* art_quick_read_barrier_mark_reg17(mirror::Object*);
59extern "C" mirror::Object* art_quick_read_barrier_mark_reg18(mirror::Object*);
60extern "C" mirror::Object* art_quick_read_barrier_mark_reg19(mirror::Object*);
61extern "C" mirror::Object* art_quick_read_barrier_mark_reg20(mirror::Object*);
62extern "C" mirror::Object* art_quick_read_barrier_mark_reg21(mirror::Object*);
63extern "C" mirror::Object* art_quick_read_barrier_mark_reg22(mirror::Object*);
64extern "C" mirror::Object* art_quick_read_barrier_mark_reg22(mirror::Object*);
65extern "C" mirror::Object* art_quick_read_barrier_mark_reg23(mirror::Object*);
66extern "C" mirror::Object* art_quick_read_barrier_mark_reg24(mirror::Object*);
67extern "C" mirror::Object* art_quick_read_barrier_mark_reg25(mirror::Object*);
68extern "C" mirror::Object* art_quick_read_barrier_mark_reg26(mirror::Object*);
69extern "C" mirror::Object* art_quick_read_barrier_mark_reg27(mirror::Object*);
70extern "C" mirror::Object* art_quick_read_barrier_mark_reg28(mirror::Object*);
71extern "C" mirror::Object* art_quick_read_barrier_mark_reg29(mirror::Object*);
72
Mathieu Chartierfe814e82016-11-09 14:32:49 -080073void 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 Gampe3cfa4d02015-10-06 17:04:01 -0700114void InitEntryPoints(JniEntryPoints* jpoints, QuickEntryPoints* qpoints) {
Andreas Gampec7ed09b2016-04-25 20:08:55 -0700115 DefaultInitEntryPoints(jpoints, qpoints);
Stuart Monteithb95a5342014-03-12 13:32:32 +0000116
117 // Cast
Mathieu Chartier9fd8c602016-11-14 14:38:53 -0800118 qpoints->pInstanceofNonTrivial = artInstanceOfFromCode;
Mathieu Chartierb99f4d62016-11-07 16:17:26 -0800119 qpoints->pCheckInstanceOf = art_quick_check_instance_of;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000120
Stuart Monteithb95a5342014-03-12 13:32:32 +0000121 // Math
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700122 // TODO null entrypoints not needed for ARM64 - generate inline.
Zheng Xu0210d112014-06-17 12:25:48 +0800123 qpoints->pCmpgDouble = nullptr;
124 qpoints->pCmpgFloat = nullptr;
125 qpoints->pCmplDouble = nullptr;
126 qpoints->pCmplFloat = nullptr;
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100127 qpoints->pFmod = fmod;
Zheng Xu0210d112014-06-17 12:25:48 +0800128 qpoints->pL2d = nullptr;
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100129 qpoints->pFmodf = fmodf;
Zheng Xu0210d112014-06-17 12:25:48 +0800130 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 Monteithb95a5342014-03-12 13:32:32 +0000142
Anton Kirilov02fc24e2016-01-20 16:48:19 +0000143 // 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 Monteithb95a5342014-03-12 13:32:32 +0000162 // Intrinsics
163 qpoints->pIndexOf = art_quick_indexof;
Scott Wakeling1f36f412016-04-21 11:13:45 +0100164 // The ARM64 StringCompareTo intrinsic does not call the runtime.
165 qpoints->pStringCompareTo = nullptr;
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100166 qpoints->pMemcpy = memcpy;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000167
Roland Levillain0d5a2812015-11-13 10:07:31 +0000168 // Read barrier.
Hiroshi Yamauchi1cc71eb2015-05-07 10:47:27 -0700169 qpoints->pReadBarrierJni = ReadBarrierJni;
Mathieu Chartier36c22712016-08-12 13:19:44 -0700170 qpoints->pReadBarrierMarkReg16 = nullptr; // IP0 is used as a temp by the asm stub.
Mathieu Chartierfe814e82016-11-09 14:32:49 -0800171 UpdateReadBarrierEntrypoints(qpoints, /*is_marking*/ false);
Man Cao1aee9002015-07-14 22:31:42 -0700172 qpoints->pReadBarrierSlow = artReadBarrierSlow;
Roland Levillain0d5a2812015-11-13 10:07:31 +0000173 qpoints->pReadBarrierForRootSlow = artReadBarrierForRootSlow;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000174};
175
176} // namespace art