Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/solaris/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#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"56#ifdef COMPILER157#ifdef ASSERT5859/*60* To avoid the most part of potential link errors61* we link this program with -z nodefs .62*63* But for 'debug1' and 'fastdebug1' we still have to provide64* a particular workaround for the following symbols below.65* It will be good to find out a generic way in the future.66*/6768#pragma weak tty69#pragma weak CMSExpAvgFactor7071#if defined(i386) || defined(__i386) || defined(__amd64)72#pragma weak noreg73#endif /* i386 */7475LIR_Opr LIR_OprFact::illegalOpr = (LIR_Opr) 0;7677address StubRoutines::_call_stub_return_address = NULL;7879StubQueue* AbstractInterpreter::_code = NULL;8081#endif /* ASSERT */82#endif /* COMPILER1 */8384#define GEN_OFFS(Type,Name) \85switch(gen_variant) { \86case GEN_OFFSET: \87printf("#define OFFSET_%-33s %d\n", \88#Type #Name, offset_of(Type, Name)); \89break; \90case GEN_INDEX: \91printf("#define IDX_OFFSET_%-33s %d\n", \92#Type #Name, index++); \93break; \94case GEN_TABLE: \95printf("\tOFFSET_%s,\n", #Type #Name); \96break; \97}9899#define GEN_SIZE(Type) \100switch(gen_variant) { \101case GEN_OFFSET: \102printf("#define SIZE_%-35s %d\n", \103#Type, sizeof(Type)); \104break; \105case GEN_INDEX: \106printf("#define IDX_SIZE_%-35s %d\n", \107#Type, index++); \108break; \109case GEN_TABLE: \110printf("\tSIZE_%s,\n", #Type); \111break; \112}113114#define GEN_VALUE(String,Value) \115switch(gen_variant) { \116case GEN_OFFSET: \117printf("#define %-40s %d\n", #String, Value); \118break; \119case GEN_INDEX: \120printf("#define IDX_%-40s %d\n", #String, index++); \121break; \122case GEN_TABLE: \123printf("\t" #String ",\n"); \124break; \125}126127void gen_prologue(GEN_variant gen_variant) {128const char *suffix;129130switch(gen_variant) {131case GEN_OFFSET: suffix = ".h"; break;132case GEN_INDEX: suffix = "Index.h"; break;133case GEN_TABLE: suffix = ".cpp"; break;134}135136printf("/*\n");137printf(" * JvmOffsets%s !!!DO NOT EDIT!!! \n", suffix);138printf(" * The generateJvmOffsets program generates this file!\n");139printf(" */\n\n");140switch(gen_variant) {141142case GEN_OFFSET:143case GEN_INDEX:144break;145146case GEN_TABLE:147printf("#include \"JvmOffsets.h\"\n");148printf("\n");149printf("int __JvmOffsets[] = {\n");150break;151}152}153154void gen_epilogue(GEN_variant gen_variant) {155if (gen_variant != GEN_TABLE) {156return;157}158printf("};\n\n");159return;160}161162int generateJvmOffsets(GEN_variant gen_variant) {163int index = 0; /* It is used to generate JvmOffsetsIndex.h */164int pointer_size = sizeof(void *);165int data_model = (pointer_size == 4) ? PR_MODEL_ILP32 : PR_MODEL_LP64;166167gen_prologue(gen_variant);168169GEN_VALUE(DATA_MODEL, data_model);170GEN_VALUE(POINTER_SIZE, pointer_size);171#if defined(TIERED)172GEN_VALUE(COMPILER, 3);173#elif COMPILER1174GEN_VALUE(COMPILER, 1);175#elif COMPILER2176GEN_VALUE(COMPILER, 2);177#else178GEN_VALUE(COMPILER, 0);179#endif // COMPILER1 && COMPILER2180printf("\n");181182GEN_OFFS(CollectedHeap, _reserved);183GEN_OFFS(MemRegion, _start);184GEN_OFFS(MemRegion, _word_size);185GEN_SIZE(HeapWord);186printf("\n");187188GEN_OFFS(VMStructEntry, typeName);189GEN_OFFS(VMStructEntry, fieldName);190GEN_OFFS(VMStructEntry, address);191GEN_SIZE(VMStructEntry);192printf("\n");193194GEN_VALUE(MAX_METHOD_CODE_SIZE, max_method_code_size);195#if defined(sparc) || defined(__sparc)196GEN_VALUE(OFFSET_interpreter_frame_method, 2 * pointer_size); /* L2 in saved window */197GEN_VALUE(OFFSET_interpreter_frame_sender_sp, 13 * pointer_size); /* I5 in saved window */198// Fake value for consistency. It is not going to be used.199GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, 0xFFFF);200#elif defined(i386) || defined(__i386) || defined(__amd64)201GEN_VALUE(OFFSET_interpreter_frame_sender_sp, -1 * pointer_size);202GEN_VALUE(OFFSET_interpreter_frame_method, -3 * pointer_size);203GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, -7 * pointer_size);204#endif205206GEN_OFFS(Klass, _name);207GEN_OFFS(ConstantPool, _pool_holder);208printf("\n");209210GEN_VALUE(OFFSET_HeapBlockHeader_used, offset_of(HeapBlock::Header, _used));211GEN_OFFS(oopDesc, _metadata);212printf("\n");213214GEN_VALUE(AccessFlags_NATIVE, JVM_ACC_NATIVE);215GEN_VALUE(ConstMethod_has_linenumber_table, ConstMethod::_has_linenumber_table);216GEN_OFFS(AccessFlags, _flags);217GEN_OFFS(Symbol, _length);218GEN_OFFS(Symbol, _body);219printf("\n");220221GEN_OFFS(Method, _constMethod);222GEN_OFFS(Method, _access_flags);223printf("\n");224225GEN_OFFS(ConstMethod, _constants);226GEN_OFFS(ConstMethod, _flags);227GEN_OFFS(ConstMethod, _code_size);228GEN_OFFS(ConstMethod, _name_index);229GEN_OFFS(ConstMethod, _signature_index);230printf("\n");231232GEN_OFFS(CodeHeap, _memory);233GEN_OFFS(CodeHeap, _segmap);234GEN_OFFS(CodeHeap, _log2_segment_size);235printf("\n");236237GEN_OFFS(VirtualSpace, _low_boundary);238GEN_OFFS(VirtualSpace, _high_boundary);239GEN_OFFS(VirtualSpace, _low);240GEN_OFFS(VirtualSpace, _high);241printf("\n");242243GEN_OFFS(CodeBlob, _name);244GEN_OFFS(CodeBlob, _header_size);245GEN_OFFS(CodeBlob, _content_offset);246GEN_OFFS(CodeBlob, _code_offset);247GEN_OFFS(CodeBlob, _data_offset);248GEN_OFFS(CodeBlob, _frame_size);249printf("\n");250251GEN_OFFS(nmethod, _method);252GEN_OFFS(nmethod, _metadata_offset);253GEN_OFFS(nmethod, _scopes_data_offset);254GEN_OFFS(nmethod, _scopes_pcs_offset);255GEN_OFFS(nmethod, _handler_table_offset);256GEN_OFFS(nmethod, _deoptimize_offset);257GEN_OFFS(nmethod, _orig_pc_offset);258259GEN_OFFS(PcDesc, _pc_offset);260GEN_OFFS(PcDesc, _scope_decode_offset);261262printf("\n");263264GEN_OFFS(NarrowPtrStruct, _base);265GEN_OFFS(NarrowPtrStruct, _shift);266printf("\n");267268GEN_VALUE(SIZE_HeapBlockHeader, sizeof(HeapBlock::Header));269GEN_SIZE(oopDesc);270GEN_SIZE(ConstantPool);271printf("\n");272273GEN_SIZE(PcDesc);274GEN_SIZE(Method);275GEN_SIZE(ConstMethod);276GEN_SIZE(nmethod);277GEN_SIZE(CodeBlob);278GEN_SIZE(BufferBlob);279GEN_SIZE(SingletonBlob);280GEN_SIZE(RuntimeStub);281GEN_SIZE(SafepointBlob);282283gen_epilogue(gen_variant);284printf("\n");285286fflush(stdout);287return 0;288}289290291