comparison src/share/vm/runtime/deoptimization.cpp @ 5110:0ebca2e35ca5

more preparations for disabling runtime feedback selectively based on deoptimization history
author Christian Haeubl <christian.haeubl@oracle.com>
date Thu, 15 Mar 2012 15:31:34 -0700
parents 1b907994bf2d
children dad1ac9dba7d
comparison
equal deleted inserted replaced
5109:6766253384bf 5110:0ebca2e35ca5
1131 } 1131 }
1132 BiasedLocking::revoke_at_safepoint(objects_to_revoke); 1132 BiasedLocking::revoke_at_safepoint(objects_to_revoke);
1133 } 1133 }
1134 1134
1135 1135
1136 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr) { 1136 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) {
1137 assert(fr.can_be_deoptimized(), "checking frame type"); 1137 assert(fr.can_be_deoptimized(), "checking frame type");
1138 1138
1139 gather_statistics(Reason_constraint, Action_none, Bytecodes::_illegal); 1139 gather_statistics(reason, Action_none, Bytecodes::_illegal);
1140 1140
1141 // Patch the nmethod so that when execution returns to it we will 1141 // Patch the nmethod so that when execution returns to it we will
1142 // deopt the execution state and return to the interpreter. 1142 // deopt the execution state and return to the interpreter.
1143 fr.deoptimize(thread); 1143 fr.deoptimize(thread);
1144 } 1144 }
1145 1145
1146 void Deoptimization::deoptimize(JavaThread* thread, frame fr, RegisterMap *map) { 1146 void Deoptimization::deoptimize(JavaThread* thread, frame fr, RegisterMap *map, DeoptReason reason) {
1147 // Deoptimize only if the frame comes from compile code. 1147 // Deoptimize only if the frame comes from compile code.
1148 // Do not deoptimize the frame which is already patched 1148 // Do not deoptimize the frame which is already patched
1149 // during the execution of the loops below. 1149 // during the execution of the loops below.
1150 if (!fr.is_compiled_frame() || fr.is_deoptimized_frame()) { 1150 if (!fr.is_compiled_frame() || fr.is_deoptimized_frame()) {
1151 return; 1151 return;
1153 ResourceMark rm; 1153 ResourceMark rm;
1154 DeoptimizationMarker dm; 1154 DeoptimizationMarker dm;
1155 if (UseBiasedLocking) { 1155 if (UseBiasedLocking) {
1156 revoke_biases_of_monitors(thread, fr, map); 1156 revoke_biases_of_monitors(thread, fr, map);
1157 } 1157 }
1158 deoptimize_single_frame(thread, fr); 1158 deoptimize_single_frame(thread, fr, reason);
1159 1159
1160 } 1160 }
1161 1161
1162 1162
1163 void Deoptimization::deoptimize_frame_internal(JavaThread* thread, intptr_t* id) { 1163 void Deoptimization::deoptimize_frame_internal(JavaThread* thread, intptr_t* id, DeoptReason reason) {
1164 assert(thread == Thread::current() || SafepointSynchronize::is_at_safepoint(), 1164 assert(thread == Thread::current() || SafepointSynchronize::is_at_safepoint(),
1165 "can only deoptimize other thread at a safepoint"); 1165 "can only deoptimize other thread at a safepoint");
1166 // Compute frame and register map based on thread and sp. 1166 // Compute frame and register map based on thread and sp.
1167 RegisterMap reg_map(thread, UseBiasedLocking); 1167 RegisterMap reg_map(thread, UseBiasedLocking);
1168 frame fr = thread->last_frame(); 1168 frame fr = thread->last_frame();
1169 while (fr.id() != id) { 1169 while (fr.id() != id) {
1170 fr = fr.sender(&reg_map); 1170 fr = fr.sender(&reg_map);
1171 } 1171 }
1172 deoptimize(thread, fr, &reg_map); 1172 deoptimize(thread, fr, &reg_map, reason);
1173 } 1173 }
1174 1174
1175 1175
1176 void Deoptimization::deoptimize_frame(JavaThread* thread, intptr_t* id) { 1176 void Deoptimization::deoptimize_frame(JavaThread* thread, intptr_t* id, DeoptReason reason) {
1177 if (thread == Thread::current()) { 1177 if (thread == Thread::current()) {
1178 Deoptimization::deoptimize_frame_internal(thread, id); 1178 Deoptimization::deoptimize_frame_internal(thread, id, reason);
1179 } else { 1179 } else {
1180 VM_DeoptimizeFrame deopt(thread, id); 1180 VM_DeoptimizeFrame deopt(thread, id, reason);
1181 VMThread::execute(&deopt); 1181 VMThread::execute(&deopt);
1182 } 1182 }
1183 } 1183 }
1184 1184
1185 1185
1811 1811
1812 //--------------------------------statics-------------------------------------- 1812 //--------------------------------statics--------------------------------------
1813 Deoptimization::DeoptAction Deoptimization::_unloaded_action 1813 Deoptimization::DeoptAction Deoptimization::_unloaded_action
1814 = Deoptimization::Action_reinterpret; 1814 = Deoptimization::Action_reinterpret;
1815 const char* Deoptimization::_trap_reason_name[Reason_LIMIT] = { 1815 const char* Deoptimization::_trap_reason_name[Reason_LIMIT] = {
1816 #ifdef GRAAL
1817 "none",
1818 "null_check",
1819 "range_check",
1820 "class_check",
1821 "array_check",
1822 "unreached",
1823 "type_checked_inlining",
1824 "optimized_type_check",
1825 "not_compiled_exception_handler",
1826 "unresolved",
1827 "jsr_mismatch",
1828 "div0_check",
1829 "constraint"
1830 #else
1816 // Note: Keep this in sync. with enum DeoptReason. 1831 // Note: Keep this in sync. with enum DeoptReason.
1817 "none", 1832 "none",
1818 "null_check", 1833 "null_check",
1819 "null_assert", 1834 "null_assert",
1820 "range_check", 1835 "range_check",
1829 "constraint", 1844 "constraint",
1830 "div0_check", 1845 "div0_check",
1831 "age", 1846 "age",
1832 "predicate", 1847 "predicate",
1833 "loop_limit_check" 1848 "loop_limit_check"
1849 #endif
1834 }; 1850 };
1835 const char* Deoptimization::_trap_action_name[Action_LIMIT] = { 1851 const char* Deoptimization::_trap_action_name[Action_LIMIT] = {
1836 // Note: Keep this in sync. with enum DeoptAction. 1852 // Note: Keep this in sync. with enum DeoptAction.
1837 "none", 1853 "none",
1838 "maybe_recompile", 1854 "maybe_recompile",