comparison src/share/vm/opto/parse2.cpp @ 17:ff5961f4c095

6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long) Reviewed-by: kvn, rasbold
author never
date Wed, 05 Dec 2007 09:01:00 -0800
parents a61af66fc99e
children 73970d8c0b27
comparison
equal deleted inserted replaced
16:f8236e79048a 17:ff5961f4c095
883 883
884 //----------------------------------do_ifnull---------------------------------- 884 //----------------------------------do_ifnull----------------------------------
885 void Parse::do_ifnull(BoolTest::mask btest) { 885 void Parse::do_ifnull(BoolTest::mask btest) {
886 int target_bci = iter().get_dest(); 886 int target_bci = iter().get_dest();
887 887
888 Block* branch_block = successor_for_bci(target_bci);
889 Block* next_block = successor_for_bci(iter().next_bci());
890
888 float cnt; 891 float cnt;
889 float prob = branch_prediction(cnt, btest, target_bci); 892 float prob = branch_prediction(cnt, btest, target_bci);
890 if (prob == PROB_UNKNOWN) { 893 if (prob == PROB_UNKNOWN) {
891 // (An earlier version of do_ifnull omitted this trap for OSR methods.) 894 // (An earlier version of do_ifnull omitted this trap for OSR methods.)
892 #ifndef PRODUCT 895 #ifndef PRODUCT
900 // the path may be cold again. Make sure it doesn't look untaken 903 // the path may be cold again. Make sure it doesn't look untaken
901 profile_taken_branch(target_bci, !ProfileInterpreter); 904 profile_taken_branch(target_bci, !ProfileInterpreter);
902 uncommon_trap(Deoptimization::Reason_unreached, 905 uncommon_trap(Deoptimization::Reason_unreached,
903 Deoptimization::Action_reinterpret, 906 Deoptimization::Action_reinterpret,
904 NULL, "cold"); 907 NULL, "cold");
908 if (EliminateAutoBox) {
909 // Mark the successor blocks as parsed
910 branch_block->next_path_num();
911 next_block->next_path_num();
912 }
905 return; 913 return;
906 } 914 }
907 915
908 // If this is a backwards branch in the bytecodes, add Safepoint 916 // If this is a backwards branch in the bytecodes, add Safepoint
909 maybe_add_safepoint(target_bci); 917 maybe_add_safepoint(target_bci);
910 Block* branch_block = successor_for_bci(target_bci);
911 Block* next_block = successor_for_bci(iter().next_bci());
912 918
913 explicit_null_checks_inserted++; 919 explicit_null_checks_inserted++;
914 Node* a = null(); 920 Node* a = null();
915 Node* b = pop(); 921 Node* b = pop();
916 Node* c = _gvn.transform( new (C, 3) CmpPNode(b, a) ); 922 Node* c = _gvn.transform( new (C, 3) CmpPNode(b, a) );
933 Node* iftrue = _gvn.transform( new (C, 1) IfTrueNode (iff) ); 939 Node* iftrue = _gvn.transform( new (C, 1) IfTrueNode (iff) );
934 set_control(iftrue); 940 set_control(iftrue);
935 941
936 if (stopped()) { // Path is dead? 942 if (stopped()) { // Path is dead?
937 explicit_null_checks_elided++; 943 explicit_null_checks_elided++;
944 if (EliminateAutoBox) {
945 // Mark the successor block as parsed
946 branch_block->next_path_num();
947 }
938 } else { // Path is live. 948 } else { // Path is live.
939 // Update method data 949 // Update method data
940 profile_taken_branch(target_bci); 950 profile_taken_branch(target_bci);
941 adjust_map_after_if(btest, c, prob, branch_block, next_block); 951 adjust_map_after_if(btest, c, prob, branch_block, next_block);
942 if (!stopped()) 952 if (!stopped())
948 Node* iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff) ); 958 Node* iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff) );
949 set_control(iffalse); 959 set_control(iffalse);
950 960
951 if (stopped()) { // Path is dead? 961 if (stopped()) { // Path is dead?
952 explicit_null_checks_elided++; 962 explicit_null_checks_elided++;
963 if (EliminateAutoBox) {
964 // Mark the successor block as parsed
965 next_block->next_path_num();
966 }
953 } else { // Path is live. 967 } else { // Path is live.
954 // Update method data 968 // Update method data
955 profile_not_taken_branch(); 969 profile_not_taken_branch();
956 adjust_map_after_if(BoolTest(btest).negate(), c, 1.0-prob, 970 adjust_map_after_if(BoolTest(btest).negate(), c, 1.0-prob,
957 next_block, branch_block); 971 next_block, branch_block);
959 } 973 }
960 974
961 //------------------------------------do_if------------------------------------ 975 //------------------------------------do_if------------------------------------
962 void Parse::do_if(BoolTest::mask btest, Node* c) { 976 void Parse::do_if(BoolTest::mask btest, Node* c) {
963 int target_bci = iter().get_dest(); 977 int target_bci = iter().get_dest();
978
979 Block* branch_block = successor_for_bci(target_bci);
980 Block* next_block = successor_for_bci(iter().next_bci());
964 981
965 float cnt; 982 float cnt;
966 float prob = branch_prediction(cnt, btest, target_bci); 983 float prob = branch_prediction(cnt, btest, target_bci);
967 float untaken_prob = 1.0 - prob; 984 float untaken_prob = 1.0 - prob;
968 985
978 // the path may be cold again. Make sure it doesn't look untaken 995 // the path may be cold again. Make sure it doesn't look untaken
979 profile_taken_branch(target_bci, !ProfileInterpreter); 996 profile_taken_branch(target_bci, !ProfileInterpreter);
980 uncommon_trap(Deoptimization::Reason_unreached, 997 uncommon_trap(Deoptimization::Reason_unreached,
981 Deoptimization::Action_reinterpret, 998 Deoptimization::Action_reinterpret,
982 NULL, "cold"); 999 NULL, "cold");
1000 if (EliminateAutoBox) {
1001 // Mark the successor blocks as parsed
1002 branch_block->next_path_num();
1003 next_block->next_path_num();
1004 }
983 return; 1005 return;
984 } 1006 }
985 1007
986 // Sanity check the probability value 1008 // Sanity check the probability value
987 assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser"); 1009 assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser");
1016 Node* tmp = taken_branch; 1038 Node* tmp = taken_branch;
1017 taken_branch = untaken_branch; 1039 taken_branch = untaken_branch;
1018 untaken_branch = tmp; 1040 untaken_branch = tmp;
1019 } 1041 }
1020 1042
1021 Block* branch_block = successor_for_bci(target_bci);
1022 Block* next_block = successor_for_bci(iter().next_bci());
1023
1024 // Branch is taken: 1043 // Branch is taken:
1025 { PreserveJVMState pjvms(this); 1044 { PreserveJVMState pjvms(this);
1026 taken_branch = _gvn.transform(taken_branch); 1045 taken_branch = _gvn.transform(taken_branch);
1027 set_control(taken_branch); 1046 set_control(taken_branch);
1028 1047
1029 if (!stopped()) { 1048 if (stopped()) {
1049 if (EliminateAutoBox) {
1050 // Mark the successor block as parsed
1051 branch_block->next_path_num();
1052 }
1053 } else {
1030 // Update method data 1054 // Update method data
1031 profile_taken_branch(target_bci); 1055 profile_taken_branch(target_bci);
1032 adjust_map_after_if(taken_btest, c, prob, branch_block, next_block); 1056 adjust_map_after_if(taken_btest, c, prob, branch_block, next_block);
1033 if (!stopped()) 1057 if (!stopped())
1034 merge(target_bci); 1058 merge(target_bci);
1037 1061
1038 untaken_branch = _gvn.transform(untaken_branch); 1062 untaken_branch = _gvn.transform(untaken_branch);
1039 set_control(untaken_branch); 1063 set_control(untaken_branch);
1040 1064
1041 // Branch not taken. 1065 // Branch not taken.
1042 if (!stopped()) { 1066 if (stopped()) {
1067 if (EliminateAutoBox) {
1068 // Mark the successor block as parsed
1069 next_block->next_path_num();
1070 }
1071 } else {
1043 // Update method data 1072 // Update method data
1044 profile_not_taken_branch(); 1073 profile_not_taken_branch();
1045 adjust_map_after_if(untaken_btest, c, untaken_prob, 1074 adjust_map_after_if(untaken_btest, c, untaken_prob,
1046 next_block, branch_block); 1075 next_block, branch_block);
1047 } 1076 }