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/_vtableStubs.cpp.incl" 27 28 // ----------------------------------------------------------------------------------------- 29 // Implementation of VtableStub 30 31 address VtableStub::_chunk = NULL; 32 address VtableStub::_chunk_end = NULL; 33 VMReg VtableStub::_receiver_location = VMRegImpl::Bad(); 34 35 static int num_vtable_chunks = 0; 36 37 38 void* VtableStub::operator new(size_t size, int code_size) { 39 assert(size == sizeof(VtableStub), "mismatched size"); 40 num_vtable_chunks++; 41 // compute real VtableStub size (rounded to nearest word) 42 const int real_size = round_to(code_size + sizeof(VtableStub), wordSize); 43 // malloc them in chunks to minimize header overhead 44 const int chunk_factor = 32; 45 if (_chunk == NULL || _chunk + real_size > _chunk_end) { 46 const int bytes = chunk_factor * real_size + pd_code_alignment(); | 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 "code/vtableStubs.hpp" 27 #include "compiler/disassembler.hpp" 28 #include "memory/allocation.inline.hpp" 29 #include "memory/resourceArea.hpp" 30 #include "oops/instanceKlass.hpp" 31 #include "oops/klassVtable.hpp" 32 #include "oops/oop.inline.hpp" 33 #include "prims/forte.hpp" 34 #include "prims/jvmtiExport.hpp" 35 #include "runtime/handles.inline.hpp" 36 #include "runtime/mutexLocker.hpp" 37 #include "runtime/sharedRuntime.hpp" 38 #ifdef COMPILER2 39 #include "opto/matcher.hpp" 40 #endif 41 42 // ----------------------------------------------------------------------------------------- 43 // Implementation of VtableStub 44 45 address VtableStub::_chunk = NULL; 46 address VtableStub::_chunk_end = NULL; 47 VMReg VtableStub::_receiver_location = VMRegImpl::Bad(); 48 49 static int num_vtable_chunks = 0; 50 51 52 void* VtableStub::operator new(size_t size, int code_size) { 53 assert(size == sizeof(VtableStub), "mismatched size"); 54 num_vtable_chunks++; 55 // compute real VtableStub size (rounded to nearest word) 56 const int real_size = round_to(code_size + sizeof(VtableStub), wordSize); 57 // malloc them in chunks to minimize header overhead 58 const int chunk_factor = 32; 59 if (_chunk == NULL || _chunk + real_size > _chunk_end) { 60 const int bytes = chunk_factor * real_size + pd_code_alignment(); |