hotspot/src/share/vm/runtime/vmStructs.hpp
author sbohne
Tue, 04 Mar 2008 09:44:24 -0500
changeset 231 3cfeeae32993
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6666698: EnableBiasedLocking with BiasedLockingStartupDelay can block Watcher thread Summary: Enqueue VM_EnableBiasedLocking operation asynchronously Reviewed-by: never, xlu, kbr, acorn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2001 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// This table encapsulates the debugging information required by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// serviceability agent in order to run. Specifically, we need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// understand the layout of certain C data structures (offsets, in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// bytes, of their fields.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// There are alternatives for the design of this mechanism, including
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// parsing platform-specific debugging symbols from a debug build into
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// a program database. While this current mechanism can be considered
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// to be a workaround for the inability to debug arbitrary C and C++
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// programs at the present time, it does have certain advantages.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// First, it is platform-independent, which will vastly simplify the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// initial bringup of the system both now and on future platforms.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Second, it is embedded within the VM, as opposed to being in a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// separate program database; experience has shown that whenever
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// portions of a system are decoupled, version skew is problematic.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// Third, generating a program database, for example for a product
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// build, would probably require two builds to be done: the desired
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// product build as well as an intermediary build with the PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// flag turned on but also compiled with -g, leading to a doubling of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// the time required to get a serviceability agent-debuggable product
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// build. Fourth, and very significantly, this table probably
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// preserves more information about field types than stabs do; for
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// example, it preserves the fact that a field is a "jlong" rather
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// than transforming the type according to the typedef in jni_md.h,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// which allows the Java-side code to identify "Java-sized" fields in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// C++ data structures. If the symbol parsing mechanism was redone
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// using stabs, it might still be necessary to have a table somewhere
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// containing this information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// Do not change the sizes or signedness of the integer values in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// these data structures; they are fixed over in the serviceability
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// agent's Java code (for bootstrapping).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  const char* typeName;            // The type name containing the given field (example: "Klass")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  const char* fieldName;           // The field name within the type           (example: "_name")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  const char* typeString;          // Quoted name of the type of this field (example: "symbolOopDesc*";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
                                   // parsed in Java to ensure type correctness
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  int32_t  isStatic;               // Indicates whether following field is an offset or an address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  uint64_t offset;                 // Offset of field within structure; only used for nonstatic fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  void* address;                   // Address of field; only used for static fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
                                   // ("offset" can not be reused because of apparent SparcWorks compiler bug
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
                                   // in generation of initializer data)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
} VMStructEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  const char* typeName;            // Type name (example: "methodOopDesc")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  const char* superclassName;      // Superclass name, or null if none (example: "oopDesc")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  int32_t isOopType;               // Does this type represent an oop typedef? (i.e., "methodOop" or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
                                   // "klassOop", but NOT "methodOopDesc")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  int32_t isIntegerType;           // Does this type represent an integer type (of arbitrary size)?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  int32_t isUnsigned;              // If so, is it unsigned?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  uint64_t size;                   // Size, in bytes, of the type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
} VMTypeEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  const char* name;                // Name of constant (example: "_thread_in_native")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  int32_t value;                   // Value of constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
} VMIntConstantEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  const char* name;                // Name of constant (example: "_thread_in_native")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  uint64_t value;                  // Value of constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
} VMLongConstantEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
// This class is a friend of most classes, to be able to access
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
// private fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
class VMStructs {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // The last entry is identified over in the serviceability agent by
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // the fact that it has a NULL fieldName
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  static VMStructEntry localHotSpotVMStructs[];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // The last entry is identified over in the serviceability agent by
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // the fact that it has a NULL typeName
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  static VMTypeEntry   localHotSpotVMTypes[];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // Table of integer constants required by the serviceability agent.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // The last entry is identified over in the serviceability agent by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // the fact that it has a NULL typeName
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  static VMIntConstantEntry localHotSpotVMIntConstants[];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // Table of long constants required by the serviceability agent.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // The last entry is identified over in the serviceability agent by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // the fact that it has a NULL typeName
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  static VMLongConstantEntry localHotSpotVMLongConstants[];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // This is used to run any checking code necessary for validation of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // the data structure (debug build only)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  static void init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // Look up a type in localHotSpotVMTypes using strcmp() (debug build only).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // Returns 1 if found, 0 if not.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  //  debug_only(static int findType(const char* typeName);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  static int findType(const char* typeName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
};