comparison src/os/bsd/dtrace/generateJvmOffsets.cpp @ 4006:436b4a3231bf

7098194: integrate macosx-port changes Summary: Integrate bsd-port/hotspot and macosx-port/hotspot changes as of 2011.09.29. Reviewed-by: kvn, dholmes, never, phh Contributed-by: Christos Zoulas <christos@zoulas.com>, Greg Lewis <glewis@eyesbeyond.com>, Kurt Miller <kurt@intricatesoftware.com>, Alexander Strange <astrange@apple.com>, Mike Swingler <swingler@apple.com>, Roger Hoover <rhoover@apple.com>, Victor Hernandez <vhernandez@apple.com>, Pratik Solanki <psolanki@apple.com>
author dcubed
date Thu, 13 Oct 2011 09:35:42 -0700
parents
children da91efe96a93
comparison
equal deleted inserted replaced
4005:2ef3386478e6 4006:436b4a3231bf
1 /*
2 * Copyright (c) 2003, 2011, 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 // not on macosx #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/constMethodOop.hpp"
49 #include "oops/klass.hpp"
50 #include "oops/methodOop.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
58 // These are defined somewhere for Solaris
59 #define PR_MODEL_ILP32 1
60 #define PR_MODEL_LP64 2
61
62 #ifdef COMPILER1
63 #if defined(DEBUG) || defined(FASTDEBUG)
64
65 /*
66 * To avoid the most part of potential link errors
67 * we link this program with -z nodefs .
68 *
69 * But for 'debug1' and 'fastdebug1' we still have to provide
70 * a particular workaround for the following symbols bellow.
71 * It will be good to find out a generic way in the future.
72 */
73
74 #pragma weak tty
75 #pragma weak CMSExpAvgFactor
76
77 #if defined(i386) || defined(__i386) || defined(__amd64)
78 #pragma weak noreg
79 #endif /* i386 */
80
81 LIR_Opr LIR_OprFact::illegalOpr = (LIR_Opr) 0;
82
83 address StubRoutines::_call_stub_return_address = NULL;
84
85 StubQueue* AbstractInterpreter::_code = NULL;
86
87 #endif /* defined(DEBUG) || defined(FASTDEBUG) */
88 #endif /* COMPILER1 */
89
90 #define GEN_OFFS(Type,Name) \
91 switch(gen_variant) { \
92 case GEN_OFFSET: \
93 printf("#define OFFSET_%-33s %ld\n", \
94 #Type #Name, offset_of(Type, Name)); \
95 break; \
96 case GEN_INDEX: \
97 printf("#define IDX_OFFSET_%-33s %d\n", \
98 #Type #Name, index++); \
99 break; \
100 case GEN_TABLE: \
101 printf("\tOFFSET_%s,\n", #Type #Name); \
102 break; \
103 }
104
105 #define GEN_SIZE(Type) \
106 switch(gen_variant) { \
107 case GEN_OFFSET: \
108 printf("#define SIZE_%-35s %ld\n", \
109 #Type, sizeof(Type)); \
110 break; \
111 case GEN_INDEX: \
112 printf("#define IDX_SIZE_%-35s %d\n", \
113 #Type, index++); \
114 break; \
115 case GEN_TABLE: \
116 printf("\tSIZE_%s,\n", #Type); \
117 break; \
118 }
119
120 #define GEN_VALUE(String,Value) \
121 switch(gen_variant) { \
122 case GEN_OFFSET: \
123 printf("#define %-40s %d\n", #String, Value); \
124 break; \
125 case GEN_INDEX: \
126 printf("#define IDX_%-40s %d\n", #String, index++); \
127 break; \
128 case GEN_TABLE: \
129 printf("\t" #String ",\n"); \
130 break; \
131 }
132
133 void gen_prologue(GEN_variant gen_variant) {
134 const char *suffix;
135
136 switch(gen_variant) {
137 case GEN_OFFSET: suffix = ".h"; break;
138 case GEN_INDEX: suffix = "Index.h"; break;
139 case GEN_TABLE: suffix = ".cpp"; break;
140 }
141
142 printf("/*\n");
143 printf(" * JvmOffsets%s !!!DO NOT EDIT!!! \n", suffix);
144 printf(" * The generateJvmOffsets program generates this file!\n");
145 printf(" */\n\n");
146 switch(gen_variant) {
147
148 case GEN_OFFSET:
149 case GEN_INDEX:
150 break;
151
152 case GEN_TABLE:
153 printf("#include \"JvmOffsets.h\"\n");
154 printf("\n");
155 printf("int __JvmOffsets[] = {\n");
156 break;
157 }
158 }
159
160 void gen_epilogue(GEN_variant gen_variant) {
161 if (gen_variant != GEN_TABLE) {
162 return;
163 }
164 printf("};\n\n");
165 return;
166 }
167
168 int generateJvmOffsets(GEN_variant gen_variant) {
169 int index = 0; /* It is used to generate JvmOffsetsIndex.h */
170 int pointer_size = sizeof(void *);
171 int data_model = (pointer_size == 4) ? PR_MODEL_ILP32 : PR_MODEL_LP64;
172
173 gen_prologue(gen_variant);
174
175 GEN_VALUE(DATA_MODEL, data_model);
176 GEN_VALUE(POINTER_SIZE, pointer_size);
177 #if defined(TIERED)
178 GEN_VALUE(COMPILER, 3);
179 #elif COMPILER1
180 GEN_VALUE(COMPILER, 1);
181 #elif COMPILER2
182 GEN_VALUE(COMPILER, 2);
183 #else
184 GEN_VALUE(COMPILER, 0);
185 #endif // COMPILER1 && COMPILER2
186 printf("\n");
187
188 GEN_OFFS(CollectedHeap, _reserved);
189 GEN_OFFS(MemRegion, _start);
190 GEN_OFFS(MemRegion, _word_size);
191 GEN_SIZE(HeapWord);
192 printf("\n");
193
194 GEN_OFFS(VMStructEntry, typeName);
195 GEN_OFFS(VMStructEntry, fieldName);
196 GEN_OFFS(VMStructEntry, address);
197 GEN_SIZE(VMStructEntry);
198 printf("\n");
199
200 GEN_VALUE(MAX_METHOD_CODE_SIZE, max_method_code_size);
201 #if defined(sparc) || defined(__sparc)
202 GEN_VALUE(OFFSET_interpreter_frame_method, 2 * pointer_size); /* L2 in saved window */
203 GEN_VALUE(OFFSET_interpreter_frame_sender_sp, 13 * pointer_size); /* I5 in saved window */
204 // Fake value for consistency. It is not going to be used.
205 GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, 0xFFFF);
206 #elif defined(i386) || defined(__i386) || defined(__amd64)
207 GEN_VALUE(OFFSET_interpreter_frame_sender_sp, -1 * pointer_size);
208 GEN_VALUE(OFFSET_interpreter_frame_method, -3 * pointer_size);
209 GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, -7 * pointer_size);
210 #endif
211
212 GEN_OFFS(Klass, _name);
213 GEN_OFFS(constantPoolOopDesc, _pool_holder);
214 printf("\n");
215
216 GEN_VALUE(OFFSET_HeapBlockHeader_used, (int) offset_of(HeapBlock::Header, _used));
217 GEN_OFFS(oopDesc, _metadata);
218 printf("\n");
219
220 GEN_VALUE(AccessFlags_NATIVE, JVM_ACC_NATIVE);
221 GEN_VALUE(constMethodOopDesc_has_linenumber_table, constMethodOopDesc::_has_linenumber_table);
222 GEN_OFFS(AccessFlags, _flags);
223 GEN_OFFS(Symbol, _length);
224 GEN_OFFS(Symbol, _body);
225 printf("\n");
226
227 GEN_OFFS(methodOopDesc, _constMethod);
228 GEN_OFFS(methodOopDesc, _constants);
229 GEN_OFFS(methodOopDesc, _access_flags);
230 printf("\n");
231
232 GEN_OFFS(constMethodOopDesc, _flags);
233 GEN_OFFS(constMethodOopDesc, _code_size);
234 GEN_OFFS(constMethodOopDesc, _name_index);
235 GEN_OFFS(constMethodOopDesc, _signature_index);
236 printf("\n");
237
238 GEN_OFFS(CodeHeap, _memory);
239 GEN_OFFS(CodeHeap, _segmap);
240 GEN_OFFS(CodeHeap, _log2_segment_size);
241 printf("\n");
242
243 GEN_OFFS(VirtualSpace, _low_boundary);
244 GEN_OFFS(VirtualSpace, _high_boundary);
245 GEN_OFFS(VirtualSpace, _low);
246 GEN_OFFS(VirtualSpace, _high);
247 printf("\n");
248
249 GEN_OFFS(CodeBlob, _name);
250 GEN_OFFS(CodeBlob, _header_size);
251 GEN_OFFS(CodeBlob, _content_offset);
252 GEN_OFFS(CodeBlob, _code_offset);
253 GEN_OFFS(CodeBlob, _data_offset);
254 GEN_OFFS(CodeBlob, _frame_size);
255 printf("\n");
256
257 GEN_OFFS(nmethod, _method);
258 GEN_OFFS(nmethod, _oops_offset);
259 GEN_OFFS(nmethod, _scopes_data_offset);
260 GEN_OFFS(nmethod, _scopes_pcs_offset);
261 GEN_OFFS(nmethod, _handler_table_offset);
262 GEN_OFFS(nmethod, _deoptimize_offset);
263 GEN_OFFS(nmethod, _orig_pc_offset);
264
265 GEN_OFFS(PcDesc, _pc_offset);
266 GEN_OFFS(PcDesc, _scope_decode_offset);
267
268 printf("\n");
269
270 GEN_OFFS(NarrowOopStruct, _base);
271 GEN_OFFS(NarrowOopStruct, _shift);
272 printf("\n");
273
274 GEN_VALUE(SIZE_HeapBlockHeader, (int) sizeof(HeapBlock::Header));
275 GEN_SIZE(oopDesc);
276 GEN_SIZE(constantPoolOopDesc);
277 printf("\n");
278
279 GEN_SIZE(PcDesc);
280 GEN_SIZE(methodOopDesc);
281 GEN_SIZE(constMethodOopDesc);
282 GEN_SIZE(nmethod);
283 GEN_SIZE(CodeBlob);
284 GEN_SIZE(BufferBlob);
285 GEN_SIZE(SingletonBlob);
286 GEN_SIZE(RuntimeStub);
287 GEN_SIZE(SafepointBlob);
288
289 gen_epilogue(gen_variant);
290 printf("\n");
291
292 fflush(stdout);
293 return 0;
294 }