Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp
32285 views
/*1* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324/*25* This is to provide sanity check in jhelper.d which compares SCCS26* versions of generateJvmOffsets.cpp used to create and extract27* contents of __JvmOffsets[] table.28* The __JvmOffsets[] table is located in generated JvmOffsets.cpp.29*30* GENOFFS_SCCS_VER 3431*/3233#include "generateJvmOffsets.h"3435/* A workaround for private and protected fields */36#define private public37#define protected public3839// not on macosx #include <proc_service.h>40#include "code/codeBlob.hpp"41#include "code/nmethod.hpp"42#include "code/pcDesc.hpp"43#include "gc_interface/collectedHeap.hpp"44#include "memory/heap.hpp"45#include "memory/memRegion.hpp"46#include "memory/universe.hpp"47#include "oops/constMethod.hpp"48#include "oops/klass.hpp"49#include "oops/method.hpp"50#include "oops/oop.hpp"51#include "oops/symbol.hpp"52#include "runtime/virtualspace.hpp"53#include "runtime/vmStructs.hpp"54#include "utilities/accessFlags.hpp"55#include "utilities/globalDefinitions.hpp"5657// These are defined somewhere for Solaris58#define PR_MODEL_ILP32 159#define PR_MODEL_LP64 26061#ifdef COMPILER162#ifdef ASSERT6364/*65* To avoid the most part of potential link errors66* we link this program with -z nodefs .67*68* But for 'debug1' and 'fastdebug1' we still have to provide69* a particular workaround for the following symbols bellow.70* It will be good to find out a generic way in the future.71*/7273#pragma weak tty74#pragma weak CMSExpAvgFactor7576#if defined(i386) || defined(__i386) || defined(__amd64)77#pragma weak noreg78#endif /* i386 */7980LIR_Opr LIR_OprFact::illegalOpr = (LIR_Opr) 0;8182address StubRoutines::_call_stub_return_address = NULL;8384StubQueue* AbstractInterpreter::_code = NULL;8586#endif /* ASSERT */87#endif /* COMPILER1 */8889#define GEN_OFFS(Type,Name) \90switch(gen_variant) { \91case GEN_OFFSET: \92printf("#define OFFSET_%-33s %ld\n", \93#Type #Name, offset_of(Type, Name)); \94break; \95case GEN_INDEX: \96printf("#define IDX_OFFSET_%-33s %d\n", \97#Type #Name, index++); \98break; \99case GEN_TABLE: \100printf("\tOFFSET_%s,\n", #Type #Name); \101break; \102}103104#define GEN_SIZE(Type) \105switch(gen_variant) { \106case GEN_OFFSET: \107printf("#define SIZE_%-35s %ld\n", \108#Type, sizeof(Type)); \109break; \110case GEN_INDEX: \111printf("#define IDX_SIZE_%-35s %d\n", \112#Type, index++); \113break; \114case GEN_TABLE: \115printf("\tSIZE_%s,\n", #Type); \116break; \117}118119#define GEN_VALUE(String,Value) \120switch(gen_variant) { \121case GEN_OFFSET: \122printf("#define %-40s %d\n", #String, Value); \123break; \124case GEN_INDEX: \125printf("#define IDX_%-40s %d\n", #String, index++); \126break; \127case GEN_TABLE: \128printf("\t" #String ",\n"); \129break; \130}131132void gen_prologue(GEN_variant gen_variant) {133const char *suffix;134135switch(gen_variant) {136case GEN_OFFSET: suffix = ".h"; break;137case GEN_INDEX: suffix = "Index.h"; break;138case GEN_TABLE: suffix = ".cpp"; break;139}140141printf("/*\n");142printf(" * JvmOffsets%s !!!DO NOT EDIT!!! \n", suffix);143printf(" * The generateJvmOffsets program generates this file!\n");144printf(" */\n\n");145switch(gen_variant) {146147case GEN_OFFSET:148case GEN_INDEX:149break;150151case GEN_TABLE:152printf("#include \"JvmOffsets.h\"\n");153printf("\n");154printf("int __JvmOffsets[] = {\n");155break;156}157}158159void gen_epilogue(GEN_variant gen_variant) {160if (gen_variant != GEN_TABLE) {161return;162}163printf("};\n\n");164return;165}166167int generateJvmOffsets(GEN_variant gen_variant) {168int index = 0; /* It is used to generate JvmOffsetsIndex.h */169int pointer_size = sizeof(void *);170int data_model = (pointer_size == 4) ? PR_MODEL_ILP32 : PR_MODEL_LP64;171172gen_prologue(gen_variant);173174GEN_VALUE(DATA_MODEL, data_model);175GEN_VALUE(POINTER_SIZE, pointer_size);176#if defined(TIERED)177GEN_VALUE(COMPILER, 3);178#elif COMPILER1179GEN_VALUE(COMPILER, 1);180#elif COMPILER2181GEN_VALUE(COMPILER, 2);182#else183GEN_VALUE(COMPILER, 0);184#endif // COMPILER1 && COMPILER2185printf("\n");186187GEN_OFFS(CollectedHeap, _reserved);188GEN_OFFS(MemRegion, _start);189GEN_OFFS(MemRegion, _word_size);190GEN_SIZE(HeapWord);191printf("\n");192193GEN_OFFS(VMStructEntry, typeName);194GEN_OFFS(VMStructEntry, fieldName);195GEN_OFFS(VMStructEntry, address);196GEN_SIZE(VMStructEntry);197printf("\n");198199GEN_VALUE(MAX_METHOD_CODE_SIZE, max_method_code_size);200#if defined(sparc) || defined(__sparc)201GEN_VALUE(OFFSET_interpreter_frame_method, 2 * pointer_size); /* L2 in saved window */202GEN_VALUE(OFFSET_interpreter_frame_sender_sp, 13 * pointer_size); /* I5 in saved window */203// Fake value for consistency. It is not going to be used.204GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, 0xFFFF);205#elif defined(i386) || defined(__i386) || defined(__amd64)206GEN_VALUE(OFFSET_interpreter_frame_sender_sp, -1 * pointer_size);207GEN_VALUE(OFFSET_interpreter_frame_method, -3 * pointer_size);208GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, -7 * pointer_size);209#endif210211GEN_OFFS(Klass, _name);212GEN_OFFS(ConstantPool, _pool_holder);213printf("\n");214215GEN_VALUE(OFFSET_HeapBlockHeader_used, (int) offset_of(HeapBlock::Header, _used));216GEN_OFFS(oopDesc, _metadata);217printf("\n");218219GEN_VALUE(AccessFlags_NATIVE, JVM_ACC_NATIVE);220GEN_VALUE(ConstMethod_has_linenumber_table, ConstMethod::_has_linenumber_table);221GEN_OFFS(AccessFlags, _flags);222GEN_OFFS(Symbol, _length);223GEN_OFFS(Symbol, _body);224printf("\n");225226GEN_OFFS(Method, _constMethod);227GEN_OFFS(Method, _constants);228GEN_OFFS(Method, _access_flags);229printf("\n");230231GEN_OFFS(ConstMethod, _flags);232GEN_OFFS(ConstMethod, _code_size);233GEN_OFFS(ConstMethod, _name_index);234GEN_OFFS(ConstMethod, _signature_index);235printf("\n");236237GEN_OFFS(CodeHeap, _memory);238GEN_OFFS(CodeHeap, _segmap);239GEN_OFFS(CodeHeap, _log2_segment_size);240printf("\n");241242GEN_OFFS(VirtualSpace, _low_boundary);243GEN_OFFS(VirtualSpace, _high_boundary);244GEN_OFFS(VirtualSpace, _low);245GEN_OFFS(VirtualSpace, _high);246printf("\n");247248GEN_OFFS(CodeBlob, _name);249GEN_OFFS(CodeBlob, _header_size);250GEN_OFFS(CodeBlob, _content_offset);251GEN_OFFS(CodeBlob, _code_offset);252GEN_OFFS(CodeBlob, _data_offset);253GEN_OFFS(CodeBlob, _frame_size);254printf("\n");255256GEN_OFFS(nmethod, _method);257GEN_OFFS(nmethod, _oops_offset);258GEN_OFFS(nmethod, _scopes_data_offset);259GEN_OFFS(nmethod, _scopes_pcs_offset);260GEN_OFFS(nmethod, _handler_table_offset);261GEN_OFFS(nmethod, _deoptimize_offset);262GEN_OFFS(nmethod, _orig_pc_offset);263264GEN_OFFS(PcDesc, _pc_offset);265GEN_OFFS(PcDesc, _scope_decode_offset);266267printf("\n");268269GEN_OFFS(NarrowPtrStruct, _base);270GEN_OFFS(NarrowPtrStruct, _shift);271printf("\n");272273GEN_VALUE(SIZE_HeapBlockHeader, (int) sizeof(HeapBlock::Header));274GEN_SIZE(oopDesc);275GEN_SIZE(ConstantPool);276printf("\n");277278GEN_SIZE(PcDesc);279GEN_SIZE(Method);280GEN_SIZE(ConstMethod);281GEN_SIZE(nmethod);282GEN_SIZE(CodeBlob);283GEN_SIZE(BufferBlob);284GEN_SIZE(SingletonBlob);285GEN_SIZE(RuntimeStub);286GEN_SIZE(SafepointBlob);287288gen_epilogue(gen_variant);289printf("\n");290291fflush(stdout);292return 0;293}294295296