comparison src/share/vm/ci/ciMethod.cpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents 597bc897257d 1d7922586cf6
children c38f13903fdf
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
1 /* 1 /*
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
77 // Easy to compute, so fill them in now. 77 // Easy to compute, so fill them in now.
78 _max_stack = h_m()->max_stack(); 78 _max_stack = h_m()->max_stack();
79 _max_locals = h_m()->max_locals(); 79 _max_locals = h_m()->max_locals();
80 _code_size = h_m()->code_size(); 80 _code_size = h_m()->code_size();
81 _intrinsic_id = h_m()->intrinsic_id(); 81 _intrinsic_id = h_m()->intrinsic_id();
82 _handler_count = h_m()->exception_table()->length() / 4; 82 _handler_count = h_m()->exception_table_length();
83 _uses_monitors = h_m()->access_flags().has_monitor_bytecodes(); 83 _uses_monitors = h_m()->access_flags().has_monitor_bytecodes();
84 _balanced_monitors = !_uses_monitors || h_m()->access_flags().is_monitor_matching(); 84 _balanced_monitors = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
85 _is_c1_compilable = !h_m()->is_not_c1_compilable(); 85 _is_c1_compilable = !h_m()->is_not_c1_compilable();
86 _is_c2_compilable = !h_m()->is_not_c2_compilable(); 86 _is_c2_compilable = !h_m()->is_not_c2_compilable();
87 // Lazy fields, filled in on demand. Require allocation. 87 // Lazy fields, filled in on demand. Require allocation.
196 } 196 }
197 } 197 }
198 } 198 }
199 199
200 // And load the exception table. 200 // And load the exception table.
201 typeArrayOop exc_table = me->exception_table(); 201 ExceptionTable exc_table(me);
202 202
203 // Allocate one extra spot in our list of exceptions. This 203 // Allocate one extra spot in our list of exceptions. This
204 // last entry will be used to represent the possibility that 204 // last entry will be used to represent the possibility that
205 // an exception escapes the method. See ciExceptionHandlerStream 205 // an exception escapes the method. See ciExceptionHandlerStream
206 // for details. 206 // for details.
207 _exception_handlers = 207 _exception_handlers =
208 (ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*) 208 (ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*)
209 * (_handler_count + 1)); 209 * (_handler_count + 1));
210 if (_handler_count > 0) { 210 if (_handler_count > 0) {
211 for (int i=0; i<_handler_count; i++) { 211 for (int i=0; i<_handler_count; i++) {
212 int base = i*4;
213 _exception_handlers[i] = new (arena) ciExceptionHandler( 212 _exception_handlers[i] = new (arena) ciExceptionHandler(
214 holder(), 213 holder(),
215 /* start */ exc_table->int_at(base), 214 /* start */ exc_table.start_pc(i),
216 /* limit */ exc_table->int_at(base+1), 215 /* limit */ exc_table.end_pc(i),
217 /* goto pc */ exc_table->int_at(base+2), 216 /* goto pc */ exc_table.handler_pc(i),
218 /* cp index */ exc_table->int_at(base+3)); 217 /* cp index */ exc_table.catch_type_index(i));
219 } 218 }
220 } 219 }
221 220
222 // Put an entry at the end of our list to represent the possibility 221 // Put an entry at the end of our list to represent the possibility
223 // of exceptional exit. 222 // of exceptional exit.
768 767
769 // ------------------------------------------------------------------ 768 // ------------------------------------------------------------------
770 // invokedynamic support 769 // invokedynamic support
771 770
772 // ------------------------------------------------------------------ 771 // ------------------------------------------------------------------
773 // ciMethod::is_method_handle_invoke 772 // ciMethod::is_method_handle_intrinsic
774 // 773 //
775 // Return true if the method is an instance of one of the two 774 // Return true if the method is an instance of the JVM-generated
776 // signature-polymorphic MethodHandle methods, invokeExact or invokeGeneric. 775 // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
777 bool ciMethod::is_method_handle_invoke() const { 776 bool ciMethod::is_method_handle_intrinsic() const {
778 if (!is_loaded()) { 777 vmIntrinsics::ID iid = _intrinsic_id; // do not check if loaded
779 bool flag = (holder()->name() == ciSymbol::java_lang_invoke_MethodHandle() && 778 return (MethodHandles::is_signature_polymorphic(iid) &&
780 methodOopDesc::is_method_handle_invoke_name(name()->sid())); 779 MethodHandles::is_signature_polymorphic_intrinsic(iid));
781 return flag; 780 }
782 } 781
783 VM_ENTRY_MARK; 782 // ------------------------------------------------------------------
784 return get_methodOop()->is_method_handle_invoke(); 783 // ciMethod::is_compiled_lambda_form
785 }
786
787 // ------------------------------------------------------------------
788 // ciMethod::is_method_handle_adapter
789 // 784 //
790 // Return true if the method is a generated MethodHandle adapter. 785 // Return true if the method is a generated MethodHandle adapter.
791 // These are built by MethodHandleCompiler. 786 // These are built by Java code.
792 bool ciMethod::is_method_handle_adapter() const { 787 bool ciMethod::is_compiled_lambda_form() const {
793 if (!is_loaded()) return false; 788 vmIntrinsics::ID iid = _intrinsic_id; // do not check if loaded
794 VM_ENTRY_MARK; 789 return iid == vmIntrinsics::_compiledLambdaForm;
795 return get_methodOop()->is_method_handle_adapter(); 790 }
796 } 791
797 792 // ------------------------------------------------------------------
798 ciInstance* ciMethod::method_handle_type() { 793 // ciMethod::has_member_arg
799 check_is_loaded(); 794 //
800 VM_ENTRY_MARK; 795 // Return true if the method is a linker intrinsic like _linkToVirtual.
801 oop mtype = get_methodOop()->method_handle_type(); 796 // These are built by the JVM.
802 return CURRENT_THREAD_ENV->get_object(mtype)->as_instance(); 797 bool ciMethod::has_member_arg() const {
803 } 798 vmIntrinsics::ID iid = _intrinsic_id; // do not check if loaded
804 799 return (MethodHandles::is_signature_polymorphic(iid) &&
800 MethodHandles::has_member_arg(iid));
801 }
805 802
806 // ------------------------------------------------------------------ 803 // ------------------------------------------------------------------
807 // ciMethod::ensure_method_data 804 // ciMethod::ensure_method_data
808 // 805 //
809 // Generate new methodDataOop objects at compile time. 806 // Generate new methodDataOop objects at compile time.
1023 } 1020 }
1024 1021
1025 // ------------------------------------------------------------------ 1022 // ------------------------------------------------------------------
1026 // ciMethod::code_size_for_inlining 1023 // ciMethod::code_size_for_inlining
1027 // 1024 //
1028 // Code size for inlining decisions. 1025 // Code size for inlining decisions. This method returns a code
1029 // 1026 // size of 1 for methods which has the ForceInline annotation.
1030 // Don't fully count method handle adapters against inlining budgets:
1031 // the metric we use here is the number of call sites in the adapter
1032 // as they are probably the instructions which generate some code.
1033 int ciMethod::code_size_for_inlining() { 1027 int ciMethod::code_size_for_inlining() {
1034 check_is_loaded(); 1028 check_is_loaded();
1035 1029 if (get_methodOop()->force_inline()) {
1036 // Method handle adapters 1030 return 1;
1037 if (is_method_handle_adapter()) { 1031 }
1038 // Count call sites
1039 int call_site_count = 0;
1040 ciBytecodeStream iter(this);
1041 while (iter.next() != ciBytecodeStream::EOBC()) {
1042 if (Bytecodes::is_invoke(iter.cur_bc())) {
1043 call_site_count++;
1044 }
1045 }
1046 return call_site_count;
1047 }
1048
1049 // Normal method
1050 return code_size(); 1032 return code_size();
1051 } 1033 }
1052 1034
1053 // ------------------------------------------------------------------ 1035 // ------------------------------------------------------------------
1054 // ciMethod::instructions_size 1036 // ciMethod::instructions_size
1126 EXCEPTION_MARK; 1108 EXCEPTION_MARK;
1127 HandleMark hm(THREAD); 1109 HandleMark hm(THREAD);
1128 constantPoolHandle pool (THREAD, get_methodOop()->constants()); 1110 constantPoolHandle pool (THREAD, get_methodOop()->constants());
1129 methodHandle spec_method; 1111 methodHandle spec_method;
1130 KlassHandle spec_klass; 1112 KlassHandle spec_klass;
1131 LinkResolver::resolve_method(spec_method, spec_klass, pool, refinfo_index, THREAD); 1113 Bytecodes::Code code = (is_static ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual);
1114 LinkResolver::resolve_method_statically(spec_method, spec_klass, code, pool, refinfo_index, THREAD);
1132 if (HAS_PENDING_EXCEPTION) { 1115 if (HAS_PENDING_EXCEPTION) {
1133 CLEAR_PENDING_EXCEPTION; 1116 CLEAR_PENDING_EXCEPTION;
1134 return false; 1117 return false;
1135 } else { 1118 } else {
1136 return (spec_method->is_static() == is_static); 1119 return (spec_method->is_static() == is_static);
1206 // ------------------------------------------------------------------ 1189 // ------------------------------------------------------------------
1207 // ciMethod::print_short_name 1190 // ciMethod::print_short_name
1208 // 1191 //
1209 // Print the name of this method, without signature. 1192 // Print the name of this method, without signature.
1210 void ciMethod::print_short_name(outputStream* st) { 1193 void ciMethod::print_short_name(outputStream* st) {
1211 check_is_loaded(); 1194 if (is_loaded()) {
1212 GUARDED_VM_ENTRY(get_methodOop()->print_short_name(st);) 1195 GUARDED_VM_ENTRY(get_methodOop()->print_short_name(st););
1196 } else {
1197 // Fall back if method is not loaded.
1198 holder()->print_name_on(st);
1199 st->print("::");
1200 name()->print_symbol_on(st);
1201 if (WizardMode)
1202 signature()->as_symbol()->print_symbol_on(st);
1203 }
1213 } 1204 }
1214 1205
1215 // ------------------------------------------------------------------ 1206 // ------------------------------------------------------------------
1216 // ciMethod::print_impl 1207 // ciMethod::print_impl
1217 // 1208 //
1222 name()->print_symbol_on(st); 1213 name()->print_symbol_on(st);
1223 st->print(" holder="); 1214 st->print(" holder=");
1224 holder()->print_name_on(st); 1215 holder()->print_name_on(st);
1225 st->print(" signature="); 1216 st->print(" signature=");
1226 signature()->as_symbol()->print_symbol_on(st); 1217 signature()->as_symbol()->print_symbol_on(st);
1218 st->print(" arg_size=%d", arg_size());
1227 if (is_loaded()) { 1219 if (is_loaded()) {
1228 st->print(" loaded=true flags="); 1220 st->print(" loaded=true flags=");
1229 flags().print_member_flags(st); 1221 flags().print_member_flags(st);
1230 } else { 1222 } else {
1231 st->print(" loaded=false"); 1223 st->print(" loaded=false");