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 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 19 | #include "entrypoints/jni/jni_entrypoints.h" |
Mathieu Chartier | d889178 | 2014-03-02 13:28:37 -0800 | [diff] [blame] | 20 | #include "entrypoints/quick/quick_alloc_entrypoints.h" |
Andreas Gampe | e179456 | 2014-11-04 22:26:32 -0800 | [diff] [blame] | 21 | #include "entrypoints/quick/quick_default_externs.h" |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 22 | #include "entrypoints/quick/quick_default_init_entrypoints.h" |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 23 | #include "entrypoints/quick/quick_entrypoints.h" |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 24 | #include "entrypoints/runtime_asm_entrypoints.h" |
| 25 | #include "interpreter/interpreter.h" |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 26 | |
| 27 | namespace art { |
| 28 | |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 29 | // Cast entrypoints. |
Mathieu Chartier | 9fd8c60 | 2016-11-14 14:38:53 -0800 | [diff] [blame] | 30 | extern "C" size_t art_quick_instance_of(mirror::Object* obj, mirror::Class* ref_class); |
Hiroshi Yamauchi | 3b4c189 | 2013-09-12 21:33:12 -0700 | [diff] [blame] | 31 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 32 | // Read barrier entrypoints. |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 33 | // art_quick_read_barrier_mark_regX uses an non-standard calling |
| 34 | // convention: it expects its input in register X and returns its |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 35 | // result in that same register, and saves and restores all |
| 36 | // caller-save registers. |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 37 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg00(mirror::Object*); |
| 38 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg01(mirror::Object*); |
| 39 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg02(mirror::Object*); |
| 40 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg03(mirror::Object*); |
| 41 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg05(mirror::Object*); |
| 42 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg06(mirror::Object*); |
| 43 | extern "C" mirror::Object* art_quick_read_barrier_mark_reg07(mirror::Object*); |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 44 | extern "C" mirror::Object* art_quick_read_barrier_slow(mirror::Object*, mirror::Object*, uint32_t); |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 45 | extern "C" mirror::Object* art_quick_read_barrier_for_root_slow(GcRoot<mirror::Object>*); |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 46 | |
Mathieu Chartier | 3768ade | 2017-05-02 14:04:39 -0700 | [diff] [blame] | 47 | void UpdateReadBarrierEntrypoints(QuickEntryPoints* qpoints, bool is_active) { |
| 48 | qpoints->pReadBarrierMarkReg00 = is_active ? art_quick_read_barrier_mark_reg00 : nullptr; |
| 49 | qpoints->pReadBarrierMarkReg01 = is_active ? art_quick_read_barrier_mark_reg01 : nullptr; |
| 50 | qpoints->pReadBarrierMarkReg02 = is_active ? art_quick_read_barrier_mark_reg02 : nullptr; |
| 51 | qpoints->pReadBarrierMarkReg03 = is_active ? art_quick_read_barrier_mark_reg03 : nullptr; |
| 52 | qpoints->pReadBarrierMarkReg05 = is_active ? art_quick_read_barrier_mark_reg05 : nullptr; |
| 53 | qpoints->pReadBarrierMarkReg06 = is_active ? art_quick_read_barrier_mark_reg06 : nullptr; |
| 54 | qpoints->pReadBarrierMarkReg07 = is_active ? art_quick_read_barrier_mark_reg07 : nullptr; |
Mathieu Chartier | fe814e8 | 2016-11-09 14:32:49 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Andreas Gampe | 3cfa4d0 | 2015-10-06 17:04:01 -0700 | [diff] [blame] | 57 | void InitEntryPoints(JniEntryPoints* jpoints, QuickEntryPoints* qpoints) { |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 58 | DefaultInitEntryPoints(jpoints, qpoints); |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 59 | |
| 60 | // Cast |
Mathieu Chartier | 9fd8c60 | 2016-11-14 14:38:53 -0800 | [diff] [blame] | 61 | qpoints->pInstanceofNonTrivial = art_quick_instance_of; |
Mathieu Chartier | b99f4d6 | 2016-11-07 16:17:26 -0800 | [diff] [blame] | 62 | qpoints->pCheckInstanceOf = art_quick_check_instance_of; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 63 | |
Mark Mendell | a4f1220 | 2015-08-06 15:23:34 -0400 | [diff] [blame] | 64 | // More math. |
| 65 | qpoints->pCos = cos; |
| 66 | qpoints->pSin = sin; |
| 67 | qpoints->pAcos = acos; |
| 68 | qpoints->pAsin = asin; |
| 69 | qpoints->pAtan = atan; |
| 70 | qpoints->pAtan2 = atan2; |
Vladimir Marko | 4d17987 | 2018-01-19 14:50:10 +0000 | [diff] [blame] | 71 | qpoints->pPow = pow; |
Mark Mendell | a4f1220 | 2015-08-06 15:23:34 -0400 | [diff] [blame] | 72 | qpoints->pCbrt = cbrt; |
| 73 | qpoints->pCosh = cosh; |
| 74 | qpoints->pExp = exp; |
| 75 | qpoints->pExpm1 = expm1; |
| 76 | qpoints->pHypot = hypot; |
| 77 | qpoints->pLog = log; |
| 78 | qpoints->pLog10 = log10; |
| 79 | qpoints->pNextAfter = nextafter; |
| 80 | qpoints->pSinh = sinh; |
| 81 | qpoints->pTan = tan; |
| 82 | qpoints->pTanh = tanh; |
| 83 | |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 84 | // Math |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 85 | qpoints->pD2l = art_quick_d2l; |
| 86 | qpoints->pF2l = art_quick_f2l; |
| 87 | qpoints->pLdiv = art_quick_ldiv; |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 88 | qpoints->pLmod = art_quick_lmod; |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 89 | qpoints->pLmul = art_quick_lmul; |
| 90 | qpoints->pShlLong = art_quick_lshl; |
| 91 | qpoints->pShrLong = art_quick_lshr; |
| 92 | qpoints->pUshrLong = art_quick_lushr; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 93 | |
| 94 | // Intrinsics |
Mark Mendell | 4028a6c | 2014-02-19 20:06:20 -0800 | [diff] [blame] | 95 | // qpoints->pIndexOf = nullptr; // Not needed on x86 |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 96 | qpoints->pStringCompareTo = art_quick_string_compareto; |
| 97 | qpoints->pMemcpy = art_quick_memcpy; |
| 98 | |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 99 | // Read barrier. |
Hiroshi Yamauchi | 1cc71eb | 2015-05-07 10:47:27 -0700 | [diff] [blame] | 100 | qpoints->pReadBarrierJni = ReadBarrierJni; |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame^] | 101 | UpdateReadBarrierEntrypoints(qpoints, /*is_active=*/ false); |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 102 | qpoints->pReadBarrierMarkReg04 = nullptr; // Cannot use register 4 (ESP) to pass arguments. |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 103 | // x86 has only 8 core registers. |
| 104 | qpoints->pReadBarrierMarkReg08 = nullptr; |
| 105 | qpoints->pReadBarrierMarkReg09 = nullptr; |
| 106 | qpoints->pReadBarrierMarkReg10 = nullptr; |
| 107 | qpoints->pReadBarrierMarkReg11 = nullptr; |
| 108 | qpoints->pReadBarrierMarkReg12 = nullptr; |
| 109 | qpoints->pReadBarrierMarkReg13 = nullptr; |
| 110 | qpoints->pReadBarrierMarkReg14 = nullptr; |
| 111 | qpoints->pReadBarrierMarkReg15 = nullptr; |
| 112 | qpoints->pReadBarrierMarkReg16 = nullptr; |
| 113 | qpoints->pReadBarrierMarkReg17 = nullptr; |
| 114 | qpoints->pReadBarrierMarkReg18 = nullptr; |
| 115 | qpoints->pReadBarrierMarkReg19 = nullptr; |
| 116 | qpoints->pReadBarrierMarkReg20 = nullptr; |
| 117 | qpoints->pReadBarrierMarkReg21 = nullptr; |
| 118 | qpoints->pReadBarrierMarkReg22 = nullptr; |
| 119 | qpoints->pReadBarrierMarkReg23 = nullptr; |
| 120 | qpoints->pReadBarrierMarkReg24 = nullptr; |
| 121 | qpoints->pReadBarrierMarkReg25 = nullptr; |
| 122 | qpoints->pReadBarrierMarkReg26 = nullptr; |
| 123 | qpoints->pReadBarrierMarkReg27 = nullptr; |
| 124 | qpoints->pReadBarrierMarkReg28 = nullptr; |
| 125 | qpoints->pReadBarrierMarkReg29 = nullptr; |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 126 | qpoints->pReadBarrierSlow = art_quick_read_barrier_slow; |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 127 | qpoints->pReadBarrierForRootSlow = art_quick_read_barrier_for_root_slow; |
Igor Murashkin | 2ffb703 | 2017-11-08 13:35:21 -0800 | [diff] [blame] | 128 | } |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 129 | |
| 130 | } // namespace art |