Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/allocation.cpp @ 17937:78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
8043029: Change 8037816 breaks HS build with older GCC versions which don't support diagnostic pragmas
8043164: Format warning in traceStream.hpp
Summary: Backport of main fix + two corrections, enables clang compilation, turns on format attributes, corrects/mutes warnings
Reviewed-by: kvn, coleenp, iveresov, twisti
author | drchase |
---|---|
date | Thu, 22 May 2014 15:52:41 -0400 |
parents | 7384f6a12fc1 |
children | 09619752c16d |
comparison
equal
deleted
inserted
replaced
17935:7384f6a12fc1 | 17937:78bbf4d43a14 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
77 bool MetaspaceObj::is_metaspace_object() const { | 77 bool MetaspaceObj::is_metaspace_object() const { |
78 return Metaspace::contains((void*)this); | 78 return Metaspace::contains((void*)this); |
79 } | 79 } |
80 | 80 |
81 void MetaspaceObj::print_address_on(outputStream* st) const { | 81 void MetaspaceObj::print_address_on(outputStream* st) const { |
82 st->print(" {"INTPTR_FORMAT"}", this); | 82 st->print(" {" INTPTR_FORMAT "}", p2i(this)); |
83 } | 83 } |
84 | 84 |
85 void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() { | 85 void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() { |
86 address res; | 86 address res; |
87 switch (type) { | 87 switch (type) { |
140 | 140 |
141 #ifdef ASSERT | 141 #ifdef ASSERT |
142 void ResourceObj::set_allocation_type(address res, allocation_type type) { | 142 void ResourceObj::set_allocation_type(address res, allocation_type type) { |
143 // Set allocation type in the resource object | 143 // Set allocation type in the resource object |
144 uintptr_t allocation = (uintptr_t)res; | 144 uintptr_t allocation = (uintptr_t)res; |
145 assert((allocation & allocation_mask) == 0, err_msg("address should be aligned to 4 bytes at least: " PTR_FORMAT, res)); | 145 assert((allocation & allocation_mask) == 0, err_msg("address should be aligned to 4 bytes at least: " INTPTR_FORMAT, p2i(res))); |
146 assert(type <= allocation_mask, "incorrect allocation type"); | 146 assert(type <= allocation_mask, "incorrect allocation type"); |
147 ResourceObj* resobj = (ResourceObj *)res; | 147 ResourceObj* resobj = (ResourceObj *)res; |
148 resobj->_allocation_t[0] = ~(allocation + type); | 148 resobj->_allocation_t[0] = ~(allocation + type); |
149 if (type != STACK_OR_EMBEDDED) { | 149 if (type != STACK_OR_EMBEDDED) { |
150 // Called from operator new() and CollectionSetChooser(), | 150 // Called from operator new() and CollectionSetChooser(), |
177 // Ignore garbage in other fields. | 177 // Ignore garbage in other fields. |
178 } else if (is_type_set()) { | 178 } else if (is_type_set()) { |
179 // Operator new() was called and type was set. | 179 // Operator new() was called and type was set. |
180 assert(!allocated_on_stack(), | 180 assert(!allocated_on_stack(), |
181 err_msg("not embedded or stack, this(" PTR_FORMAT ") type %d a[0]=(" PTR_FORMAT ") a[1]=(" PTR_FORMAT ")", | 181 err_msg("not embedded or stack, this(" PTR_FORMAT ") type %d a[0]=(" PTR_FORMAT ") a[1]=(" PTR_FORMAT ")", |
182 this, get_allocation_type(), _allocation_t[0], _allocation_t[1])); | 182 p2i(this), get_allocation_type(), _allocation_t[0], _allocation_t[1])); |
183 } else { | 183 } else { |
184 // Operator new() was not called. | 184 // Operator new() was not called. |
185 // Assume that it is embedded or stack object. | 185 // Assume that it is embedded or stack object. |
186 set_allocation_type((address)this, STACK_OR_EMBEDDED); | 186 set_allocation_type((address)this, STACK_OR_EMBEDDED); |
187 } | 187 } |
191 ResourceObj::ResourceObj(const ResourceObj& r) { // default copy constructor | 191 ResourceObj::ResourceObj(const ResourceObj& r) { // default copy constructor |
192 // Used in ClassFileParser::parse_constant_pool_entries() for ClassFileStream. | 192 // Used in ClassFileParser::parse_constant_pool_entries() for ClassFileStream. |
193 // Note: garbage may resembles valid value. | 193 // Note: garbage may resembles valid value. |
194 assert(~(_allocation_t[0] | allocation_mask) != (uintptr_t)this || !is_type_set(), | 194 assert(~(_allocation_t[0] | allocation_mask) != (uintptr_t)this || !is_type_set(), |
195 err_msg("embedded or stack only, this(" PTR_FORMAT ") type %d a[0]=(" PTR_FORMAT ") a[1]=(" PTR_FORMAT ")", | 195 err_msg("embedded or stack only, this(" PTR_FORMAT ") type %d a[0]=(" PTR_FORMAT ") a[1]=(" PTR_FORMAT ")", |
196 this, get_allocation_type(), _allocation_t[0], _allocation_t[1])); | 196 p2i(this), get_allocation_type(), _allocation_t[0], _allocation_t[1])); |
197 set_allocation_type((address)this, STACK_OR_EMBEDDED); | 197 set_allocation_type((address)this, STACK_OR_EMBEDDED); |
198 _allocation_t[1] = 0; // Zap verification value | 198 _allocation_t[1] = 0; // Zap verification value |
199 } | 199 } |
200 | 200 |
201 ResourceObj& ResourceObj::operator=(const ResourceObj& r) { // default copy assignment | 201 ResourceObj& ResourceObj::operator=(const ResourceObj& r) { // default copy assignment |
202 // Used in InlineTree::ok_to_inline() for WarmCallInfo. | 202 // Used in InlineTree::ok_to_inline() for WarmCallInfo. |
203 assert(allocated_on_stack(), | 203 assert(allocated_on_stack(), |
204 err_msg("copy only into local, this(" PTR_FORMAT ") type %d a[0]=(" PTR_FORMAT ") a[1]=(" PTR_FORMAT ")", | 204 err_msg("copy only into local, this(" PTR_FORMAT ") type %d a[0]=(" PTR_FORMAT ") a[1]=(" PTR_FORMAT ")", |
205 this, get_allocation_type(), _allocation_t[0], _allocation_t[1])); | 205 p2i(this), get_allocation_type(), _allocation_t[0], _allocation_t[1])); |
206 // Keep current _allocation_t value; | 206 // Keep current _allocation_t value; |
207 return *this; | 207 return *this; |
208 } | 208 } |
209 | 209 |
210 ResourceObj::~ResourceObj() { | 210 ResourceObj::~ResourceObj() { |
216 #endif // ASSERT | 216 #endif // ASSERT |
217 | 217 |
218 | 218 |
219 void trace_heap_malloc(size_t size, const char* name, void* p) { | 219 void trace_heap_malloc(size_t size, const char* name, void* p) { |
220 // A lock is not needed here - tty uses a lock internally | 220 // A lock is not needed here - tty uses a lock internally |
221 tty->print_cr("Heap malloc " INTPTR_FORMAT " " SIZE_FORMAT " %s", p, size, name == NULL ? "" : name); | 221 tty->print_cr("Heap malloc " INTPTR_FORMAT " " SIZE_FORMAT " %s", p2i(p), size, name == NULL ? "" : name); |
222 } | 222 } |
223 | 223 |
224 | 224 |
225 void trace_heap_free(void* p) { | 225 void trace_heap_free(void* p) { |
226 // A lock is not needed here - tty uses a lock internally | 226 // A lock is not needed here - tty uses a lock internally |
227 tty->print_cr("Heap free " INTPTR_FORMAT, p); | 227 tty->print_cr("Heap free " INTPTR_FORMAT, p2i(p)); |
228 } | 228 } |
229 | 229 |
230 //-------------------------------------------------------------------------------------- | 230 //-------------------------------------------------------------------------------------- |
231 // ChunkPool implementation | 231 // ChunkPool implementation |
232 | 232 |
721 | 721 |
722 void AllocatedObj::print() const { print_on(tty); } | 722 void AllocatedObj::print() const { print_on(tty); } |
723 void AllocatedObj::print_value() const { print_value_on(tty); } | 723 void AllocatedObj::print_value() const { print_value_on(tty); } |
724 | 724 |
725 void AllocatedObj::print_on(outputStream* st) const { | 725 void AllocatedObj::print_on(outputStream* st) const { |
726 st->print_cr("AllocatedObj(" INTPTR_FORMAT ")", this); | 726 st->print_cr("AllocatedObj(" INTPTR_FORMAT ")", p2i(this)); |
727 } | 727 } |
728 | 728 |
729 void AllocatedObj::print_value_on(outputStream* st) const { | 729 void AllocatedObj::print_value_on(outputStream* st) const { |
730 st->print("AllocatedObj(" INTPTR_FORMAT ")", this); | 730 st->print("AllocatedObj(" INTPTR_FORMAT ")", p2i(this)); |
731 } | 731 } |
732 | 732 |
733 julong Arena::_bytes_allocated = 0; | 733 julong Arena::_bytes_allocated = 0; |
734 | 734 |
735 void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); } | 735 void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); } |