src/share/vm/opto/graphKit.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6833129 Sdiff src/share/vm/opto

src/share/vm/opto/graphKit.cpp

Print this page




 603   kit->set_sp(_sp);
 604 }
 605 
 606 
 607 //-----------------------------BuildCutout-------------------------------------
 608 BuildCutout::BuildCutout(GraphKit* kit, Node* p, float prob, float cnt)
 609   : PreserveJVMState(kit)
 610 {
 611   assert(p->is_Con() || p->is_Bool(), "test must be a bool");
 612   SafePointNode* outer_map = _map;   // preserved map is caller's
 613   SafePointNode* inner_map = kit->map();
 614   IfNode* iff = kit->create_and_map_if(outer_map->control(), p, prob, cnt);
 615   outer_map->set_control(kit->gvn().transform( new (kit->C, 1) IfTrueNode(iff) ));
 616   inner_map->set_control(kit->gvn().transform( new (kit->C, 1) IfFalseNode(iff) ));
 617 }
 618 BuildCutout::~BuildCutout() {
 619   GraphKit* kit = _kit;
 620   assert(kit->stopped(), "cutout code must stop, throw, return, etc.");
 621 }
 622 










 623 
 624 //------------------------------clone_map--------------------------------------
 625 // Implementation of PreserveJVMState
 626 //
 627 // Only clone_map(...) here. If this function is only used in the
 628 // PreserveJVMState class we may want to get rid of this extra
 629 // function eventually and do it all there.
 630 
 631 SafePointNode* GraphKit::clone_map() {
 632   if (map() == NULL)  return NULL;
 633 
 634   // Clone the memory edge first
 635   Node* mem = MergeMemNode::make(C, map()->memory());
 636   gvn().set_type_bottom(mem);
 637 
 638   SafePointNode *clonemap = (SafePointNode*)map()->clone();
 639   JVMState* jvms = this->jvms();
 640   JVMState* clonejvms = jvms->clone_shallow(C);
 641   clonemap->set_memory(mem);
 642   clonemap->set_jvms(clonejvms);


 721     int len = (int)live_locals.size();
 722     if (!live_locals.is_valid() || len == 0)
 723       // This method is trivial, or is poisoned by a breakpoint.
 724       return true;
 725     assert(len == jvms->loc_size(), "live map consistent with locals map");
 726     for (int local = 0; local < len; local++) {
 727       if (!live_locals.at(local) && map->local(jvms, local) != top()) {
 728         if (PrintMiscellaneous && (Verbose || WizardMode)) {
 729           tty->print_cr("Zombie local %d: ", local);
 730           jvms->dump();
 731         }
 732         return false;
 733       }
 734     }
 735   }
 736   return true;
 737 }
 738 
 739 #endif //ASSERT
 740 












 741 // Helper function for adding JVMState and debug information to node
 742 void GraphKit::add_safepoint_edges(SafePointNode* call, bool must_throw) {
 743   // Add the safepoint edges to the call (or other safepoint).
 744 
 745   // Make sure dead locals are set to top.  This
 746   // should help register allocation time and cut down on the size
 747   // of the deoptimization information.
 748   assert(dead_locals_are_killed(), "garbage in debug info before safepoint");
 749 
 750   // Walk the inline list to fill in the correct set of JVMState's
 751   // Also fill in the associated edges for each JVMState.
 752 
 753   JVMState* youngest_jvms = sync_jvms();
 754 
 755   // Do we need debug info here?  If it is a SafePoint and this method
 756   // cannot de-opt, then we do NOT need any debug info.
 757   bool full_info = (C->deopt_happens() || call->Opcode() != Op_SafePoint);
 758 
 759   // If we are guaranteed to throw, we can prune everything but the
 760   // input to the current bytecode.


 764   if (must_throw) {
 765     assert(method() == youngest_jvms->method(), "sanity");
 766     if (compute_stack_effects(inputs, depth)) {
 767       can_prune_locals = true;
 768       stack_slots_not_pruned = inputs;
 769     }
 770   }
 771 
 772   if (env()->jvmti_can_examine_or_deopt_anywhere()) {
 773     // At any safepoint, this method can get breakpointed, which would
 774     // then require an immediate deoptimization.
 775     full_info = true;
 776     can_prune_locals = false;  // do not prune locals
 777     stack_slots_not_pruned = 0;
 778   }
 779 
 780   // do not scribble on the input jvms
 781   JVMState* out_jvms = youngest_jvms->clone_deep(C);
 782   call->set_jvms(out_jvms); // Start jvms list for call node
 783 







 784   // Presize the call:
 785   debug_only(uint non_debug_edges = call->req());
 786   call->add_req_batch(top(), youngest_jvms->debug_depth());
 787   assert(call->req() == non_debug_edges + youngest_jvms->debug_depth(), "");
 788 
 789   // Set up edges so that the call looks like this:
 790   //  Call [state:] ctl io mem fptr retadr
 791   //       [parms:] parm0 ... parmN
 792   //       [root:]  loc0 ... locN stk0 ... stkSP mon0 obj0 ... monN objN
 793   //    [...mid:]   loc0 ... locN stk0 ... stkSP mon0 obj0 ... monN objN [...]
 794   //       [young:] loc0 ... locN stk0 ... stkSP mon0 obj0 ... monN objN
 795   // Note that caller debug info precedes callee debug info.
 796 
 797   // Fill pointer walks backwards from "young:" to "root:" in the diagram above:
 798   uint debug_ptr = call->req();
 799 
 800   // Loop over the map input edges associated with jvms, add them
 801   // to the call node, & reset all offsets to match call node array.
 802   for (JVMState* in_jvms = youngest_jvms; in_jvms != NULL; ) {
 803     uint debug_end   = debug_ptr;




 603   kit->set_sp(_sp);
 604 }
 605 
 606 
 607 //-----------------------------BuildCutout-------------------------------------
 608 BuildCutout::BuildCutout(GraphKit* kit, Node* p, float prob, float cnt)
 609   : PreserveJVMState(kit)
 610 {
 611   assert(p->is_Con() || p->is_Bool(), "test must be a bool");
 612   SafePointNode* outer_map = _map;   // preserved map is caller's
 613   SafePointNode* inner_map = kit->map();
 614   IfNode* iff = kit->create_and_map_if(outer_map->control(), p, prob, cnt);
 615   outer_map->set_control(kit->gvn().transform( new (kit->C, 1) IfTrueNode(iff) ));
 616   inner_map->set_control(kit->gvn().transform( new (kit->C, 1) IfFalseNode(iff) ));
 617 }
 618 BuildCutout::~BuildCutout() {
 619   GraphKit* kit = _kit;
 620   assert(kit->stopped(), "cutout code must stop, throw, return, etc.");
 621 }
 622 
 623 //---------------------------PreserveReexecuteState----------------------------
 624 PreserveReexecuteState::PreserveReexecuteState(GraphKit* kit) {
 625   _kit    =    kit;
 626   _sp     =    kit->sp();
 627   _reexecute = kit->jvms()->should_reexecute();
 628 }
 629 PreserveReexecuteState::~PreserveReexecuteState() {
 630   _kit->jvms()->set_reexecute(_reexecute);
 631   _kit->set_sp(_sp);
 632 }
 633 
 634 //------------------------------clone_map--------------------------------------
 635 // Implementation of PreserveJVMState
 636 //
 637 // Only clone_map(...) here. If this function is only used in the
 638 // PreserveJVMState class we may want to get rid of this extra
 639 // function eventually and do it all there.
 640 
 641 SafePointNode* GraphKit::clone_map() {
 642   if (map() == NULL)  return NULL;
 643 
 644   // Clone the memory edge first
 645   Node* mem = MergeMemNode::make(C, map()->memory());
 646   gvn().set_type_bottom(mem);
 647 
 648   SafePointNode *clonemap = (SafePointNode*)map()->clone();
 649   JVMState* jvms = this->jvms();
 650   JVMState* clonejvms = jvms->clone_shallow(C);
 651   clonemap->set_memory(mem);
 652   clonemap->set_jvms(clonejvms);


 731     int len = (int)live_locals.size();
 732     if (!live_locals.is_valid() || len == 0)
 733       // This method is trivial, or is poisoned by a breakpoint.
 734       return true;
 735     assert(len == jvms->loc_size(), "live map consistent with locals map");
 736     for (int local = 0; local < len; local++) {
 737       if (!live_locals.at(local) && map->local(jvms, local) != top()) {
 738         if (PrintMiscellaneous && (Verbose || WizardMode)) {
 739           tty->print_cr("Zombie local %d: ", local);
 740           jvms->dump();
 741         }
 742         return false;
 743       }
 744     }
 745   }
 746   return true;
 747 }
 748 
 749 #endif //ASSERT
 750 
 751 // Helper function for enforcing certain bytecodes to reexecute if 
 752 // deoptimization happens
 753 static bool should_reexecute_implied_by_bytecode(JVMState *jvms) {
 754   ciMethod* cur_method = jvms->method();
 755   int       cur_bci   = jvms->bci();
 756   if (cur_method != NULL && cur_bci != InvocationEntryBci) {
 757     Bytecodes::Code code = cur_method->java_code_at_bci(cur_bci);
 758     return Interpreter::bytecode_should_reexecute(code);
 759   } else
 760     return false;
 761 }
 762 
 763 // Helper function for adding JVMState and debug information to node
 764 void GraphKit::add_safepoint_edges(SafePointNode* call, bool must_throw) {
 765   // Add the safepoint edges to the call (or other safepoint).
 766 
 767   // Make sure dead locals are set to top.  This
 768   // should help register allocation time and cut down on the size
 769   // of the deoptimization information.
 770   assert(dead_locals_are_killed(), "garbage in debug info before safepoint");
 771 
 772   // Walk the inline list to fill in the correct set of JVMState's
 773   // Also fill in the associated edges for each JVMState.
 774 
 775   JVMState* youngest_jvms = sync_jvms();
 776 
 777   // Do we need debug info here?  If it is a SafePoint and this method
 778   // cannot de-opt, then we do NOT need any debug info.
 779   bool full_info = (C->deopt_happens() || call->Opcode() != Op_SafePoint);
 780 
 781   // If we are guaranteed to throw, we can prune everything but the
 782   // input to the current bytecode.


 786   if (must_throw) {
 787     assert(method() == youngest_jvms->method(), "sanity");
 788     if (compute_stack_effects(inputs, depth)) {
 789       can_prune_locals = true;
 790       stack_slots_not_pruned = inputs;
 791     }
 792   }
 793 
 794   if (env()->jvmti_can_examine_or_deopt_anywhere()) {
 795     // At any safepoint, this method can get breakpointed, which would
 796     // then require an immediate deoptimization.
 797     full_info = true;
 798     can_prune_locals = false;  // do not prune locals
 799     stack_slots_not_pruned = 0;
 800   }
 801 
 802   // do not scribble on the input jvms
 803   JVMState* out_jvms = youngest_jvms->clone_deep(C);
 804   call->set_jvms(out_jvms); // Start jvms list for call node
 805 
 806   // For a known set of bytecodes, the interpreter should reexecute them if
 807   // deoptimization happens. We set the reexecute bit for them here
 808   if (out_jvms->should_reexecute() == JVMState::RE_Undefined && //don't touch defined values
 809       should_reexecute_implied_by_bytecode(out_jvms)) {
 810     out_jvms->set_reexecute(JVMState::RE_True);
 811   }
 812 
 813   // Presize the call:
 814   debug_only(uint non_debug_edges = call->req());
 815   call->add_req_batch(top(), youngest_jvms->debug_depth());
 816   assert(call->req() == non_debug_edges + youngest_jvms->debug_depth(), "");
 817 
 818   // Set up edges so that the call looks like this:
 819   //  Call [state:] ctl io mem fptr retadr
 820   //       [parms:] parm0 ... parmN
 821   //       [root:]  loc0 ... locN stk0 ... stkSP mon0 obj0 ... monN objN
 822   //    [...mid:]   loc0 ... locN stk0 ... stkSP mon0 obj0 ... monN objN [...]
 823   //       [young:] loc0 ... locN stk0 ... stkSP mon0 obj0 ... monN objN
 824   // Note that caller debug info precedes callee debug info.
 825 
 826   // Fill pointer walks backwards from "young:" to "root:" in the diagram above:
 827   uint debug_ptr = call->req();
 828 
 829   // Loop over the map input edges associated with jvms, add them
 830   // to the call node, & reset all offsets to match call node array.
 831   for (JVMState* in_jvms = youngest_jvms; in_jvms != NULL; ) {
 832     uint debug_end   = debug_ptr;


src/share/vm/opto/graphKit.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File