1 /* 2 * Copyright (c) 1997, 2005, 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 "incls/_precompiled.incl" 26 # include "incls/_allocation.cpp.incl" 27 28 void* CHeapObj::operator new(size_t size){ 29 return (void *) AllocateHeap(size, "CHeapObj-new"); 30 } 31 32 void CHeapObj::operator delete(void* p){ 33 FreeHeap(p); 34 } 35 36 void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; 37 void StackObj::operator delete(void* p) { ShouldNotCallThis(); }; 38 void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; 39 void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }; 40 41 void* ResourceObj::operator new(size_t size, allocation_type type) { 42 address res; 43 switch (type) { 44 case C_HEAP: 45 res = (address)AllocateHeap(size, "C_Heap: ResourceOBJ"); 46 DEBUG_ONLY(set_allocation_type(res, C_HEAP);) | 1 /* 2 * Copyright (c) 1997, 2010, 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 "memory/allocation.hpp" 27 #include "memory/allocation.inline.hpp" 28 #include "memory/resourceArea.hpp" 29 #include "runtime/os.hpp" 30 #include "runtime/task.hpp" 31 #include "runtime/threadCritical.hpp" 32 #include "utilities/ostream.hpp" 33 #ifdef TARGET_OS_FAMILY_linux 34 # include "os_linux.inline.hpp" 35 #endif 36 #ifdef TARGET_OS_FAMILY_solaris 37 # include "os_solaris.inline.hpp" 38 #endif 39 #ifdef TARGET_OS_FAMILY_windows 40 # include "os_windows.inline.hpp" 41 #endif 42 43 void* CHeapObj::operator new(size_t size){ 44 return (void *) AllocateHeap(size, "CHeapObj-new"); 45 } 46 47 void CHeapObj::operator delete(void* p){ 48 FreeHeap(p); 49 } 50 51 void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; 52 void StackObj::operator delete(void* p) { ShouldNotCallThis(); }; 53 void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; 54 void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }; 55 56 void* ResourceObj::operator new(size_t size, allocation_type type) { 57 address res; 58 switch (type) { 59 case C_HEAP: 60 res = (address)AllocateHeap(size, "C_Heap: ResourceOBJ"); 61 DEBUG_ONLY(set_allocation_type(res, C_HEAP);) |