3619N/A * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A/*************************************************************************/ 0N/A/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING */ 0N/A/* Should you use GrowableArrays to contain handles you must be certain */ 0N/A/* the the GrowableArray does not outlive the HandleMark that contains */ 0N/A/* the handles. Since GrowableArrays are typically resource allocated */ 0N/A/* the following is an example of INCORRECT CODE, */ 0N/A/* ResourceMark rm; */ 0N/A/* GrowableArray<Handle>* arr = new GrowableArray<Handle>(size); */ 0N/A/* Handle h(THREAD, some_oop); */ 0N/A/* arr->append(h); */ 0N/A/* if (arr->length() != 0 ) { */ 0N/A/* oop bad_oop = arr->at(0)(); // Handle is BAD HERE. */ 0N/A/* If the GrowableArrays you are creating is C_Heap allocated then it */ 0N/A/* hould not old handles since the handles could trivially try and */ 0N/A/* outlive their HandleMark. In some situations you might need to do */ 0N/A/* this and it would be legal but be very careful and see if you can do */ 0N/A/* the code in some other manner. */ 0N/A/*************************************************************************/ 0N/A// To call default constructor the placement operator new() is used. 0N/A// It should be empty (it only returns the passed void* pointer). 0N/A// The definition of placement operator new(size_t, void*) in the <new>. 0N/A// Need the correct linkage to call qsort without warnings 0N/A // 0 means default ResourceArea 0N/A // 1 means on C heap 0N/A // otherwise, allocate in _arena 0N/A // Where are we going to allocate memory? 0N/A // This GA will use the resource stack for storage if c_heap==false, 0N/A // Else it will use the C heap. Use clear_and_deallocate to avoid leaks. 3863N/A // memory type has to be specified for C heap allocation 1605N/A "growable array must be on stack if elements are not on arena and not on C heap");
0N/A // This GA will use the given arena for storage. 0N/A // Consider using new(arena) GrowableArray<T> to allocate the header. 1605N/A // Relax next assert to allow object allocation on resource area, 1605N/A // on stack or embedded into an other object. 1605N/A "growable array must be on arena or on stack if elements are on arena");
432N/A // some uses pass the Thread explicitly for speed (4990299 tuning) 0N/A for (
int i = 0; i <
_max; i++) ::
new ((
void*)&
_data[i]) E();
0N/A // Does nothing for resource and arena objects 3619N/A // Returns TRUE if elem is added. 0N/A // start at the end of the array 0N/A for (
int i =
_len-
1; i >= 0; i--) {
3619N/A // Replace removed element with last one. 1080N/A // inserts the given element before the element at index i 0N/A for (
int i = 0; i < l->
_len; i++) {
0N/A // sort by fixed-stride sub arrays: 0N/A// Global GrowableArray methods (one instance in the library per each 'E' type). 0N/A // grow the array by doubling its size (amortized growth) 0N/A// This function clears and deallocate the data in the growable array that 0N/A// has been allocated on the C heap. It's not public - called by the 0N/A "clear_and_deallocate should only be called when on C heap");
1879N/A#
endif // SHARE_VM_UTILITIES_GROWABLEARRAY_HPP