596N/A * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 596N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 596N/A * This code is free software; you can redistribute it and/or modify it 596N/A * under the terms of the GNU General Public License version 2 only, as 596N/A * published by the Free Software Foundation. 596N/A * This code is distributed in the hope that it will be useful, but WITHOUT 596N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 596N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 596N/A * version 2 for more details (a copy is included in the LICENSE file that 596N/A * accompanied this code). 596N/A * You should have received a copy of the GNU General Public License version 596N/A * 2 along with this work; if not, write to the Free Software Foundation, 596N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 596N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 596N/A// The resource area holds temporary data structures in the VM. 596N/A// The actual allocation areas are thread local. Typical usage: 596N/A// int foo[] = NEW_RESOURCE_ARRAY(int, 64); 596N/A//------------------------------ResourceArea----------------------------------- 596N/A// A ResourceArea is an Arena that supports safe usage of ResourceMark. 596N/A fatal(
"memory leak: allocating without ResourceMark");
596N/A // use malloc, but save pointer in res. area for later freeing 596N/A//------------------------------ResourceMark----------------------------------- 596N/A// A resource mark releases all resources allocated after it was constructed 596N/A// when the destructor is called. Typically used as a local variable. 596N/A // reset arena size before delete chunks. Otherwise, the total 596N/A // arena size could exceed total chunk size 596N/A // clear out this chunk (to detect allocation bugs) 596N/A//------------------------------DeoptResourceMark----------------------------------- 596N/A// A deopt resource mark releases all resources allocated after it was constructed 596N/A// when the destructor is called. Typically used as a local variable. It differs 596N/A// from a typical resource more in that it is C-Heap allocated so that deoptimization 596N/A// can use data structures that are arena based but are not amenable to vanilla 596N/A// ResourceMarks because deoptimization can not use a stack allocated mark. During 596N/A// deoptimization we go thru the following steps: 596N/A// 1: create the vframeArray (contains pointers to Resource allocated structures) 596N/A// This allocates the DeoptResourceMark. 596N/A// 2: return to assembly stub and remove stub frame and deoptee frame and create 596N/A// the new skeletal frames. 596N/A// 3: push new stub frame and call unpack_frames 596N/A// 4: retrieve information from the vframeArray to populate the skeletal frames 596N/A// 5: release the DeoptResourceMark 596N/A// 6: return to stub and eventually to interpreter 596N/A// With old style eager deoptimization the vframeArray was created by the vmThread there 596N/A// was no way for the vframeArray to contain resource allocated objects and so 596N/A// a complex set of data structures to simulate an array of vframes in CHeap memory 596N/A// was used. With new style lazy deoptimization the vframeArray is created in the 596N/A// the thread that will use it and we can use a much simpler scheme for the vframeArray 596N/A// leveraging existing data structures if we simply create a way to manage this one 596N/A// special need for a ResourceMark. If ResourceMark simply inherited from CHeapObj 596N/A// then existing ResourceMarks would work fine since no one use new to allocate them 596N/A// and they would be stack allocated. This leaves open the possibilty of accidental 596N/A// misuse so we simple duplicate the ResourceMark functionality here. 596N/A // reset arena size before delete chunks. Otherwise, the total 596N/A // arena size could exceed total chunk size 596N/A // clear out this chunk (to detect allocation bugs) 596N/A#
endif // SHARE_VM_MEMORY_RESOURCEAREA_HPP