45 memset(aligned_addr, 0, size);
46
47 // Since free expects pointers returned by malloc, aligned_addr cannot be
48 // freed since it is most likely not the same as addr after alignment.
49 return (uintptr_t)aligned_addr;
50 }
51
52 inline size_t ZUtils::bytes_to_words(size_t size_in_bytes) {
53 assert(is_aligned(size_in_bytes, BytesPerWord), "Size not word aligned");
54 return size_in_bytes >> LogBytesPerWord;
55 }
56
57 inline size_t ZUtils::words_to_bytes(size_t size_in_words) {
58 return size_in_words << LogBytesPerWord;
59 }
60
61 inline size_t ZUtils::object_size(zaddress addr) {
62 return words_to_bytes(to_oop(addr)->size());
63 }
64
65 inline void ZUtils::object_copy_disjoint(zaddress from, zaddress to, size_t size) {
66 Copy::aligned_disjoint_words((HeapWord*)untype(from), (HeapWord*)untype(to), bytes_to_words(size));
67 }
68
69 inline void ZUtils::object_copy_conjoint(zaddress from, zaddress to, size_t size) {
70 if (from != to) {
71 Copy::aligned_conjoint_words((HeapWord*)untype(from), (HeapWord*)untype(to), bytes_to_words(size));
72 }
73 }
74
75 template <typename T>
76 inline void ZUtils::copy_disjoint(T* dest, const T* src, size_t count) {
77 memcpy(dest, src, sizeof(T) * count);
78 }
79
80 template <typename T>
81 inline void ZUtils::copy_disjoint(T* dest, const T* src, int count) {
82 assert(count >= 0, "must be positive %d", count);
83
84 copy_disjoint(dest, src, static_cast<size_t>(count));
|
45 memset(aligned_addr, 0, size);
46
47 // Since free expects pointers returned by malloc, aligned_addr cannot be
48 // freed since it is most likely not the same as addr after alignment.
49 return (uintptr_t)aligned_addr;
50 }
51
52 inline size_t ZUtils::bytes_to_words(size_t size_in_bytes) {
53 assert(is_aligned(size_in_bytes, BytesPerWord), "Size not word aligned");
54 return size_in_bytes >> LogBytesPerWord;
55 }
56
57 inline size_t ZUtils::words_to_bytes(size_t size_in_words) {
58 return size_in_words << LogBytesPerWord;
59 }
60
61 inline size_t ZUtils::object_size(zaddress addr) {
62 return words_to_bytes(to_oop(addr)->size());
63 }
64
65 inline size_t ZUtils::copy_size(zaddress addr, size_t old_size) {
66 oop obj = to_oop(addr);
67 return words_to_bytes(obj->copy_size(bytes_to_words(old_size), obj->mark()));
68 }
69
70 inline void ZUtils::initialize_hash_if_necessary(zaddress to_addr, zaddress from_addr) {
71 to_oop(to_addr)->initialize_hash_if_necessary(to_oop(from_addr));
72 }
73
74 inline void ZUtils::object_copy_disjoint(zaddress from, zaddress to, size_t size) {
75 Copy::aligned_disjoint_words((HeapWord*)untype(from), (HeapWord*)untype(to), bytes_to_words(size));
76 }
77
78 inline void ZUtils::object_copy_conjoint(zaddress from, zaddress to, size_t size) {
79 if (from != to) {
80 Copy::aligned_conjoint_words((HeapWord*)untype(from), (HeapWord*)untype(to), bytes_to_words(size));
81 }
82 }
83
84 template <typename T>
85 inline void ZUtils::copy_disjoint(T* dest, const T* src, size_t count) {
86 memcpy(dest, src, sizeof(T) * count);
87 }
88
89 template <typename T>
90 inline void ZUtils::copy_disjoint(T* dest, const T* src, int count) {
91 assert(count >= 0, "must be positive %d", count);
92
93 copy_disjoint(dest, src, static_cast<size_t>(count));
|