396 }
397
398 // Align objects by rounding up their size, in HeapWord units.
399
400 #define align_object_size_(size) align_size_up_(size, MinObjAlignment)
401
402 inline intptr_t align_object_size(intptr_t size) {
403 return align_size_up(size, MinObjAlignment);
404 }
405
406 inline bool is_object_aligned(intptr_t addr) {
407 return addr == align_object_size(addr);
408 }
409
410 // Pad out certain offsets to jlong alignment, in HeapWord units.
411
412 inline intptr_t align_object_offset(intptr_t offset) {
413 return align_size_up(offset, HeapWordsPerLong);
414 }
415
416 // The expected size in bytes of a cache line, used to pad data structures.
417 #define DEFAULT_CACHE_LINE_SIZE 64
418
419 // Bytes needed to pad type to avoid cache-line sharing; alignment should be the
420 // expected cache line size (a power of two). The first addend avoids sharing
421 // when the start address is not a multiple of alignment; the second maintains
422 // alignment of starting addresses that happen to be a multiple.
423 #define PADDING_SIZE(type, alignment) \
424 ((alignment) + align_size_up_(sizeof(type), alignment))
425
426 // Templates to create a subclass padded to avoid cache line sharing. These are
427 // effective only when applied to derived-most (leaf) classes.
428
429 // When no args are passed to the base ctor.
430 template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
431 class Padded: public T {
432 private:
433 char _pad_buf_[PADDING_SIZE(T, alignment)];
434 };
435
1256 #define SSIZE_FORMAT "%" PRIdPTR
1257 #define SIZE_FORMAT "%" PRIuPTR
1258 #define SSIZE_FORMAT_W(width) "%" #width PRIdPTR
1259 #define SIZE_FORMAT_W(width) "%" #width PRIuPTR
1260
1261 #define INTX_FORMAT "%" PRIdPTR
1262 #define UINTX_FORMAT "%" PRIuPTR
1263 #define INTX_FORMAT_W(width) "%" #width PRIdPTR
1264 #define UINTX_FORMAT_W(width) "%" #width PRIuPTR
1265
1266
1267 // Enable zap-a-lot if in debug version.
1268
1269 # ifdef ASSERT
1270 # ifdef COMPILER2
1271 # define ENABLE_ZAP_DEAD_LOCALS
1272 #endif /* COMPILER2 */
1273 # endif /* ASSERT */
1274
1275 #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0]))
1276
1277 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
|
396 }
397
398 // Align objects by rounding up their size, in HeapWord units.
399
400 #define align_object_size_(size) align_size_up_(size, MinObjAlignment)
401
402 inline intptr_t align_object_size(intptr_t size) {
403 return align_size_up(size, MinObjAlignment);
404 }
405
406 inline bool is_object_aligned(intptr_t addr) {
407 return addr == align_object_size(addr);
408 }
409
410 // Pad out certain offsets to jlong alignment, in HeapWord units.
411
412 inline intptr_t align_object_offset(intptr_t offset) {
413 return align_size_up(offset, HeapWordsPerLong);
414 }
415
416 // Clamp an address to be within a specific page
417 // 1. If addr is on the page it is returned as is
418 // 2. If addr is above the page_address the start of the *next* page will be returned
419 // 3. Otherwise, if addr is below the page_address the start of the page will be returned
420 address clamp_address_in_page(address addr, address page_address);
421
422
423 // The expected size in bytes of a cache line, used to pad data structures.
424 #define DEFAULT_CACHE_LINE_SIZE 64
425
426 // Bytes needed to pad type to avoid cache-line sharing; alignment should be the
427 // expected cache line size (a power of two). The first addend avoids sharing
428 // when the start address is not a multiple of alignment; the second maintains
429 // alignment of starting addresses that happen to be a multiple.
430 #define PADDING_SIZE(type, alignment) \
431 ((alignment) + align_size_up_(sizeof(type), alignment))
432
433 // Templates to create a subclass padded to avoid cache line sharing. These are
434 // effective only when applied to derived-most (leaf) classes.
435
436 // When no args are passed to the base ctor.
437 template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
438 class Padded: public T {
439 private:
440 char _pad_buf_[PADDING_SIZE(T, alignment)];
441 };
442
1263 #define SSIZE_FORMAT "%" PRIdPTR
1264 #define SIZE_FORMAT "%" PRIuPTR
1265 #define SSIZE_FORMAT_W(width) "%" #width PRIdPTR
1266 #define SIZE_FORMAT_W(width) "%" #width PRIuPTR
1267
1268 #define INTX_FORMAT "%" PRIdPTR
1269 #define UINTX_FORMAT "%" PRIuPTR
1270 #define INTX_FORMAT_W(width) "%" #width PRIdPTR
1271 #define UINTX_FORMAT_W(width) "%" #width PRIuPTR
1272
1273
1274 // Enable zap-a-lot if in debug version.
1275
1276 # ifdef ASSERT
1277 # ifdef COMPILER2
1278 # define ENABLE_ZAP_DEAD_LOCALS
1279 #endif /* COMPILER2 */
1280 # endif /* ASSERT */
1281
1282 #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0]))
1283
1284
1285 #ifndef PRODUCT
1286
1287 // For unit testing only
1288 class GlobalDefinitions {
1289 public:
1290 static void test_globals();
1291 };
1292
1293 #endif // PRODUCT
1294
1295 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
|