blob: c2078f02c17ad244dae96625934b177b71c50728 [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.
Andreas Gampe67409972016-07-19 22:34:53 -070033extern "C" size_t artIsAssignableFromCode(const mirror::Class* klass,
34 const mirror::Class* ref_class);
Stuart Monteithb95a5342014-03-12 13:32:32 +000035
Roland Levillain02b75802016-07-13 11:54:35 +010036// Read barrier entrypoints.
37// art_quick_read_barrier_mark_regX uses an non-standard calling
38// convention: it expects its input in register X and returns its
Roland Levillain4359e612016-07-20 11:32:19 +010039// result in that same register, and saves and restores all
40// caller-save registers.
41extern "C" mirror::Object* art_quick_read_barrier_mark_reg00(mirror::Object*);
Roland Levillain02b75802016-07-13 11:54:35 +010042extern "C" mirror::Object* art_quick_read_barrier_mark_reg01(mirror::Object*);
43extern "C" mirror::Object* art_quick_read_barrier_mark_reg02(mirror::Object*);
44extern "C" mirror::Object* art_quick_read_barrier_mark_reg03(mirror::Object*);
45extern "C" mirror::Object* art_quick_read_barrier_mark_reg04(mirror::Object*);
46extern "C" mirror::Object* art_quick_read_barrier_mark_reg05(mirror::Object*);
47extern "C" mirror::Object* art_quick_read_barrier_mark_reg06(mirror::Object*);
48extern "C" mirror::Object* art_quick_read_barrier_mark_reg07(mirror::Object*);
49extern "C" mirror::Object* art_quick_read_barrier_mark_reg08(mirror::Object*);
50extern "C" mirror::Object* art_quick_read_barrier_mark_reg09(mirror::Object*);
51extern "C" mirror::Object* art_quick_read_barrier_mark_reg10(mirror::Object*);
52extern "C" mirror::Object* art_quick_read_barrier_mark_reg11(mirror::Object*);
53extern "C" mirror::Object* art_quick_read_barrier_mark_reg12(mirror::Object*);
54extern "C" mirror::Object* art_quick_read_barrier_mark_reg12(mirror::Object*);
55extern "C" mirror::Object* art_quick_read_barrier_mark_reg13(mirror::Object*);
56extern "C" mirror::Object* art_quick_read_barrier_mark_reg14(mirror::Object*);
57extern "C" mirror::Object* art_quick_read_barrier_mark_reg15(mirror::Object*);
58extern "C" mirror::Object* art_quick_read_barrier_mark_reg16(mirror::Object*);
59extern "C" mirror::Object* art_quick_read_barrier_mark_reg17(mirror::Object*);
60extern "C" mirror::Object* art_quick_read_barrier_mark_reg18(mirror::Object*);
61extern "C" mirror::Object* art_quick_read_barrier_mark_reg19(mirror::Object*);
62extern "C" mirror::Object* art_quick_read_barrier_mark_reg20(mirror::Object*);
63extern "C" mirror::Object* art_quick_read_barrier_mark_reg21(mirror::Object*);
64extern "C" mirror::Object* art_quick_read_barrier_mark_reg22(mirror::Object*);
65extern "C" mirror::Object* art_quick_read_barrier_mark_reg22(mirror::Object*);
66extern "C" mirror::Object* art_quick_read_barrier_mark_reg23(mirror::Object*);
67extern "C" mirror::Object* art_quick_read_barrier_mark_reg24(mirror::Object*);
68extern "C" mirror::Object* art_quick_read_barrier_mark_reg25(mirror::Object*);
69extern "C" mirror::Object* art_quick_read_barrier_mark_reg26(mirror::Object*);
70extern "C" mirror::Object* art_quick_read_barrier_mark_reg27(mirror::Object*);
71extern "C" mirror::Object* art_quick_read_barrier_mark_reg28(mirror::Object*);
72extern "C" mirror::Object* art_quick_read_barrier_mark_reg29(mirror::Object*);
73
Andreas Gampe3cfa4d02015-10-06 17:04:01 -070074void InitEntryPoints(JniEntryPoints* jpoints, QuickEntryPoints* qpoints) {
Andreas Gampec7ed09b2016-04-25 20:08:55 -070075 DefaultInitEntryPoints(jpoints, qpoints);
Stuart Monteithb95a5342014-03-12 13:32:32 +000076
77 // Cast
Serban Constantinescu9bd88b02015-04-22 16:24:46 +010078 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
Stuart Monteithb95a5342014-03-12 13:32:32 +000079 qpoints->pCheckCast = art_quick_check_cast;
80
Stuart Monteithb95a5342014-03-12 13:32:32 +000081 // Math
Mathieu Chartier2cebb242015-04-21 16:50:40 -070082 // TODO null entrypoints not needed for ARM64 - generate inline.
Zheng Xu0210d112014-06-17 12:25:48 +080083 qpoints->pCmpgDouble = nullptr;
84 qpoints->pCmpgFloat = nullptr;
85 qpoints->pCmplDouble = nullptr;
86 qpoints->pCmplFloat = nullptr;
Serban Constantinescu9bd88b02015-04-22 16:24:46 +010087 qpoints->pFmod = fmod;
Zheng Xu0210d112014-06-17 12:25:48 +080088 qpoints->pL2d = nullptr;
Serban Constantinescu9bd88b02015-04-22 16:24:46 +010089 qpoints->pFmodf = fmodf;
Zheng Xu0210d112014-06-17 12:25:48 +080090 qpoints->pL2f = nullptr;
91 qpoints->pD2iz = nullptr;
92 qpoints->pF2iz = nullptr;
93 qpoints->pIdivmod = nullptr;
94 qpoints->pD2l = nullptr;
95 qpoints->pF2l = nullptr;
96 qpoints->pLdiv = nullptr;
97 qpoints->pLmod = nullptr;
98 qpoints->pLmul = nullptr;
99 qpoints->pShlLong = nullptr;
100 qpoints->pShrLong = nullptr;
101 qpoints->pUshrLong = nullptr;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000102
Anton Kirilov02fc24e2016-01-20 16:48:19 +0000103 // More math.
104 qpoints->pCos = cos;
105 qpoints->pSin = sin;
106 qpoints->pAcos = acos;
107 qpoints->pAsin = asin;
108 qpoints->pAtan = atan;
109 qpoints->pAtan2 = atan2;
110 qpoints->pCbrt = cbrt;
111 qpoints->pCosh = cosh;
112 qpoints->pExp = exp;
113 qpoints->pExpm1 = expm1;
114 qpoints->pHypot = hypot;
115 qpoints->pLog = log;
116 qpoints->pLog10 = log10;
117 qpoints->pNextAfter = nextafter;
118 qpoints->pSinh = sinh;
119 qpoints->pTan = tan;
120 qpoints->pTanh = tanh;
121
Stuart Monteithb95a5342014-03-12 13:32:32 +0000122 // Intrinsics
123 qpoints->pIndexOf = art_quick_indexof;
Scott Wakeling1f36f412016-04-21 11:13:45 +0100124 // The ARM64 StringCompareTo intrinsic does not call the runtime.
125 qpoints->pStringCompareTo = nullptr;
Serban Constantinescu9bd88b02015-04-22 16:24:46 +0100126 qpoints->pMemcpy = memcpy;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000127
Roland Levillain0d5a2812015-11-13 10:07:31 +0000128 // Read barrier.
Hiroshi Yamauchi1cc71eb2015-05-07 10:47:27 -0700129 qpoints->pReadBarrierJni = ReadBarrierJni;
Roland Levillaind549c282016-07-25 12:49:15 +0100130 // ARM64 is the architecture with the largest number of core
131 // registers (32) that supports the read barrier configuration.
132 // Because registers 30 (LR) and 31 (SP/XZR) cannot be used to pass
133 // arguments, only define ReadBarrierMarkRegX entrypoints for the
134 // first 30 registers. This limitation is not a problem on other
135 // supported architectures (ARM, x86 and x86-64) either, as they
136 // have less core registers (resp. 16, 8 and 16). (We may have to
137 // revise that design choice if read barrier support is added for
138 // MIPS and/or MIPS64.)
Roland Levillain4359e612016-07-20 11:32:19 +0100139 qpoints->pReadBarrierMarkReg00 = art_quick_read_barrier_mark_reg00;
Roland Levillain02b75802016-07-13 11:54:35 +0100140 qpoints->pReadBarrierMarkReg01 = art_quick_read_barrier_mark_reg01;
141 qpoints->pReadBarrierMarkReg02 = art_quick_read_barrier_mark_reg02;
142 qpoints->pReadBarrierMarkReg03 = art_quick_read_barrier_mark_reg03;
143 qpoints->pReadBarrierMarkReg04 = art_quick_read_barrier_mark_reg04;
144 qpoints->pReadBarrierMarkReg05 = art_quick_read_barrier_mark_reg05;
145 qpoints->pReadBarrierMarkReg06 = art_quick_read_barrier_mark_reg06;
146 qpoints->pReadBarrierMarkReg07 = art_quick_read_barrier_mark_reg07;
147 qpoints->pReadBarrierMarkReg08 = art_quick_read_barrier_mark_reg08;
148 qpoints->pReadBarrierMarkReg09 = art_quick_read_barrier_mark_reg09;
149 qpoints->pReadBarrierMarkReg10 = art_quick_read_barrier_mark_reg10;
150 qpoints->pReadBarrierMarkReg11 = art_quick_read_barrier_mark_reg11;
151 qpoints->pReadBarrierMarkReg12 = art_quick_read_barrier_mark_reg12;
152 qpoints->pReadBarrierMarkReg13 = art_quick_read_barrier_mark_reg13;
153 qpoints->pReadBarrierMarkReg14 = art_quick_read_barrier_mark_reg14;
154 qpoints->pReadBarrierMarkReg15 = art_quick_read_barrier_mark_reg15;
Mathieu Chartier36c22712016-08-12 13:19:44 -0700155 qpoints->pReadBarrierMarkReg16 = nullptr; // IP0 is used as a temp by the asm stub.
Roland Levillain02b75802016-07-13 11:54:35 +0100156 qpoints->pReadBarrierMarkReg17 = art_quick_read_barrier_mark_reg17;
157 qpoints->pReadBarrierMarkReg18 = art_quick_read_barrier_mark_reg18;
158 qpoints->pReadBarrierMarkReg19 = art_quick_read_barrier_mark_reg19;
159 qpoints->pReadBarrierMarkReg20 = art_quick_read_barrier_mark_reg20;
160 qpoints->pReadBarrierMarkReg21 = art_quick_read_barrier_mark_reg21;
161 qpoints->pReadBarrierMarkReg22 = art_quick_read_barrier_mark_reg22;
162 qpoints->pReadBarrierMarkReg23 = art_quick_read_barrier_mark_reg23;
163 qpoints->pReadBarrierMarkReg24 = art_quick_read_barrier_mark_reg24;
164 qpoints->pReadBarrierMarkReg25 = art_quick_read_barrier_mark_reg25;
165 qpoints->pReadBarrierMarkReg26 = art_quick_read_barrier_mark_reg26;
166 qpoints->pReadBarrierMarkReg27 = art_quick_read_barrier_mark_reg27;
167 qpoints->pReadBarrierMarkReg28 = art_quick_read_barrier_mark_reg28;
168 qpoints->pReadBarrierMarkReg29 = art_quick_read_barrier_mark_reg29;
Man Cao1aee9002015-07-14 22:31:42 -0700169 qpoints->pReadBarrierSlow = artReadBarrierSlow;
Roland Levillain0d5a2812015-11-13 10:07:31 +0000170 qpoints->pReadBarrierForRootSlow = artReadBarrierForRootSlow;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000171};
172
173} // namespace art