src/os/bsd/dtrace/generateJvmOffsets.cpp

Fri, 12 Apr 2013 15:53:30 -0700

author
drchase
date
Fri, 12 Apr 2013 15:53:30 -0700
changeset 4942
f36e073d56a4
parent 4159
8e47bac5643a
child 6876
710a3c8b516e
permissions
-rw-r--r--

7104565: trim jprt build targets
Summary: remove JPRT debug builds, remove -DDEBUG -DFASTDEBUG and use ASSERT instead in sources
Reviewed-by: dholmes, kvn, coleenp

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

mercurial