Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp
32285 views
1
/*
2
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
/*
26
* This is to provide sanity check in jhelper.d which compares SCCS
27
* versions of generateJvmOffsets.cpp used to create and extract
28
* contents of __JvmOffsets[] table.
29
* The __JvmOffsets[] table is located in generated JvmOffsets.cpp.
30
*
31
* GENOFFS_SCCS_VER 34
32
*/
33
34
#include "generateJvmOffsets.h"
35
36
/* A workaround for private and protected fields */
37
#define private public
38
#define protected public
39
40
#include <proc_service.h>
41
#include "code/codeBlob.hpp"
42
#include "code/nmethod.hpp"
43
#include "code/pcDesc.hpp"
44
#include "gc_interface/collectedHeap.hpp"
45
#include "memory/heap.hpp"
46
#include "memory/memRegion.hpp"
47
#include "memory/universe.hpp"
48
#include "oops/constMethod.hpp"
49
#include "oops/klass.hpp"
50
#include "oops/method.hpp"
51
#include "oops/oop.hpp"
52
#include "oops/symbol.hpp"
53
#include "runtime/virtualspace.hpp"
54
#include "runtime/vmStructs.hpp"
55
#include "utilities/accessFlags.hpp"
56
#include "utilities/globalDefinitions.hpp"
57
#ifdef COMPILER1
58
#ifdef ASSERT
59
60
/*
61
* To avoid the most part of potential link errors
62
* we link this program with -z nodefs .
63
*
64
* But for 'debug1' and 'fastdebug1' we still have to provide
65
* a particular workaround for the following symbols below.
66
* It will be good to find out a generic way in the future.
67
*/
68
69
#pragma weak tty
70
#pragma weak CMSExpAvgFactor
71
72
#if defined(i386) || defined(__i386) || defined(__amd64)
73
#pragma weak noreg
74
#endif /* i386 */
75
76
LIR_Opr LIR_OprFact::illegalOpr = (LIR_Opr) 0;
77
78
address StubRoutines::_call_stub_return_address = NULL;
79
80
StubQueue* AbstractInterpreter::_code = NULL;
81
82
#endif /* ASSERT */
83
#endif /* COMPILER1 */
84
85
#define GEN_OFFS(Type,Name) \
86
switch(gen_variant) { \
87
case GEN_OFFSET: \
88
printf("#define OFFSET_%-33s %d\n", \
89
#Type #Name, offset_of(Type, Name)); \
90
break; \
91
case GEN_INDEX: \
92
printf("#define IDX_OFFSET_%-33s %d\n", \
93
#Type #Name, index++); \
94
break; \
95
case GEN_TABLE: \
96
printf("\tOFFSET_%s,\n", #Type #Name); \
97
break; \
98
}
99
100
#define GEN_SIZE(Type) \
101
switch(gen_variant) { \
102
case GEN_OFFSET: \
103
printf("#define SIZE_%-35s %d\n", \
104
#Type, sizeof(Type)); \
105
break; \
106
case GEN_INDEX: \
107
printf("#define IDX_SIZE_%-35s %d\n", \
108
#Type, index++); \
109
break; \
110
case GEN_TABLE: \
111
printf("\tSIZE_%s,\n", #Type); \
112
break; \
113
}
114
115
#define GEN_VALUE(String,Value) \
116
switch(gen_variant) { \
117
case GEN_OFFSET: \
118
printf("#define %-40s %d\n", #String, Value); \
119
break; \
120
case GEN_INDEX: \
121
printf("#define IDX_%-40s %d\n", #String, index++); \
122
break; \
123
case GEN_TABLE: \
124
printf("\t" #String ",\n"); \
125
break; \
126
}
127
128
void gen_prologue(GEN_variant gen_variant) {
129
const char *suffix;
130
131
switch(gen_variant) {
132
case GEN_OFFSET: suffix = ".h"; break;
133
case GEN_INDEX: suffix = "Index.h"; break;
134
case GEN_TABLE: suffix = ".cpp"; break;
135
}
136
137
printf("/*\n");
138
printf(" * JvmOffsets%s !!!DO NOT EDIT!!! \n", suffix);
139
printf(" * The generateJvmOffsets program generates this file!\n");
140
printf(" */\n\n");
141
switch(gen_variant) {
142
143
case GEN_OFFSET:
144
case GEN_INDEX:
145
break;
146
147
case GEN_TABLE:
148
printf("#include \"JvmOffsets.h\"\n");
149
printf("\n");
150
printf("int __JvmOffsets[] = {\n");
151
break;
152
}
153
}
154
155
void gen_epilogue(GEN_variant gen_variant) {
156
if (gen_variant != GEN_TABLE) {
157
return;
158
}
159
printf("};\n\n");
160
return;
161
}
162
163
int generateJvmOffsets(GEN_variant gen_variant) {
164
int index = 0; /* It is used to generate JvmOffsetsIndex.h */
165
int pointer_size = sizeof(void *);
166
int data_model = (pointer_size == 4) ? PR_MODEL_ILP32 : PR_MODEL_LP64;
167
168
gen_prologue(gen_variant);
169
170
GEN_VALUE(DATA_MODEL, data_model);
171
GEN_VALUE(POINTER_SIZE, pointer_size);
172
#if defined(TIERED)
173
GEN_VALUE(COMPILER, 3);
174
#elif COMPILER1
175
GEN_VALUE(COMPILER, 1);
176
#elif COMPILER2
177
GEN_VALUE(COMPILER, 2);
178
#else
179
GEN_VALUE(COMPILER, 0);
180
#endif // COMPILER1 && COMPILER2
181
printf("\n");
182
183
GEN_OFFS(CollectedHeap, _reserved);
184
GEN_OFFS(MemRegion, _start);
185
GEN_OFFS(MemRegion, _word_size);
186
GEN_SIZE(HeapWord);
187
printf("\n");
188
189
GEN_OFFS(VMStructEntry, typeName);
190
GEN_OFFS(VMStructEntry, fieldName);
191
GEN_OFFS(VMStructEntry, address);
192
GEN_SIZE(VMStructEntry);
193
printf("\n");
194
195
GEN_VALUE(MAX_METHOD_CODE_SIZE, max_method_code_size);
196
#if defined(sparc) || defined(__sparc)
197
GEN_VALUE(OFFSET_interpreter_frame_method, 2 * pointer_size); /* L2 in saved window */
198
GEN_VALUE(OFFSET_interpreter_frame_sender_sp, 13 * pointer_size); /* I5 in saved window */
199
// Fake value for consistency. It is not going to be used.
200
GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, 0xFFFF);
201
#elif defined(i386) || defined(__i386) || defined(__amd64)
202
GEN_VALUE(OFFSET_interpreter_frame_sender_sp, -1 * pointer_size);
203
GEN_VALUE(OFFSET_interpreter_frame_method, -3 * pointer_size);
204
GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, -7 * pointer_size);
205
#endif
206
207
GEN_OFFS(Klass, _name);
208
GEN_OFFS(ConstantPool, _pool_holder);
209
printf("\n");
210
211
GEN_VALUE(OFFSET_HeapBlockHeader_used, offset_of(HeapBlock::Header, _used));
212
GEN_OFFS(oopDesc, _metadata);
213
printf("\n");
214
215
GEN_VALUE(AccessFlags_NATIVE, JVM_ACC_NATIVE);
216
GEN_VALUE(ConstMethod_has_linenumber_table, ConstMethod::_has_linenumber_table);
217
GEN_OFFS(AccessFlags, _flags);
218
GEN_OFFS(Symbol, _length);
219
GEN_OFFS(Symbol, _body);
220
printf("\n");
221
222
GEN_OFFS(Method, _constMethod);
223
GEN_OFFS(Method, _access_flags);
224
printf("\n");
225
226
GEN_OFFS(ConstMethod, _constants);
227
GEN_OFFS(ConstMethod, _flags);
228
GEN_OFFS(ConstMethod, _code_size);
229
GEN_OFFS(ConstMethod, _name_index);
230
GEN_OFFS(ConstMethod, _signature_index);
231
printf("\n");
232
233
GEN_OFFS(CodeHeap, _memory);
234
GEN_OFFS(CodeHeap, _segmap);
235
GEN_OFFS(CodeHeap, _log2_segment_size);
236
printf("\n");
237
238
GEN_OFFS(VirtualSpace, _low_boundary);
239
GEN_OFFS(VirtualSpace, _high_boundary);
240
GEN_OFFS(VirtualSpace, _low);
241
GEN_OFFS(VirtualSpace, _high);
242
printf("\n");
243
244
GEN_OFFS(CodeBlob, _name);
245
GEN_OFFS(CodeBlob, _header_size);
246
GEN_OFFS(CodeBlob, _content_offset);
247
GEN_OFFS(CodeBlob, _code_offset);
248
GEN_OFFS(CodeBlob, _data_offset);
249
GEN_OFFS(CodeBlob, _frame_size);
250
printf("\n");
251
252
GEN_OFFS(nmethod, _method);
253
GEN_OFFS(nmethod, _metadata_offset);
254
GEN_OFFS(nmethod, _scopes_data_offset);
255
GEN_OFFS(nmethod, _scopes_pcs_offset);
256
GEN_OFFS(nmethod, _handler_table_offset);
257
GEN_OFFS(nmethod, _deoptimize_offset);
258
GEN_OFFS(nmethod, _orig_pc_offset);
259
260
GEN_OFFS(PcDesc, _pc_offset);
261
GEN_OFFS(PcDesc, _scope_decode_offset);
262
263
printf("\n");
264
265
GEN_OFFS(NarrowPtrStruct, _base);
266
GEN_OFFS(NarrowPtrStruct, _shift);
267
printf("\n");
268
269
GEN_VALUE(SIZE_HeapBlockHeader, sizeof(HeapBlock::Header));
270
GEN_SIZE(oopDesc);
271
GEN_SIZE(ConstantPool);
272
printf("\n");
273
274
GEN_SIZE(PcDesc);
275
GEN_SIZE(Method);
276
GEN_SIZE(ConstMethod);
277
GEN_SIZE(nmethod);
278
GEN_SIZE(CodeBlob);
279
GEN_SIZE(BufferBlob);
280
GEN_SIZE(SingletonBlob);
281
GEN_SIZE(RuntimeStub);
282
GEN_SIZE(SafepointBlob);
283
284
gen_epilogue(gen_variant);
285
printf("\n");
286
287
fflush(stdout);
288
return 0;
289
}
290
291