comparison src/share/vm/interpreter/interpreterRuntime.cpp @ 4137:04b9a2566eec

Merge with hsx23/hotspot.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 17 Dec 2011 21:40:27 +0100
parents be4ca325525a 12d38ffcba2a
children 33df1aeaebbf
comparison
equal deleted inserted replaced
3737:9dc19b7d89a3 4137:04b9a2566eec
519 519
520 IRT_ENTRY(void, InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode)) 520 IRT_ENTRY(void, InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode))
521 // resolve field 521 // resolve field
522 FieldAccessInfo info; 522 FieldAccessInfo info;
523 constantPoolHandle pool(thread, method(thread)->constants()); 523 constantPoolHandle pool(thread, method(thread)->constants());
524 bool is_put = (bytecode == Bytecodes::_putfield || bytecode == Bytecodes::_putstatic);
524 bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic); 525 bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic);
525 526
526 { 527 {
527 JvmtiHideSingleStepping jhss(thread); 528 JvmtiHideSingleStepping jhss(thread);
528 LinkResolver::resolve_field(info, pool, get_index_u2_cpcache(thread, bytecode), 529 LinkResolver::resolve_field(info, pool, get_index_u2_cpcache(thread, bytecode),
538 // We need to delay resolving put instructions on final fields 539 // We need to delay resolving put instructions on final fields
539 // until we actually invoke one. This is required so we throw 540 // until we actually invoke one. This is required so we throw
540 // exceptions at the correct place. If we do not resolve completely 541 // exceptions at the correct place. If we do not resolve completely
541 // in the current pass, leaving the put_code set to zero will 542 // in the current pass, leaving the put_code set to zero will
542 // cause the next put instruction to reresolve. 543 // cause the next put instruction to reresolve.
543 bool is_put = (bytecode == Bytecodes::_putfield ||
544 bytecode == Bytecodes::_putstatic);
545 Bytecodes::Code put_code = (Bytecodes::Code)0; 544 Bytecodes::Code put_code = (Bytecodes::Code)0;
546 545
547 // We also need to delay resolving getstatic instructions until the 546 // We also need to delay resolving getstatic instructions until the
548 // class is intitialized. This is required so that access to the static 547 // class is intitialized. This is required so that access to the static
549 // field will call the initialization function every time until the class 548 // field will call the initialization function every time until the class
551 instanceKlass *klass = instanceKlass::cast(info.klass()->as_klassOop()); 550 instanceKlass *klass = instanceKlass::cast(info.klass()->as_klassOop());
552 bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) && 551 bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) &&
553 !klass->is_initialized()); 552 !klass->is_initialized());
554 Bytecodes::Code get_code = (Bytecodes::Code)0; 553 Bytecodes::Code get_code = (Bytecodes::Code)0;
555 554
556
557 if (!uninitialized_static) { 555 if (!uninitialized_static) {
558 get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield); 556 get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);
559 if (is_put || !info.access_flags().is_final()) { 557 if (is_put || !info.access_flags().is_final()) {
560 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield); 558 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
561 } 559 }
560 }
561
562 if (is_put && !is_static && klass->is_subclass_of(SystemDictionary::CallSite_klass()) && (info.name() == vmSymbols::target_name())) {
563 const jint direction = frame::interpreter_frame_expression_stack_direction();
564 Handle call_site (THREAD, *((oop*) thread->last_frame().interpreter_frame_tos_at(-1 * direction)));
565 Handle method_handle(THREAD, *((oop*) thread->last_frame().interpreter_frame_tos_at( 0 * direction)));
566 assert(call_site ->is_a(SystemDictionary::CallSite_klass()), "must be");
567 assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "must be");
568
569 {
570 // Walk all nmethods depending on this call site.
571 MutexLocker mu(Compile_lock, thread);
572 Universe::flush_dependents_on(call_site, method_handle);
573 }
574
575 // Don't allow fast path for setting CallSite.target and sub-classes.
576 put_code = (Bytecodes::Code) 0;
562 } 577 }
563 578
564 cache_entry(thread)->set_field( 579 cache_entry(thread)->set_field(
565 get_code, 580 get_code,
566 put_code, 581 put_code,
854 assert(fr.is_interpreted_frame(), "must come from interpreter"); 869 assert(fr.is_interpreted_frame(), "must come from interpreter");
855 methodHandle method(thread, fr.interpreter_frame_method()); 870 methodHandle method(thread, fr.interpreter_frame_method());
856 const int branch_bci = branch_bcp != NULL ? method->bci_from(branch_bcp) : InvocationEntryBci; 871 const int branch_bci = branch_bcp != NULL ? method->bci_from(branch_bcp) : InvocationEntryBci;
857 const int bci = branch_bcp != NULL ? method->bci_from(fr.interpreter_frame_bcp()) : InvocationEntryBci; 872 const int bci = branch_bcp != NULL ? method->bci_from(fr.interpreter_frame_bcp()) : InvocationEntryBci;
858 873
859 nmethod* osr_nm = CompilationPolicy::policy()->event(method, method, branch_bci, bci, CompLevel_none, thread); 874 nmethod* osr_nm = CompilationPolicy::policy()->event(method, method, branch_bci, bci, CompLevel_none, NULL, thread);
860 875
861 if (osr_nm != NULL) { 876 if (osr_nm != NULL) {
862 // We may need to do on-stack replacement which requires that no 877 // We may need to do on-stack replacement which requires that no
863 // monitors in the activation are biased because their 878 // monitors in the activation are biased because their
864 // BasicObjectLocks will need to migrate during OSR. Force 879 // BasicObjectLocks will need to migrate during OSR. Force
979 ConstantPoolCacheEntry *cp_entry)) 994 ConstantPoolCacheEntry *cp_entry))
980 995
981 // check the access_flags for the field in the klass 996 // check the access_flags for the field in the klass
982 997
983 instanceKlass* ik = instanceKlass::cast(java_lang_Class::as_klassOop(cp_entry->f1())); 998 instanceKlass* ik = instanceKlass::cast(java_lang_Class::as_klassOop(cp_entry->f1()));
984 typeArrayOop fields = ik->fields();
985 int index = cp_entry->field_index(); 999 int index = cp_entry->field_index();
986 assert(index < fields->length(), "holders field index is out of range"); 1000 if ((ik->field_access_flags(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return;
987 // bail out if field accesses are not watched
988 if ((fields->ushort_at(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return;
989 1001
990 switch(cp_entry->flag_state()) { 1002 switch(cp_entry->flag_state()) {
991 case btos: // fall through 1003 case btos: // fall through
992 case ctos: // fall through 1004 case ctos: // fall through
993 case stos: // fall through 1005 case stos: // fall through
1016 1028
1017 klassOop k = java_lang_Class::as_klassOop(cp_entry->f1()); 1029 klassOop k = java_lang_Class::as_klassOop(cp_entry->f1());
1018 1030
1019 // check the access_flags for the field in the klass 1031 // check the access_flags for the field in the klass
1020 instanceKlass* ik = instanceKlass::cast(k); 1032 instanceKlass* ik = instanceKlass::cast(k);
1021 typeArrayOop fields = ik->fields();
1022 int index = cp_entry->field_index(); 1033 int index = cp_entry->field_index();
1023 assert(index < fields->length(), "holders field index is out of range");
1024 // bail out if field modifications are not watched 1034 // bail out if field modifications are not watched
1025 if ((fields->ushort_at(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return; 1035 if ((ik->field_access_flags(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return;
1026 1036
1027 char sig_type = '\0'; 1037 char sig_type = '\0';
1028 1038
1029 switch(cp_entry->flag_state()) { 1039 switch(cp_entry->flag_state()) {
1030 case btos: sig_type = 'Z'; break; 1040 case btos: sig_type = 'Z'; break;
1239 // before trying to fetch the native entry point and klass mirror. 1249 // before trying to fetch the native entry point and klass mirror.
1240 // We must set the signature handler last, so that multiple processors 1250 // We must set the signature handler last, so that multiple processors
1241 // preparing the same method will be sure to see non-null entry & mirror. 1251 // preparing the same method will be sure to see non-null entry & mirror.
1242 IRT_END 1252 IRT_END
1243 1253
1244 #if defined(IA32) || defined(AMD64) 1254 #if defined(IA32) || defined(AMD64) || defined(ARM)
1245 IRT_LEAF(void, InterpreterRuntime::popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address)) 1255 IRT_LEAF(void, InterpreterRuntime::popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address))
1246 if (src_address == dest_address) { 1256 if (src_address == dest_address) {
1247 return; 1257 return;
1248 } 1258 }
1249 ResetNoHandleMark rnm; // In a LEAF entry. 1259 ResetNoHandleMark rnm; // In a LEAF entry.