src/share/vm/opto/graphKit.cpp

changeset 1648
6deeaebad47a
parent 1601
7b0e9cba0307
child 1692
7b4415a18c8a
equal deleted inserted replaced
1631:f3345b7b01b4 1648:6deeaebad47a
1 /* 1 /*
2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 2001-2010 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
453 return method->java_code_at_bci(bci); 453 return method->java_code_at_bci(bci);
454 else 454 else
455 return Bytecodes::_illegal; 455 return Bytecodes::_illegal;
456 } 456 }
457 457
458 void GraphKit::uncommon_trap_if_should_post_on_exceptions(Deoptimization::DeoptReason reason,
459 bool must_throw) {
460 // if the exception capability is set, then we will generate code
461 // to check the JavaThread.should_post_on_exceptions flag to see
462 // if we actually need to report exception events (for this
463 // thread). If we don't need to report exception events, we will
464 // take the normal fast path provided by add_exception_events. If
465 // exception event reporting is enabled for this thread, we will
466 // take the uncommon_trap in the BuildCutout below.
467
468 // first must access the should_post_on_exceptions_flag in this thread's JavaThread
469 Node* jthread = _gvn.transform(new (C, 1) ThreadLocalNode());
470 Node* adr = basic_plus_adr(top(), jthread, in_bytes(JavaThread::should_post_on_exceptions_flag_offset()));
471 Node* should_post_flag = make_load(control(), adr, TypeInt::INT, T_INT, Compile::AliasIdxRaw, false);
472
473 // Test the should_post_on_exceptions_flag vs. 0
474 Node* chk = _gvn.transform( new (C, 3) CmpINode(should_post_flag, intcon(0)) );
475 Node* tst = _gvn.transform( new (C, 2) BoolNode(chk, BoolTest::eq) );
476
477 // Branch to slow_path if should_post_on_exceptions_flag was true
478 { BuildCutout unless(this, tst, PROB_MAX);
479 // Do not try anything fancy if we're notifying the VM on every throw.
480 // Cf. case Bytecodes::_athrow in parse2.cpp.
481 uncommon_trap(reason, Deoptimization::Action_none,
482 (ciKlass*)NULL, (char*)NULL, must_throw);
483 }
484
485 }
486
458 //------------------------------builtin_throw---------------------------------- 487 //------------------------------builtin_throw----------------------------------
459 void GraphKit::builtin_throw(Deoptimization::DeoptReason reason, Node* arg) { 488 void GraphKit::builtin_throw(Deoptimization::DeoptReason reason, Node* arg) {
460 bool must_throw = true; 489 bool must_throw = true;
461 490
462 if (env()->jvmti_can_post_exceptions()) { 491 if (env()->jvmti_can_post_on_exceptions()) {
463 // Do not try anything fancy if we're notifying the VM on every throw. 492 // check if we must post exception events, take uncommon trap if so
464 // Cf. case Bytecodes::_athrow in parse2.cpp. 493 uncommon_trap_if_should_post_on_exceptions(reason, must_throw);
465 uncommon_trap(reason, Deoptimization::Action_none, 494 // here if should_post_on_exceptions is false
466 (ciKlass*)NULL, (char*)NULL, must_throw); 495 // continue on with the normal codegen
467 return;
468 } 496 }
469 497
470 // If this particular condition has not yet happened at this 498 // If this particular condition has not yet happened at this
471 // bytecode, then use the uncommon trap mechanism, and allow for 499 // bytecode, then use the uncommon trap mechanism, and allow for
472 // a future recompilation if several traps occur here. 500 // a future recompilation if several traps occur here.

mercurial