1402 #define PTR_FORMAT "0x%08" PRIxPTR
1403 #endif // _LP64
1404
1405 #define INTPTR_FORMAT_W(width) "%" #width PRIxPTR
1406
1407 #define SSIZE_FORMAT "%" PRIdPTR
1408 #define SIZE_FORMAT "%" PRIuPTR
1409 #define SIZE_FORMAT_HEX "0x%" PRIxPTR
1410 #define SSIZE_FORMAT_W(width) "%" #width PRIdPTR
1411 #define SIZE_FORMAT_W(width) "%" #width PRIuPTR
1412 #define SIZE_FORMAT_HEX_W(width) "0x%" #width PRIxPTR
1413
1414 #define INTX_FORMAT "%" PRIdPTR
1415 #define UINTX_FORMAT "%" PRIuPTR
1416 #define INTX_FORMAT_W(width) "%" #width PRIdPTR
1417 #define UINTX_FORMAT_W(width) "%" #width PRIuPTR
1418
1419
1420 #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0]))
1421
1422 // Dereference vptr
1423 // All C++ compilers that we know of have the vtbl pointer in the first
1424 // word. If there are exceptions, this function needs to be made compiler
1425 // specific.
1426 static inline void* dereference_vptr(const void* addr) {
1427 return *(void**)addr;
1428 }
1429
1430 #ifndef PRODUCT
1431
1432 // For unit testing only
1433 class GlobalDefinitions {
1434 public:
1435 static void test_globals();
1436 };
1437
1438 #endif // PRODUCT
1439
1440 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
|
1402 #define PTR_FORMAT "0x%08" PRIxPTR
1403 #endif // _LP64
1404
1405 #define INTPTR_FORMAT_W(width) "%" #width PRIxPTR
1406
1407 #define SSIZE_FORMAT "%" PRIdPTR
1408 #define SIZE_FORMAT "%" PRIuPTR
1409 #define SIZE_FORMAT_HEX "0x%" PRIxPTR
1410 #define SSIZE_FORMAT_W(width) "%" #width PRIdPTR
1411 #define SIZE_FORMAT_W(width) "%" #width PRIuPTR
1412 #define SIZE_FORMAT_HEX_W(width) "0x%" #width PRIxPTR
1413
1414 #define INTX_FORMAT "%" PRIdPTR
1415 #define UINTX_FORMAT "%" PRIuPTR
1416 #define INTX_FORMAT_W(width) "%" #width PRIdPTR
1417 #define UINTX_FORMAT_W(width) "%" #width PRIuPTR
1418
1419
1420 #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0]))
1421
1422 //----------------------------------------------------------------------------------------------------
1423 // Sum and product which can never overflow: they wrap, just like the
1424 // Java operations. Note that we don't intend these to be used for
1425 // general-purpose arithmetic: their purpose is to emulate Java
1426 // operations.
1427
1428 // The goal of this code to avoid undefined or implementation-defined
1429 // behaviour. The use of an lvalue to reference cast is explicitly
1430 // permitted by Lvalues and rvalues [basic.lval]. [Section 3.10 Para
1431 // 15 in C++03]
1432 #define JAVA_INTEGER_OP(OP, NAME, TYPE, UNSIGNED_TYPE) \
1433 inline TYPE NAME (TYPE in1, TYPE in2) { \
1434 UNSIGNED_TYPE ures = static_cast<UNSIGNED_TYPE>(in1); \
1435 ures OP ## = static_cast<UNSIGNED_TYPE>(in2); \
1436 return reinterpret_cast<TYPE&>(ures); \
1437 }
1438
1439 JAVA_INTEGER_OP(+, java_add, jint, juint)
1440 JAVA_INTEGER_OP(-, java_subtract, jint, juint)
1441 JAVA_INTEGER_OP(*, java_multiply, jint, juint)
1442 JAVA_INTEGER_OP(+, java_add, jlong, julong)
1443 JAVA_INTEGER_OP(-, java_subtract, jlong, julong)
1444 JAVA_INTEGER_OP(*, java_multiply, jlong, julong)
1445
1446 #undef JAVA_INTEGER_OP
1447
1448 // Dereference vptr
1449 // All C++ compilers that we know of have the vtbl pointer in the first
1450 // word. If there are exceptions, this function needs to be made compiler
1451 // specific.
1452 static inline void* dereference_vptr(const void* addr) {
1453 return *(void**)addr;
1454 }
1455
1456 #ifndef PRODUCT
1457
1458 // For unit testing only
1459 class GlobalDefinitions {
1460 public:
1461 static void test_globals();
1462 };
1463
1464 #endif // PRODUCT
1465
1466 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
|