121 methodHandle m (thread, method(thread)); 122 Bytecode_loadconstant ldc(m, bci(thread)); 123 oop result = ldc.resolve_constant(CHECK); 124 #ifdef ASSERT 125 { 126 // The bytecode wrappers aren't GC-safe so construct a new one 127 Bytecode_loadconstant ldc2(m, bci(thread)); 128 oop coop = m->constants()->resolved_references()->obj_at(ldc2.cache_index()); 129 assert(result == coop, "expected result for assembly code"); 130 } 131 #endif 132 thread->set_vm_result(result); 133 } 134 IRT_END 135 136 137 //------------------------------------------------------------------------------------------------------------------------ 138 // Allocation 139 140 IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index)) 141 Klass* k_oop = pool->klass_at(index, CHECK); 142 instanceKlassHandle klass (THREAD, k_oop); 143 144 // Make sure we are not instantiating an abstract klass 145 klass->check_valid_for_instantiation(true, CHECK); 146 147 // Make sure klass is initialized 148 klass->initialize(CHECK); 149 150 // At this point the class may not be fully initialized 151 // because of recursive initialization. If it is fully 152 // initialized & has_finalized is not set, we rewrite 153 // it into its fast version (Note: no locking is needed 154 // here since this is an atomic byte write and can be 155 // done more than once). 156 // 157 // Note: In case of classes with has_finalized we don't 158 // rewrite since that saves us an extra check in 159 // the fast version which then would call the 160 // slow version anyway (and do a call back into 161 // Java). 162 // If we have a breakpoint, then we don't rewrite 444 445 // tracing 446 if (log_is_enabled(Info, exceptions)) { 447 ResourceMark rm(thread); 448 stringStream tempst; 449 tempst.print("interpreter method <%s>\n" 450 " at bci %d for thread " INTPTR_FORMAT, 451 h_method->print_value_string(), current_bci, p2i(thread)); 452 Exceptions::log_exception(h_exception, tempst); 453 } 454 // Don't go paging in something which won't be used. 455 // else if (extable->length() == 0) { 456 // // disabled for now - interpreter is not using shortcut yet 457 // // (shortcut is not to call runtime if we have no exception handlers) 458 // // warning("performance bug: should not call runtime if method has no exception handlers"); 459 // } 460 // for AbortVMOnException flag 461 Exceptions::debug_check_abort(h_exception); 462 463 // exception handler lookup 464 KlassHandle h_klass(THREAD, h_exception->klass()); 465 handler_bci = Method::fast_exception_handler_bci_for(h_method, h_klass, current_bci, THREAD); 466 if (HAS_PENDING_EXCEPTION) { 467 // We threw an exception while trying to find the exception handler. 468 // Transfer the new exception to the exception handle which will 469 // be set into thread local storage, and do another lookup for an 470 // exception handler for this exception, this time starting at the 471 // BCI of the exception handler which caused the exception to be 472 // thrown (bug 4307310). 473 h_exception = Handle(THREAD, PENDING_EXCEPTION); 474 CLEAR_PENDING_EXCEPTION; 475 if (handler_bci >= 0) { 476 current_bci = handler_bci; 477 should_repeat = true; 478 } 479 } 480 } while (should_repeat == true); 481 482 #if INCLUDE_JVMCI 483 if (EnableJVMCI && h_method->method_data() != NULL) { 484 ResourceMark rm(thread); 485 ProfileData* pdata = h_method->method_data()->allocate_bci_to_data(current_bci, NULL); 1053 } 1054 IRT_END 1055 1056 IRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread *thread, oopDesc* obj, 1057 ConstantPoolCacheEntry *cp_entry)) 1058 1059 // check the access_flags for the field in the klass 1060 1061 InstanceKlass* ik = InstanceKlass::cast(cp_entry->f1_as_klass()); 1062 int index = cp_entry->field_index(); 1063 if ((ik->field_access_flags(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return; 1064 1065 bool is_static = (obj == NULL); 1066 HandleMark hm(thread); 1067 1068 Handle h_obj; 1069 if (!is_static) { 1070 // non-static field accessors have an object, but we need a handle 1071 h_obj = Handle(thread, obj); 1072 } 1073 instanceKlassHandle h_cp_entry_f1(thread, (Klass*)cp_entry->f1_as_klass()); 1074 jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2_as_index(), is_static); 1075 JvmtiExport::post_field_access(thread, method(thread), bcp(thread), h_cp_entry_f1, h_obj, fid); 1076 IRT_END 1077 1078 IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread, 1079 oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value)) 1080 1081 Klass* k = (Klass*)cp_entry->f1_as_klass(); 1082 1083 // check the access_flags for the field in the klass 1084 InstanceKlass* ik = InstanceKlass::cast(k); 1085 int index = cp_entry->field_index(); 1086 // bail out if field modifications are not watched 1087 if ((ik->field_access_flags(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return; 1088 1089 char sig_type = '\0'; 1090 1091 switch(cp_entry->flag_state()) { 1092 case btos: sig_type = 'B'; break; 1093 case ztos: sig_type = 'Z'; break; 1094 case ctos: sig_type = 'C'; break; 1095 case stos: sig_type = 'S'; break; 1096 case itos: sig_type = 'I'; break; 1097 case ftos: sig_type = 'F'; break; 1098 case atos: sig_type = 'L'; break; 1099 case ltos: sig_type = 'J'; break; 1100 case dtos: sig_type = 'D'; break; 1101 default: ShouldNotReachHere(); return; 1102 } 1103 bool is_static = (obj == NULL); 1104 1105 HandleMark hm(thread); 1106 instanceKlassHandle h_klass(thread, k); 1107 jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_klass, cp_entry->f2_as_index(), is_static); 1108 jvalue fvalue; 1109 #ifdef _LP64 1110 fvalue = *value; 1111 #else 1112 // Long/double values are stored unaligned and also noncontiguously with 1113 // tagged stacks. We can't just do a simple assignment even in the non- 1114 // J/D cases because a C++ compiler is allowed to assume that a jvalue is 1115 // 8-byte aligned, and interpreter stack slots are only 4-byte aligned. 1116 // We assume that the two halves of longs/doubles are stored in interpreter 1117 // stack slots in platform-endian order. 1118 jlong_accessor u; 1119 jint* newval = (jint*)value; 1120 u.words[0] = newval[0]; 1121 u.words[1] = newval[Interpreter::stackElementWords]; // skip if tag 1122 fvalue.j = u.long_value; 1123 #endif // _LP64 1124 1125 Handle h_obj; 1126 if (!is_static) { 1127 // non-static field accessors have an object, but we need a handle 1128 h_obj = Handle(thread, obj); 1129 } 1130 1131 JvmtiExport::post_raw_field_modification(thread, method(thread), bcp(thread), h_klass, h_obj, 1132 fid, sig_type, &fvalue); 1133 IRT_END 1134 1135 IRT_ENTRY(void, InterpreterRuntime::post_method_entry(JavaThread *thread)) 1136 JvmtiExport::post_method_entry(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); 1137 IRT_END 1138 1139 1140 IRT_ENTRY(void, InterpreterRuntime::post_method_exit(JavaThread *thread)) 1141 JvmtiExport::post_method_exit(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); 1142 IRT_END 1143 1144 IRT_LEAF(int, InterpreterRuntime::interpreter_contains(address pc)) 1145 { 1146 return (Interpreter::contains(pc) ? 1 : 0); 1147 } 1148 IRT_END 1149 1150 1151 // Implementation of SignatureHandlerLibrary | 121 methodHandle m (thread, method(thread)); 122 Bytecode_loadconstant ldc(m, bci(thread)); 123 oop result = ldc.resolve_constant(CHECK); 124 #ifdef ASSERT 125 { 126 // The bytecode wrappers aren't GC-safe so construct a new one 127 Bytecode_loadconstant ldc2(m, bci(thread)); 128 oop coop = m->constants()->resolved_references()->obj_at(ldc2.cache_index()); 129 assert(result == coop, "expected result for assembly code"); 130 } 131 #endif 132 thread->set_vm_result(result); 133 } 134 IRT_END 135 136 137 //------------------------------------------------------------------------------------------------------------------------ 138 // Allocation 139 140 IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index)) 141 Klass* k = pool->klass_at(index, CHECK); 142 InstanceKlass* klass = InstanceKlass::cast(k); 143 144 // Make sure we are not instantiating an abstract klass 145 klass->check_valid_for_instantiation(true, CHECK); 146 147 // Make sure klass is initialized 148 klass->initialize(CHECK); 149 150 // At this point the class may not be fully initialized 151 // because of recursive initialization. If it is fully 152 // initialized & has_finalized is not set, we rewrite 153 // it into its fast version (Note: no locking is needed 154 // here since this is an atomic byte write and can be 155 // done more than once). 156 // 157 // Note: In case of classes with has_finalized we don't 158 // rewrite since that saves us an extra check in 159 // the fast version which then would call the 160 // slow version anyway (and do a call back into 161 // Java). 162 // If we have a breakpoint, then we don't rewrite 444 445 // tracing 446 if (log_is_enabled(Info, exceptions)) { 447 ResourceMark rm(thread); 448 stringStream tempst; 449 tempst.print("interpreter method <%s>\n" 450 " at bci %d for thread " INTPTR_FORMAT, 451 h_method->print_value_string(), current_bci, p2i(thread)); 452 Exceptions::log_exception(h_exception, tempst); 453 } 454 // Don't go paging in something which won't be used. 455 // else if (extable->length() == 0) { 456 // // disabled for now - interpreter is not using shortcut yet 457 // // (shortcut is not to call runtime if we have no exception handlers) 458 // // warning("performance bug: should not call runtime if method has no exception handlers"); 459 // } 460 // for AbortVMOnException flag 461 Exceptions::debug_check_abort(h_exception); 462 463 // exception handler lookup 464 Klass* klass = h_exception->klass(); 465 handler_bci = Method::fast_exception_handler_bci_for(h_method, klass, current_bci, THREAD); 466 if (HAS_PENDING_EXCEPTION) { 467 // We threw an exception while trying to find the exception handler. 468 // Transfer the new exception to the exception handle which will 469 // be set into thread local storage, and do another lookup for an 470 // exception handler for this exception, this time starting at the 471 // BCI of the exception handler which caused the exception to be 472 // thrown (bug 4307310). 473 h_exception = Handle(THREAD, PENDING_EXCEPTION); 474 CLEAR_PENDING_EXCEPTION; 475 if (handler_bci >= 0) { 476 current_bci = handler_bci; 477 should_repeat = true; 478 } 479 } 480 } while (should_repeat == true); 481 482 #if INCLUDE_JVMCI 483 if (EnableJVMCI && h_method->method_data() != NULL) { 484 ResourceMark rm(thread); 485 ProfileData* pdata = h_method->method_data()->allocate_bci_to_data(current_bci, NULL); 1053 } 1054 IRT_END 1055 1056 IRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread *thread, oopDesc* obj, 1057 ConstantPoolCacheEntry *cp_entry)) 1058 1059 // check the access_flags for the field in the klass 1060 1061 InstanceKlass* ik = InstanceKlass::cast(cp_entry->f1_as_klass()); 1062 int index = cp_entry->field_index(); 1063 if ((ik->field_access_flags(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return; 1064 1065 bool is_static = (obj == NULL); 1066 HandleMark hm(thread); 1067 1068 Handle h_obj; 1069 if (!is_static) { 1070 // non-static field accessors have an object, but we need a handle 1071 h_obj = Handle(thread, obj); 1072 } 1073 InstanceKlass* cp_entry_f1 = InstanceKlass::cast(cp_entry->f1_as_klass()); 1074 jfieldID fid = jfieldIDWorkaround::to_jfieldID(cp_entry_f1, cp_entry->f2_as_index(), is_static); 1075 JvmtiExport::post_field_access(thread, method(thread), bcp(thread), cp_entry_f1, h_obj, fid); 1076 IRT_END 1077 1078 IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread, 1079 oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value)) 1080 1081 Klass* k = cp_entry->f1_as_klass(); 1082 1083 // check the access_flags for the field in the klass 1084 InstanceKlass* ik = InstanceKlass::cast(k); 1085 int index = cp_entry->field_index(); 1086 // bail out if field modifications are not watched 1087 if ((ik->field_access_flags(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return; 1088 1089 char sig_type = '\0'; 1090 1091 switch(cp_entry->flag_state()) { 1092 case btos: sig_type = 'B'; break; 1093 case ztos: sig_type = 'Z'; break; 1094 case ctos: sig_type = 'C'; break; 1095 case stos: sig_type = 'S'; break; 1096 case itos: sig_type = 'I'; break; 1097 case ftos: sig_type = 'F'; break; 1098 case atos: sig_type = 'L'; break; 1099 case ltos: sig_type = 'J'; break; 1100 case dtos: sig_type = 'D'; break; 1101 default: ShouldNotReachHere(); return; 1102 } 1103 bool is_static = (obj == NULL); 1104 1105 HandleMark hm(thread); 1106 jfieldID fid = jfieldIDWorkaround::to_jfieldID(ik, cp_entry->f2_as_index(), is_static); 1107 jvalue fvalue; 1108 #ifdef _LP64 1109 fvalue = *value; 1110 #else 1111 // Long/double values are stored unaligned and also noncontiguously with 1112 // tagged stacks. We can't just do a simple assignment even in the non- 1113 // J/D cases because a C++ compiler is allowed to assume that a jvalue is 1114 // 8-byte aligned, and interpreter stack slots are only 4-byte aligned. 1115 // We assume that the two halves of longs/doubles are stored in interpreter 1116 // stack slots in platform-endian order. 1117 jlong_accessor u; 1118 jint* newval = (jint*)value; 1119 u.words[0] = newval[0]; 1120 u.words[1] = newval[Interpreter::stackElementWords]; // skip if tag 1121 fvalue.j = u.long_value; 1122 #endif // _LP64 1123 1124 Handle h_obj; 1125 if (!is_static) { 1126 // non-static field accessors have an object, but we need a handle 1127 h_obj = Handle(thread, obj); 1128 } 1129 1130 JvmtiExport::post_raw_field_modification(thread, method(thread), bcp(thread), ik, h_obj, 1131 fid, sig_type, &fvalue); 1132 IRT_END 1133 1134 IRT_ENTRY(void, InterpreterRuntime::post_method_entry(JavaThread *thread)) 1135 JvmtiExport::post_method_entry(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); 1136 IRT_END 1137 1138 1139 IRT_ENTRY(void, InterpreterRuntime::post_method_exit(JavaThread *thread)) 1140 JvmtiExport::post_method_exit(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); 1141 IRT_END 1142 1143 IRT_LEAF(int, InterpreterRuntime::interpreter_contains(address pc)) 1144 { 1145 return (Interpreter::contains(pc) ? 1 : 0); 1146 } 1147 IRT_END 1148 1149 1150 // Implementation of SignatureHandlerLibrary |