comparison src/share/vm/utilities/globalDefinitions.hpp @ 12355:cefad50507d8

Merge with hs25-b53
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 11 Oct 2013 10:38:03 +0200
parents 58fc8e2b7b6d 190899198332
children 359f7e70ae7f
comparison
equal deleted inserted replaced
12058:ccb4f2af2319 12355:cefad50507d8
400 // for use in places like enum definitions that require compile-time constant 400 // for use in places like enum definitions that require compile-time constant
401 // expressions and a function for all other places so as to get type checking. 401 // expressions and a function for all other places so as to get type checking.
402 402
403 #define align_size_up_(size, alignment) (((size) + ((alignment) - 1)) & ~((alignment) - 1)) 403 #define align_size_up_(size, alignment) (((size) + ((alignment) - 1)) & ~((alignment) - 1))
404 404
405 inline bool is_size_aligned(size_t size, size_t alignment) {
406 return align_size_up_(size, alignment) == size;
407 }
408
409 inline bool is_ptr_aligned(void* ptr, size_t alignment) {
410 return align_size_up_((intptr_t)ptr, (intptr_t)alignment) == (intptr_t)ptr;
411 }
412
405 inline intptr_t align_size_up(intptr_t size, intptr_t alignment) { 413 inline intptr_t align_size_up(intptr_t size, intptr_t alignment) {
406 return align_size_up_(size, alignment); 414 return align_size_up_(size, alignment);
407 } 415 }
408 416
409 #define align_size_down_(size, alignment) ((size) & ~((alignment) - 1)) 417 #define align_size_down_(size, alignment) ((size) & ~((alignment) - 1))
411 inline intptr_t align_size_down(intptr_t size, intptr_t alignment) { 419 inline intptr_t align_size_down(intptr_t size, intptr_t alignment) {
412 return align_size_down_(size, alignment); 420 return align_size_down_(size, alignment);
413 } 421 }
414 422
415 #define is_size_aligned_(size, alignment) ((size) == (align_size_up_(size, alignment))) 423 #define is_size_aligned_(size, alignment) ((size) == (align_size_up_(size, alignment)))
424
425 inline void* align_ptr_up(void* ptr, size_t alignment) {
426 return (void*)align_size_up((intptr_t)ptr, (intptr_t)alignment);
427 }
428
429 inline void* align_ptr_down(void* ptr, size_t alignment) {
430 return (void*)align_size_down((intptr_t)ptr, (intptr_t)alignment);
431 }
416 432
417 // Align objects by rounding up their size, in HeapWord units. 433 // Align objects by rounding up their size, in HeapWord units.
418 434
419 #define align_object_size_(size) align_size_up_(size, MinObjAlignment) 435 #define align_object_size_(size) align_size_up_(size, MinObjAlignment)
420 436
949 965
950 966
951 // (These must be implemented as #defines because C++ compilers are 967 // (These must be implemented as #defines because C++ compilers are
952 // not obligated to inline non-integral constants!) 968 // not obligated to inline non-integral constants!)
953 #define badAddress ((address)::badAddressVal) 969 #define badAddress ((address)::badAddressVal)
954 #define badOop ((oop)::badOopVal) 970 #define badOop (cast_to_oop(::badOopVal))
955 #define badHeapWord (::badHeapWordVal) 971 #define badHeapWord (::badHeapWordVal)
956 #define badJNIHandle ((oop)::badJNIHandleVal) 972 #define badJNIHandle (cast_to_oop(::badJNIHandleVal))
957 973
958 // Default TaskQueue size is 16K (32-bit) or 128K (64-bit) 974 // Default TaskQueue size is 16K (32-bit) or 128K (64-bit)
959 #define TASKQUEUE_SIZE (NOT_LP64(1<<14) LP64_ONLY(1<<17)) 975 #define TASKQUEUE_SIZE (NOT_LP64(1<<14) LP64_ONLY(1<<17))
960 976
961 //---------------------------------------------------------------------------------------------------- 977 //----------------------------------------------------------------------------------------------------