blob: 0a5ebfa81bc4c97cae6c07e820114c1a9dba1cf3 [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
17#include <memory>
Dave Allison8ce6b902014-08-26 11:07:58 -070018#include <setjmp.h>
Andreas Gampe4352b452014-06-04 18:59:01 -070019
20#include "base/macros.h"
21#include "common_runtime_test.h"
22#include "thread.h"
23
24// This test checks the offsets of values in the thread TLS and entrypoint structures. A failure
25// of this test means that offsets have changed from the last update of the test. This indicates
26// that an oat version bump may be in order, and some defines should be carefully checked (or their
27// corresponding tests run).
28
29namespace art {
30
31// OFFSETOF_MEMBER uses reinterpret_cast. This means it is not a constexpr. So we cannot use
32// compile-time assertions. Once we find another way, adjust the define accordingly.
33#define CHECKED(expr, name) \
34 EXPECT_TRUE(expr) << #name
35
36// Macro to check whether two fields have an expected difference in offsets. The error is named
37// name.
38#define EXPECT_OFFSET_DIFF(first_type, first_field, second_type, second_field, diff, name) \
39 CHECKED(OFFSETOF_MEMBER(second_type, second_field) \
40 - OFFSETOF_MEMBER(first_type, first_field) == diff, name)
41
42// Helper macro for when the fields are from the same type.
43#define EXPECT_OFFSET_DIFFNP(type, first_field, second_field, diff) \
44 EXPECT_OFFSET_DIFF(type, first_field, type, second_field, diff, \
45 type ## _ ## first_field ## _ ## second_field)
46
47// Helper macro for when the fields are from the same type and in the same member of said type.
48#define EXPECT_OFFSET_DIFFP(type, prefix, first_field, second_field, diff) \
49 EXPECT_OFFSET_DIFF(type, prefix . first_field, type, prefix . second_field, diff, \
50 type ## _ ## prefix ## _ ## first_field ## _ ## second_field)
51
52// Macro to check whether two fields have at least an expected difference in offsets. The error is
53// named name.
54#define EXPECT_OFFSET_DIFF_GT(first_type, first_field, second_type, second_field, diff, name) \
55 CHECKED(OFFSETOF_MEMBER(second_type, second_field) \
56 - OFFSETOF_MEMBER(first_type, first_field) >= diff, name)
57
58// Helper macro for when the fields are from the same type.
59#define EXPECT_OFFSET_DIFF_GT3(type, first_field, second_field, diff, name) \
60 EXPECT_OFFSET_DIFF_GT(type, first_field, type, second_field, diff, name)
61
62class EntrypointsOrderTest : public CommonRuntimeTest {
63 protected:
64 void CheckThreadOffsets() {
65 CHECKED(OFFSETOF_MEMBER(Thread, tls32_.state_and_flags) == 0, thread_flags_at_zero);
66 EXPECT_OFFSET_DIFFP(Thread, tls32_, state_and_flags, suspend_count, 4);
67 EXPECT_OFFSET_DIFFP(Thread, tls32_, suspend_count, debug_suspend_count, 4);
68 EXPECT_OFFSET_DIFFP(Thread, tls32_, debug_suspend_count, thin_lock_thread_id, 4);
69 EXPECT_OFFSET_DIFFP(Thread, tls32_, thin_lock_thread_id, tid, 4);
70 EXPECT_OFFSET_DIFFP(Thread, tls32_, tid, daemon, 4);
71 EXPECT_OFFSET_DIFFP(Thread, tls32_, daemon, throwing_OutOfMemoryError, 4);
72 EXPECT_OFFSET_DIFFP(Thread, tls32_, throwing_OutOfMemoryError, no_thread_suspension, 4);
73 EXPECT_OFFSET_DIFFP(Thread, tls32_, no_thread_suspension, thread_exit_check_count, 4);
Nicolas Geoffray7642cfc2015-02-26 10:56:09 +000074 EXPECT_OFFSET_DIFFP(Thread, tls32_, thread_exit_check_count, handling_signal_, 4);
Mingyao Yang1f2d3ba2015-05-18 12:12:50 -070075 EXPECT_OFFSET_DIFFP(Thread, tls32_, handling_signal_,
76 deoptimization_return_value_is_reference, 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
82 EXPECT_OFFSET_DIFFP(Thread, tls64_, trace_clock_base, deoptimization_return_value, 8);
83 EXPECT_OFFSET_DIFFP(Thread, tls64_, deoptimization_return_value, stats, 8);
84
85 // TODO: Better connection. Take alignment into account.
86 EXPECT_OFFSET_DIFF_GT3(Thread, tls64_.stats, tlsPtr_.card_table, 8, thread_tls64_to_tlsptr);
87
Ian Rogers13735952014-10-08 12:43:28 -070088 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, card_table, exception, sizeof(void*));
89 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, exception, stack_end, sizeof(void*));
90 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, stack_end, managed_stack, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -070091 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, managed_stack, suspend_trigger, sizeof(ManagedStack));
Ian Rogers13735952014-10-08 12:43:28 -070092 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, suspend_trigger, jni_env, sizeof(void*));
Andreas Gampe449357d2015-06-01 22:29:51 -070093 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, jni_env, tmp_jni_env, sizeof(void*));
94 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, tmp_jni_env, self, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -070095 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, self, opeer, sizeof(void*));
96 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, opeer, jpeer, sizeof(void*));
97 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, jpeer, stack_begin, sizeof(void*));
98 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, stack_begin, stack_size, sizeof(void*));
Nicolas Geoffray14691c52015-03-05 10:40:17 +000099 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, stack_size, stack_trace_sample, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -0700100 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, stack_trace_sample, wait_next, sizeof(void*));
101 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, wait_next, monitor_enter_object, sizeof(void*));
102 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, monitor_enter_object, top_handle_scope, sizeof(void*));
103 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, top_handle_scope, class_loader_override, sizeof(void*));
104 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, class_loader_override, long_jump_context, sizeof(void*));
105 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, long_jump_context, instrumentation_stack, sizeof(void*));
106 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, instrumentation_stack, debug_invoke_req, sizeof(void*));
107 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, debug_invoke_req, single_step_control, sizeof(void*));
Mingyao Yang1f2d3ba2015-05-18 12:12:50 -0700108 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, single_step_control, stacked_shadow_frame_record,
Ian Rogers13735952014-10-08 12:43:28 -0700109 sizeof(void*));
Mingyao Yang1f2d3ba2015-05-18 12:12:50 -0700110 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, stacked_shadow_frame_record,
111 deoptimization_return_value_stack, sizeof(void*));
112 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, deoptimization_return_value_stack, name, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -0700113 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, name, pthread_self, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700114 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, pthread_self, last_no_thread_suspension_cause,
Ian Rogers13735952014-10-08 12:43:28 -0700115 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700116 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, last_no_thread_suspension_cause, checkpoint_functions,
Ian Rogers13735952014-10-08 12:43:28 -0700117 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700118 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, checkpoint_functions, interpreter_entrypoints,
Ian Rogers13735952014-10-08 12:43:28 -0700119 sizeof(void*) * 3);
Andreas Gampe4352b452014-06-04 18:59:01 -0700120
121 // Skip across the entrypoints structures.
122
Ian Rogers13735952014-10-08 12:43:28 -0700123 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*));
125 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_end, thread_local_objects, sizeof(void*));
126 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_objects, rosalloc_runs, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700127 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, rosalloc_runs, thread_local_alloc_stack_top,
Ian Rogers13735952014-10-08 12:43:28 -0700128 sizeof(void*) * kNumRosAllocThreadLocalSizeBrackets);
Andreas Gampe4352b452014-06-04 18:59:01 -0700129 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_alloc_stack_top, thread_local_alloc_stack_end,
Ian Rogers13735952014-10-08 12:43:28 -0700130 sizeof(void*));
131 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_alloc_stack_end, held_mutexes, sizeof(void*));
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800132 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, held_mutexes, nested_signal_state,
133 sizeof(void*) * kLockLevelCount);
134 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, nested_signal_state, flip_function, sizeof(void*));
Mathieu Chartier12d625f2015-03-13 11:33:37 -0700135 EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, flip_function, method_verifier, sizeof(void*));
136 EXPECT_OFFSET_DIFF(Thread, tlsPtr_.method_verifier, Thread, wait_mutex_, sizeof(void*),
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800137 thread_tlsptr_end);
Andreas Gampe4352b452014-06-04 18:59:01 -0700138 }
139
140 void CheckInterpreterEntryPoints() {
141 CHECKED(OFFSETOF_MEMBER(InterpreterEntryPoints, pInterpreterToInterpreterBridge) == 0,
142 InterpreterEntryPoints_start_with_i2i);
143 EXPECT_OFFSET_DIFFNP(InterpreterEntryPoints, pInterpreterToInterpreterBridge,
Ian Rogers13735952014-10-08 12:43:28 -0700144 pInterpreterToCompiledCodeBridge, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700145 CHECKED(OFFSETOF_MEMBER(InterpreterEntryPoints, pInterpreterToCompiledCodeBridge)
Ian Rogers13735952014-10-08 12:43:28 -0700146 + sizeof(void*) == sizeof(InterpreterEntryPoints), InterpreterEntryPoints_all);
Andreas Gampe4352b452014-06-04 18:59:01 -0700147 }
148
149 void CheckJniEntryPoints() {
150 CHECKED(OFFSETOF_MEMBER(JniEntryPoints, pDlsymLookup) == 0,
151 JniEntryPoints_start_with_dlsymlookup);
152 CHECKED(OFFSETOF_MEMBER(JniEntryPoints, pDlsymLookup)
Ian Rogers13735952014-10-08 12:43:28 -0700153 + sizeof(void*) == sizeof(JniEntryPoints), JniEntryPoints_all);
Andreas Gampe4352b452014-06-04 18:59:01 -0700154 }
155
Andreas Gampe4352b452014-06-04 18:59:01 -0700156 void CheckQuickEntryPoints() {
157 CHECKED(OFFSETOF_MEMBER(QuickEntryPoints, pAllocArray) == 0,
158 QuickEntryPoints_start_with_allocarray);
Ian Rogers13735952014-10-08 12:43:28 -0700159 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocArray, pAllocArrayResolved, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700160 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocArrayResolved, pAllocArrayWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700161 sizeof(void*));
162 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocArrayWithAccessCheck, pAllocObject, sizeof(void*));
163 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocObject, pAllocObjectResolved, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700164 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocObjectResolved, pAllocObjectInitialized,
Ian Rogers13735952014-10-08 12:43:28 -0700165 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700166 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocObjectInitialized, pAllocObjectWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700167 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700168 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocObjectWithAccessCheck, pCheckAndAllocArray,
Ian Rogers13735952014-10-08 12:43:28 -0700169 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700170 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCheckAndAllocArray, pCheckAndAllocArrayWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700171 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700172 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCheckAndAllocArrayWithAccessCheck,
Jeff Hao848f70a2014-01-15 13:49:50 -0800173 pAllocStringFromBytes, sizeof(void*));
174 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocStringFromBytes, pAllocStringFromChars,
175 sizeof(void*));
176 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocStringFromChars, pAllocStringFromString,
177 sizeof(void*));
178 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAllocStringFromString, pInstanceofNonTrivial,
179 sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -0700180 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInstanceofNonTrivial, pCheckCast, sizeof(void*));
181 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCheckCast, pInitializeStaticStorage, 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*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700211 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pGetObjStatic, pAputObjectWithNullAndBoundCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700212 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700213 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAputObjectWithNullAndBoundCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700214 pAputObjectWithBoundCheck, sizeof(void*));
215 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAputObjectWithBoundCheck, pAputObject, sizeof(void*));
216 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pAputObject, pHandleFillArrayData, sizeof(void*));
217 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pHandleFillArrayData, pJniMethodStart, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700218 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodStart, pJniMethodStartSynchronized,
Ian Rogers13735952014-10-08 12:43:28 -0700219 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700220 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodStartSynchronized, pJniMethodEnd,
Ian Rogers13735952014-10-08 12:43:28 -0700221 sizeof(void*));
222 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodEnd, pJniMethodEndSynchronized, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700223 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodEndSynchronized, pJniMethodEndWithReference,
Ian Rogers13735952014-10-08 12:43:28 -0700224 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700225 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pJniMethodEndWithReference,
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*));
235 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pCmplFloat, pFmod, sizeof(void*));
236 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pFmod, pL2d, sizeof(void*));
237 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pL2d, pFmodf, sizeof(void*));
238 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pFmodf, pL2f, sizeof(void*));
239 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pL2f, pD2iz, sizeof(void*));
240 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pD2iz, pF2iz, sizeof(void*));
241 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pF2iz, pIdivmod, sizeof(void*));
242 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pIdivmod, pD2l, sizeof(void*));
243 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pD2l, pF2l, sizeof(void*));
244 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pF2l, pLdiv, sizeof(void*));
245 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pLdiv, pLmod, sizeof(void*));
246 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pLmod, pLmul, sizeof(void*));
247 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pLmul, pShlLong, sizeof(void*));
248 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pShlLong, pShrLong, sizeof(void*));
249 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pShrLong, pUshrLong, sizeof(void*));
250 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pUshrLong, pIndexOf, sizeof(void*));
251 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pIndexOf, pStringCompareTo, sizeof(void*));
252 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pStringCompareTo, pMemcpy, sizeof(void*));
253 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pMemcpy, pQuickImtConflictTrampoline, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700254 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pQuickImtConflictTrampoline, pQuickResolutionTrampoline,
Ian Rogers13735952014-10-08 12:43:28 -0700255 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700256 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pQuickResolutionTrampoline, pQuickToInterpreterBridge,
Ian Rogers13735952014-10-08 12:43:28 -0700257 sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700258 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pQuickToInterpreterBridge,
Ian Rogers13735952014-10-08 12:43:28 -0700259 pInvokeDirectTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700260 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeDirectTrampolineWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700261 pInvokeInterfaceTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700262 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeInterfaceTrampolineWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700263 pInvokeStaticTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700264 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeStaticTrampolineWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700265 pInvokeSuperTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700266 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeSuperTrampolineWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700267 pInvokeVirtualTrampolineWithAccessCheck, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700268 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pInvokeVirtualTrampolineWithAccessCheck,
Ian Rogers13735952014-10-08 12:43:28 -0700269 pTestSuspend, sizeof(void*));
270 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pTestSuspend, pDeliverException, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700271
Ian Rogers13735952014-10-08 12:43:28 -0700272 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pDeliverException, pThrowArrayBounds, sizeof(void*));
273 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowArrayBounds, pThrowDivZero, sizeof(void*));
274 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowDivZero, pThrowNoSuchMethod, sizeof(void*));
275 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowNoSuchMethod, pThrowNullPointer, sizeof(void*));
276 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowNullPointer, pThrowStackOverflow, sizeof(void*));
Mingyao Yangd43b3ac2015-04-01 14:03:04 -0700277 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pThrowStackOverflow, pDeoptimize, sizeof(void*));
278 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pDeoptimize, pA64Load, sizeof(void*));
Ian Rogers13735952014-10-08 12:43:28 -0700279 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pA64Load, pA64Store, sizeof(void*));
Andreas Gampe4352b452014-06-04 18:59:01 -0700280
Jeff Hao848f70a2014-01-15 13:49:50 -0800281 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pA64Store, pNewEmptyString, sizeof(void*));
282 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewEmptyString, pNewStringFromBytes_B, sizeof(void*));
283 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_B, pNewStringFromBytes_BI,
284 sizeof(void*));
285 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BI, pNewStringFromBytes_BII,
286 sizeof(void*));
287 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BII, pNewStringFromBytes_BIII,
288 sizeof(void*));
289 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BIII, pNewStringFromBytes_BIIString,
290 sizeof(void*));
291 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BIIString,
292 pNewStringFromBytes_BString, sizeof(void*));
293 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BString,
294 pNewStringFromBytes_BIICharset, sizeof(void*));
295 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BIICharset,
296 pNewStringFromBytes_BCharset, sizeof(void*));
297 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromBytes_BCharset,
298 pNewStringFromChars_C, sizeof(void*));
299 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromChars_C, pNewStringFromChars_CII,
300 sizeof(void*));
301 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromChars_CII, pNewStringFromChars_IIC,
302 sizeof(void*));
303 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromChars_IIC, pNewStringFromCodePoints,
304 sizeof(void*));
305 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromCodePoints, pNewStringFromString,
306 sizeof(void*));
307 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromString, pNewStringFromStringBuffer,
308 sizeof(void*));
309 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromStringBuffer, pNewStringFromStringBuilder,
310 sizeof(void*));
Hiroshi Yamauchi1cc71eb2015-05-07 10:47:27 -0700311 EXPECT_OFFSET_DIFFNP(QuickEntryPoints, pNewStringFromStringBuilder, pReadBarrierJni,
312 sizeof(void*));
Jeff Hao848f70a2014-01-15 13:49:50 -0800313
Hiroshi Yamauchi1cc71eb2015-05-07 10:47:27 -0700314 CHECKED(OFFSETOF_MEMBER(QuickEntryPoints, pReadBarrierJni)
Ian Rogers13735952014-10-08 12:43:28 -0700315 + sizeof(void*) == sizeof(QuickEntryPoints), QuickEntryPoints_all);
Andreas Gampe4352b452014-06-04 18:59:01 -0700316 }
317};
318
319TEST_F(EntrypointsOrderTest, ThreadOffsets) {
320 CheckThreadOffsets();
321}
322
323TEST_F(EntrypointsOrderTest, InterpreterEntryPoints) {
324 CheckInterpreterEntryPoints();
325}
326
327TEST_F(EntrypointsOrderTest, JniEntryPoints) {
328 CheckJniEntryPoints();
329}
330
Andreas Gampe4352b452014-06-04 18:59:01 -0700331TEST_F(EntrypointsOrderTest, QuickEntryPoints) {
332 CheckQuickEntryPoints();
333}
334
335} // namespace art