Mercurial > hg > truffle
comparison src/share/vm/memory/allocation.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 4ca6dc0799b6 09619752c16d |
children | 7848fc12602b |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
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. |
43 # include "os_solaris.inline.hpp" | 43 # include "os_solaris.inline.hpp" |
44 #endif | 44 #endif |
45 #ifdef TARGET_OS_FAMILY_windows | 45 #ifdef TARGET_OS_FAMILY_windows |
46 # include "os_windows.inline.hpp" | 46 # include "os_windows.inline.hpp" |
47 #endif | 47 #endif |
48 #ifdef TARGET_OS_FAMILY_aix | |
49 # include "os_aix.inline.hpp" | |
50 #endif | |
48 #ifdef TARGET_OS_FAMILY_bsd | 51 #ifdef TARGET_OS_FAMILY_bsd |
49 # include "os_bsd.inline.hpp" | 52 # include "os_bsd.inline.hpp" |
50 #endif | 53 #endif |
51 | 54 |
52 void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; } | 55 void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; } |
69 | 72 |
70 bool MetaspaceObj::is_shared() const { | 73 bool MetaspaceObj::is_shared() const { |
71 return MetaspaceShared::is_in_shared_space(this); | 74 return MetaspaceShared::is_in_shared_space(this); |
72 } | 75 } |
73 | 76 |
74 | |
75 bool MetaspaceObj::is_metaspace_object() const { | 77 bool MetaspaceObj::is_metaspace_object() const { |
76 return Metaspace::contains((void*)this); | 78 return Metaspace::contains((void*)this); |
77 } | 79 } |
78 | 80 |
79 void MetaspaceObj::print_address_on(outputStream* st) const { | 81 void MetaspaceObj::print_address_on(outputStream* st) const { |
80 st->print(" {"INTPTR_FORMAT"}", this); | 82 st->print(" {" INTPTR_FORMAT "}", p2i(this)); |
81 } | 83 } |
82 | 84 |
83 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() { |
84 address res; | 86 address res; |
85 switch (type) { | 87 switch (type) { |
138 | 140 |
139 #ifdef ASSERT | 141 #ifdef ASSERT |
140 void ResourceObj::set_allocation_type(address res, allocation_type type) { | 142 void ResourceObj::set_allocation_type(address res, allocation_type type) { |
141 // Set allocation type in the resource object | 143 // Set allocation type in the resource object |
142 uintptr_t allocation = (uintptr_t)res; | 144 uintptr_t allocation = (uintptr_t)res; |
143 assert((allocation & allocation_mask) == 0, "address should be aligned to 4 bytes at least"); | 145 assert((allocation & allocation_mask) == 0, err_msg("address should be aligned to 4 bytes at least: " INTPTR_FORMAT, p2i(res))); |
144 assert(type <= allocation_mask, "incorrect allocation type"); | 146 assert(type <= allocation_mask, "incorrect allocation type"); |
145 ResourceObj* resobj = (ResourceObj *)res; | 147 ResourceObj* resobj = (ResourceObj *)res; |
146 resobj->_allocation_t[0] = ~(allocation + type); | 148 resobj->_allocation_t[0] = ~(allocation + type); |
147 if (type != STACK_OR_EMBEDDED) { | 149 if (type != STACK_OR_EMBEDDED) { |
148 // Called from operator new() and CollectionSetChooser(), | 150 // Called from operator new() and CollectionSetChooser(), |
175 // Ignore garbage in other fields. | 177 // Ignore garbage in other fields. |
176 } else if (is_type_set()) { | 178 } else if (is_type_set()) { |
177 // Operator new() was called and type was set. | 179 // Operator new() was called and type was set. |
178 assert(!allocated_on_stack(), | 180 assert(!allocated_on_stack(), |
179 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 ")", |
180 this, get_allocation_type(), _allocation_t[0], _allocation_t[1])); | 182 p2i(this), get_allocation_type(), _allocation_t[0], _allocation_t[1])); |
181 } else { | 183 } else { |
182 // Operator new() was not called. | 184 // Operator new() was not called. |
183 // Assume that it is embedded or stack object. | 185 // Assume that it is embedded or stack object. |
184 set_allocation_type((address)this, STACK_OR_EMBEDDED); | 186 set_allocation_type((address)this, STACK_OR_EMBEDDED); |
185 } | 187 } |
189 ResourceObj::ResourceObj(const ResourceObj& r) { // default copy constructor | 191 ResourceObj::ResourceObj(const ResourceObj& r) { // default copy constructor |
190 // Used in ClassFileParser::parse_constant_pool_entries() for ClassFileStream. | 192 // Used in ClassFileParser::parse_constant_pool_entries() for ClassFileStream. |
191 // Note: garbage may resembles valid value. | 193 // Note: garbage may resembles valid value. |
192 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(), |
193 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 ")", |
194 this, get_allocation_type(), _allocation_t[0], _allocation_t[1])); | 196 p2i(this), get_allocation_type(), _allocation_t[0], _allocation_t[1])); |
195 set_allocation_type((address)this, STACK_OR_EMBEDDED); | 197 set_allocation_type((address)this, STACK_OR_EMBEDDED); |
196 _allocation_t[1] = 0; // Zap verification value | 198 _allocation_t[1] = 0; // Zap verification value |
197 } | 199 } |
198 | 200 |
199 ResourceObj& ResourceObj::operator=(const ResourceObj& r) { // default copy assignment | 201 ResourceObj& ResourceObj::operator=(const ResourceObj& r) { // default copy assignment |
200 // Used in InlineTree::ok_to_inline() for WarmCallInfo. | 202 // Used in InlineTree::ok_to_inline() for WarmCallInfo. |
201 assert(allocated_on_stack(), | 203 assert(allocated_on_stack(), |
202 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 ")", |
203 this, get_allocation_type(), _allocation_t[0], _allocation_t[1])); | 205 p2i(this), get_allocation_type(), _allocation_t[0], _allocation_t[1])); |
204 // Keep current _allocation_t value; | 206 // Keep current _allocation_t value; |
205 return *this; | 207 return *this; |
206 } | 208 } |
207 | 209 |
208 ResourceObj::~ResourceObj() { | 210 ResourceObj::~ResourceObj() { |
214 #endif // ASSERT | 216 #endif // ASSERT |
215 | 217 |
216 | 218 |
217 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) { |
218 // A lock is not needed here - tty uses a lock internally | 220 // A lock is not needed here - tty uses a lock internally |
219 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); |
220 } | 222 } |
221 | 223 |
222 | 224 |
223 void trace_heap_free(void* p) { | 225 void trace_heap_free(void* p) { |
224 // A lock is not needed here - tty uses a lock internally | 226 // A lock is not needed here - tty uses a lock internally |
225 tty->print_cr("Heap free " INTPTR_FORMAT, p); | 227 tty->print_cr("Heap free " INTPTR_FORMAT, p2i(p)); |
226 } | 228 } |
227 | 229 |
228 //-------------------------------------------------------------------------------------- | 230 //-------------------------------------------------------------------------------------- |
229 // ChunkPool implementation | 231 // ChunkPool implementation |
230 | 232 |
557 | 559 |
558 Chunk *k = _chunk; // Get filled-up chunk address | 560 Chunk *k = _chunk; // Get filled-up chunk address |
559 _chunk = new (alloc_failmode, len) Chunk(len); | 561 _chunk = new (alloc_failmode, len) Chunk(len); |
560 | 562 |
561 if (_chunk == NULL) { | 563 if (_chunk == NULL) { |
564 _chunk = k; // restore the previous value of _chunk | |
562 return NULL; | 565 return NULL; |
563 } | 566 } |
564 if (k) k->set_next(_chunk); // Append new chunk to end of linked list | 567 if (k) k->set_next(_chunk); // Append new chunk to end of linked list |
565 else _first = _chunk; | 568 else _first = _chunk; |
566 _hwm = _chunk->bottom(); // Save the cached hwm, max | 569 _hwm = _chunk->bottom(); // Save the cached hwm, max |
719 | 722 |
720 void AllocatedObj::print() const { print_on(tty); } | 723 void AllocatedObj::print() const { print_on(tty); } |
721 void AllocatedObj::print_value() const { print_value_on(tty); } | 724 void AllocatedObj::print_value() const { print_value_on(tty); } |
722 | 725 |
723 void AllocatedObj::print_on(outputStream* st) const { | 726 void AllocatedObj::print_on(outputStream* st) const { |
724 st->print_cr("AllocatedObj(" INTPTR_FORMAT ")", this); | 727 st->print_cr("AllocatedObj(" INTPTR_FORMAT ")", p2i(this)); |
725 } | 728 } |
726 | 729 |
727 void AllocatedObj::print_value_on(outputStream* st) const { | 730 void AllocatedObj::print_value_on(outputStream* st) const { |
728 st->print("AllocatedObj(" INTPTR_FORMAT ")", this); | 731 st->print("AllocatedObj(" INTPTR_FORMAT ")", p2i(this)); |
729 } | 732 } |
730 | 733 |
731 julong Arena::_bytes_allocated = 0; | 734 julong Arena::_bytes_allocated = 0; |
732 | 735 |
733 void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); } | 736 void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); } |