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); |
| 46 | extern int CmpgDouble(double a, double b); |
| 47 | extern int CmplDouble(double a, double b); |
| 48 | extern int CmpgFloat(float a, float b); |
| 49 | extern int 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 | /* Helper for both JNI and regular compiled code */ |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 55 | extern "C" void art_deliver_exception_from_code(void*); |
Ian Rogers | ad42e13 | 2011-09-17 20:23:33 -0700 | [diff] [blame] | 56 | |
Ian Rogers | 466bb25 | 2011-10-14 03:29:56 -0700 | [diff] [blame] | 57 | extern "C" void art_proxy_invoke_handler(); |
| 58 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 59 | #if defined(__arm__) |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 60 | /* Compiler helpers */ |
Ian Rogers | 1bddec3 | 2012-02-04 12:27:34 -0800 | [diff] [blame] | 61 | extern "C" int32_t art_get32_static_from_code(uint32_t); |
| 62 | extern "C" int64_t art_get64_static_from_code(uint32_t); |
| 63 | extern "C" void* art_get_obj_static_from_code(uint32_t); |
| 64 | extern "C" int32_t art_get32_instance_from_code(uint32_t, void*); |
| 65 | extern "C" int64_t art_get64_instance_from_code(uint32_t, void*); |
| 66 | extern "C" void* art_get_obj_instance_from_code(uint32_t, void*); |
| 67 | extern "C" int art_set32_static_from_code(uint32_t, int32_t); |
| 68 | extern "C" int art_set64_static_from_code(uint32_t, int64_t); |
| 69 | extern "C" int art_set_obj_static_from_code(uint32_t, void*); |
| 70 | extern "C" int art_set32_instance_from_code(uint32_t, void*, int32_t); |
| 71 | extern "C" int art_set64_instance_from_code(uint32_t, void*, int64_t); |
| 72 | 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] | 73 | extern "C" void art_can_put_array_element_from_code(void*, void*); |
| 74 | extern "C" void art_check_cast_from_code(void*, void*); |
| 75 | extern "C" void art_do_long_jump(uint32_t*, uint32_t*); |
| 76 | extern "C" void art_handle_fill_data_from_code(void*, void*); |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 77 | 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] | 78 | extern "C" void art_invoke_interface_trampoline(uint32_t, void*); |
Ian Rogers | a32a6fd | 2012-02-06 20:18:44 -0800 | [diff] [blame] | 79 | 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] | 80 | 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] | 81 | extern "C" void art_invoke_super_trampoline_with_access_check(uint32_t, void*); |
| 82 | 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] | 83 | extern "C" void art_lock_object_from_code(void*); |
Ian Rogers | cbba6ac | 2011-09-22 16:28:37 -0700 | [diff] [blame] | 84 | extern "C" void art_test_suspend(); |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 85 | extern "C" void art_throw_array_bounds_from_code(int32_t index, int32_t limit); |
| 86 | extern "C" void art_throw_div_zero_from_code(); |
Ian Rogers | c0c8dc8 | 2011-09-24 18:15:59 -0700 | [diff] [blame] | 87 | extern "C" void art_throw_neg_array_size_from_code(int32_t size); |
| 88 | 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] | 89 | extern "C" void art_throw_null_pointer_exception_from_code(); |
Ian Rogers | 932746a | 2011-09-22 18:57:50 -0700 | [diff] [blame] | 90 | extern "C" void art_throw_stack_overflow_from_code(void*); |
Ian Rogers | c0c8dc8 | 2011-09-24 18:15:59 -0700 | [diff] [blame] | 91 | 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] | 92 | extern "C" void art_unlock_object_from_code(void*); |
Brian Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 93 | 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] | 94 | 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] | 95 | 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] | 96 | 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] | 97 | 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] | 98 | 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] | 99 | extern "C" void* art_initialize_static_storage_from_code(uint32_t, void*); |
Ian Rogers | 28ad40d | 2011-10-27 15:19:26 -0700 | [diff] [blame] | 100 | extern "C" void* art_initialize_type_from_code(uint32_t, void*); |
Ian Rogers | b093c6b | 2011-10-31 16:19:55 -0700 | [diff] [blame] | 101 | 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] | 102 | extern "C" void art_trace_entry_from_code(void*); |
| 103 | extern "C" void art_trace_exit_from_code(); |
Brian Carlstrom | 6fd03fb | 2011-10-17 16:11:00 -0700 | [diff] [blame] | 104 | extern "C" void* art_resolve_string_from_code(void*, uint32_t); |
buzbee | 44b412b | 2012-02-04 08:50:53 -0800 | [diff] [blame] | 105 | extern "C" void art_update_debugger(void*, void*, int32_t, void*); |
Ian Rogers | 60db5ab | 2012-02-20 17:02:00 -0800 | [diff] [blame] | 106 | extern "C" void art_work_around_app_jni_bugs(); |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 107 | |
| 108 | /* Conversions */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 109 | extern "C" float __aeabi_i2f(int op1); // INT_TO_FLOAT |
| 110 | extern "C" int __aeabi_f2iz(float op1); // FLOAT_TO_INT |
| 111 | extern "C" float __aeabi_d2f(double op1); // DOUBLE_TO_FLOAT |
| 112 | extern "C" double __aeabi_f2d(float op1); // FLOAT_TO_DOUBLE |
| 113 | extern "C" double __aeabi_i2d(int op1); // INT_TO_DOUBLE |
| 114 | extern "C" int __aeabi_d2iz(double op1); // DOUBLE_TO_INT |
| 115 | extern "C" float __aeabi_l2f(long op1); // LONG_TO_FLOAT |
| 116 | extern "C" double __aeabi_l2d(long op1); // LONG_TO_DOUBLE |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 117 | |
| 118 | /* Single-precision FP arithmetics */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 119 | extern "C" float __aeabi_fadd(float a, float b); // ADD_FLOAT[_2ADDR] |
| 120 | extern "C" float __aeabi_fsub(float a, float b); // SUB_FLOAT[_2ADDR] |
| 121 | extern "C" float __aeabi_fdiv(float a, float b); // DIV_FLOAT[_2ADDR] |
| 122 | extern "C" float __aeabi_fmul(float a, float b); // MUL_FLOAT[_2ADDR] |
| 123 | extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR] |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 124 | |
| 125 | /* Double-precision FP arithmetics */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 126 | extern "C" double __aeabi_dadd(double a, double b); // ADD_DOUBLE[_2ADDR] |
| 127 | extern "C" double __aeabi_dsub(double a, double b); // SUB_DOUBLE[_2ADDR] |
| 128 | extern "C" double __aeabi_ddiv(double a, double b); // DIV_DOUBLE[_2ADDR] |
| 129 | extern "C" double __aeabi_dmul(double a, double b); // MUL_DOUBLE[_2ADDR] |
| 130 | extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR] |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 131 | |
| 132 | /* Integer arithmetics */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 133 | extern "C" int __aeabi_idivmod(int op1, int op2); // REM_INT[_2ADDR|_LIT8|_LIT16] |
| 134 | extern "C" int __aeabi_idiv(int op1, int op2); // DIV_INT[_2ADDR|_LIT8|_LIT16] |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 135 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 136 | /* Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR] */ |
Ian Rogers | ff1ed47 | 2011-09-20 13:46:24 -0700 | [diff] [blame] | 137 | extern "C" long long __aeabi_ldivmod(long long op1, long long op2); |
| 138 | extern "C" long long __aeabi_lmul(long long op1, long long op2); |
Ian Rogers | cbba6ac | 2011-09-22 16:28:37 -0700 | [diff] [blame] | 139 | extern "C" uint64_t art_shl_long(uint64_t, uint32_t); |
| 140 | extern "C" uint64_t art_shr_long(uint64_t, uint32_t); |
| 141 | extern "C" uint64_t art_ushr_long(uint64_t, uint32_t); |
buzbee | 7b1b86d | 2011-08-26 18:59:10 -0700 | [diff] [blame] | 142 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 143 | #endif |
| 144 | |
Bill Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 145 | #if defined(__mips__) |
| 146 | /* Conversions */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 147 | extern "C" float __floatsisf(int op1); // INT_TO_FLOAT |
| 148 | extern "C" int __fixsfsi(float op1); // FLOAT_TO_INT |
| 149 | extern "C" float __truncdfsf2(double op1); // DOUBLE_TO_FLOAT |
| 150 | extern "C" double __extendsfdf2(float op1); // FLOAT_TO_DOUBLE |
| 151 | extern "C" double __floatsidf(int op1); // INT_TO_DOUBLE |
| 152 | extern "C" int __fixdfsi(double op1); // DOUBLE_TO_INT |
| 153 | extern "C" float __floatdisf(long long op1); // LONG_TO_FLOAT |
| 154 | extern "C" double __floatdidf(long long op1); // LONG_TO_DOUBLE |
| 155 | extern "C" long long __fixsfdi(float op1); // FLOAT_TO_LONG |
| 156 | extern "C" long long __fixdfdi(double op1); // DOUBLE_TO_LONG |
Bill Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 157 | |
| 158 | /* Single-precision FP arithmetics */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 159 | extern "C" float __addsf3(float a, float b); // ADD_FLOAT[_2ADDR] |
| 160 | extern "C" float __subsf3(float a, float b); // SUB_FLOAT[_2ADDR] |
| 161 | extern "C" float __divsf3(float a, float b); // DIV_FLOAT[_2ADDR] |
| 162 | extern "C" float __mulsf3(float a, float b); // MUL_FLOAT[_2ADDR] |
| 163 | extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR] |
Bill Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 164 | |
| 165 | /* Double-precision FP arithmetics */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 166 | extern "C" double __adddf3(double a, double b); // ADD_DOUBLE[_2ADDR] |
| 167 | extern "C" double __subdf3(double a, double b); // SUB_DOUBLE[_2ADDR] |
| 168 | extern "C" double __divdf3(double a, double b); // DIV_DOUBLE[_2ADDR] |
| 169 | extern "C" double __muldf3(double a, double b); // MUL_DOUBLE[_2ADDR] |
| 170 | extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR] |
Bill Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 171 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 172 | /* Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR] */ |
Bill Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 173 | extern "C" long long __divdi3(long long op1, long long op2); |
| 174 | extern "C" long long __moddi3(long long op1, long long op2); |
Bill Buzbee | 11f9d21 | 2012-03-03 20:03:18 -0800 | [diff] [blame] | 175 | #endif |
| 176 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 177 | #endif // ART_SRC_RUNTIME_SUPPORT_H_ |