blob: 35f88b56dab1abd55dacecb6defd8e9649ae3b0e [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 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 */
buzbee54330722011-08-23 16:46:55 -070016
17#ifndef ART_SRC_RUNTIME_SUPPORT_H_
18#define ART_SRC_RUNTIME_SUPPORT_H_
19
Shih-wei Liao2d831012011-09-28 22:06:53 -070020#include "class_linker.h"
21#include "object.h"
22#include "thread_list.h"
23#include "utils.h"
24
25namespace art {
26
Ian Rogers4a510d82011-10-09 14:30:24 -070027extern void CheckSuspendFromCode(Thread* thread);
Ian Rogersce9eca62011-10-07 17:11:03 -070028extern Array* CheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count,
Ian Rogers0eb7d7e2012-01-31 21:12:32 -080029 Thread* self, bool access_check);
Shih-wei Liao2d831012011-09-28 22:06:53 -070030extern void DebugMe(Method* method, uint32_t info);
Elliott Hughes91bf6cd2012-02-14 17:27:48 -080031extern void UpdateDebuggerFromCode(Method* method, Thread* thread , int32_t dex_pc, Method** sp);
Shih-wei Liao2d831012011-09-28 22:06:53 -070032extern Object* DecodeJObjectInThread(Thread* thread, jobject obj);
Ian Rogers1bddec32012-02-04 12:27:34 -080033extern Field* FindFieldFromCode(uint32_t field_idx, const Method* referrer, Thread* self,
jeffhao8cd6dda2012-02-22 10:15:34 -080034 bool is_static, bool is_primitive, bool is_set, size_t expected_size);
Shih-wei Liao2d831012011-09-28 22:06:53 -070035extern void* FindNativeMethod(Thread* thread);
36extern void ThrowAbstractMethodErrorFromCode(Method* method, Thread* thread, Method** sp);
Ian Rogers19846512012-02-24 11:42:47 -080037const void* UnresolvedDirectMethodTrampolineFromCode(Method*, Method**, Thread*,
38 Runtime::TrampolineType);
Elliott Hughesf3778f62012-01-26 14:14:35 -080039extern Class* ResolveVerifyAndClinit(uint32_t type_idx, const Method* referrer, Thread* self,
40 bool can_run_clinit, bool verify_access);
Shih-wei Liao2d831012011-09-28 22:06:53 -070041extern Class* InitializeTypeFromCode(uint32_t type_idx, Method* method);
Ian Rogerscaab8c42011-10-12 12:11:18 -070042uint32_t IsAssignableFromCode(const Class* klass, const Class* ref_class);
43void ObjectInitFromCode(Object* o);
Shih-wei Liao2d831012011-09-28 22:06:53 -070044extern void LockObjectFromCode(Thread* thread, Object* obj);
Elliott Hughes0ece7b92012-03-09 18:14:40 -080045uint32_t TraceMethodUnwindFromCode(Thread* self);
Ian Rogersc6f3bb82012-03-21 20:40:33 -070046extern int32_t CmpgDouble(double a, double b);
47extern int32_t CmplDouble(double a, double b);
48extern int32_t CmpgFloat(float a, float b);
49extern int32_t CmplFloat(float a, float b);
Shih-wei Liao2d831012011-09-28 22:06:53 -070050extern int64_t D2L(double d);
51extern int64_t F2L(float f);
52
53} // namespace art
Ian Rogersad42e132011-09-17 20:23:33 -070054
Elliott Hughesc0f09332012-03-26 13:27:06 -070055// Helpers for both compiled code and libart.
56extern "C" void art_deliver_exception_from_code(void*);
Ian Rogers466bb252011-10-14 03:29:56 -070057extern "C" void art_proxy_invoke_handler();
Elliott Hughesc0f09332012-03-26 13:27:06 -070058extern "C" void art_update_debugger(void*, void*, int32_t, void*);
Ian Rogers466bb252011-10-14 03:29:56 -070059
buzbee54330722011-08-23 16:46:55 -070060#if defined(__arm__)
buzbee7b1b86d2011-08-26 18:59:10 -070061 /* Compiler helpers */
buzbeefc9e6fa2012-03-23 15:14:29 -070062 extern "C" int32_t __memcmp16(void*, void*, int32_t);
63 extern "C" int32_t art_indexof(void*, uint32_t, uint32_t, uint32_t);
64 extern "C" int32_t art_string_compareto(void*, void*);
Ian Rogers1bddec32012-02-04 12:27:34 -080065 extern "C" int32_t art_get32_static_from_code(uint32_t);
66 extern "C" int64_t art_get64_static_from_code(uint32_t);
67 extern "C" void* art_get_obj_static_from_code(uint32_t);
68 extern "C" int32_t art_get32_instance_from_code(uint32_t, void*);
69 extern "C" int64_t art_get64_instance_from_code(uint32_t, void*);
70 extern "C" void* art_get_obj_instance_from_code(uint32_t, void*);
71 extern "C" int art_set32_static_from_code(uint32_t, int32_t);
72 extern "C" int art_set64_static_from_code(uint32_t, int64_t);
73 extern "C" int art_set_obj_static_from_code(uint32_t, void*);
74 extern "C" int art_set32_instance_from_code(uint32_t, void*, int32_t);
75 extern "C" int art_set64_instance_from_code(uint32_t, void*, int64_t);
76 extern "C" int art_set_obj_instance_from_code(uint32_t, void*, void*);
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -070077 extern "C" void art_can_put_array_element_from_code(void*, void*);
78 extern "C" void art_check_cast_from_code(void*, void*);
79 extern "C" void art_do_long_jump(uint32_t*, uint32_t*);
80 extern "C" void art_handle_fill_data_from_code(void*, void*);
Ian Rogersc8b306f2012-02-17 21:34:44 -080081 extern "C" void art_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -070082 extern "C" void art_invoke_interface_trampoline(uint32_t, void*);
Ian Rogersa32a6fd2012-02-06 20:18:44 -080083 extern "C" void art_invoke_interface_trampoline_with_access_check(uint32_t, void*);
Ian Rogersc8b306f2012-02-17 21:34:44 -080084 extern "C" void art_invoke_static_trampoline_with_access_check(uint32_t, void*);
Ian Rogersa32a6fd2012-02-06 20:18:44 -080085 extern "C" void art_invoke_super_trampoline_with_access_check(uint32_t, void*);
86 extern "C" void art_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -070087 extern "C" void art_lock_object_from_code(void*);
Ian Rogerscbba6ac2011-09-22 16:28:37 -070088 extern "C" void art_test_suspend();
Ian Rogersff1ed472011-09-20 13:46:24 -070089 extern "C" void art_throw_array_bounds_from_code(int32_t index, int32_t limit);
90 extern "C" void art_throw_div_zero_from_code();
Ian Rogersc0c8dc82011-09-24 18:15:59 -070091 extern "C" void art_throw_neg_array_size_from_code(int32_t size);
92 extern "C" void art_throw_no_such_method_from_code(int32_t method_idx);
Ian Rogersff1ed472011-09-20 13:46:24 -070093 extern "C" void art_throw_null_pointer_exception_from_code();
Ian Rogers932746a2011-09-22 18:57:50 -070094 extern "C" void art_throw_stack_overflow_from_code(void*);
Ian Rogersc0c8dc82011-09-24 18:15:59 -070095 extern "C" void art_throw_verification_error_from_code(int32_t src1, int32_t ref);
Ian Rogers4f0d07c2011-10-06 23:38:47 -070096 extern "C" void art_unlock_object_from_code(void*);
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -070097 extern "C" void* art_alloc_array_from_code(uint32_t, void*, int32_t);
Ian Rogers0eb7d7e2012-01-31 21:12:32 -080098 extern "C" void* art_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t);
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -070099 extern "C" void* art_alloc_object_from_code(uint32_t type_idx, void* method);
Ian Rogers28ad40d2011-10-27 15:19:26 -0700100 extern "C" void* art_alloc_object_from_code_with_access_check(uint32_t type_idx, void* method);
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -0700101 extern "C" void* art_check_and_alloc_array_from_code(uint32_t, void*, int32_t);
Ian Rogers0eb7d7e2012-01-31 21:12:32 -0800102 extern "C" void* art_check_and_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t);
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -0700103 extern "C" void* art_initialize_static_storage_from_code(uint32_t, void*);
Ian Rogers28ad40d2011-10-27 15:19:26 -0700104 extern "C" void* art_initialize_type_from_code(uint32_t, void*);
Ian Rogersb093c6b2011-10-31 16:19:55 -0700105 extern "C" void* art_initialize_type_and_verify_access_from_code(uint32_t, void*);
jeffhaoe343b762011-12-05 16:36:44 -0800106 extern "C" void art_trace_entry_from_code(void*);
107 extern "C" void art_trace_exit_from_code();
Brian Carlstrom6fd03fb2011-10-17 16:11:00 -0700108 extern "C" void* art_resolve_string_from_code(void*, uint32_t);
Ian Rogers60db5ab2012-02-20 17:02:00 -0800109 extern "C" void art_work_around_app_jni_bugs();
buzbee7b1b86d2011-08-26 18:59:10 -0700110
111 /* Conversions */
Ian Rogersc6f3bb82012-03-21 20:40:33 -0700112 extern "C" float __aeabi_i2f(int32_t op1); // INT_TO_FLOAT
113 extern "C" int32_t __aeabi_f2iz(float op1); // FLOAT_TO_INT
Elliott Hughesadb8c672012-03-06 16:49:32 -0800114 extern "C" float __aeabi_d2f(double op1); // DOUBLE_TO_FLOAT
115 extern "C" double __aeabi_f2d(float op1); // FLOAT_TO_DOUBLE
Ian Rogersc6f3bb82012-03-21 20:40:33 -0700116 extern "C" double __aeabi_i2d(int32_t op1); // INT_TO_DOUBLE
117 extern "C" int32_t __aeabi_d2iz(double op1); // DOUBLE_TO_INT
118 extern "C" float __aeabi_l2f(int64_t op1); // LONG_TO_FLOAT
119 extern "C" double __aeabi_l2d(int64_t op1); // LONG_TO_DOUBLE
buzbee7b1b86d2011-08-26 18:59:10 -0700120
121 /* Single-precision FP arithmetics */
Elliott Hughesadb8c672012-03-06 16:49:32 -0800122 extern "C" float __aeabi_fadd(float a, float b); // ADD_FLOAT[_2ADDR]
123 extern "C" float __aeabi_fsub(float a, float b); // SUB_FLOAT[_2ADDR]
124 extern "C" float __aeabi_fdiv(float a, float b); // DIV_FLOAT[_2ADDR]
125 extern "C" float __aeabi_fmul(float a, float b); // MUL_FLOAT[_2ADDR]
126 extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
buzbee7b1b86d2011-08-26 18:59:10 -0700127
128 /* Double-precision FP arithmetics */
Elliott Hughesadb8c672012-03-06 16:49:32 -0800129 extern "C" double __aeabi_dadd(double a, double b); // ADD_DOUBLE[_2ADDR]
130 extern "C" double __aeabi_dsub(double a, double b); // SUB_DOUBLE[_2ADDR]
131 extern "C" double __aeabi_ddiv(double a, double b); // DIV_DOUBLE[_2ADDR]
132 extern "C" double __aeabi_dmul(double a, double b); // MUL_DOUBLE[_2ADDR]
133 extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
buzbee7b1b86d2011-08-26 18:59:10 -0700134
135 /* Integer arithmetics */
Ian Rogersc6f3bb82012-03-21 20:40:33 -0700136 extern "C" int __aeabi_idivmod(int32_t op1, int32_t op2); // REM_INT[_2ADDR|_LIT8|_LIT16]
137 extern "C" int __aeabi_idiv(int32_t op1, int32_t op2); // DIV_INT[_2ADDR|_LIT8|_LIT16]
buzbee7b1b86d2011-08-26 18:59:10 -0700138
Elliott Hughesadb8c672012-03-06 16:49:32 -0800139 /* Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR] */
Ian Rogersff1ed472011-09-20 13:46:24 -0700140 extern "C" long long __aeabi_ldivmod(long long op1, long long op2);
141 extern "C" long long __aeabi_lmul(long long op1, long long op2);
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700142 extern "C" uint64_t art_shl_long(uint64_t, uint32_t);
143 extern "C" uint64_t art_shr_long(uint64_t, uint32_t);
144 extern "C" uint64_t art_ushr_long(uint64_t, uint32_t);
buzbee7b1b86d2011-08-26 18:59:10 -0700145
buzbee54330722011-08-23 16:46:55 -0700146#endif
147
Bill Buzbee11f9d212012-03-03 20:03:18 -0800148#if defined(__mips__)
149 /* Conversions */
Ian Rogersc6f3bb82012-03-21 20:40:33 -0700150 extern "C" float __floatsisf(int op1); // INT_TO_FLOAT
151 extern "C" int32_t __fixsfsi(float op1); // FLOAT_TO_INT
152 extern "C" float __truncdfsf2(double op1); // DOUBLE_TO_FLOAT
153 extern "C" double __extendsfdf2(float op1); // FLOAT_TO_DOUBLE
154 extern "C" double __floatsidf(int op1); // INT_TO_DOUBLE
155 extern "C" int32_t __fixdfsi(double op1); // DOUBLE_TO_INT
156 extern "C" float __floatdisf(int64_t op1); // LONG_TO_FLOAT
157 extern "C" double __floatdidf(int64_t op1); // LONG_TO_DOUBLE
158 extern "C" int64_t __fixsfdi(float op1); // FLOAT_TO_LONG
159 extern "C" int64_t __fixdfdi(double op1); // DOUBLE_TO_LONG
Bill Buzbee11f9d212012-03-03 20:03:18 -0800160
161 /* Single-precision FP arithmetics */
Elliott Hughesadb8c672012-03-06 16:49:32 -0800162 extern "C" float __addsf3(float a, float b); // ADD_FLOAT[_2ADDR]
163 extern "C" float __subsf3(float a, float b); // SUB_FLOAT[_2ADDR]
164 extern "C" float __divsf3(float a, float b); // DIV_FLOAT[_2ADDR]
165 extern "C" float __mulsf3(float a, float b); // MUL_FLOAT[_2ADDR]
166 extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
Bill Buzbee11f9d212012-03-03 20:03:18 -0800167
168 /* Double-precision FP arithmetics */
Elliott Hughesadb8c672012-03-06 16:49:32 -0800169 extern "C" double __adddf3(double a, double b); // ADD_DOUBLE[_2ADDR]
170 extern "C" double __subdf3(double a, double b); // SUB_DOUBLE[_2ADDR]
171 extern "C" double __divdf3(double a, double b); // DIV_DOUBLE[_2ADDR]
172 extern "C" double __muldf3(double a, double b); // MUL_DOUBLE[_2ADDR]
173 extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
Bill Buzbee11f9d212012-03-03 20:03:18 -0800174
Elliott Hughesadb8c672012-03-06 16:49:32 -0800175 /* Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR] */
Ian Rogersc6f3bb82012-03-21 20:40:33 -0700176 extern "C" long long __divdi3(int64_t op1, int64_t op2);
177 extern "C" long long __moddi3(int64_t op1, int64_t op2);
Bill Buzbee11f9d212012-03-03 20:03:18 -0800178#endif
179
buzbee54330722011-08-23 16:46:55 -0700180#endif // ART_SRC_RUNTIME_SUPPORT_H_