1109 assert(m != NULL, "expecting a method in this frame"); |
1109 assert(m != NULL, "expecting a method in this frame"); |
1110 f(m); |
1110 f(m); |
1111 } |
1111 } |
1112 } |
1112 } |
1113 |
1113 |
1114 # ifdef ENABLE_ZAP_DEAD_LOCALS |
|
1115 |
|
1116 void frame::CheckValueClosure::do_oop(oop* p) { |
|
1117 if (CheckOopishValues && Universe::heap()->is_in_reserved(*p)) { |
|
1118 warning("value @ " INTPTR_FORMAT " looks oopish (" INTPTR_FORMAT ") (thread = " INTPTR_FORMAT ")", p, (address)*p, Thread::current()); |
|
1119 } |
|
1120 } |
|
1121 frame::CheckValueClosure frame::_check_value; |
|
1122 |
|
1123 |
|
1124 void frame::CheckOopClosure::do_oop(oop* p) { |
|
1125 if (*p != NULL && !(*p)->is_oop()) { |
|
1126 warning("value @ " INTPTR_FORMAT " should be an oop (" INTPTR_FORMAT ") (thread = " INTPTR_FORMAT ")", p, (address)*p, Thread::current()); |
|
1127 } |
|
1128 } |
|
1129 frame::CheckOopClosure frame::_check_oop; |
|
1130 |
|
1131 void frame::check_derived_oop(oop* base, oop* derived) { |
|
1132 _check_oop.do_oop(base); |
|
1133 } |
|
1134 |
|
1135 |
|
1136 void frame::ZapDeadClosure::do_oop(oop* p) { |
|
1137 if (TraceZapDeadLocals) tty->print_cr("zapping @ " INTPTR_FORMAT " containing " INTPTR_FORMAT, p, (address)*p); |
|
1138 *p = cast_to_oop<intptr_t>(0xbabebabe); |
|
1139 } |
|
1140 frame::ZapDeadClosure frame::_zap_dead; |
|
1141 |
|
1142 void frame::zap_dead_locals(JavaThread* thread, const RegisterMap* map) { |
|
1143 assert(thread == Thread::current(), "need to synchronize to do this to another thread"); |
|
1144 // Tracing - part 1 |
|
1145 if (TraceZapDeadLocals) { |
|
1146 ResourceMark rm(thread); |
|
1147 tty->print_cr("--------------------------------------------------------------------------------"); |
|
1148 tty->print("Zapping dead locals in "); |
|
1149 print_on(tty); |
|
1150 tty->cr(); |
|
1151 } |
|
1152 // Zapping |
|
1153 if (is_entry_frame ()) zap_dead_entry_locals (thread, map); |
|
1154 else if (is_interpreted_frame()) zap_dead_interpreted_locals(thread, map); |
|
1155 else if (is_compiled_frame()) zap_dead_compiled_locals (thread, map); |
|
1156 |
|
1157 else |
|
1158 // could be is_runtime_frame |
|
1159 // so remove error: ShouldNotReachHere(); |
|
1160 ; |
|
1161 // Tracing - part 2 |
|
1162 if (TraceZapDeadLocals) { |
|
1163 tty->cr(); |
|
1164 } |
|
1165 } |
|
1166 |
|
1167 |
|
1168 void frame::zap_dead_interpreted_locals(JavaThread *thread, const RegisterMap* map) { |
|
1169 // get current interpreter 'pc' |
|
1170 assert(is_interpreted_frame(), "Not an interpreted frame"); |
|
1171 Method* m = interpreter_frame_method(); |
|
1172 int bci = interpreter_frame_bci(); |
|
1173 |
|
1174 int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals(); |
|
1175 |
|
1176 // process dynamic part |
|
1177 InterpreterFrameClosure value_blk(this, max_locals, m->max_stack(), |
|
1178 &_check_value); |
|
1179 InterpreterFrameClosure oop_blk(this, max_locals, m->max_stack(), |
|
1180 &_check_oop ); |
|
1181 InterpreterFrameClosure dead_blk(this, max_locals, m->max_stack(), |
|
1182 &_zap_dead ); |
|
1183 |
|
1184 // get frame map |
|
1185 InterpreterOopMap mask; |
|
1186 m->mask_for(bci, &mask); |
|
1187 mask.iterate_all( &oop_blk, &value_blk, &dead_blk); |
|
1188 } |
|
1189 |
|
1190 |
|
1191 void frame::zap_dead_compiled_locals(JavaThread* thread, const RegisterMap* reg_map) { |
|
1192 |
|
1193 ResourceMark rm(thread); |
|
1194 assert(_cb != NULL, "sanity check"); |
|
1195 if (_cb->oop_maps() != NULL) { |
|
1196 OopMapSet::all_do(this, reg_map, &_check_oop, check_derived_oop, &_check_value); |
|
1197 } |
|
1198 } |
|
1199 |
|
1200 |
|
1201 void frame::zap_dead_entry_locals(JavaThread*, const RegisterMap*) { |
|
1202 if (TraceZapDeadLocals) warning("frame::zap_dead_entry_locals unimplemented"); |
|
1203 } |
|
1204 |
|
1205 |
|
1206 void frame::zap_dead_deoptimized_locals(JavaThread*, const RegisterMap*) { |
|
1207 if (TraceZapDeadLocals) warning("frame::zap_dead_deoptimized_locals unimplemented"); |
|
1208 } |
|
1209 |
|
1210 # endif // ENABLE_ZAP_DEAD_LOCALS |
|
1211 |
|
1212 void frame::verify(const RegisterMap* map) { |
1114 void frame::verify(const RegisterMap* map) { |
1213 // for now make sure receiver type is correct |
1115 // for now make sure receiver type is correct |
1214 if (is_interpreted_frame()) { |
1116 if (is_interpreted_frame()) { |
1215 Method* method = interpreter_frame_method(); |
1117 Method* method = interpreter_frame_method(); |
1216 guarantee(method->is_method(), "method is wrong in frame::verify"); |
1118 guarantee(method->is_method(), "method is wrong in frame::verify"); |