< prev index next >

src/share/vm/prims/methodHandleWalk.cpp

Print this page
rev 4134 : 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
Summary: Change constMethodOop::_exception_table to optionally inlined u2 table.
Reviewed-by: bdelsart, coleenp, kamg
   1 /*
   2  * Copyright (c) 2008, 2011, 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  *


1779 
1780   return cpool;
1781 }
1782 
1783 
1784 methodHandle MethodHandleCompiler::get_method_oop(TRAPS) {
1785   methodHandle empty;
1786   // Create a method that holds the generated bytecode.  invokedynamic
1787   // has no receiver, normal MH calls do.
1788   int flags_bits;
1789   if (for_invokedynamic())
1790     flags_bits = (/*JVM_MH_INVOKE_BITS |*/ JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SYNTHETIC | JVM_ACC_STATIC);
1791   else
1792     flags_bits = (/*JVM_MH_INVOKE_BITS |*/ JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SYNTHETIC);
1793 
1794   // Create a new method
1795   methodHandle m;
1796   {
1797     methodOop m_oop = oopFactory::new_method(bytecode_length(),
1798                                              accessFlags_from(flags_bits),
1799                                              0, 0, 0, oopDesc::IsSafeConc, CHECK_(empty));
1800     m = methodHandle(THREAD, m_oop);
1801   }
1802 
1803   constantPoolHandle cpool = get_constant_pool(CHECK_(empty));
1804   m->set_constants(cpool());
1805 
1806   m->set_name_index(_name_index);
1807   m->set_signature_index(_signature_index);
1808 
1809   m->set_code((address) bytecode());
1810 
1811   m->set_max_stack(_max_stack);
1812   m->set_max_locals(max_locals());
1813   m->set_size_of_parameters(_num_params);
1814 
1815   typeArrayHandle exception_handlers(THREAD, Universe::the_empty_int_array());
1816   m->set_exception_table(exception_handlers());
1817 
1818   // Rewrite the method and set up the constant pool cache.
1819   objArrayOop m_array = oopFactory::new_system_objArray(1, CHECK_(empty));
1820   objArrayHandle methods(THREAD, m_array);
1821   methods->obj_at_put(0, m());
1822   Rewriter::rewrite(_target_klass(), cpool, methods, CHECK_(empty));  // Use fake class.
1823   Rewriter::relocate_and_link(_target_klass(), methods, CHECK_(empty));  // Use fake class.
1824 
1825   // Pre-resolve selected CP cache entries, to avoid problems with class loader scoping.
1826   constantPoolCacheHandle cpc(THREAD, cpool->cache());
1827   for (int i = 0; i < cpc->length(); i++) {
1828     ConstantPoolCacheEntry* e = cpc->entry_at(i);
1829     assert(!e->is_secondary_entry(), "no indy instructions in here, yet");
1830     int constant_pool_index = e->constant_pool_index();
1831     ConstantValue* cv = _constants.at(constant_pool_index);
1832     if (!cv->has_linkage())  continue;
1833     methodHandle m = cv->linkage();
1834     int index;
1835     switch (cv->tag()) {
1836     case JVM_CONSTANT_Methodref:


   1 /*
   2  * Copyright (c) 2008, 2012, 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  *


1779 
1780   return cpool;
1781 }
1782 
1783 
1784 methodHandle MethodHandleCompiler::get_method_oop(TRAPS) {
1785   methodHandle empty;
1786   // Create a method that holds the generated bytecode.  invokedynamic
1787   // has no receiver, normal MH calls do.
1788   int flags_bits;
1789   if (for_invokedynamic())
1790     flags_bits = (/*JVM_MH_INVOKE_BITS |*/ JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SYNTHETIC | JVM_ACC_STATIC);
1791   else
1792     flags_bits = (/*JVM_MH_INVOKE_BITS |*/ JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SYNTHETIC);
1793 
1794   // Create a new method
1795   methodHandle m;
1796   {
1797     methodOop m_oop = oopFactory::new_method(bytecode_length(),
1798                                              accessFlags_from(flags_bits),
1799                                              0, 0, 0, 0, oopDesc::IsSafeConc, CHECK_(empty));
1800     m = methodHandle(THREAD, m_oop);
1801   }
1802 
1803   constantPoolHandle cpool = get_constant_pool(CHECK_(empty));
1804   m->set_constants(cpool());
1805 
1806   m->set_name_index(_name_index);
1807   m->set_signature_index(_signature_index);
1808 
1809   m->set_code((address) bytecode());
1810 
1811   m->set_max_stack(_max_stack);
1812   m->set_max_locals(max_locals());
1813   m->set_size_of_parameters(_num_params);



1814 
1815   // Rewrite the method and set up the constant pool cache.
1816   objArrayOop m_array = oopFactory::new_system_objArray(1, CHECK_(empty));
1817   objArrayHandle methods(THREAD, m_array);
1818   methods->obj_at_put(0, m());
1819   Rewriter::rewrite(_target_klass(), cpool, methods, CHECK_(empty));  // Use fake class.
1820   Rewriter::relocate_and_link(_target_klass(), methods, CHECK_(empty));  // Use fake class.
1821 
1822   // Pre-resolve selected CP cache entries, to avoid problems with class loader scoping.
1823   constantPoolCacheHandle cpc(THREAD, cpool->cache());
1824   for (int i = 0; i < cpc->length(); i++) {
1825     ConstantPoolCacheEntry* e = cpc->entry_at(i);
1826     assert(!e->is_secondary_entry(), "no indy instructions in here, yet");
1827     int constant_pool_index = e->constant_pool_index();
1828     ConstantValue* cv = _constants.at(constant_pool_index);
1829     if (!cv->has_linkage())  continue;
1830     methodHandle m = cv->linkage();
1831     int index;
1832     switch (cv->tag()) {
1833     case JVM_CONSTANT_Methodref:


< prev index next >