src/share/vm/utilities/globalDefinitions.hpp

Sun, 25 Sep 2011 16:03:29 -0700

author
never
date
Sun, 25 Sep 2011 16:03:29 -0700
changeset 3156
f08d439fab8c
parent 2729
e863062e521d
child 3202
436b4a3231bf
permissions
-rw-r--r--

7089790: integrate bsd-port changes
Reviewed-by: kvn, twisti, jrose
Contributed-by: Kurt Miller <kurt@intricatesoftware.com>, Greg Lewis <glewis@eyesbeyond.com>, Jung-uk Kim <jkim@freebsd.org>, Christos Zoulas <christos@zoulas.com>, Landon Fuller <landonf@plausible.coop>, The FreeBSD Foundation <board@freebsdfoundation.org>, Michael Franz <mvfranz@gmail.com>, Roger Hoover <rhoover@apple.com>, Alexander Strange <astrange@apple.com>

     1 /*
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
    26 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
    28 #define __STDC_FORMAT_MACROS
    30 #ifdef TARGET_COMPILER_gcc
    31 # include "utilities/globalDefinitions_gcc.hpp"
    32 #endif
    33 #ifdef TARGET_COMPILER_visCPP
    34 # include "utilities/globalDefinitions_visCPP.hpp"
    35 #endif
    36 #ifdef TARGET_COMPILER_sparcWorks
    37 # include "utilities/globalDefinitions_sparcWorks.hpp"
    38 #endif
    40 #include "utilities/macros.hpp"
    42 // This file holds all globally used constants & types, class (forward)
    43 // declarations and a few frequently used utility functions.
    45 //----------------------------------------------------------------------------------------------------
    46 // Constants
    48 const int LogBytesPerShort   = 1;
    49 const int LogBytesPerInt     = 2;
    50 #ifdef _LP64
    51 const int LogBytesPerWord    = 3;
    52 #else
    53 const int LogBytesPerWord    = 2;
    54 #endif
    55 const int LogBytesPerLong    = 3;
    57 const int BytesPerShort      = 1 << LogBytesPerShort;
    58 const int BytesPerInt        = 1 << LogBytesPerInt;
    59 const int BytesPerWord       = 1 << LogBytesPerWord;
    60 const int BytesPerLong       = 1 << LogBytesPerLong;
    62 const int LogBitsPerByte     = 3;
    63 const int LogBitsPerShort    = LogBitsPerByte + LogBytesPerShort;
    64 const int LogBitsPerInt      = LogBitsPerByte + LogBytesPerInt;
    65 const int LogBitsPerWord     = LogBitsPerByte + LogBytesPerWord;
    66 const int LogBitsPerLong     = LogBitsPerByte + LogBytesPerLong;
    68 const int BitsPerByte        = 1 << LogBitsPerByte;
    69 const int BitsPerShort       = 1 << LogBitsPerShort;
    70 const int BitsPerInt         = 1 << LogBitsPerInt;
    71 const int BitsPerWord        = 1 << LogBitsPerWord;
    72 const int BitsPerLong        = 1 << LogBitsPerLong;
    74 const int WordAlignmentMask  = (1 << LogBytesPerWord) - 1;
    75 const int LongAlignmentMask  = (1 << LogBytesPerLong) - 1;
    77 const int WordsPerLong       = 2;       // Number of stack entries for longs
    79 const int oopSize            = sizeof(char*); // Full-width oop
    80 extern int heapOopSize;                       // Oop within a java object
    81 const int wordSize           = sizeof(char*);
    82 const int longSize           = sizeof(jlong);
    83 const int jintSize           = sizeof(jint);
    84 const int size_tSize         = sizeof(size_t);
    86 const int BytesPerOop        = BytesPerWord;  // Full-width oop
    88 extern int LogBytesPerHeapOop;                // Oop within a java object
    89 extern int LogBitsPerHeapOop;
    90 extern int BytesPerHeapOop;
    91 extern int BitsPerHeapOop;
    93 // Oop encoding heap max
    94 extern uint64_t OopEncodingHeapMax;
    96 const int BitsPerJavaInteger = 32;
    97 const int BitsPerJavaLong    = 64;
    98 const int BitsPerSize_t      = size_tSize * BitsPerByte;
   100 // Size of a char[] needed to represent a jint as a string in decimal.
   101 const int jintAsStringSize = 12;
   103 // In fact this should be
   104 // log2_intptr(sizeof(class JavaThread)) - log2_intptr(64);
   105 // see os::set_memory_serialize_page()
   106 #ifdef _LP64
   107 const int SerializePageShiftCount = 4;
   108 #else
   109 const int SerializePageShiftCount = 3;
   110 #endif
   112 // An opaque struct of heap-word width, so that HeapWord* can be a generic
   113 // pointer into the heap.  We require that object sizes be measured in
   114 // units of heap words, so that that
   115 //   HeapWord* hw;
   116 //   hw += oop(hw)->foo();
   117 // works, where foo is a method (like size or scavenge) that returns the
   118 // object size.
   119 class HeapWord {
   120   friend class VMStructs;
   121  private:
   122   char* i;
   123 #ifndef PRODUCT
   124  public:
   125   char* value() { return i; }
   126 #endif
   127 };
   129 // HeapWordSize must be 2^LogHeapWordSize.
   130 const int HeapWordSize        = sizeof(HeapWord);
   131 #ifdef _LP64
   132 const int LogHeapWordSize     = 3;
   133 #else
   134 const int LogHeapWordSize     = 2;
   135 #endif
   136 const int HeapWordsPerLong    = BytesPerLong / HeapWordSize;
   137 const int LogHeapWordsPerLong = LogBytesPerLong - LogHeapWordSize;
   139 // The larger HeapWordSize for 64bit requires larger heaps
   140 // for the same application running in 64bit.  See bug 4967770.
   141 // The minimum alignment to a heap word size is done.  Other
   142 // parts of the memory system may required additional alignment
   143 // and are responsible for those alignments.
   144 #ifdef _LP64
   145 #define ScaleForWordSize(x) align_size_down_((x) * 13 / 10, HeapWordSize)
   146 #else
   147 #define ScaleForWordSize(x) (x)
   148 #endif
   150 // The minimum number of native machine words necessary to contain "byte_size"
   151 // bytes.
   152 inline size_t heap_word_size(size_t byte_size) {
   153   return (byte_size + (HeapWordSize-1)) >> LogHeapWordSize;
   154 }
   157 const size_t K                  = 1024;
   158 const size_t M                  = K*K;
   159 const size_t G                  = M*K;
   160 const size_t HWperKB            = K / sizeof(HeapWord);
   162 const size_t LOG_K              = 10;
   163 const size_t LOG_M              = 2 * LOG_K;
   164 const size_t LOG_G              = 2 * LOG_M;
   166 const jint min_jint = (jint)1 << (sizeof(jint)*BitsPerByte-1); // 0x80000000 == smallest jint
   167 const jint max_jint = (juint)min_jint - 1;                     // 0x7FFFFFFF == largest jint
   169 // Constants for converting from a base unit to milli-base units.  For
   170 // example from seconds to milliseconds and microseconds
   172 const int MILLIUNITS    = 1000;         // milli units per base unit
   173 const int MICROUNITS    = 1000000;      // micro units per base unit
   174 const int NANOUNITS     = 1000000000;   // nano units per base unit
   176 inline const char* proper_unit_for_byte_size(size_t s) {
   177   if (s >= 10*M) {
   178     return "M";
   179   } else if (s >= 10*K) {
   180     return "K";
   181   } else {
   182     return "B";
   183   }
   184 }
   186 inline size_t byte_size_in_proper_unit(size_t s) {
   187   if (s >= 10*M) {
   188     return s/M;
   189   } else if (s >= 10*K) {
   190     return s/K;
   191   } else {
   192     return s;
   193   }
   194 }
   197 //----------------------------------------------------------------------------------------------------
   198 // VM type definitions
   200 // intx and uintx are the 'extended' int and 'extended' unsigned int types;
   201 // they are 32bit wide on a 32-bit platform, and 64bit wide on a 64bit platform.
   203 typedef intptr_t  intx;
   204 typedef uintptr_t uintx;
   206 const intx  min_intx  = (intx)1 << (sizeof(intx)*BitsPerByte-1);
   207 const intx  max_intx  = (uintx)min_intx - 1;
   208 const uintx max_uintx = (uintx)-1;
   210 // Table of values:
   211 //      sizeof intx         4               8
   212 // min_intx             0x80000000      0x8000000000000000
   213 // max_intx             0x7FFFFFFF      0x7FFFFFFFFFFFFFFF
   214 // max_uintx            0xFFFFFFFF      0xFFFFFFFFFFFFFFFF
   216 typedef unsigned int uint;   NEEDS_CLEANUP
   219 //----------------------------------------------------------------------------------------------------
   220 // Java type definitions
   222 // All kinds of 'plain' byte addresses
   223 typedef   signed char s_char;
   224 typedef unsigned char u_char;
   225 typedef u_char*       address;
   226 typedef uintptr_t     address_word; // unsigned integer which will hold a pointer
   227                                     // except for some implementations of a C++
   228                                     // linkage pointer to function. Should never
   229                                     // need one of those to be placed in this
   230                                     // type anyway.
   232 //  Utility functions to "portably" (?) bit twiddle pointers
   233 //  Where portable means keep ANSI C++ compilers quiet
   235 inline address       set_address_bits(address x, int m)       { return address(intptr_t(x) | m); }
   236 inline address       clear_address_bits(address x, int m)     { return address(intptr_t(x) & ~m); }
   238 //  Utility functions to "portably" make cast to/from function pointers.
   240 inline address_word  mask_address_bits(address x, int m)      { return address_word(x) & m; }
   241 inline address_word  castable_address(address x)              { return address_word(x) ; }
   242 inline address_word  castable_address(void* x)                { return address_word(x) ; }
   244 // Pointer subtraction.
   245 // The idea here is to avoid ptrdiff_t, which is signed and so doesn't have
   246 // the range we might need to find differences from one end of the heap
   247 // to the other.
   248 // A typical use might be:
   249 //     if (pointer_delta(end(), top()) >= size) {
   250 //       // enough room for an object of size
   251 //       ...
   252 // and then additions like
   253 //       ... top() + size ...
   254 // are safe because we know that top() is at least size below end().
   255 inline size_t pointer_delta(const void* left,
   256                             const void* right,
   257                             size_t element_size) {
   258   return (((uintptr_t) left) - ((uintptr_t) right)) / element_size;
   259 }
   260 // A version specialized for HeapWord*'s.
   261 inline size_t pointer_delta(const HeapWord* left, const HeapWord* right) {
   262   return pointer_delta(left, right, sizeof(HeapWord));
   263 }
   265 //
   266 // ANSI C++ does not allow casting from one pointer type to a function pointer
   267 // directly without at best a warning. This macro accomplishes it silently
   268 // In every case that is present at this point the value be cast is a pointer
   269 // to a C linkage function. In somecase the type used for the cast reflects
   270 // that linkage and a picky compiler would not complain. In other cases because
   271 // there is no convenient place to place a typedef with extern C linkage (i.e
   272 // a platform dependent header file) it doesn't. At this point no compiler seems
   273 // picky enough to catch these instances (which are few). It is possible that
   274 // using templates could fix these for all cases. This use of templates is likely
   275 // so far from the middle of the road that it is likely to be problematic in
   276 // many C++ compilers.
   277 //
   278 #define CAST_TO_FN_PTR(func_type, value) ((func_type)(castable_address(value)))
   279 #define CAST_FROM_FN_PTR(new_type, func_ptr) ((new_type)((address_word)(func_ptr)))
   281 // Unsigned byte types for os and stream.hpp
   283 // Unsigned one, two, four and eigth byte quantities used for describing
   284 // the .class file format. See JVM book chapter 4.
   286 typedef jubyte  u1;
   287 typedef jushort u2;
   288 typedef juint   u4;
   289 typedef julong  u8;
   291 const jubyte  max_jubyte  = (jubyte)-1;  // 0xFF       largest jubyte
   292 const jushort max_jushort = (jushort)-1; // 0xFFFF     largest jushort
   293 const juint   max_juint   = (juint)-1;   // 0xFFFFFFFF largest juint
   294 const julong  max_julong  = (julong)-1;  // 0xFF....FF largest julong
   296 //----------------------------------------------------------------------------------------------------
   297 // JVM spec restrictions
   299 const int max_method_code_size = 64*K - 1;  // JVM spec, 2nd ed. section 4.8.1 (p.134)
   302 //----------------------------------------------------------------------------------------------------
   303 // HotSwap - for JVMTI   aka Class File Replacement and PopFrame
   304 //
   305 // Determines whether on-the-fly class replacement and frame popping are enabled.
   307 #define HOTSWAP
   309 //----------------------------------------------------------------------------------------------------
   310 // Object alignment, in units of HeapWords.
   311 //
   312 // Minimum is max(BytesPerLong, BytesPerDouble, BytesPerOop) / HeapWordSize, so jlong, jdouble and
   313 // reference fields can be naturally aligned.
   315 extern int MinObjAlignment;
   316 extern int MinObjAlignmentInBytes;
   317 extern int MinObjAlignmentInBytesMask;
   319 extern int LogMinObjAlignment;
   320 extern int LogMinObjAlignmentInBytes;
   322 // Machine dependent stuff
   324 #ifdef TARGET_ARCH_x86
   325 # include "globalDefinitions_x86.hpp"
   326 #endif
   327 #ifdef TARGET_ARCH_sparc
   328 # include "globalDefinitions_sparc.hpp"
   329 #endif
   330 #ifdef TARGET_ARCH_zero
   331 # include "globalDefinitions_zero.hpp"
   332 #endif
   333 #ifdef TARGET_ARCH_arm
   334 # include "globalDefinitions_arm.hpp"
   335 #endif
   336 #ifdef TARGET_ARCH_ppc
   337 # include "globalDefinitions_ppc.hpp"
   338 #endif
   341 // The byte alignment to be used by Arena::Amalloc.  See bugid 4169348.
   342 // Note: this value must be a power of 2
   344 #define ARENA_AMALLOC_ALIGNMENT (2*BytesPerWord)
   346 // Signed variants of alignment helpers.  There are two versions of each, a macro
   347 // for use in places like enum definitions that require compile-time constant
   348 // expressions and a function for all other places so as to get type checking.
   350 #define align_size_up_(size, alignment) (((size) + ((alignment) - 1)) & ~((alignment) - 1))
   352 inline intptr_t align_size_up(intptr_t size, intptr_t alignment) {
   353   return align_size_up_(size, alignment);
   354 }
   356 #define align_size_down_(size, alignment) ((size) & ~((alignment) - 1))
   358 inline intptr_t align_size_down(intptr_t size, intptr_t alignment) {
   359   return align_size_down_(size, alignment);
   360 }
   362 // Align objects by rounding up their size, in HeapWord units.
   364 #define align_object_size_(size) align_size_up_(size, MinObjAlignment)
   366 inline intptr_t align_object_size(intptr_t size) {
   367   return align_size_up(size, MinObjAlignment);
   368 }
   370 inline bool is_object_aligned(intptr_t addr) {
   371   return addr == align_object_size(addr);
   372 }
   374 // Pad out certain offsets to jlong alignment, in HeapWord units.
   376 inline intptr_t align_object_offset(intptr_t offset) {
   377   return align_size_up(offset, HeapWordsPerLong);
   378 }
   380 // The expected size in bytes of a cache line, used to pad data structures.
   381 #define DEFAULT_CACHE_LINE_SIZE 64
   383 // Bytes needed to pad type to avoid cache-line sharing; alignment should be the
   384 // expected cache line size (a power of two).  The first addend avoids sharing
   385 // when the start address is not a multiple of alignment; the second maintains
   386 // alignment of starting addresses that happen to be a multiple.
   387 #define PADDING_SIZE(type, alignment)                           \
   388   ((alignment) + align_size_up_(sizeof(type), alignment))
   390 // Templates to create a subclass padded to avoid cache line sharing.  These are
   391 // effective only when applied to derived-most (leaf) classes.
   393 // When no args are passed to the base ctor.
   394 template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
   395 class Padded: public T {
   396 private:
   397   char _pad_buf_[PADDING_SIZE(T, alignment)];
   398 };
   400 // When either 0 or 1 args may be passed to the base ctor.
   401 template <class T, typename Arg1T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
   402 class Padded01: public T {
   403 public:
   404   Padded01(): T() { }
   405   Padded01(Arg1T arg1): T(arg1) { }
   406 private:
   407   char _pad_buf_[PADDING_SIZE(T, alignment)];
   408 };
   410 //----------------------------------------------------------------------------------------------------
   411 // Utility macros for compilers
   412 // used to silence compiler warnings
   414 #define Unused_Variable(var) var
   417 //----------------------------------------------------------------------------------------------------
   418 // Miscellaneous
   420 // 6302670 Eliminate Hotspot __fabsf dependency
   421 // All fabs() callers should call this function instead, which will implicitly
   422 // convert the operand to double, avoiding a dependency on __fabsf which
   423 // doesn't exist in early versions of Solaris 8.
   424 inline double fabsd(double value) {
   425   return fabs(value);
   426 }
   428 inline jint low (jlong value)                    { return jint(value); }
   429 inline jint high(jlong value)                    { return jint(value >> 32); }
   431 // the fancy casts are a hopefully portable way
   432 // to do unsigned 32 to 64 bit type conversion
   433 inline void set_low (jlong* value, jint low )    { *value &= (jlong)0xffffffff << 32;
   434                                                    *value |= (jlong)(julong)(juint)low; }
   436 inline void set_high(jlong* value, jint high)    { *value &= (jlong)(julong)(juint)0xffffffff;
   437                                                    *value |= (jlong)high       << 32; }
   439 inline jlong jlong_from(jint h, jint l) {
   440   jlong result = 0; // initialization to avoid warning
   441   set_high(&result, h);
   442   set_low(&result,  l);
   443   return result;
   444 }
   446 union jlong_accessor {
   447   jint  words[2];
   448   jlong long_value;
   449 };
   451 void basic_types_init(); // cannot define here; uses assert
   454 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
   455 enum BasicType {
   456   T_BOOLEAN  =  4,
   457   T_CHAR     =  5,
   458   T_FLOAT    =  6,
   459   T_DOUBLE   =  7,
   460   T_BYTE     =  8,
   461   T_SHORT    =  9,
   462   T_INT      = 10,
   463   T_LONG     = 11,
   464   T_OBJECT   = 12,
   465   T_ARRAY    = 13,
   466   T_VOID     = 14,
   467   T_ADDRESS  = 15,
   468   T_NARROWOOP= 16,
   469   T_CONFLICT = 17, // for stack value type with conflicting contents
   470   T_ILLEGAL  = 99
   471 };
   473 inline bool is_java_primitive(BasicType t) {
   474   return T_BOOLEAN <= t && t <= T_LONG;
   475 }
   477 inline bool is_subword_type(BasicType t) {
   478   // these guys are processed exactly like T_INT in calling sequences:
   479   return (t == T_BOOLEAN || t == T_CHAR || t == T_BYTE || t == T_SHORT);
   480 }
   482 inline bool is_signed_subword_type(BasicType t) {
   483   return (t == T_BYTE || t == T_SHORT);
   484 }
   486 // Convert a char from a classfile signature to a BasicType
   487 inline BasicType char2type(char c) {
   488   switch( c ) {
   489   case 'B': return T_BYTE;
   490   case 'C': return T_CHAR;
   491   case 'D': return T_DOUBLE;
   492   case 'F': return T_FLOAT;
   493   case 'I': return T_INT;
   494   case 'J': return T_LONG;
   495   case 'S': return T_SHORT;
   496   case 'Z': return T_BOOLEAN;
   497   case 'V': return T_VOID;
   498   case 'L': return T_OBJECT;
   499   case '[': return T_ARRAY;
   500   }
   501   return T_ILLEGAL;
   502 }
   504 extern char type2char_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
   505 inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
   506 extern int type2size[T_CONFLICT+1];         // Map BasicType to result stack elements
   507 extern const char* type2name_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
   508 inline const char* type2name(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2name_tab[t] : NULL; }
   509 extern BasicType name2type(const char* name);
   511 // Auxilary math routines
   512 // least common multiple
   513 extern size_t lcm(size_t a, size_t b);
   516 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
   517 enum BasicTypeSize {
   518   T_BOOLEAN_size = 1,
   519   T_CHAR_size    = 1,
   520   T_FLOAT_size   = 1,
   521   T_DOUBLE_size  = 2,
   522   T_BYTE_size    = 1,
   523   T_SHORT_size   = 1,
   524   T_INT_size     = 1,
   525   T_LONG_size    = 2,
   526   T_OBJECT_size  = 1,
   527   T_ARRAY_size   = 1,
   528   T_NARROWOOP_size = 1,
   529   T_VOID_size    = 0
   530 };
   533 // maps a BasicType to its instance field storage type:
   534 // all sub-word integral types are widened to T_INT
   535 extern BasicType type2field[T_CONFLICT+1];
   536 extern BasicType type2wfield[T_CONFLICT+1];
   539 // size in bytes
   540 enum ArrayElementSize {
   541   T_BOOLEAN_aelem_bytes = 1,
   542   T_CHAR_aelem_bytes    = 2,
   543   T_FLOAT_aelem_bytes   = 4,
   544   T_DOUBLE_aelem_bytes  = 8,
   545   T_BYTE_aelem_bytes    = 1,
   546   T_SHORT_aelem_bytes   = 2,
   547   T_INT_aelem_bytes     = 4,
   548   T_LONG_aelem_bytes    = 8,
   549 #ifdef _LP64
   550   T_OBJECT_aelem_bytes  = 8,
   551   T_ARRAY_aelem_bytes   = 8,
   552 #else
   553   T_OBJECT_aelem_bytes  = 4,
   554   T_ARRAY_aelem_bytes   = 4,
   555 #endif
   556   T_NARROWOOP_aelem_bytes = 4,
   557   T_VOID_aelem_bytes    = 0
   558 };
   560 extern int _type2aelembytes[T_CONFLICT+1]; // maps a BasicType to nof bytes used by its array element
   561 #ifdef ASSERT
   562 extern int type2aelembytes(BasicType t, bool allow_address = false); // asserts
   563 #else
   564 inline int type2aelembytes(BasicType t, bool allow_address = false) { return _type2aelembytes[t]; }
   565 #endif
   568 // JavaValue serves as a container for arbitrary Java values.
   570 class JavaValue {
   572  public:
   573   typedef union JavaCallValue {
   574     jfloat   f;
   575     jdouble  d;
   576     jint     i;
   577     jlong    l;
   578     jobject  h;
   579   } JavaCallValue;
   581  private:
   582   BasicType _type;
   583   JavaCallValue _value;
   585  public:
   586   JavaValue(BasicType t = T_ILLEGAL) { _type = t; }
   588   JavaValue(jfloat value) {
   589     _type    = T_FLOAT;
   590     _value.f = value;
   591   }
   593   JavaValue(jdouble value) {
   594     _type    = T_DOUBLE;
   595     _value.d = value;
   596   }
   598  jfloat get_jfloat() const { return _value.f; }
   599  jdouble get_jdouble() const { return _value.d; }
   600  jint get_jint() const { return _value.i; }
   601  jlong get_jlong() const { return _value.l; }
   602  jobject get_jobject() const { return _value.h; }
   603  JavaCallValue* get_value_addr() { return &_value; }
   604  BasicType get_type() const { return _type; }
   606  void set_jfloat(jfloat f) { _value.f = f;}
   607  void set_jdouble(jdouble d) { _value.d = d;}
   608  void set_jint(jint i) { _value.i = i;}
   609  void set_jlong(jlong l) { _value.l = l;}
   610  void set_jobject(jobject h) { _value.h = h;}
   611  void set_type(BasicType t) { _type = t; }
   613  jboolean get_jboolean() const { return (jboolean) (_value.i);}
   614  jbyte get_jbyte() const { return (jbyte) (_value.i);}
   615  jchar get_jchar() const { return (jchar) (_value.i);}
   616  jshort get_jshort() const { return (jshort) (_value.i);}
   618 };
   621 #define STACK_BIAS      0
   622 // V9 Sparc CPU's running in 64 Bit mode use a stack bias of 7ff
   623 // in order to extend the reach of the stack pointer.
   624 #if defined(SPARC) && defined(_LP64)
   625 #undef STACK_BIAS
   626 #define STACK_BIAS      0x7ff
   627 #endif
   630 // TosState describes the top-of-stack state before and after the execution of
   631 // a bytecode or method. The top-of-stack value may be cached in one or more CPU
   632 // registers. The TosState corresponds to the 'machine represention' of this cached
   633 // value. There's 4 states corresponding to the JAVA types int, long, float & double
   634 // as well as a 5th state in case the top-of-stack value is actually on the top
   635 // of stack (in memory) and thus not cached. The atos state corresponds to the itos
   636 // state when it comes to machine representation but is used separately for (oop)
   637 // type specific operations (e.g. verification code).
   639 enum TosState {         // describes the tos cache contents
   640   btos = 0,             // byte, bool tos cached
   641   ctos = 1,             // char tos cached
   642   stos = 2,             // short tos cached
   643   itos = 3,             // int tos cached
   644   ltos = 4,             // long tos cached
   645   ftos = 5,             // float tos cached
   646   dtos = 6,             // double tos cached
   647   atos = 7,             // object cached
   648   vtos = 8,             // tos not cached
   649   number_of_states,
   650   ilgl                  // illegal state: should not occur
   651 };
   654 inline TosState as_TosState(BasicType type) {
   655   switch (type) {
   656     case T_BYTE   : return btos;
   657     case T_BOOLEAN: return btos; // FIXME: Add ztos
   658     case T_CHAR   : return ctos;
   659     case T_SHORT  : return stos;
   660     case T_INT    : return itos;
   661     case T_LONG   : return ltos;
   662     case T_FLOAT  : return ftos;
   663     case T_DOUBLE : return dtos;
   664     case T_VOID   : return vtos;
   665     case T_ARRAY  : // fall through
   666     case T_OBJECT : return atos;
   667   }
   668   return ilgl;
   669 }
   671 inline BasicType as_BasicType(TosState state) {
   672   switch (state) {
   673     //case ztos: return T_BOOLEAN;//FIXME
   674     case btos : return T_BYTE;
   675     case ctos : return T_CHAR;
   676     case stos : return T_SHORT;
   677     case itos : return T_INT;
   678     case ltos : return T_LONG;
   679     case ftos : return T_FLOAT;
   680     case dtos : return T_DOUBLE;
   681     case atos : return T_OBJECT;
   682     case vtos : return T_VOID;
   683   }
   684   return T_ILLEGAL;
   685 }
   688 // Helper function to convert BasicType info into TosState
   689 // Note: Cannot define here as it uses global constant at the time being.
   690 TosState as_TosState(BasicType type);
   693 // ReferenceType is used to distinguish between java/lang/ref/Reference subclasses
   695 enum ReferenceType {
   696  REF_NONE,      // Regular class
   697  REF_OTHER,     // Subclass of java/lang/ref/Reference, but not subclass of one of the classes below
   698  REF_SOFT,      // Subclass of java/lang/ref/SoftReference
   699  REF_WEAK,      // Subclass of java/lang/ref/WeakReference
   700  REF_FINAL,     // Subclass of java/lang/ref/FinalReference
   701  REF_PHANTOM    // Subclass of java/lang/ref/PhantomReference
   702 };
   705 // JavaThreadState keeps track of which part of the code a thread is executing in. This
   706 // information is needed by the safepoint code.
   707 //
   708 // There are 4 essential states:
   709 //
   710 //  _thread_new         : Just started, but not executed init. code yet (most likely still in OS init code)
   711 //  _thread_in_native   : In native code. This is a safepoint region, since all oops will be in jobject handles
   712 //  _thread_in_vm       : Executing in the vm
   713 //  _thread_in_Java     : Executing either interpreted or compiled Java code (or could be in a stub)
   714 //
   715 // Each state has an associated xxxx_trans state, which is an intermediate state used when a thread is in
   716 // a transition from one state to another. These extra states makes it possible for the safepoint code to
   717 // handle certain thread_states without having to suspend the thread - making the safepoint code faster.
   718 //
   719 // Given a state, the xxx_trans state can always be found by adding 1.
   720 //
   721 enum JavaThreadState {
   722   _thread_uninitialized     =  0, // should never happen (missing initialization)
   723   _thread_new               =  2, // just starting up, i.e., in process of being initialized
   724   _thread_new_trans         =  3, // corresponding transition state (not used, included for completness)
   725   _thread_in_native         =  4, // running in native code
   726   _thread_in_native_trans   =  5, // corresponding transition state
   727   _thread_in_vm             =  6, // running in VM
   728   _thread_in_vm_trans       =  7, // corresponding transition state
   729   _thread_in_Java           =  8, // running in Java or in stub code
   730   _thread_in_Java_trans     =  9, // corresponding transition state (not used, included for completness)
   731   _thread_blocked           = 10, // blocked in vm
   732   _thread_blocked_trans     = 11, // corresponding transition state
   733   _thread_max_state         = 12  // maximum thread state+1 - used for statistics allocation
   734 };
   737 // Handy constants for deciding which compiler mode to use.
   738 enum MethodCompilation {
   739   InvocationEntryBci = -1,     // i.e., not a on-stack replacement compilation
   740   InvalidOSREntryBci = -2
   741 };
   743 // Enumeration to distinguish tiers of compilation
   744 enum CompLevel {
   745   CompLevel_any               = -1,
   746   CompLevel_all               = -1,
   747   CompLevel_none              = 0,         // Interpreter
   748   CompLevel_simple            = 1,         // C1
   749   CompLevel_limited_profile   = 2,         // C1, invocation & backedge counters
   750   CompLevel_full_profile      = 3,         // C1, invocation & backedge counters + mdo
   751   CompLevel_full_optimization = 4,         // C2 or Shark
   753 #if defined(COMPILER2) || defined(SHARK)
   754   CompLevel_highest_tier      = CompLevel_full_optimization,  // pure C2 and tiered
   755 #elif defined(COMPILER1)
   756   CompLevel_highest_tier      = CompLevel_simple,             // pure C1
   757 #else
   758   CompLevel_highest_tier      = CompLevel_none,
   759 #endif
   761 #if defined(TIERED)
   762   CompLevel_initial_compile   = CompLevel_full_profile        // tiered
   763 #elif defined(COMPILER1)
   764   CompLevel_initial_compile   = CompLevel_simple              // pure C1
   765 #elif defined(COMPILER2) || defined(SHARK)
   766   CompLevel_initial_compile   = CompLevel_full_optimization   // pure C2
   767 #else
   768   CompLevel_initial_compile   = CompLevel_none
   769 #endif
   770 };
   772 inline bool is_c1_compile(int comp_level) {
   773   return comp_level > CompLevel_none && comp_level < CompLevel_full_optimization;
   774 }
   776 inline bool is_c2_compile(int comp_level) {
   777   return comp_level == CompLevel_full_optimization;
   778 }
   780 inline bool is_highest_tier_compile(int comp_level) {
   781   return comp_level == CompLevel_highest_tier;
   782 }
   784 //----------------------------------------------------------------------------------------------------
   785 // 'Forward' declarations of frequently used classes
   786 // (in order to reduce interface dependencies & reduce
   787 // number of unnecessary compilations after changes)
   789 class symbolTable;
   790 class ClassFileStream;
   792 class Event;
   794 class Thread;
   795 class  VMThread;
   796 class  JavaThread;
   797 class Threads;
   799 class VM_Operation;
   800 class VMOperationQueue;
   802 class CodeBlob;
   803 class  nmethod;
   804 class  OSRAdapter;
   805 class  I2CAdapter;
   806 class  C2IAdapter;
   807 class CompiledIC;
   808 class relocInfo;
   809 class ScopeDesc;
   810 class PcDesc;
   812 class Recompiler;
   813 class Recompilee;
   814 class RecompilationPolicy;
   815 class RFrame;
   816 class  CompiledRFrame;
   817 class  InterpretedRFrame;
   819 class frame;
   821 class vframe;
   822 class   javaVFrame;
   823 class     interpretedVFrame;
   824 class     compiledVFrame;
   825 class     deoptimizedVFrame;
   826 class   externalVFrame;
   827 class     entryVFrame;
   829 class RegisterMap;
   831 class Mutex;
   832 class Monitor;
   833 class BasicLock;
   834 class BasicObjectLock;
   836 class PeriodicTask;
   838 class JavaCallWrapper;
   840 class   oopDesc;
   842 class NativeCall;
   844 class zone;
   846 class StubQueue;
   848 class outputStream;
   850 class ResourceArea;
   852 class DebugInformationRecorder;
   853 class ScopeValue;
   854 class CompressedStream;
   855 class   DebugInfoReadStream;
   856 class   DebugInfoWriteStream;
   857 class LocationValue;
   858 class ConstantValue;
   859 class IllegalValue;
   861 class PrivilegedElement;
   862 class MonitorArray;
   864 class MonitorInfo;
   866 class OffsetClosure;
   867 class OopMapCache;
   868 class InterpreterOopMap;
   869 class OopMapCacheEntry;
   870 class OSThread;
   872 typedef int (*OSThreadStartFunc)(void*);
   874 class Space;
   876 class JavaValue;
   877 class methodHandle;
   878 class JavaCallArguments;
   880 // Basic support for errors (general debug facilities not defined at this point fo the include phase)
   882 extern void basic_fatal(const char* msg);
   885 //----------------------------------------------------------------------------------------------------
   886 // Special constants for debugging
   888 const jint     badInt           = -3;                       // generic "bad int" value
   889 const long     badAddressVal    = -2;                       // generic "bad address" value
   890 const long     badOopVal        = -1;                       // generic "bad oop" value
   891 const intptr_t badHeapOopVal    = (intptr_t) CONST64(0x2BAD4B0BBAADBABE); // value used to zap heap after GC
   892 const int      badHandleValue   = 0xBC;                     // value used to zap vm handle area
   893 const int      badResourceValue = 0xAB;                     // value used to zap resource area
   894 const int      freeBlockPad     = 0xBA;                     // value used to pad freed blocks.
   895 const int      uninitBlockPad   = 0xF1;                     // value used to zap newly malloc'd blocks.
   896 const intptr_t badJNIHandleVal  = (intptr_t) CONST64(0xFEFEFEFEFEFEFEFE); // value used to zap jni handle area
   897 const juint    badHeapWordVal   = 0xBAADBABE;               // value used to zap heap after GC
   898 const int      badCodeHeapNewVal= 0xCC;                     // value used to zap Code heap at allocation
   899 const int      badCodeHeapFreeVal = 0xDD;                   // value used to zap Code heap at deallocation
   902 // (These must be implemented as #defines because C++ compilers are
   903 // not obligated to inline non-integral constants!)
   904 #define       badAddress        ((address)::badAddressVal)
   905 #define       badOop            ((oop)::badOopVal)
   906 #define       badHeapWord       (::badHeapWordVal)
   907 #define       badJNIHandle      ((oop)::badJNIHandleVal)
   909 // Default TaskQueue size is 16K (32-bit) or 128K (64-bit)
   910 #define TASKQUEUE_SIZE (NOT_LP64(1<<14) LP64_ONLY(1<<17))
   912 //----------------------------------------------------------------------------------------------------
   913 // Utility functions for bitfield manipulations
   915 const intptr_t AllBits    = ~0; // all bits set in a word
   916 const intptr_t NoBits     =  0; // no bits set in a word
   917 const jlong    NoLongBits =  0; // no bits set in a long
   918 const intptr_t OneBit     =  1; // only right_most bit set in a word
   920 // get a word with the n.th or the right-most or left-most n bits set
   921 // (note: #define used only so that they can be used in enum constant definitions)
   922 #define nth_bit(n)        (n >= BitsPerWord ? 0 : OneBit << (n))
   923 #define right_n_bits(n)   (nth_bit(n) - 1)
   924 #define left_n_bits(n)    (right_n_bits(n) << (n >= BitsPerWord ? 0 : (BitsPerWord - n)))
   926 // bit-operations using a mask m
   927 inline void   set_bits    (intptr_t& x, intptr_t m) { x |= m; }
   928 inline void clear_bits    (intptr_t& x, intptr_t m) { x &= ~m; }
   929 inline intptr_t mask_bits      (intptr_t  x, intptr_t m) { return x & m; }
   930 inline jlong    mask_long_bits (jlong     x, jlong    m) { return x & m; }
   931 inline bool mask_bits_are_true (intptr_t flags, intptr_t mask) { return (flags & mask) == mask; }
   933 // bit-operations using the n.th bit
   934 inline void    set_nth_bit(intptr_t& x, int n) { set_bits  (x, nth_bit(n)); }
   935 inline void  clear_nth_bit(intptr_t& x, int n) { clear_bits(x, nth_bit(n)); }
   936 inline bool is_set_nth_bit(intptr_t  x, int n) { return mask_bits (x, nth_bit(n)) != NoBits; }
   938 // returns the bitfield of x starting at start_bit_no with length field_length (no sign-extension!)
   939 inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) {
   940   return mask_bits(x >> start_bit_no, right_n_bits(field_length));
   941 }
   944 //----------------------------------------------------------------------------------------------------
   945 // Utility functions for integers
   947 // Avoid use of global min/max macros which may cause unwanted double
   948 // evaluation of arguments.
   949 #ifdef max
   950 #undef max
   951 #endif
   953 #ifdef min
   954 #undef min
   955 #endif
   957 #define max(a,b) Do_not_use_max_use_MAX2_instead
   958 #define min(a,b) Do_not_use_min_use_MIN2_instead
   960 // It is necessary to use templates here. Having normal overloaded
   961 // functions does not work because it is necessary to provide both 32-
   962 // and 64-bit overloaded functions, which does not work, and having
   963 // explicitly-typed versions of these routines (i.e., MAX2I, MAX2L)
   964 // will be even more error-prone than macros.
   965 template<class T> inline T MAX2(T a, T b)           { return (a > b) ? a : b; }
   966 template<class T> inline T MIN2(T a, T b)           { return (a < b) ? a : b; }
   967 template<class T> inline T MAX3(T a, T b, T c)      { return MAX2(MAX2(a, b), c); }
   968 template<class T> inline T MIN3(T a, T b, T c)      { return MIN2(MIN2(a, b), c); }
   969 template<class T> inline T MAX4(T a, T b, T c, T d) { return MAX2(MAX3(a, b, c), d); }
   970 template<class T> inline T MIN4(T a, T b, T c, T d) { return MIN2(MIN3(a, b, c), d); }
   972 template<class T> inline T ABS(T x)                 { return (x > 0) ? x : -x; }
   974 // true if x is a power of 2, false otherwise
   975 inline bool is_power_of_2(intptr_t x) {
   976   return ((x != NoBits) && (mask_bits(x, x - 1) == NoBits));
   977 }
   979 // long version of is_power_of_2
   980 inline bool is_power_of_2_long(jlong x) {
   981   return ((x != NoLongBits) && (mask_long_bits(x, x - 1) == NoLongBits));
   982 }
   984 //* largest i such that 2^i <= x
   985 //  A negative value of 'x' will return '31'
   986 inline int log2_intptr(intptr_t x) {
   987   int i = -1;
   988   uintptr_t p =  1;
   989   while (p != 0 && p <= (uintptr_t)x) {
   990     // p = 2^(i+1) && p <= x (i.e., 2^(i+1) <= x)
   991     i++; p *= 2;
   992   }
   993   // p = 2^(i+1) && x < p (i.e., 2^i <= x < 2^(i+1))
   994   // (if p = 0 then overflow occurred and i = 31)
   995   return i;
   996 }
   998 //* largest i such that 2^i <= x
   999 //  A negative value of 'x' will return '63'
  1000 inline int log2_long(jlong x) {
  1001   int i = -1;
  1002   julong p =  1;
  1003   while (p != 0 && p <= (julong)x) {
  1004     // p = 2^(i+1) && p <= x (i.e., 2^(i+1) <= x)
  1005     i++; p *= 2;
  1007   // p = 2^(i+1) && x < p (i.e., 2^i <= x < 2^(i+1))
  1008   // (if p = 0 then overflow occurred and i = 63)
  1009   return i;
  1012 //* the argument must be exactly a power of 2
  1013 inline int exact_log2(intptr_t x) {
  1014   #ifdef ASSERT
  1015     if (!is_power_of_2(x)) basic_fatal("x must be a power of 2");
  1016   #endif
  1017   return log2_intptr(x);
  1020 //* the argument must be exactly a power of 2
  1021 inline int exact_log2_long(jlong x) {
  1022   #ifdef ASSERT
  1023     if (!is_power_of_2_long(x)) basic_fatal("x must be a power of 2");
  1024   #endif
  1025   return log2_long(x);
  1029 // returns integer round-up to the nearest multiple of s (s must be a power of two)
  1030 inline intptr_t round_to(intptr_t x, uintx s) {
  1031   #ifdef ASSERT
  1032     if (!is_power_of_2(s)) basic_fatal("s must be a power of 2");
  1033   #endif
  1034   const uintx m = s - 1;
  1035   return mask_bits(x + m, ~m);
  1038 // returns integer round-down to the nearest multiple of s (s must be a power of two)
  1039 inline intptr_t round_down(intptr_t x, uintx s) {
  1040   #ifdef ASSERT
  1041     if (!is_power_of_2(s)) basic_fatal("s must be a power of 2");
  1042   #endif
  1043   const uintx m = s - 1;
  1044   return mask_bits(x, ~m);
  1048 inline bool is_odd (intx x) { return x & 1;      }
  1049 inline bool is_even(intx x) { return !is_odd(x); }
  1051 // "to" should be greater than "from."
  1052 inline intx byte_size(void* from, void* to) {
  1053   return (address)to - (address)from;
  1056 //----------------------------------------------------------------------------------------------------
  1057 // Avoid non-portable casts with these routines (DEPRECATED)
  1059 // NOTE: USE Bytes class INSTEAD WHERE POSSIBLE
  1060 //       Bytes is optimized machine-specifically and may be much faster then the portable routines below.
  1062 // Given sequence of four bytes, build into a 32-bit word
  1063 // following the conventions used in class files.
  1064 // On the 386, this could be realized with a simple address cast.
  1065 //
  1067 // This routine takes eight bytes:
  1068 inline u8 build_u8_from( u1 c1, u1 c2, u1 c3, u1 c4, u1 c5, u1 c6, u1 c7, u1 c8 ) {
  1069   return  (( u8(c1) << 56 )  &  ( u8(0xff) << 56 ))
  1070        |  (( u8(c2) << 48 )  &  ( u8(0xff) << 48 ))
  1071        |  (( u8(c3) << 40 )  &  ( u8(0xff) << 40 ))
  1072        |  (( u8(c4) << 32 )  &  ( u8(0xff) << 32 ))
  1073        |  (( u8(c5) << 24 )  &  ( u8(0xff) << 24 ))
  1074        |  (( u8(c6) << 16 )  &  ( u8(0xff) << 16 ))
  1075        |  (( u8(c7) <<  8 )  &  ( u8(0xff) <<  8 ))
  1076        |  (( u8(c8) <<  0 )  &  ( u8(0xff) <<  0 ));
  1079 // This routine takes four bytes:
  1080 inline u4 build_u4_from( u1 c1, u1 c2, u1 c3, u1 c4 ) {
  1081   return  (( u4(c1) << 24 )  &  0xff000000)
  1082        |  (( u4(c2) << 16 )  &  0x00ff0000)
  1083        |  (( u4(c3) <<  8 )  &  0x0000ff00)
  1084        |  (( u4(c4) <<  0 )  &  0x000000ff);
  1087 // And this one works if the four bytes are contiguous in memory:
  1088 inline u4 build_u4_from( u1* p ) {
  1089   return  build_u4_from( p[0], p[1], p[2], p[3] );
  1092 // Ditto for two-byte ints:
  1093 inline u2 build_u2_from( u1 c1, u1 c2 ) {
  1094   return  u2((( u2(c1) <<  8 )  &  0xff00)
  1095           |  (( u2(c2) <<  0 )  &  0x00ff));
  1098 // And this one works if the two bytes are contiguous in memory:
  1099 inline u2 build_u2_from( u1* p ) {
  1100   return  build_u2_from( p[0], p[1] );
  1103 // Ditto for floats:
  1104 inline jfloat build_float_from( u1 c1, u1 c2, u1 c3, u1 c4 ) {
  1105   u4 u = build_u4_from( c1, c2, c3, c4 );
  1106   return  *(jfloat*)&u;
  1109 inline jfloat build_float_from( u1* p ) {
  1110   u4 u = build_u4_from( p );
  1111   return  *(jfloat*)&u;
  1115 // now (64-bit) longs
  1117 inline jlong build_long_from( u1 c1, u1 c2, u1 c3, u1 c4, u1 c5, u1 c6, u1 c7, u1 c8 ) {
  1118   return  (( jlong(c1) << 56 )  &  ( jlong(0xff) << 56 ))
  1119        |  (( jlong(c2) << 48 )  &  ( jlong(0xff) << 48 ))
  1120        |  (( jlong(c3) << 40 )  &  ( jlong(0xff) << 40 ))
  1121        |  (( jlong(c4) << 32 )  &  ( jlong(0xff) << 32 ))
  1122        |  (( jlong(c5) << 24 )  &  ( jlong(0xff) << 24 ))
  1123        |  (( jlong(c6) << 16 )  &  ( jlong(0xff) << 16 ))
  1124        |  (( jlong(c7) <<  8 )  &  ( jlong(0xff) <<  8 ))
  1125        |  (( jlong(c8) <<  0 )  &  ( jlong(0xff) <<  0 ));
  1128 inline jlong build_long_from( u1* p ) {
  1129   return  build_long_from( p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7] );
  1133 // Doubles, too!
  1134 inline jdouble build_double_from( u1 c1, u1 c2, u1 c3, u1 c4, u1 c5, u1 c6, u1 c7, u1 c8 ) {
  1135   jlong u = build_long_from( c1, c2, c3, c4, c5, c6, c7, c8 );
  1136   return  *(jdouble*)&u;
  1139 inline jdouble build_double_from( u1* p ) {
  1140   jlong u = build_long_from( p );
  1141   return  *(jdouble*)&u;
  1145 // Portable routines to go the other way:
  1147 inline void explode_short_to( u2 x, u1& c1, u1& c2 ) {
  1148   c1 = u1(x >> 8);
  1149   c2 = u1(x);
  1152 inline void explode_short_to( u2 x, u1* p ) {
  1153   explode_short_to( x, p[0], p[1]);
  1156 inline void explode_int_to( u4 x, u1& c1, u1& c2, u1& c3, u1& c4 ) {
  1157   c1 = u1(x >> 24);
  1158   c2 = u1(x >> 16);
  1159   c3 = u1(x >>  8);
  1160   c4 = u1(x);
  1163 inline void explode_int_to( u4 x, u1* p ) {
  1164   explode_int_to( x, p[0], p[1], p[2], p[3]);
  1168 // Pack and extract shorts to/from ints:
  1170 inline int extract_low_short_from_int(jint x) {
  1171   return x & 0xffff;
  1174 inline int extract_high_short_from_int(jint x) {
  1175   return (x >> 16) & 0xffff;
  1178 inline int build_int_from_shorts( jushort low, jushort high ) {
  1179   return ((int)((unsigned int)high << 16) | (unsigned int)low);
  1182 // Printf-style formatters for fixed- and variable-width types as pointers and
  1183 // integers.  These are derived from the definitions in inttypes.h.  If the platform
  1184 // doesn't provide appropriate definitions, they should be provided in
  1185 // the compiler-specific definitions file (e.g., globalDefinitions_gcc.hpp)
  1187 #define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false")
  1189 // Format 32-bit quantities.
  1190 #define INT32_FORMAT           "%" PRId32
  1191 #define UINT32_FORMAT          "%" PRIu32
  1192 #define INT32_FORMAT_W(width)  "%" #width PRId32
  1193 #define UINT32_FORMAT_W(width) "%" #width PRIu32
  1195 #define PTR32_FORMAT           "0x%08" PRIx32
  1197 // Format 64-bit quantities.
  1198 #define INT64_FORMAT           "%" PRId64
  1199 #define UINT64_FORMAT          "%" PRIu64
  1200 #define INT64_FORMAT_W(width)  "%" #width PRId64
  1201 #define UINT64_FORMAT_W(width) "%" #width PRIu64
  1203 #define PTR64_FORMAT           "0x%016" PRIx64
  1205 // Format pointers which change size between 32- and 64-bit.
  1206 #ifdef  _LP64
  1207 #define INTPTR_FORMAT "0x%016" PRIxPTR
  1208 #define PTR_FORMAT    "0x%016" PRIxPTR
  1209 #else   // !_LP64
  1210 #define INTPTR_FORMAT "0x%08"  PRIxPTR
  1211 #define PTR_FORMAT    "0x%08"  PRIxPTR
  1212 #endif  // _LP64
  1214 #define SSIZE_FORMAT          "%" PRIdPTR
  1215 #define SIZE_FORMAT           "%" PRIuPTR
  1216 #define SSIZE_FORMAT_W(width) "%" #width PRIdPTR
  1217 #define SIZE_FORMAT_W(width)  "%" #width PRIuPTR
  1219 #define INTX_FORMAT           "%" PRIdPTR
  1220 #define UINTX_FORMAT          "%" PRIuPTR
  1221 #define INTX_FORMAT_W(width)  "%" #width PRIdPTR
  1222 #define UINTX_FORMAT_W(width) "%" #width PRIuPTR
  1225 // Enable zap-a-lot if in debug version.
  1227 # ifdef ASSERT
  1228 # ifdef COMPILER2
  1229 #   define ENABLE_ZAP_DEAD_LOCALS
  1230 #endif /* COMPILER2 */
  1231 # endif /* ASSERT */
  1233 #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0]))
  1235 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP

mercurial