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