src/share/vm/runtime/vmStructs.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/runtime/vmStructs.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,136 @@
     1.4 +/*
     1.5 + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_RUNTIME_VMSTRUCTS_HPP
    1.29 +#define SHARE_VM_RUNTIME_VMSTRUCTS_HPP
    1.30 +
    1.31 +#include "utilities/debug.hpp"
    1.32 +#ifdef COMPILER1
    1.33 +#include "c1/c1_Runtime1.hpp"
    1.34 +#endif
    1.35 +
    1.36 +// This table encapsulates the debugging information required by the
    1.37 +// serviceability agent in order to run. Specifically, we need to
    1.38 +// understand the layout of certain C data structures (offsets, in
    1.39 +// bytes, of their fields.)
    1.40 +//
    1.41 +// There are alternatives for the design of this mechanism, including
    1.42 +// parsing platform-specific debugging symbols from a debug build into
    1.43 +// a program database. While this current mechanism can be considered
    1.44 +// to be a workaround for the inability to debug arbitrary C and C++
    1.45 +// programs at the present time, it does have certain advantages.
    1.46 +// First, it is platform-independent, which will vastly simplify the
    1.47 +// initial bringup of the system both now and on future platforms.
    1.48 +// Second, it is embedded within the VM, as opposed to being in a
    1.49 +// separate program database; experience has shown that whenever
    1.50 +// portions of a system are decoupled, version skew is problematic.
    1.51 +// Third, generating a program database, for example for a product
    1.52 +// build, would probably require two builds to be done: the desired
    1.53 +// product build as well as an intermediary build with the PRODUCT
    1.54 +// flag turned on but also compiled with -g, leading to a doubling of
    1.55 +// the time required to get a serviceability agent-debuggable product
    1.56 +// build. Fourth, and very significantly, this table probably
    1.57 +// preserves more information about field types than stabs do; for
    1.58 +// example, it preserves the fact that a field is a "jlong" rather
    1.59 +// than transforming the type according to the typedef in jni_md.h,
    1.60 +// which allows the Java-side code to identify "Java-sized" fields in
    1.61 +// C++ data structures. If the symbol parsing mechanism was redone
    1.62 +// using stabs, it might still be necessary to have a table somewhere
    1.63 +// containing this information.
    1.64 +//
    1.65 +// Do not change the sizes or signedness of the integer values in
    1.66 +// these data structures; they are fixed over in the serviceability
    1.67 +// agent's Java code (for bootstrapping).
    1.68 +
    1.69 +typedef struct {
    1.70 +  const char* typeName;            // The type name containing the given field (example: "Klass")
    1.71 +  const char* fieldName;           // The field name within the type           (example: "_name")
    1.72 +  const char* typeString;          // Quoted name of the type of this field (example: "Symbol*";
    1.73 +                                   // parsed in Java to ensure type correctness
    1.74 +  int32_t  isStatic;               // Indicates whether following field is an offset or an address
    1.75 +  uint64_t offset;                 // Offset of field within structure; only used for nonstatic fields
    1.76 +  void* address;                   // Address of field; only used for static fields
    1.77 +                                   // ("offset" can not be reused because of apparent SparcWorks compiler bug
    1.78 +                                   // in generation of initializer data)
    1.79 +} VMStructEntry;
    1.80 +
    1.81 +typedef struct {
    1.82 +  const char* typeName;            // Type name (example: "Method")
    1.83 +  const char* superclassName;      // Superclass name, or null if none (example: "oopDesc")
    1.84 +  int32_t isOopType;               // Does this type represent an oop typedef? (i.e., "Method*" or
    1.85 +                                   // "Klass*", but NOT "Method")
    1.86 +  int32_t isIntegerType;           // Does this type represent an integer type (of arbitrary size)?
    1.87 +  int32_t isUnsigned;              // If so, is it unsigned?
    1.88 +  uint64_t size;                   // Size, in bytes, of the type
    1.89 +} VMTypeEntry;
    1.90 +
    1.91 +typedef struct {
    1.92 +  const char* name;                // Name of constant (example: "_thread_in_native")
    1.93 +  int32_t value;                   // Value of constant
    1.94 +} VMIntConstantEntry;
    1.95 +
    1.96 +typedef struct {
    1.97 +  const char* name;                // Name of constant (example: "_thread_in_native")
    1.98 +  uint64_t value;                  // Value of constant
    1.99 +} VMLongConstantEntry;
   1.100 +
   1.101 +// This class is a friend of most classes, to be able to access
   1.102 +// private fields
   1.103 +class VMStructs {
   1.104 +public:
   1.105 +  // The last entry is identified over in the serviceability agent by
   1.106 +  // the fact that it has a NULL fieldName
   1.107 +  static VMStructEntry localHotSpotVMStructs[];
   1.108 +
   1.109 +  // The last entry is identified over in the serviceability agent by
   1.110 +  // the fact that it has a NULL typeName
   1.111 +  static VMTypeEntry   localHotSpotVMTypes[];
   1.112 +
   1.113 +  // Table of integer constants required by the serviceability agent.
   1.114 +  // The last entry is identified over in the serviceability agent by
   1.115 +  // the fact that it has a NULL typeName
   1.116 +  static VMIntConstantEntry localHotSpotVMIntConstants[];
   1.117 +
   1.118 +  // Table of long constants required by the serviceability agent.
   1.119 +  // The last entry is identified over in the serviceability agent by
   1.120 +  // the fact that it has a NULL typeName
   1.121 +  static VMLongConstantEntry localHotSpotVMLongConstants[];
   1.122 +
   1.123 +  // This is used to run any checking code necessary for validation of
   1.124 +  // the data structure (debug build only)
   1.125 +  static void init();
   1.126 +
   1.127 +#ifndef PRODUCT
   1.128 +  // Execute unit tests
   1.129 +  static void test();
   1.130 +#endif
   1.131 +
   1.132 +private:
   1.133 +  // Look up a type in localHotSpotVMTypes using strcmp() (debug build only).
   1.134 +  // Returns 1 if found, 0 if not.
   1.135 +  //  debug_only(static int findType(const char* typeName);)
   1.136 +  static int findType(const char* typeName);
   1.137 +};
   1.138 +
   1.139 +#endif // SHARE_VM_RUNTIME_VMSTRUCTS_HPP

mercurial