1 /* 2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/shared/genCollectedHeap.hpp" 27 #include "memory/allocation.hpp" 28 #include "memory/allocation.inline.hpp" 29 #include "memory/arena.hpp" 30 #include "memory/metaspaceShared.hpp" 31 #include "memory/resourceArea.hpp" 32 #include "memory/universe.hpp" 33 #include "runtime/atomic.hpp" 34 #include "runtime/os.hpp" 35 #include "runtime/task.hpp" 36 #include "runtime/threadCritical.hpp" 37 #include "services/memTracker.hpp" 38 #include "utilities/ostream.hpp" 39 40 void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; } 41 void StackObj::operator delete(void* p) { ShouldNotCallThis(); } 42 void* StackObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; } 43 void StackObj::operator delete [](void* p) { ShouldNotCallThis(); } 44 45 void* _ValueObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; } 46 void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); } 47 void* _ValueObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; } 48 void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); } 49 50 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, 51 size_t word_size, 52 MetaspaceObj::Type type, TRAPS) throw() { 53 // Klass has it's own operator new 54 return Metaspace::allocate(loader_data, word_size, type, THREAD); 55 } 56 57 bool MetaspaceObj::is_shared() const { 58 return MetaspaceShared::is_in_shared_space(this); 59 } 60 61 bool MetaspaceObj::is_metaspace_object() const { 62 return Metaspace::contains((void*)this); 63 } 64 65 void MetaspaceObj::print_address_on(outputStream* st) const { 66 st->print(" {" INTPTR_FORMAT "}", p2i(this)); 67 } 68 69 void* ResourceObj::operator new(size_t size, Arena *arena) throw() { 70 address res = (address)arena->Amalloc(size); 71 DEBUG_ONLY(set_allocation_type(res, ARENA);) 72 return res; 73 } 74 75 void* ResourceObj::operator new [](size_t size, Arena *arena) throw() { 76 address res = (address)arena->Amalloc(size); 77 DEBUG_ONLY(set_allocation_type(res, ARENA);) 78 return res; | 1 /* 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/shared/genCollectedHeap.hpp" 27 #include "memory/allocation.hpp" 28 #include "memory/allocation.inline.hpp" 29 #include "memory/arena.hpp" 30 #include "memory/metaspaceShared.hpp" 31 #include "memory/resourceArea.hpp" 32 #include "memory/universe.hpp" 33 #include "runtime/atomic.hpp" 34 #include "runtime/os.hpp" 35 #include "runtime/task.hpp" 36 #include "runtime/threadCritical.hpp" 37 #include "services/memTracker.hpp" 38 #include "utilities/ostream.hpp" 39 40 void* MetaspaceObj::_shared_metaspace_base = NULL; 41 void* MetaspaceObj::_shared_metaspace_top = NULL; 42 43 void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; } 44 void StackObj::operator delete(void* p) { ShouldNotCallThis(); } 45 void* StackObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; } 46 void StackObj::operator delete [](void* p) { ShouldNotCallThis(); } 47 48 void* _ValueObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; } 49 void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); } 50 void* _ValueObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; } 51 void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); } 52 53 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, 54 size_t word_size, 55 MetaspaceObj::Type type, TRAPS) throw() { 56 // Klass has it's own operator new 57 return Metaspace::allocate(loader_data, word_size, type, THREAD); 58 } 59 60 bool MetaspaceObj::is_metaspace_object() const { 61 return Metaspace::contains((void*)this); 62 } 63 64 void MetaspaceObj::print_address_on(outputStream* st) const { 65 st->print(" {" INTPTR_FORMAT "}", p2i(this)); 66 } 67 68 void* ResourceObj::operator new(size_t size, Arena *arena) throw() { 69 address res = (address)arena->Amalloc(size); 70 DEBUG_ONLY(set_allocation_type(res, ARENA);) 71 return res; 72 } 73 74 void* ResourceObj::operator new [](size_t size, Arena *arena) throw() { 75 address res = (address)arena->Amalloc(size); 76 DEBUG_ONLY(set_allocation_type(res, ARENA);) 77 return res; |