Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef ART_SRC_RUNTIME_SUPPORT_H_ |
| 18 | #define ART_SRC_RUNTIME_SUPPORT_H_ |
| 19 | |
Shih-wei Liao | 2d83101 | 2011-09-28 22:06:53 -0700 | [diff] [blame] | 20 | #include "class_linker.h" |
| 21 | #include "object.h" |
| 22 | #include "thread_list.h" |
| 23 | #include "utils.h" |
| 24 | |
| 25 | namespace art { |
| 26 | |
Ian Rogers | 4a510d8 | 2011-10-09 14:30:24 -0700 | [diff] [blame] | 27 | extern void CheckSuspendFromCode(Thread* thread); |
Ian Rogers | ce9eca6 | 2011-10-07 17:11:03 -0700 | [diff] [blame] | 28 | extern Array* CheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 29 | Thread* self, bool access_check); |
Shih-wei Liao | 2d83101 | 2011-09-28 22:06:53 -0700 | [diff] [blame] | 30 | extern void DebugMe(Method* method, uint32_t info); |
Elliott Hughes | 91bf6cd | 2012-02-14 17:27:48 -0800 | [diff] [blame] | 31 | extern void UpdateDebuggerFromCode(Method* method, Thread* thread , int32_t dex_pc, Method** sp); |
Shih-wei Liao | 2d83101 | 2011-09-28 22:06:53 -0700 | [diff] [blame] | 32 | extern Object* DecodeJObjectInThread(Thread* thread, jobject obj); |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 33 | extern Field* FindFieldFromCode(uint32_t field_idx, const Method* referrer, Thread* self, |
jeffhao | 8cd6dda | 2012-02-22 10:15:34 -0800 | [diff] [blame] | 34 | bool is_static, bool is_primitive, bool is_set, size_t expected_size); |
Shih-wei Liao | 2d83101 | 2011-09-28 22:06:53 -0700 | [diff] [blame] | 35 | extern void* FindNativeMethod(Thread* thread); |
| 36 | extern void ThrowAbstractMethodErrorFromCode(Method* method, Thread* thread, Method** sp); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 37 | const void* UnresolvedDirectMethodTrampolineFromCode(Method*, Method**, Thread*, |
| 38 | Runtime::TrampolineType); |
Elliott Hughes | f3778f6 | 2012-01-26 14:14:35 -0800 | [diff] [blame] | 39 | extern Class* ResolveVerifyAndClinit(uint32_t type_idx, const Method* referrer, Thread* self, |
| 40 | bool can_run_clinit, bool verify_access); |
Shih-wei Liao | 2d83101 | 2011-09-28 22:06:53 -0700 | [diff] [blame] | 41 | extern Class* InitializeTypeFromCode(uint32_t type_idx, Method* method); |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 42 | uint32_t IsAssignableFromCode(const Class* klass, const Class* ref_class); |
| 43 | void ObjectInitFromCode(Object* o); |
Shih-wei Liao | 2d83101 | 2011-09-28 22:06:53 -0700 | [diff] [blame] | 44 | extern void LockObjectFromCode(Thread* thread, Object* obj); |
Elliott Hughes | 0ece7b9 | 2012-03-09 18:14:40 -0800 | [diff] [blame] | 45 | uint32_t TraceMethodUnwindFromCode(Thread* self); |
Ian Rogers | c6f3bb8 | 2012-03-21 20:40:33 -0700 | [diff] [blame] | 46 | extern int32_t CmpgDouble(double a, double b); |
| 47 | extern int32_t CmplDouble(double a, double b); |
| 48 | extern int32_t CmpgFloat(float a, float b); |
| 49 | extern int32_t CmplFloat(float a, float b); |
Shih-wei Liao | 2d83101 | 2011-09-28 22:06:53 -0700 | [diff] [blame] | 50 | extern int64_t D2L(double d); |
| 51 | extern int64_t F2L(float f); |
| 52 | |
| 53 | } // namespace art |
Ian Rogers | ad42e13 | 2011-09-17 20:23:33 -0700 | [diff] [blame] | 54 | |
Elliott Hughes | c0f0933 | 2012-03-26 13:27:06 -0700 | [diff] [blame] | 55 | // Helpers for both compiled code and libart. |
| 56 | extern "C" void art_deliver_exception_from_code(void*); |
Ian Rogers | 466bb25 | 2011-10-14 03:29:56 -0700 | [diff] [blame] | 57 | extern "C" void art_proxy_invoke_handler(); |
Elliott Hughes | c0f0933 | 2012-03-26 13:27:06 -0700 | [diff] [blame] | 58 | extern "C" void art_update_debugger(void*, void*, int32_t, void*); |
Ian Rogers | 466bb25 | 2011-10-14 03:29:56 -0700 | [diff] [blame] | 59 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 60 | #if defined(__arm__) |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 61 | /* Compiler helpers */ |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 62 | 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 Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 65 | 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 Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 77 | 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 Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 81 | extern "C" void art_invoke_direct_trampoline_with_access_check(uint32_t, void*); |
Brian Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 82 | extern "C" void art_invoke_interface_trampoline(uint32_t, void*); |
Ian Rogers | a32a6fd | 2012-02-06 20:18:44 -0800 | [diff] [blame] | 83 | extern "C" void art_invoke_interface_trampoline_with_access_check(uint32_t, void*); |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 84 | extern "C" void art_invoke_static_trampoline_with_access_check(uint32_t, void*); |
Ian Rogers | a32a6fd | 2012-02-06 20:18:44 -0800 | [diff] [blame] | 85 | 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 Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 87 | extern "C" void art_lock_object_from_code(void*); |
Ian Rogers | cbba6ac | 2011-09-22 16:28:37 -0700 | [diff] [blame] | 88 | extern "C" void art_test_suspend(); |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 89 | 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 Rogers | c0c8dc8 | 2011-09-24 18:15:59 -0700 | [diff] [blame] | 91 | 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 Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 93 | extern "C" void art_throw_null_pointer_exception_from_code(); |
Ian Rogers | 932746a | 2011-09-22 18:57:50 -0700 | [diff] [blame] | 94 | extern "C" void art_throw_stack_overflow_from_code(void*); |
Ian Rogers | c0c8dc8 | 2011-09-24 18:15:59 -0700 | [diff] [blame] | 95 | extern "C" void art_throw_verification_error_from_code(int32_t src1, int32_t ref); |
Ian Rogers | 4f0d07c | 2011-10-06 23:38:47 -0700 | [diff] [blame] | 96 | extern "C" void art_unlock_object_from_code(void*); |
Brian Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 97 | extern "C" void* art_alloc_array_from_code(uint32_t, void*, int32_t); |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 98 | extern "C" void* art_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); |
Brian Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 99 | extern "C" void* art_alloc_object_from_code(uint32_t type_idx, void* method); |
Ian Rogers | 28ad40d | 2011-10-27 15:19:26 -0700 | [diff] [blame] | 100 | extern "C" void* art_alloc_object_from_code_with_access_check(uint32_t type_idx, void* method); |
Brian Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 101 | extern "C" void* art_check_and_alloc_array_from_code(uint32_t, void*, int32_t); |
Ian Rogers | 0eb7d7e | 2012-01-31 21:12:32 -0800 | [diff] [blame] | 102 | extern "C" void* art_check_and_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); |
Brian Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 103 | extern "C" void* art_initialize_static_storage_from_code(uint32_t, void*); |
Ian Rogers | 28ad40d | 2011-10-27 15:19:26 -0700 | [diff] [blame] | 104 | extern "C" void* art_initialize_type_from_code(uint32_t, void*); |
Ian Rogers | b093c6b | 2011-10-31 16:19:55 -0700 | [diff] [blame] | 105 | extern "C" void* art_initialize_type_and_verify_access_from_code(uint32_t, void*); |
jeffhao | e343b76 | 2011-12-05 16:36:44 -0800 | [diff] [blame] | 106 | extern "C" void art_trace_entry_from_code(void*); |
| 107 | extern "C" void art_trace_exit_from_code(); |
Brian Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 108 | extern "C" void* art_resolve_string_from_code(void*, uint32_t); |
Ian Rogers | 60db5ab | 2012-02-20 17:02:00 -0800 | [diff] [blame] | 109 | extern "C" void art_work_around_app_jni_bugs(); |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 110 | |
| 111 | /* Conversions */ |
Ian Rogers | c6f3bb8 | 2012-03-21 20:40:33 -0700 | [diff] [blame] | 112 | extern "C" float __aeabi_i2f(int32_t op1); // INT_TO_FLOAT |
| 113 | extern "C" int32_t __aeabi_f2iz(float op1); // FLOAT_TO_INT |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 114 | extern "C" float __aeabi_d2f(double op1); // DOUBLE_TO_FLOAT |
| 115 | extern "C" double __aeabi_f2d(float op1); // FLOAT_TO_DOUBLE |
Ian Rogers | c6f3bb8 | 2012-03-21 20:40:33 -0700 | [diff] [blame] | 116 | 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 |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 120 | |
| 121 | /* Single-precision FP arithmetics */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 122 | 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] |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 127 | |
| 128 | /* Double-precision FP arithmetics */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 129 | 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] |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 134 | |
| 135 | /* Integer arithmetics */ |
Ian Rogers | c6f3bb8 | 2012-03-21 20:40:33 -0700 | [diff] [blame] | 136 | 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] |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 138 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 139 | /* Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR] */ |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 140 | 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 Rogers | cbba6ac | 2011-09-22 16:28:37 -0700 | [diff] [blame] | 142 | 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); |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 145 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 146 | #endif |
| 147 | |
Bill Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 148 | #if defined(__mips__) |
| 149 | /* Conversions */ |
Ian Rogers | c6f3bb8 | 2012-03-21 20:40:33 -0700 | [diff] [blame] | 150 | 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 Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 160 | |
| 161 | /* Single-precision FP arithmetics */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 162 | 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 Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 167 | |
| 168 | /* Double-precision FP arithmetics */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 169 | 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 Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 174 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 175 | /* Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR] */ |
Ian Rogers | c6f3bb8 | 2012-03-21 20:40:33 -0700 | [diff] [blame] | 176 | extern "C" long long __divdi3(int64_t op1, int64_t op2); |
| 177 | extern "C" long long __moddi3(int64_t op1, int64_t op2); |
Bill Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 178 | #endif |
| 179 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 180 | #endif // ART_SRC_RUNTIME_SUPPORT_H_ |