• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #include <math.h>
18 
19 #include "entrypoints/jni/jni_entrypoints.h"
20 #include "entrypoints/quick/quick_alloc_entrypoints.h"
21 #include "entrypoints/quick/quick_default_externs.h"
22 #include "entrypoints/quick/quick_default_init_entrypoints.h"
23 #include "entrypoints/quick/quick_entrypoints.h"
24 #include "entrypoints/runtime_asm_entrypoints.h"
25 #include "interpreter/interpreter.h"
26 #include "trace_profile.h"
27 
28 namespace art HIDDEN {
29 
30 // Cast entrypoints.
31 extern "C" size_t art_quick_instance_of(mirror::Object* obj, mirror::Class* ref_class);
32 
33 // Read barrier entrypoints.
34 // art_quick_read_barrier_mark_regX uses an non-standard calling
35 // convention: it expects its input in register X and returns its
36 // result in that same register, and saves and restores all
37 // caller-save registers.
38 extern "C" mirror::Object* art_quick_read_barrier_mark_reg00(mirror::Object*);
39 extern "C" mirror::Object* art_quick_read_barrier_mark_reg01(mirror::Object*);
40 extern "C" mirror::Object* art_quick_read_barrier_mark_reg02(mirror::Object*);
41 extern "C" mirror::Object* art_quick_read_barrier_mark_reg03(mirror::Object*);
42 extern "C" mirror::Object* art_quick_read_barrier_mark_reg05(mirror::Object*);
43 extern "C" mirror::Object* art_quick_read_barrier_mark_reg06(mirror::Object*);
44 extern "C" mirror::Object* art_quick_read_barrier_mark_reg07(mirror::Object*);
45 extern "C" mirror::Object* art_quick_read_barrier_slow(mirror::Object*, mirror::Object*, uint32_t);
46 extern "C" mirror::Object* art_quick_read_barrier_for_root_slow(GcRoot<mirror::Object>*);
47 
UpdateReadBarrierEntrypoints(QuickEntryPoints * qpoints,bool is_active)48 void UpdateReadBarrierEntrypoints(QuickEntryPoints* qpoints, bool is_active) {
49   qpoints->SetReadBarrierMarkReg00(is_active ? art_quick_read_barrier_mark_reg00 : nullptr);
50   qpoints->SetReadBarrierMarkReg01(is_active ? art_quick_read_barrier_mark_reg01 : nullptr);
51   qpoints->SetReadBarrierMarkReg02(is_active ? art_quick_read_barrier_mark_reg02 : nullptr);
52   qpoints->SetReadBarrierMarkReg03(is_active ? art_quick_read_barrier_mark_reg03 : nullptr);
53   qpoints->SetReadBarrierMarkReg05(is_active ? art_quick_read_barrier_mark_reg05 : nullptr);
54   qpoints->SetReadBarrierMarkReg06(is_active ? art_quick_read_barrier_mark_reg06 : nullptr);
55   qpoints->SetReadBarrierMarkReg07(is_active ? art_quick_read_barrier_mark_reg07 : nullptr);
56 }
57 
InitEntryPoints(JniEntryPoints * jpoints,QuickEntryPoints * qpoints,bool monitor_jni_entry_exit)58 void InitEntryPoints(JniEntryPoints* jpoints,
59                      QuickEntryPoints* qpoints,
60                      bool monitor_jni_entry_exit) {
61   DefaultInitEntryPoints(jpoints, qpoints, monitor_jni_entry_exit);
62 
63   // Cast
64   qpoints->SetInstanceofNonTrivial(art_quick_instance_of);
65   qpoints->SetCheckInstanceOf(art_quick_check_instance_of);
66 
67   // More math.
68   qpoints->SetCos(cos);
69   qpoints->SetSin(sin);
70   qpoints->SetAcos(acos);
71   qpoints->SetAsin(asin);
72   qpoints->SetAtan(atan);
73   qpoints->SetAtan2(atan2);
74   qpoints->SetPow(pow);
75   qpoints->SetCbrt(cbrt);
76   qpoints->SetCosh(cosh);
77   qpoints->SetExp(exp);
78   qpoints->SetExpm1(expm1);
79   qpoints->SetHypot(hypot);
80   qpoints->SetLog(log);
81   qpoints->SetLog10(log10);
82   qpoints->SetNextAfter(nextafter);
83   qpoints->SetSinh(sinh);
84   qpoints->SetTan(tan);
85   qpoints->SetTanh(tanh);
86 
87   // Math
88   qpoints->SetD2l(art_quick_d2l);
89   qpoints->SetF2l(art_quick_f2l);
90   qpoints->SetLdiv(art_quick_ldiv);
91   qpoints->SetLmod(art_quick_lmod);
92   qpoints->SetLmul(art_quick_lmul);
93   qpoints->SetShlLong(art_quick_lshl);
94   qpoints->SetShrLong(art_quick_lshr);
95   qpoints->SetUshrLong(art_quick_lushr);
96 
97   // Intrinsics
98   // qpoints->pIndexOf = nullptr;  // Not needed on x86
99   qpoints->SetStringCompareTo(art_quick_string_compareto);
100   qpoints->SetMemcpy(art_quick_memcpy);
101 
102   // Read barrier.
103   UpdateReadBarrierEntrypoints(qpoints, /*is_active=*/ false);
104   qpoints->SetReadBarrierMarkReg04(nullptr);  // Cannot use register 4 (ESP) to pass arguments.
105   // x86 has only 8 core registers.
106   qpoints->SetReadBarrierMarkReg08(nullptr);
107   qpoints->SetReadBarrierMarkReg09(nullptr);
108   qpoints->SetReadBarrierMarkReg10(nullptr);
109   qpoints->SetReadBarrierMarkReg11(nullptr);
110   qpoints->SetReadBarrierMarkReg12(nullptr);
111   qpoints->SetReadBarrierMarkReg13(nullptr);
112   qpoints->SetReadBarrierMarkReg14(nullptr);
113   qpoints->SetReadBarrierMarkReg15(nullptr);
114   qpoints->SetReadBarrierMarkReg16(nullptr);
115   qpoints->SetReadBarrierMarkReg17(nullptr);
116   qpoints->SetReadBarrierMarkReg18(nullptr);
117   qpoints->SetReadBarrierMarkReg19(nullptr);
118   qpoints->SetReadBarrierMarkReg20(nullptr);
119   qpoints->SetReadBarrierMarkReg21(nullptr);
120   qpoints->SetReadBarrierMarkReg22(nullptr);
121   qpoints->SetReadBarrierMarkReg23(nullptr);
122   qpoints->SetReadBarrierMarkReg24(nullptr);
123   qpoints->SetReadBarrierMarkReg25(nullptr);
124   qpoints->SetReadBarrierMarkReg26(nullptr);
125   qpoints->SetReadBarrierMarkReg27(nullptr);
126   qpoints->SetReadBarrierMarkReg28(nullptr);
127   qpoints->SetReadBarrierMarkReg29(nullptr);
128   qpoints->SetReadBarrierSlow(art_quick_read_barrier_slow);
129   qpoints->SetReadBarrierForRootSlow(art_quick_read_barrier_for_root_slow);
130 }
131 
UpdateLowOverheadTraceEntrypoints(QuickEntryPoints * qpoints,LowOverheadTraceType trace_type)132 void UpdateLowOverheadTraceEntrypoints([[maybe_unused]] QuickEntryPoints* qpoints,
133                                        [[maybe_unused]] LowOverheadTraceType trace_type) {
134   // This is a nop on this architecture. Low overhead tracing is only implemented for ARM64.
135 }
136 
137 }  // namespace art
138