Mercurial > hg > graal-jvmci-8
comparison src/share/vm/interpreter/interpreter.cpp @ 900:9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
Summary: developed a reexecute logic for the interpreter to reexecute the bytecode when deopt happens
Reviewed-by: kvn, never, jrose, twisti
author | cfang |
---|---|
date | Fri, 31 Jul 2009 17:12:33 -0700 |
parents | e5b0439ef4ae |
children | 389049f3f393 |
comparison
equal
deleted
inserted
replaced
899:55cb84cd1247 | 900:9987d9d5eb0e |
---|---|
282 | 282 |
283 | 283 |
284 //------------------------------------------------------------------------------------------------------------------------ | 284 //------------------------------------------------------------------------------------------------------------------------ |
285 // Deoptimization support | 285 // Deoptimization support |
286 | 286 |
287 // If deoptimization happens, this method returns the point where to continue in | 287 // If deoptimization happens, this function returns the point of next bytecode to continue execution |
288 // interpreter. For calls (invokexxxx, newxxxx) the continuation is at next | 288 address AbstractInterpreter::deopt_continue_after_entry(methodOop method, address bcp, int callee_parameters, bool is_top_frame) { |
289 // bci and the top of stack is in eax/edx/FPU tos. | |
290 // For putfield/getfield, put/getstatic, the continuation is at the same | |
291 // bci and the TOS is on stack. | |
292 | |
293 // Note: deopt_entry(type, 0) means reexecute bytecode | |
294 // deopt_entry(type, length) means continue at next bytecode | |
295 | |
296 address AbstractInterpreter::continuation_for(methodOop method, address bcp, int callee_parameters, bool is_top_frame, bool& use_next_mdp) { | |
297 assert(method->contains(bcp), "just checkin'"); | 289 assert(method->contains(bcp), "just checkin'"); |
298 Bytecodes::Code code = Bytecodes::java_code_at(bcp); | 290 Bytecodes::Code code = Bytecodes::java_code_at(bcp); |
291 assert(!Interpreter::bytecode_should_reexecute(code), "should not reexecute"); | |
299 int bci = method->bci_from(bcp); | 292 int bci = method->bci_from(bcp); |
300 int length = -1; // initial value for debugging | 293 int length = -1; // initial value for debugging |
301 // compute continuation length | 294 // compute continuation length |
302 length = Bytecodes::length_at(bcp); | 295 length = Bytecodes::length_at(bcp); |
303 // compute result type | 296 // compute result type |
304 BasicType type = T_ILLEGAL; | 297 BasicType type = T_ILLEGAL; |
305 // when continuing after a compiler safepoint, re-execute the bytecode | 298 |
306 // (an invoke is continued after the safepoint) | 299 switch (code) { |
307 use_next_mdp = true; | 300 case Bytecodes::_invokevirtual : |
301 case Bytecodes::_invokespecial : | |
302 case Bytecodes::_invokestatic : | |
303 case Bytecodes::_invokeinterface: { | |
304 Thread *thread = Thread::current(); | |
305 ResourceMark rm(thread); | |
306 methodHandle mh(thread, method); | |
307 type = Bytecode_invoke_at(mh, bci)->result_type(thread); | |
308 // since the cache entry might not be initialized: | |
309 // (NOT needed for the old calling convension) | |
310 if (!is_top_frame) { | |
311 int index = Bytes::get_native_u2(bcp+1); | |
312 method->constants()->cache()->entry_at(index)->set_parameter_size(callee_parameters); | |
313 } | |
314 break; | |
315 } | |
316 | |
317 case Bytecodes::_ldc : | |
318 type = constant_pool_type( method, *(bcp+1) ); | |
319 break; | |
320 | |
321 case Bytecodes::_ldc_w : // fall through | |
322 case Bytecodes::_ldc2_w: | |
323 type = constant_pool_type( method, Bytes::get_Java_u2(bcp+1) ); | |
324 break; | |
325 | |
326 default: | |
327 type = Bytecodes::result_type(code); | |
328 break; | |
329 } | |
330 | |
331 // return entry point for computed continuation state & bytecode length | |
332 return | |
333 is_top_frame | |
334 ? Interpreter::deopt_entry (as_TosState(type), length) | |
335 : Interpreter::return_entry(as_TosState(type), length); | |
336 } | |
337 | |
338 // If deoptimization happens, this function returns the point where the interpreter reexecutes | |
339 // the bytecode. | |
340 // Note: Bytecodes::_athrow is a special case in that it does not return | |
341 // Interpreter::deopt_entry(vtos, 0) like others | |
342 address AbstractInterpreter::deopt_reexecute_entry(methodOop method, address bcp) { | |
343 assert(method->contains(bcp), "just checkin'"); | |
344 Bytecodes::Code code = Bytecodes::java_code_at(bcp); | |
345 #ifdef COMPILER1 | |
346 if(code == Bytecodes::_athrow ) { | |
347 return Interpreter::rethrow_exception_entry(); | |
348 } | |
349 #endif /* COMPILER1 */ | |
350 return Interpreter::deopt_entry(vtos, 0); | |
351 } | |
352 | |
353 // If deoptimization happens, the interpreter should reexecute these bytecodes. | |
354 // This function mainly helps the compilers to set up the reexecute bit. | |
355 bool AbstractInterpreter::bytecode_should_reexecute(Bytecodes::Code code) { | |
308 switch (code) { | 356 switch (code) { |
309 case Bytecodes::_lookupswitch: | 357 case Bytecodes::_lookupswitch: |
310 case Bytecodes::_tableswitch: | 358 case Bytecodes::_tableswitch: |
311 case Bytecodes::_fast_binaryswitch: | 359 case Bytecodes::_fast_binaryswitch: |
312 case Bytecodes::_fast_linearswitch: | 360 case Bytecodes::_fast_linearswitch: |
338 case Bytecodes::_getfield : | 386 case Bytecodes::_getfield : |
339 case Bytecodes::_putfield : | 387 case Bytecodes::_putfield : |
340 case Bytecodes::_getstatic : | 388 case Bytecodes::_getstatic : |
341 case Bytecodes::_putstatic : | 389 case Bytecodes::_putstatic : |
342 case Bytecodes::_aastore : | 390 case Bytecodes::_aastore : |
343 // reexecute the operation and TOS value is on stack | |
344 assert(is_top_frame, "must be top frame"); | |
345 use_next_mdp = false; | |
346 return Interpreter::deopt_entry(vtos, 0); | |
347 break; | |
348 | |
349 #ifdef COMPILER1 | 391 #ifdef COMPILER1 |
392 //special case of reexecution | |
350 case Bytecodes::_athrow : | 393 case Bytecodes::_athrow : |
351 assert(is_top_frame, "must be top frame"); | 394 #endif |
352 use_next_mdp = false; | 395 return true; |
353 return Interpreter::rethrow_exception_entry(); | |
354 break; | |
355 #endif /* COMPILER1 */ | |
356 | |
357 case Bytecodes::_invokevirtual : | |
358 case Bytecodes::_invokespecial : | |
359 case Bytecodes::_invokestatic : | |
360 case Bytecodes::_invokeinterface: { | |
361 Thread *thread = Thread::current(); | |
362 ResourceMark rm(thread); | |
363 methodHandle mh(thread, method); | |
364 type = Bytecode_invoke_at(mh, bci)->result_type(thread); | |
365 // since the cache entry might not be initialized: | |
366 // (NOT needed for the old calling convension) | |
367 if (!is_top_frame) { | |
368 int index = Bytes::get_native_u2(bcp+1); | |
369 method->constants()->cache()->entry_at(index)->set_parameter_size(callee_parameters); | |
370 } | |
371 break; | |
372 } | |
373 | |
374 case Bytecodes::_ldc : | |
375 type = constant_pool_type( method, *(bcp+1) ); | |
376 break; | |
377 | |
378 case Bytecodes::_ldc_w : // fall through | |
379 case Bytecodes::_ldc2_w: | |
380 type = constant_pool_type( method, Bytes::get_Java_u2(bcp+1) ); | |
381 break; | |
382 | 396 |
383 default: | 397 default: |
384 type = Bytecodes::result_type(code); | 398 return false; |
385 break; | 399 } |
386 } | |
387 | |
388 // return entry point for computed continuation state & bytecode length | |
389 return | |
390 is_top_frame | |
391 ? Interpreter::deopt_entry (as_TosState(type), length) | |
392 : Interpreter::return_entry(as_TosState(type), length); | |
393 } | 400 } |
394 | 401 |
395 void AbstractInterpreterGenerator::bang_stack_shadow_pages(bool native_call) { | 402 void AbstractInterpreterGenerator::bang_stack_shadow_pages(bool native_call) { |
396 // Quick & dirty stack overflow checking: bang the stack & handle trap. | 403 // Quick & dirty stack overflow checking: bang the stack & handle trap. |
397 // Note that we do the banging after the frame is setup, since the exception | 404 // Note that we do the banging after the frame is setup, since the exception |