blob: 1fdf439d3f090d616e2b8ead960401b437afd86b [file] [log] [blame]
Andreas Gampe4352b452014-06-04 18:59:01 -07001/*
2 * Copyright (C) 2014 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
Dave Allison8ce6b902014-08-26 11:07:58 -070017#include <setjmp.h>
Andreas Gampe4352b452014-06-04 18:59:01 -070018
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070019#include <memory>
20
Andreas Gampe4352b452014-06-04 18:59:01 -070021#include "base/macros.h"
22#include "common_runtime_test.h"
23#include "thread.h"
24
25// This test checks the offsets of values in the thread TLS and entrypoint structures. A failure
26// of this test means that offsets have changed from the last update of the test. This indicates
27// that an oat version bump may be in order, and some defines should be carefully checked (or their
28// corresponding tests run).
29
30namespace art {
31
32// OFFSETOF_MEMBER uses reinterpret_cast. This means it is not a constexpr. So we cannot use
33// compile-time assertions. Once we find another way, adjust the define accordingly.
34#define CHECKED(expr, name) \
35 EXPECT_TRUE(expr) << #name
36
37// Macro to check whether two fields have an expected difference in offsets. The error is named
38// name.
39#define EXPECT_OFFSET_DIFF(first_type, first_field, second_type, second_field, diff, name) \
40 CHECKED(OFFSETOF_MEMBER(second_type, second_field) \
Chih-Hung Hsieh1a0de6a2016-08-26 15:06:11 -070041 - OFFSETOF_MEMBER(first_type, first_field) == (diff), name)
Andreas Gampe4352b452014-06-04 18:59:01 -070042
43// Helper macro for when the fields are from the same type.
44#define EXPECT_OFFSET_DIFFNP(type, first_field, second_field, diff) \
45 EXPECT_OFFSET_DIFF(type, first_field, type, second_field, diff, \
46 type ## _ ## first_field ## _ ## second_field)
47
48// Helper macro for when the fields are from the same type and in the same member of said type.
Chih-Hung Hsieh1a0de6a2016-08-26 15:06:11 -070049// NOLINT, do not add parentheses around 'prefix'.
Andreas Gampe4352b452014-06-04 18:59:01 -070050#define EXPECT_OFFSET_DIFFP(type, prefix, first_field, second_field, diff) \
Chih-Hung Hsieh1a0de6a2016-08-26 15:06:11 -070051 EXPECT_OFFSET_DIFF(type, prefix . first_field, type, prefix . second_field, diff, /* NOLINT */ \
Andreas Gampe4352b452014-06-04 18:59:01 -070052 type ## _ ## prefix ## _ ## first_field ## _ ## second_field)
53
54// Macro to check whether two fields have at least an expected difference in offsets. The error is
55// named name.
56#define EXPECT_OFFSET_DIFF_GT(first_type, first_field, second_type, second_field, diff, name) \
57 CHECKED(OFFSETOF_MEMBER(second_type, second_field) \
Chih-Hung Hsieh1a0de6a2016-08-26 15:06:11 -070058 - OFFSETOF_MEMBER(first_type, first_field) >= (diff), name)
Andreas Gampe4352b452014-06-04 18:59:01 -070059
60// Helper macro for when the fields are from the same type.
61#define EXPECT_OFFSET_DIFF_GT3(type, first_field, second_field, diff, name) \
62 EXPECT_OFFSET_DIFF_GT(type, first_field, type, second_field, diff, name)
63
64class EntrypointsOrderTest : public CommonRuntimeTest {
65 protected:
66 void CheckThreadOffsets() {
67 CHECKED(OFFSETOF_MEMBER(Thread, tls32_.state_and_flags) == 0, thread_flags_at_zero);
68 EXPECT_OFFSET_DIFFP(Thread, tls32_, state_and_flags, suspend_count, 4);
69 EXPECT_OFFSET_DIFFP(Thread, tls32_, suspend_count, debug_suspend_count, 4);
70 EXPECT_OFFSET_DIFFP(Thread, tls32_, debug_suspend_count, thin_lock_thread_id, 4);
71 EXPECT_OFFSET_DIFFP(Thread, tls32_, thin_lock_thread_id, tid, 4);
72 EXPECT_OFFSET_DIFFP(Thread, tls32_, tid, daemon, 4);
73 EXPECT_OFFSET_DIFFP(Thread, tls32_, daemon, throwing_OutOfMemoryError, 4);
74 EXPECT_OFFSET_DIFFP(Thread, tls32_, throwing_OutOfMemoryError, no_thread_suspension, 4);
75 EXPECT_OFFSET_DIFFP(Thread, tls32_, no_thread_suspension, thread_exit_check_count, 4);
Nicolas Geoffray7642cfc2015-02-26 10:56:09 +000076 EXPECT_OFFSET_DIFFP(Thread, tls32_, thread_exit_check_count, handling_signal_, 4);
Andreas Gampe4352b452014-06-04 18:59:01 -070077
78 // TODO: Better connection. Take alignment into account.
79 EXPECT_OFFSET_DIFF_GT3(Thread, tls32_.thread_exit_check_count, tls64_.trace_clock_base, 4,
80 thread_tls32_to_tls64);
81
Sebastien Hertz07474662015-08-25 15:12:33 +000082 EXPECT_OFFSET_DIFFP(Thread, tls64_, trace_clock_base, stats, 8);
Andreas Gampe4352b452014-06-04 18:59:01 -070083
84 // TODO: Better connection. Take alignment into account.
85 EXPECT_OFFSET_DIFF_GT3(Thread, tls64_.stats, tlsPtr_.card_table, 8, thread_tls64_to_tlsptr);
86
Ian Rogers13735952014-10-08 12:43:28 -070087 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, card_table, exception, sizeof(void*));
88 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, exception, stack_end, sizeof(void*));
89 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, stack_end, managed_stack, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -070090 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, managed_stack, suspend_trigger, sizeof(ManagedStack));
Ian Rogers13735952014-10-08 12:43:28 -070091 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, suspend_trigger, jni_env, sizeof(void*));
Andreas Gampe449357d2015-06-01 22:29:51 -070092 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, jni_env, tmp_jni_env, sizeof(void*));
93 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, tmp_jni_env, self, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -070094 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, self, opeer, sizeof(void*));
95 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, opeer, jpeer, sizeof(void*));
96 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, jpeer, stack_begin, sizeof(void*));
97 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, stack_begin, stack_size, sizeof(void*));
Nicolas Geoffray340dafa2016-11-18 16:03:10 +000098 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, stack_size, deps_or_stack_trace_sample, sizeof(void*));
99 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, deps_or_stack_trace_sample, wait_next, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -0700100 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, wait_next, monitor_enter_object, sizeof(void*));
101 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, monitor_enter_object, top_handle_scope, sizeof(void*));
102 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, top_handle_scope, class_loader_override, sizeof(void*));
103 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, class_loader_override, long_jump_context, sizeof(void*));
104 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, long_jump_context, instrumentation_stack, sizeof(void*));
105 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, instrumentation_stack, debug_invoke_req, sizeof(void*));
106 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, debug_invoke_req, single_step_control, sizeof(void*));
Mingyao Yang1f2d3ba2015-05-18 12:12:50 -0700107 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, single_step_control, stacked_shadow_frame_record,
Ian Rogers13735952014-10-08 12:43:28 -0700108 sizeof(void*));
Mingyao Yang1f2d3ba2015-05-18 12:12:50 -0700109 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, stacked_shadow_frame_record,
Sebastien Hertz07474662015-08-25 15:12:33 +0000110 deoptimization_context_stack, sizeof(void*));
Mingyao Yang99170c62015-07-06 11:10:37 -0700111 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, deoptimization_context_stack,
112 frame_id_to_shadow_frame, sizeof(void*));
113 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, frame_id_to_shadow_frame, name, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -0700114 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, name, pthread_self, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700115 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, pthread_self, last_no_thread_suspension_cause,
Ian Rogers13735952014-10-08 12:43:28 -0700116 sizeof(void*));
Mathieu Chartier952e1e32016-06-13 14:04:02 -0700117 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, last_no_thread_suspension_cause, checkpoint_function,
Ian Rogers13735952014-10-08 12:43:28 -0700118 sizeof(void*));
Mathieu Chartier952e1e32016-06-13 14:04:02 -0700119 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, checkpoint_function, active_suspend_barriers,
120 sizeof(void*));
Roland Levillaine71b3542017-01-16 14:58:23 +0000121 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, active_suspend_barriers, thread_local_start,
Mathieu Chartier952e1e32016-06-13 14:04:02 -0700122 sizeof(Thread::tls_ptr_sized_values::active_suspend_barriers));
Roland Levillaine71b3542017-01-16 14:58:23 +0000123 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_start, thread_local_pos, sizeof(void*));
124 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_pos, thread_local_end, sizeof(void*));
Mathieu Chartier28a24b32017-04-19 23:54:33 -0700125 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_end, thread_local_limit, sizeof(void*));
126 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_limit, thread_local_objects, sizeof(void*));
Roland Levillaine71b3542017-01-16 14:58:23 +0000127 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_objects, jni_entrypoints, sizeof(size_t));
Andreas Gampe4352b452014-06-04 18:59:01 -0700128
129 // Skip across the entrypoints structures.
buzbee1452bee2015-03-06 14:43:04 -0800130 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, mterp_current_ibase, mterp_default_ibase, sizeof(void*));
131 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, mterp_default_ibase, mterp_alt_ibase, sizeof(void*));
132 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, mterp_alt_ibase, rosalloc_runs, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700133 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, rosalloc_runs, thread_local_alloc_stack_top,
Hiroshi Yamauchi7ed9c562016-02-02 15:22:09 -0800134 sizeof(void*) * kNumRosAllocThreadLocalSizeBracketsInThread);
Andreas Gampe4352b452014-06-04 18:59:01 -0700135 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_alloc_stack_top, thread_local_alloc_stack_end,
Ian Rogers13735952014-10-08 12:43:28 -0700136 sizeof(void*));
137 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_alloc_stack_end, held_mutexes, sizeof(void*));
Josh Gaoefd20cb2017-02-28 16:53:59 -0800138 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, held_mutexes, flip_function,
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800139 sizeof(void*) * kLockLevelCount);
Mathieu Chartier12d625f2015-03-13 11:33:37 -0700140 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, flip_function, method_verifier, sizeof(void*));
Hiroshi Yamauchi0b713572015-06-16 18:29:23 -0700141 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, method_verifier, thread_local_mark_stack, sizeof(void*));
Alex Light848574c2017-09-25 16:59:39 -0700142 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_mark_stack, async_exception, sizeof(void*));
143 EXPECT_OFFSET_DIFF(Thread, tlsPtr_.async_exception, Thread, wait_mutex_, sizeof(void*),
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800144 thread_tlsptr_end);
Andreas Gampe4352b452014-06-04 18:59:01 -0700145 }
146
Andreas Gampe4352b452014-06-04 18:59:01 -0700147 void CheckJniEntryPoints() {
148 CHECKED(OFFSETOF_MEMBER(JniEntryPoints, pDlsymLookup) == 0,
149 JniEntryPoints_start_with_dlsymlookup);
150 CHECKED(OFFSETOF_MEMBER(JniEntryPoints, pDlsymLookup)
Ian Rogers13735952014-10-08 12:43:28 -0700151 + sizeof(void*) == sizeof(JniEntryPoints), JniEntryPoints_all);
Andreas Gampe4352b452014-06-04 18:59:01 -0700152 }
153
Andreas Gampe4352b452014-06-04 18:59:01 -0700154 void CheckQuickEntryPoints() {
Nicolas Geoffray8d91ac32017-01-18 18:07:15 +0000155 CHECKED(OFFSETOF_MEMBER(QuickEntryPoints, pAllocArrayResolved) == 0,
156 QuickEntryPoints_start_with_allocarray_resoved);
Nicolas Geoffrayb048cb72017-01-23 22:50:24 +0000157 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocArrayResolved, pAllocArrayResolved8,
158 sizeof(void*));
159 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocArrayResolved8, pAllocArrayResolved16,
160 sizeof(void*));
161 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocArrayResolved16, pAllocArrayResolved32,
162 sizeof(void*));
163 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocArrayResolved32, pAllocArrayResolved64,
164 sizeof(void*));
165 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocArrayResolved64, pAllocObjectResolved,
Nicolas Geoffray0d3998b2017-01-12 15:35:12 +0000166 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700167 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocObjectResolved, pAllocObjectInitialized,
Ian Rogers13735952014-10-08 12:43:28 -0700168 sizeof(void*));
Nicolas Geoffray0d3998b2017-01-12 15:35:12 +0000169 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocObjectInitialized, pAllocObjectWithChecks,
Ian Rogers13735952014-10-08 12:43:28 -0700170 sizeof(void*));
Nicolas Geoffray39cee662017-01-13 16:04:53 +0000171 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocObjectWithChecks, pAllocStringFromBytes,
Ian Rogers13735952014-10-08 12:43:28 -0700172 sizeof(void*));
Jeff Hao848f70a2014-01-15 13:49:50 -0800173 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocStringFromBytes, pAllocStringFromChars,
174 sizeof(void*));
175 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocStringFromChars, pAllocStringFromString,
176 sizeof(void*));
177 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocStringFromString, pInstanceofNonTrivial,
178 sizeof(void*));
Mathieu Chartierb99f4d62016-11-07 16:17:26 -0800179 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInstanceofNonTrivial, pCheckInstanceOf, sizeof(void*));
180 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCheckInstanceOf, pInitializeStaticStorage,
181 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700182 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInitializeStaticStorage, pInitializeTypeAndVerifyAccess,
Ian Rogers13735952014-10-08 12:43:28 -0700183 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700184 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInitializeTypeAndVerifyAccess, pInitializeType,
Ian Rogers13735952014-10-08 12:43:28 -0700185 sizeof(void*));
186 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInitializeType, pResolveString, sizeof(void*));
187 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pResolveString, pSet8Instance, sizeof(void*));
188 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSet8Instance, pSet8Static, sizeof(void*));
189 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSet8Static, pSet16Instance, sizeof(void*));
190 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSet16Instance, pSet16Static, sizeof(void*));
191 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSet16Static, pSet32Instance, sizeof(void*));
192 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSet32Instance, pSet32Static, sizeof(void*));
193 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSet32Static, pSet64Instance, sizeof(void*));
194 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSet64Instance, pSet64Static, sizeof(void*));
195 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSet64Static, pSetObjInstance, sizeof(void*));
196 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSetObjInstance, pSetObjStatic, sizeof(void*));
197 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSetObjStatic, pGetByteInstance, sizeof(void*));
198 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetByteInstance, pGetBooleanInstance, sizeof(void*));
199 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetBooleanInstance, pGetByteStatic, sizeof(void*));
200 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetByteStatic, pGetBooleanStatic, sizeof(void*));
201 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetBooleanStatic, pGetShortInstance, sizeof(void*));
202 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetShortInstance, pGetCharInstance, sizeof(void*));
203 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetCharInstance, pGetShortStatic, sizeof(void*));
204 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetShortStatic, pGetCharStatic, sizeof(void*));
205 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetCharStatic, pGet32Instance, sizeof(void*));
206 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGet32Instance, pGet32Static, sizeof(void*));
207 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGet32Static, pGet64Instance, sizeof(void*));
208 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGet64Instance, pGet64Static, sizeof(void*));
209 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGet64Static, pGetObjInstance, sizeof(void*));
210 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetObjInstance, pGetObjStatic, sizeof(void*));
Nicolas Geoffray39cee662017-01-13 16:04:53 +0000211 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetObjStatic, pAputObject, sizeof(void*));
212 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAputObject, pJniMethodStart, sizeof(void*));
Igor Murashkin9d4b6da2016-07-29 09:51:58 -0700213 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodStart, pJniMethodFastStart,
214 sizeof(void*));
215 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodFastStart, pJniMethodStartSynchronized,
Ian Rogers13735952014-10-08 12:43:28 -0700216 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700217 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodStartSynchronized, pJniMethodEnd,
Ian Rogers13735952014-10-08 12:43:28 -0700218 sizeof(void*));
Igor Murashkin9d4b6da2016-07-29 09:51:58 -0700219 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodEnd, pJniMethodFastEnd, sizeof(void*));
220 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodFastEnd, pJniMethodEndSynchronized, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700221 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodEndSynchronized, pJniMethodEndWithReference,
Ian Rogers13735952014-10-08 12:43:28 -0700222 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700223 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodEndWithReference,
Igor Murashkinaf1e2992016-10-12 17:44:50 -0700224 pJniMethodFastEndWithReference, sizeof(void*));
225 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodFastEndWithReference,
Ian Rogers13735952014-10-08 12:43:28 -0700226 pJniMethodEndWithReferenceSynchronized, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700227 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodEndWithReferenceSynchronized,
Ian Rogers13735952014-10-08 12:43:28 -0700228 pQuickGenericJniTrampoline, sizeof(void*));
229 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pQuickGenericJniTrampoline, pLockObject, sizeof(void*));
230 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pLockObject, pUnlockObject, sizeof(void*));
231 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pUnlockObject, pCmpgDouble, sizeof(void*));
232 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCmpgDouble, pCmpgFloat, sizeof(void*));
233 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCmpgFloat, pCmplDouble, sizeof(void*));
234 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCmplDouble, pCmplFloat, sizeof(void*));
Mark Mendella4f12202015-08-06 15:23:34 -0400235 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCmplFloat, pCos, sizeof(void*));
236 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCos, pSin, sizeof(void*));
237 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSin, pAcos, sizeof(void*));
238 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAcos, pAsin, sizeof(void*));
239 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAsin, pAtan, sizeof(void*));
240 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAtan, pAtan2, sizeof(void*));
Vladimir Marko4d179872018-01-19 14:50:10 +0000241 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAtan2, pPow, sizeof(void*));
242 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pPow, pCbrt, sizeof(void*));
Mark Mendella4f12202015-08-06 15:23:34 -0400243 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCbrt, pCosh, sizeof(void*));
244 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCosh, pExp, sizeof(void*));
245 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pExp, pExpm1, sizeof(void*));
246 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pExpm1, pHypot, sizeof(void*));
247 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pHypot, pLog, sizeof(void*));
248 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pLog, pLog10, sizeof(void*));
249 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pLog10, pNextAfter, sizeof(void*));
250 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNextAfter, pSinh, sizeof(void*));
251 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pSinh, pTan, sizeof(void*));
252 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pTan, pTanh, sizeof(void*));
253 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pTanh, pFmod, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -0700254 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pFmod, pL2d, sizeof(void*));
255 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pL2d, pFmodf, sizeof(void*));
256 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pFmodf, pL2f, sizeof(void*));
257 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pL2f, pD2iz, sizeof(void*));
258 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pD2iz, pF2iz, sizeof(void*));
259 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pF2iz, pIdivmod, sizeof(void*));
260 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pIdivmod, pD2l, sizeof(void*));
261 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pD2l, pF2l, sizeof(void*));
262 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pF2l, pLdiv, sizeof(void*));
263 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pLdiv, pLmod, sizeof(void*));
264 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pLmod, pLmul, sizeof(void*));
265 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pLmul, pShlLong, sizeof(void*));
266 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pShlLong, pShrLong, sizeof(void*));
267 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pShrLong, pUshrLong, sizeof(void*));
268 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pUshrLong, pIndexOf, sizeof(void*));
269 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pIndexOf, pStringCompareTo, sizeof(void*));
270 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pStringCompareTo, pMemcpy, sizeof(void*));
271 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pMemcpy, pQuickImtConflictTrampoline, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700272 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pQuickImtConflictTrampoline, pQuickResolutionTrampoline,
Ian Rogers13735952014-10-08 12:43:28 -0700273 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700274 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pQuickResolutionTrampoline, pQuickToInterpreterBridge,
Ian Rogers13735952014-10-08 12:43:28 -0700275 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700276 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pQuickToInterpreterBridge,
Ian Rogers13735952014-10-08 12:43:28 -0700277 pInvokeDirectTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700278 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeDirectTrampolineWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700279 pInvokeInterfaceTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700280 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeInterfaceTrampolineWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700281 pInvokeStaticTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700282 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeStaticTrampolineWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700283 pInvokeSuperTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700284 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeSuperTrampolineWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700285 pInvokeVirtualTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700286 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeVirtualTrampolineWithAccessCheck,
Orion Hodsonac141392017-01-13 11:53:47 +0000287 pInvokePolymorphic, sizeof(void*));
288 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokePolymorphic,
Ian Rogers13735952014-10-08 12:43:28 -0700289 pTestSuspend, sizeof(void*));
290 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pTestSuspend, pDeliverException, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700291
Ian Rogers13735952014-10-08 12:43:28 -0700292 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pDeliverException, pThrowArrayBounds, sizeof(void*));
293 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowArrayBounds, pThrowDivZero, sizeof(void*));
Vladimir Marko05846472016-09-14 12:49:57 +0100294 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowDivZero, pThrowNullPointer, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -0700295 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowNullPointer, pThrowStackOverflow, sizeof(void*));
Vladimir Marko87f3fcb2016-04-28 15:52:11 +0100296 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowStackOverflow, pThrowStringBounds, sizeof(void*));
297 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowStringBounds, pDeoptimize, sizeof(void*));
Mingyao Yangd43b3ac2015-04-01 14:03:04 -0700298 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pDeoptimize, pA64Load, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -0700299 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pA64Load, pA64Store, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700300
Jeff Hao848f70a2014-01-15 13:49:50 -0800301 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pA64Store, pNewEmptyString, sizeof(void*));
302 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewEmptyString, pNewStringFromBytes_B, sizeof(void*));
303 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_B, pNewStringFromBytes_BI,
304 sizeof(void*));
305 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BI, pNewStringFromBytes_BII,
306 sizeof(void*));
307 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BII, pNewStringFromBytes_BIII,
308 sizeof(void*));
309 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BIII, pNewStringFromBytes_BIIString,
310 sizeof(void*));
311 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BIIString,
312 pNewStringFromBytes_BString, sizeof(void*));
313 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BString,
314 pNewStringFromBytes_BIICharset, sizeof(void*));
315 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BIICharset,
316 pNewStringFromBytes_BCharset, sizeof(void*));
317 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BCharset,
318 pNewStringFromChars_C, sizeof(void*));
319 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromChars_C, pNewStringFromChars_CII,
320 sizeof(void*));
321 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromChars_CII, pNewStringFromChars_IIC,
322 sizeof(void*));
323 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromChars_IIC, pNewStringFromCodePoints,
324 sizeof(void*));
325 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromCodePoints, pNewStringFromString,
326 sizeof(void*));
327 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromString, pNewStringFromStringBuffer,
328 sizeof(void*));
329 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromStringBuffer, pNewStringFromStringBuilder,
330 sizeof(void*));
Hiroshi Yamauchi1cc71eb2015-05-07 10:47:27 -0700331 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromStringBuilder, pReadBarrierJni,
332 sizeof(void*));
Roland Levillain02b75802016-07-13 11:54:35 +0100333 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierJni, pReadBarrierMarkReg00, sizeof(void*));
334 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg00, pReadBarrierMarkReg01,
335 sizeof(void*));
336 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg01, pReadBarrierMarkReg02,
337 sizeof(void*));
338 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg02, pReadBarrierMarkReg03,
339 sizeof(void*));
340 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg03, pReadBarrierMarkReg04,
341 sizeof(void*));
342 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg04, pReadBarrierMarkReg05,
343 sizeof(void*));
344 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg05, pReadBarrierMarkReg06,
345 sizeof(void*));
346 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg06, pReadBarrierMarkReg07,
347 sizeof(void*));
348 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg07, pReadBarrierMarkReg08,
349 sizeof(void*));
350 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg08, pReadBarrierMarkReg09,
351 sizeof(void*));
352 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg09, pReadBarrierMarkReg10,
353 sizeof(void*));
354 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg10, pReadBarrierMarkReg11,
355 sizeof(void*));
356 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg11, pReadBarrierMarkReg12,
357 sizeof(void*));
358 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg12, pReadBarrierMarkReg13,
359 sizeof(void*));
360 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg13, pReadBarrierMarkReg14,
361 sizeof(void*));
362 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg14, pReadBarrierMarkReg15,
363 sizeof(void*));
364 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg15, pReadBarrierMarkReg16,
365 sizeof(void*));
366 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg16, pReadBarrierMarkReg17,
367 sizeof(void*));
368 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg17, pReadBarrierMarkReg18,
369 sizeof(void*));
370 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg18, pReadBarrierMarkReg19,
371 sizeof(void*));
372 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg19, pReadBarrierMarkReg20,
373 sizeof(void*));
374 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg20, pReadBarrierMarkReg21,
375 sizeof(void*));
376 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg21, pReadBarrierMarkReg22,
377 sizeof(void*));
378 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg22, pReadBarrierMarkReg23,
379 sizeof(void*));
380 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg23, pReadBarrierMarkReg24,
381 sizeof(void*));
382 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg24, pReadBarrierMarkReg25,
383 sizeof(void*));
384 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg25, pReadBarrierMarkReg26,
385 sizeof(void*));
386 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg26, pReadBarrierMarkReg27,
387 sizeof(void*));
388 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg27, pReadBarrierMarkReg28,
389 sizeof(void*));
390 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg28, pReadBarrierMarkReg29,
391 sizeof(void*));
Roland Levillaind549c282016-07-25 12:49:15 +0100392 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierMarkReg29, pReadBarrierSlow, sizeof(void*));
Roland Levillain0d5a2812015-11-13 10:07:31 +0000393 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pReadBarrierSlow, pReadBarrierForRootSlow,
394 sizeof(void*));
Jeff Hao848f70a2014-01-15 13:49:50 -0800395
Roland Levillain0d5a2812015-11-13 10:07:31 +0000396 CHECKED(OFFSETOF_MEMBER(QuickEntryPoints, pReadBarrierForRootSlow)
Ian Rogers13735952014-10-08 12:43:28 -0700397 + sizeof(void*) == sizeof(QuickEntryPoints), QuickEntryPoints_all);
Andreas Gampe4352b452014-06-04 18:59:01 -0700398 }
399};
400
401TEST_F(EntrypointsOrderTest, ThreadOffsets) {
402 CheckThreadOffsets();
403}
404
Andreas Gampe4352b452014-06-04 18:59:01 -0700405TEST_F(EntrypointsOrderTest, JniEntryPoints) {
406 CheckJniEntryPoints();
407}
408
Andreas Gampe4352b452014-06-04 18:59:01 -0700409TEST_F(EntrypointsOrderTest, QuickEntryPoints) {
410 CheckQuickEntryPoints();
411}
412
413} // namespace art