src/share/vm/utilities/globalDefinitions.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/utilities

src/share/vm/utilities/globalDefinitions.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2013, 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  *


  25 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
  26 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
  27 
  28 #ifndef __STDC_FORMAT_MACROS
  29 #define __STDC_FORMAT_MACROS
  30 #endif
  31 
  32 #ifdef TARGET_COMPILER_gcc
  33 # include "utilities/globalDefinitions_gcc.hpp"
  34 #endif
  35 #ifdef TARGET_COMPILER_visCPP
  36 # include "utilities/globalDefinitions_visCPP.hpp"
  37 #endif
  38 #ifdef TARGET_COMPILER_sparcWorks
  39 # include "utilities/globalDefinitions_sparcWorks.hpp"
  40 #endif
  41 #ifdef TARGET_COMPILER_xlc
  42 # include "utilities/globalDefinitions_xlc.hpp"
  43 #endif
  44 


























  45 #include "utilities/macros.hpp"
  46 
  47 // This file holds all globally used constants & types, class (forward)
  48 // declarations and a few frequently used utility functions.
  49 
  50 //----------------------------------------------------------------------------------------------------
  51 // Constants
  52 
  53 const int LogBytesPerShort   = 1;
  54 const int LogBytesPerInt     = 2;
  55 #ifdef _LP64
  56 const int LogBytesPerWord    = 3;
  57 #else
  58 const int LogBytesPerWord    = 2;
  59 #endif
  60 const int LogBytesPerLong    = 3;
  61 
  62 const int BytesPerShort      = 1 << LogBytesPerShort;
  63 const int BytesPerInt        = 1 << LogBytesPerInt;
  64 const int BytesPerWord       = 1 << LogBytesPerWord;


1267 
1268 inline void explode_int_to( u4 x, u1* p ) {
1269   explode_int_to( x, p[0], p[1], p[2], p[3]);
1270 }
1271 
1272 
1273 // Pack and extract shorts to/from ints:
1274 
1275 inline int extract_low_short_from_int(jint x) {
1276   return x & 0xffff;
1277 }
1278 
1279 inline int extract_high_short_from_int(jint x) {
1280   return (x >> 16) & 0xffff;
1281 }
1282 
1283 inline int build_int_from_shorts( jushort low, jushort high ) {
1284   return ((int)((unsigned int)high << 16) | (unsigned int)low);
1285 }
1286 





1287 // Printf-style formatters for fixed- and variable-width types as pointers and
1288 // integers.  These are derived from the definitions in inttypes.h.  If the platform
1289 // doesn't provide appropriate definitions, they should be provided in
1290 // the compiler-specific definitions file (e.g., globalDefinitions_gcc.hpp)
1291 
1292 #define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false")
1293 
1294 // Format 32-bit quantities.
1295 #define INT32_FORMAT           "%" PRId32
1296 #define UINT32_FORMAT          "%" PRIu32
1297 #define INT32_FORMAT_W(width)  "%" #width PRId32
1298 #define UINT32_FORMAT_W(width) "%" #width PRIu32
1299 
1300 #define PTR32_FORMAT           "0x%08" PRIx32
1301 
1302 // Format 64-bit quantities.
1303 #define INT64_FORMAT           "%" PRId64
1304 #define UINT64_FORMAT          "%" PRIu64

1305 #define INT64_FORMAT_W(width)  "%" #width PRId64
1306 #define UINT64_FORMAT_W(width) "%" #width PRIu64
1307 
1308 #define PTR64_FORMAT           "0x%016" PRIx64
1309 
1310 // Format jlong, if necessary
1311 #ifndef JLONG_FORMAT
1312 #define JLONG_FORMAT           INT64_FORMAT
1313 #endif
1314 #ifndef JULONG_FORMAT
1315 #define JULONG_FORMAT          UINT64_FORMAT
1316 #endif
1317 
1318 // Format pointers which change size between 32- and 64-bit.
1319 #ifdef  _LP64
1320 #define INTPTR_FORMAT "0x%016" PRIxPTR
1321 #define PTR_FORMAT    "0x%016" PRIxPTR
1322 #else   // !_LP64
1323 #define INTPTR_FORMAT "0x%08"  PRIxPTR
1324 #define PTR_FORMAT    "0x%08"  PRIxPTR
1325 #endif  // _LP64
1326 


1327 #define SSIZE_FORMAT             "%"   PRIdPTR
1328 #define SIZE_FORMAT              "%"   PRIuPTR
1329 #define SIZE_FORMAT_HEX          "0x%" PRIxPTR
1330 #define SSIZE_FORMAT_W(width)    "%"   #width PRIdPTR
1331 #define SIZE_FORMAT_W(width)     "%"   #width PRIuPTR
1332 #define SIZE_FORMAT_HEX_W(width) "0x%" #width PRIxPTR
1333 
1334 #define INTX_FORMAT           "%" PRIdPTR
1335 #define UINTX_FORMAT          "%" PRIuPTR
1336 #define INTX_FORMAT_W(width)  "%" #width PRIdPTR
1337 #define UINTX_FORMAT_W(width) "%" #width PRIuPTR
1338 
1339 
1340 // Enable zap-a-lot if in debug version.
1341 
1342 # ifdef ASSERT
1343 # ifdef COMPILER2
1344 #   define ENABLE_ZAP_DEAD_LOCALS
1345 #endif /* COMPILER2 */
1346 # endif /* ASSERT */
1347 
1348 #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0]))
1349 
1350 // Dereference vptr
1351 // All C++ compilers that we know of have the vtbl pointer in the first
1352 // word.  If there are exceptions, this function needs to be made compiler
1353 // specific.
1354 static inline void* dereference_vptr(void* addr) {
1355   return *(void**)addr;
1356 }
1357 
1358 
1359 #ifndef PRODUCT
1360 
1361 // For unit testing only
1362 class GlobalDefinitions {
1363 public:
1364   static void test_globals();
1365 };
1366 
1367 #endif // PRODUCT
1368 
1369 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
   1 /*
   2  * Copyright (c) 1997, 2014, 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  *


  25 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
  26 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
  27 
  28 #ifndef __STDC_FORMAT_MACROS
  29 #define __STDC_FORMAT_MACROS
  30 #endif
  31 
  32 #ifdef TARGET_COMPILER_gcc
  33 # include "utilities/globalDefinitions_gcc.hpp"
  34 #endif
  35 #ifdef TARGET_COMPILER_visCPP
  36 # include "utilities/globalDefinitions_visCPP.hpp"
  37 #endif
  38 #ifdef TARGET_COMPILER_sparcWorks
  39 # include "utilities/globalDefinitions_sparcWorks.hpp"
  40 #endif
  41 #ifdef TARGET_COMPILER_xlc
  42 # include "utilities/globalDefinitions_xlc.hpp"
  43 #endif
  44 
  45 #ifndef PRAGMA_DIAG_PUSH
  46 #define PRAGMA_DIAG_PUSH
  47 #endif
  48 #ifndef PRAGMA_DIAG_POP
  49 #define PRAGMA_DIAG_POP
  50 #endif
  51 #ifndef PRAGMA_FORMAT_NONLITERAL_IGNORED
  52 #define PRAGMA_FORMAT_NONLITERAL_IGNORED
  53 #endif
  54 #ifndef PRAGMA_FORMAT_IGNORED
  55 #define PRAGMA_FORMAT_IGNORED
  56 #endif
  57 #ifndef PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL
  58 #define PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL
  59 #endif
  60 #ifndef PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL
  61 #define PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL
  62 #endif
  63 #ifndef PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  64 #define PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  65 #endif
  66 #ifndef ATTRIBUTE_PRINTF
  67 #define ATTRIBUTE_PRINTF(fmt, vargs)
  68 #endif
  69 
  70 
  71 #include "utilities/macros.hpp"
  72 
  73 // This file holds all globally used constants & types, class (forward)
  74 // declarations and a few frequently used utility functions.
  75 
  76 //----------------------------------------------------------------------------------------------------
  77 // Constants
  78 
  79 const int LogBytesPerShort   = 1;
  80 const int LogBytesPerInt     = 2;
  81 #ifdef _LP64
  82 const int LogBytesPerWord    = 3;
  83 #else
  84 const int LogBytesPerWord    = 2;
  85 #endif
  86 const int LogBytesPerLong    = 3;
  87 
  88 const int BytesPerShort      = 1 << LogBytesPerShort;
  89 const int BytesPerInt        = 1 << LogBytesPerInt;
  90 const int BytesPerWord       = 1 << LogBytesPerWord;


1293 
1294 inline void explode_int_to( u4 x, u1* p ) {
1295   explode_int_to( x, p[0], p[1], p[2], p[3]);
1296 }
1297 
1298 
1299 // Pack and extract shorts to/from ints:
1300 
1301 inline int extract_low_short_from_int(jint x) {
1302   return x & 0xffff;
1303 }
1304 
1305 inline int extract_high_short_from_int(jint x) {
1306   return (x >> 16) & 0xffff;
1307 }
1308 
1309 inline int build_int_from_shorts( jushort low, jushort high ) {
1310   return ((int)((unsigned int)high << 16) | (unsigned int)low);
1311 }
1312 
1313 // Convert pointer to intptr_t, for use in printing pointers.
1314 inline intptr_t p2i(const void * p) {
1315   return (intptr_t) p;
1316 }
1317 
1318 // Printf-style formatters for fixed- and variable-width types as pointers and
1319 // integers.  These are derived from the definitions in inttypes.h.  If the platform
1320 // doesn't provide appropriate definitions, they should be provided in
1321 // the compiler-specific definitions file (e.g., globalDefinitions_gcc.hpp)
1322 
1323 #define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false")
1324 
1325 // Format 32-bit quantities.
1326 #define INT32_FORMAT           "%" PRId32
1327 #define UINT32_FORMAT          "%" PRIu32
1328 #define INT32_FORMAT_W(width)  "%" #width PRId32
1329 #define UINT32_FORMAT_W(width) "%" #width PRIu32
1330 
1331 #define PTR32_FORMAT           "0x%08" PRIx32
1332 
1333 // Format 64-bit quantities.
1334 #define INT64_FORMAT           "%" PRId64
1335 #define UINT64_FORMAT          "%" PRIu64
1336 #define UINT64_FORMAT_X        "%" PRIx64
1337 #define INT64_FORMAT_W(width)  "%" #width PRId64
1338 #define UINT64_FORMAT_W(width) "%" #width PRIu64
1339 
1340 #define PTR64_FORMAT           "0x%016" PRIx64
1341 
1342 // Format jlong, if necessary
1343 #ifndef JLONG_FORMAT
1344 #define JLONG_FORMAT           INT64_FORMAT
1345 #endif
1346 #ifndef JULONG_FORMAT
1347 #define JULONG_FORMAT          UINT64_FORMAT
1348 #endif
1349 
1350 // Format pointers which change size between 32- and 64-bit.
1351 #ifdef  _LP64
1352 #define INTPTR_FORMAT "0x%016" PRIxPTR
1353 #define PTR_FORMAT    "0x%016" PRIxPTR
1354 #else   // !_LP64
1355 #define INTPTR_FORMAT "0x%08"  PRIxPTR
1356 #define PTR_FORMAT    "0x%08"  PRIxPTR
1357 #endif  // _LP64
1358 
1359 #define PTR_FORMAT_W(width)   "%" #width PRIxPTR
1360 
1361 #define SSIZE_FORMAT             "%"   PRIdPTR
1362 #define SIZE_FORMAT              "%"   PRIuPTR
1363 #define SIZE_FORMAT_HEX          "0x%" PRIxPTR
1364 #define SSIZE_FORMAT_W(width)    "%"   #width PRIdPTR
1365 #define SIZE_FORMAT_W(width)     "%"   #width PRIuPTR
1366 #define SIZE_FORMAT_HEX_W(width) "0x%" #width PRIxPTR
1367 
1368 #define INTX_FORMAT           "%" PRIdPTR
1369 #define UINTX_FORMAT          "%" PRIuPTR
1370 #define INTX_FORMAT_W(width)  "%" #width PRIdPTR
1371 #define UINTX_FORMAT_W(width) "%" #width PRIuPTR
1372 
1373 
1374 // Enable zap-a-lot if in debug version.
1375 
1376 # ifdef ASSERT
1377 # ifdef COMPILER2
1378 #   define ENABLE_ZAP_DEAD_LOCALS
1379 #endif /* COMPILER2 */
1380 # endif /* ASSERT */
1381 
1382 #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0]))
1383 
1384 // Dereference vptr
1385 // All C++ compilers that we know of have the vtbl pointer in the first
1386 // word.  If there are exceptions, this function needs to be made compiler
1387 // specific.
1388 static inline void* dereference_vptr(void* addr) {
1389   return *(void**)addr;
1390 }
1391 

1392 #ifndef PRODUCT
1393 
1394 // For unit testing only
1395 class GlobalDefinitions {
1396 public:
1397   static void test_globals();
1398 };
1399 
1400 #endif // PRODUCT
1401 
1402 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
src/share/vm/utilities/globalDefinitions.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File