Mercurial > hg > graal-compiler
comparison src/share/vm/opto/stringopts.cpp @ 6948:e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Nov 2012 23:14:12 +0100 |
parents | e626685e9f6c |
children | 2aff40cb4703 |
comparison
equal
deleted
inserted
replaced
6711:ae13cc658b80 | 6948:e522a00b91aa |
---|---|
67 _end(end), | 67 _end(end), |
68 _begin(NULL), | 68 _begin(NULL), |
69 _multiple(false), | 69 _multiple(false), |
70 _string_alloc(NULL), | 70 _string_alloc(NULL), |
71 _stringopts(stringopts) { | 71 _stringopts(stringopts) { |
72 _arguments = new (_stringopts->C, 1) Node(1); | 72 _arguments = new (_stringopts->C) Node(1); |
73 _arguments->del_req(0); | 73 _arguments->del_req(0); |
74 } | 74 } |
75 | 75 |
76 bool validate_control_flow(); | 76 bool validate_control_flow(); |
77 | 77 |
218 Node* uct = _uncommon_traps.at(u); | 218 Node* uct = _uncommon_traps.at(u); |
219 | 219 |
220 // Build a new call using the jvms state of the allocate | 220 // Build a new call using the jvms state of the allocate |
221 address call_addr = SharedRuntime::uncommon_trap_blob()->entry_point(); | 221 address call_addr = SharedRuntime::uncommon_trap_blob()->entry_point(); |
222 const TypeFunc* call_type = OptoRuntime::uncommon_trap_Type(); | 222 const TypeFunc* call_type = OptoRuntime::uncommon_trap_Type(); |
223 int size = call_type->domain()->cnt(); | |
224 const TypePtr* no_memory_effects = NULL; | 223 const TypePtr* no_memory_effects = NULL; |
225 Compile* C = _stringopts->C; | 224 Compile* C = _stringopts->C; |
226 CallStaticJavaNode* call = new (C, size) CallStaticJavaNode(call_type, call_addr, "uncommon_trap", | 225 CallStaticJavaNode* call = new (C) CallStaticJavaNode(call_type, call_addr, "uncommon_trap", |
227 jvms->bci(), no_memory_effects); | 226 jvms->bci(), no_memory_effects); |
228 for (int e = 0; e < TypeFunc::Parms; e++) { | 227 for (int e = 0; e < TypeFunc::Parms; e++) { |
229 call->init_req(e, uct->in(e)); | 228 call->init_req(e, uct->in(e)); |
230 } | 229 } |
231 // Set the trap request to record intrinsic failure if this trap | 230 // Set the trap request to record intrinsic failure if this trap |
232 // is taken too many times. Ideally we would handle then traps by | 231 // is taken too many times. Ideally we would handle then traps by |
967 type, T_OBJECT, | 966 type, T_OBJECT, |
968 C->get_alias_index(mirror_type->add_offset(field->offset_in_bytes()))); | 967 C->get_alias_index(mirror_type->add_offset(field->offset_in_bytes()))); |
969 } | 968 } |
970 | 969 |
971 Node* PhaseStringOpts::int_stringSize(GraphKit& kit, Node* arg) { | 970 Node* PhaseStringOpts::int_stringSize(GraphKit& kit, Node* arg) { |
972 RegionNode *final_merge = new (C, 3) RegionNode(3); | 971 RegionNode *final_merge = new (C) RegionNode(3); |
973 kit.gvn().set_type(final_merge, Type::CONTROL); | 972 kit.gvn().set_type(final_merge, Type::CONTROL); |
974 Node* final_size = new (C, 3) PhiNode(final_merge, TypeInt::INT); | 973 Node* final_size = new (C) PhiNode(final_merge, TypeInt::INT); |
975 kit.gvn().set_type(final_size, TypeInt::INT); | 974 kit.gvn().set_type(final_size, TypeInt::INT); |
976 | 975 |
977 IfNode* iff = kit.create_and_map_if(kit.control(), | 976 IfNode* iff = kit.create_and_map_if(kit.control(), |
978 __ Bool(__ CmpI(arg, __ intcon(0x80000000)), BoolTest::ne), | 977 __ Bool(__ CmpI(arg, __ intcon(0x80000000)), BoolTest::ne), |
979 PROB_FAIR, COUNT_UNKNOWN); | 978 PROB_FAIR, COUNT_UNKNOWN); |
986 final_merge->init_req(2, C->top()); | 985 final_merge->init_req(2, C->top()); |
987 final_size->init_req(2, C->top()); | 986 final_size->init_req(2, C->top()); |
988 } else { | 987 } else { |
989 | 988 |
990 // int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); | 989 // int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); |
991 RegionNode *r = new (C, 3) RegionNode(3); | 990 RegionNode *r = new (C) RegionNode(3); |
992 kit.gvn().set_type(r, Type::CONTROL); | 991 kit.gvn().set_type(r, Type::CONTROL); |
993 Node *phi = new (C, 3) PhiNode(r, TypeInt::INT); | 992 Node *phi = new (C) PhiNode(r, TypeInt::INT); |
994 kit.gvn().set_type(phi, TypeInt::INT); | 993 kit.gvn().set_type(phi, TypeInt::INT); |
995 Node *size = new (C, 3) PhiNode(r, TypeInt::INT); | 994 Node *size = new (C) PhiNode(r, TypeInt::INT); |
996 kit.gvn().set_type(size, TypeInt::INT); | 995 kit.gvn().set_type(size, TypeInt::INT); |
997 Node* chk = __ CmpI(arg, __ intcon(0)); | 996 Node* chk = __ CmpI(arg, __ intcon(0)); |
998 Node* p = __ Bool(chk, BoolTest::lt); | 997 Node* p = __ Bool(chk, BoolTest::lt); |
999 IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_FAIR, COUNT_UNKNOWN); | 998 IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_FAIR, COUNT_UNKNOWN); |
1000 Node* lessthan = __ IfTrue(iff); | 999 Node* lessthan = __ IfTrue(iff); |
1015 // return i+1; | 1014 // return i+1; |
1016 | 1015 |
1017 // Add loop predicate first. | 1016 // Add loop predicate first. |
1018 kit.add_predicate(); | 1017 kit.add_predicate(); |
1019 | 1018 |
1020 RegionNode *loop = new (C, 3) RegionNode(3); | 1019 RegionNode *loop = new (C) RegionNode(3); |
1021 loop->init_req(1, kit.control()); | 1020 loop->init_req(1, kit.control()); |
1022 kit.gvn().set_type(loop, Type::CONTROL); | 1021 kit.gvn().set_type(loop, Type::CONTROL); |
1023 | 1022 |
1024 Node *index = new (C, 3) PhiNode(loop, TypeInt::INT); | 1023 Node *index = new (C) PhiNode(loop, TypeInt::INT); |
1025 index->init_req(1, __ intcon(0)); | 1024 index->init_req(1, __ intcon(0)); |
1026 kit.gvn().set_type(index, TypeInt::INT); | 1025 kit.gvn().set_type(index, TypeInt::INT); |
1027 kit.set_control(loop); | 1026 kit.set_control(loop); |
1028 Node* sizeTable = fetch_static_field(kit, size_table_field); | 1027 Node* sizeTable = fetch_static_field(kit, size_table_field); |
1029 | 1028 |
1052 | 1051 |
1053 return final_size; | 1052 return final_size; |
1054 } | 1053 } |
1055 | 1054 |
1056 void PhaseStringOpts::int_getChars(GraphKit& kit, Node* arg, Node* char_array, Node* start, Node* end) { | 1055 void PhaseStringOpts::int_getChars(GraphKit& kit, Node* arg, Node* char_array, Node* start, Node* end) { |
1057 RegionNode *final_merge = new (C, 4) RegionNode(4); | 1056 RegionNode *final_merge = new (C) RegionNode(4); |
1058 kit.gvn().set_type(final_merge, Type::CONTROL); | 1057 kit.gvn().set_type(final_merge, Type::CONTROL); |
1059 Node *final_mem = PhiNode::make(final_merge, kit.memory(char_adr_idx), Type::MEMORY, TypeAryPtr::CHARS); | 1058 Node *final_mem = PhiNode::make(final_merge, kit.memory(char_adr_idx), Type::MEMORY, TypeAryPtr::CHARS); |
1060 kit.gvn().set_type(final_mem, Type::MEMORY); | 1059 kit.gvn().set_type(final_mem, Type::MEMORY); |
1061 | 1060 |
1062 // need to handle Integer.MIN_VALUE specially because negating doesn't make it positive | 1061 // need to handle Integer.MIN_VALUE specially because negating doesn't make it positive |
1102 { | 1101 { |
1103 IfNode* iff = kit.create_and_map_if(kit.control(), | 1102 IfNode* iff = kit.create_and_map_if(kit.control(), |
1104 __ Bool(__ CmpI(arg, __ intcon(0)), BoolTest::lt), | 1103 __ Bool(__ CmpI(arg, __ intcon(0)), BoolTest::lt), |
1105 PROB_FAIR, COUNT_UNKNOWN); | 1104 PROB_FAIR, COUNT_UNKNOWN); |
1106 | 1105 |
1107 RegionNode *merge = new (C, 3) RegionNode(3); | 1106 RegionNode *merge = new (C) RegionNode(3); |
1108 kit.gvn().set_type(merge, Type::CONTROL); | 1107 kit.gvn().set_type(merge, Type::CONTROL); |
1109 i = new (C, 3) PhiNode(merge, TypeInt::INT); | 1108 i = new (C) PhiNode(merge, TypeInt::INT); |
1110 kit.gvn().set_type(i, TypeInt::INT); | 1109 kit.gvn().set_type(i, TypeInt::INT); |
1111 sign = new (C, 3) PhiNode(merge, TypeInt::INT); | 1110 sign = new (C) PhiNode(merge, TypeInt::INT); |
1112 kit.gvn().set_type(sign, TypeInt::INT); | 1111 kit.gvn().set_type(sign, TypeInt::INT); |
1113 | 1112 |
1114 merge->init_req(1, __ IfTrue(iff)); | 1113 merge->init_req(1, __ IfTrue(iff)); |
1115 i->init_req(1, __ SubI(__ intcon(0), arg)); | 1114 i->init_req(1, __ SubI(__ intcon(0), arg)); |
1116 sign->init_req(1, __ intcon('-')); | 1115 sign->init_req(1, __ intcon('-')); |
1135 | 1134 |
1136 { | 1135 { |
1137 // Add loop predicate first. | 1136 // Add loop predicate first. |
1138 kit.add_predicate(); | 1137 kit.add_predicate(); |
1139 | 1138 |
1140 RegionNode *head = new (C, 3) RegionNode(3); | 1139 RegionNode *head = new (C) RegionNode(3); |
1141 head->init_req(1, kit.control()); | 1140 head->init_req(1, kit.control()); |
1142 kit.gvn().set_type(head, Type::CONTROL); | 1141 kit.gvn().set_type(head, Type::CONTROL); |
1143 Node *i_phi = new (C, 3) PhiNode(head, TypeInt::INT); | 1142 Node *i_phi = new (C) PhiNode(head, TypeInt::INT); |
1144 i_phi->init_req(1, i); | 1143 i_phi->init_req(1, i); |
1145 kit.gvn().set_type(i_phi, TypeInt::INT); | 1144 kit.gvn().set_type(i_phi, TypeInt::INT); |
1146 charPos = PhiNode::make(head, charPos); | 1145 charPos = PhiNode::make(head, charPos); |
1147 kit.gvn().set_type(charPos, TypeInt::INT); | 1146 kit.gvn().set_type(charPos, TypeInt::INT); |
1148 Node *mem = PhiNode::make(head, kit.memory(char_adr_idx), Type::MEMORY, TypeAryPtr::CHARS); | 1147 Node *mem = PhiNode::make(head, kit.memory(char_adr_idx), Type::MEMORY, TypeAryPtr::CHARS); |
1259 | 1258 |
1260 // pull the JVMState of the allocation into a SafePointNode to serve as | 1259 // pull the JVMState of the allocation into a SafePointNode to serve as |
1261 // as a shim for the insertion of the new code. | 1260 // as a shim for the insertion of the new code. |
1262 JVMState* jvms = sc->begin()->jvms()->clone_shallow(C); | 1261 JVMState* jvms = sc->begin()->jvms()->clone_shallow(C); |
1263 uint size = sc->begin()->req(); | 1262 uint size = sc->begin()->req(); |
1264 SafePointNode* map = new (C, size) SafePointNode(size, jvms); | 1263 SafePointNode* map = new (C) SafePointNode(size, jvms); |
1265 | 1264 |
1266 // copy the control and memory state from the final call into our | 1265 // copy the control and memory state from the final call into our |
1267 // new starting state. This allows any preceeding tests to feed | 1266 // new starting state. This allows any preceeding tests to feed |
1268 // into the new section of code. | 1267 // into the new section of code. |
1269 for (uint i1 = 0; i1 < TypeFunc::Parms; i1++) { | 1268 for (uint i1 = 0; i1 < TypeFunc::Parms; i1++) { |
1304 | 1303 |
1305 Node* null_string = __ makecon(TypeInstPtr::make(C->env()->the_null_string())); | 1304 Node* null_string = __ makecon(TypeInstPtr::make(C->env()->the_null_string())); |
1306 | 1305 |
1307 // Create a region for the overflow checks to merge into. | 1306 // Create a region for the overflow checks to merge into. |
1308 int args = MAX2(sc->num_arguments(), 1); | 1307 int args = MAX2(sc->num_arguments(), 1); |
1309 RegionNode* overflow = new (C, args) RegionNode(args); | 1308 RegionNode* overflow = new (C) RegionNode(args); |
1310 kit.gvn().set_type(overflow, Type::CONTROL); | 1309 kit.gvn().set_type(overflow, Type::CONTROL); |
1311 | 1310 |
1312 // Create a hook node to hold onto the individual sizes since they | 1311 // Create a hook node to hold onto the individual sizes since they |
1313 // are need for the copying phase. | 1312 // are need for the copying phase. |
1314 Node* string_sizes = new (C, args) Node(args); | 1313 Node* string_sizes = new (C) Node(args); |
1315 | 1314 |
1316 Node* length = __ intcon(0); | 1315 Node* length = __ intcon(0); |
1317 for (int argi = 0; argi < sc->num_arguments(); argi++) { | 1316 for (int argi = 0; argi < sc->num_arguments(); argi++) { |
1318 Node* arg = sc->argument(argi); | 1317 Node* arg = sc->argument(argi); |
1319 switch (sc->mode(argi)) { | 1318 switch (sc->mode(argi)) { |
1353 arg = null_string; | 1352 arg = null_string; |
1354 sc->set_argument(argi, arg); | 1353 sc->set_argument(argi, arg); |
1355 } else if (!type->higher_equal(TypeInstPtr::NOTNULL)) { | 1354 } else if (!type->higher_equal(TypeInstPtr::NOTNULL)) { |
1356 // s = s != null ? s : "null"; | 1355 // s = s != null ? s : "null"; |
1357 // length = length + (s.count - s.offset); | 1356 // length = length + (s.count - s.offset); |
1358 RegionNode *r = new (C, 3) RegionNode(3); | 1357 RegionNode *r = new (C) RegionNode(3); |
1359 kit.gvn().set_type(r, Type::CONTROL); | 1358 kit.gvn().set_type(r, Type::CONTROL); |
1360 Node *phi = new (C, 3) PhiNode(r, type); | 1359 Node *phi = new (C) PhiNode(r, type); |
1361 kit.gvn().set_type(phi, phi->bottom_type()); | 1360 kit.gvn().set_type(phi, phi->bottom_type()); |
1362 Node* p = __ Bool(__ CmpP(arg, kit.null()), BoolTest::ne); | 1361 Node* p = __ Bool(__ CmpP(arg, kit.null()), BoolTest::ne); |
1363 IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_MIN, COUNT_UNKNOWN); | 1362 IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_MIN, COUNT_UNKNOWN); |
1364 Node* notnull = __ IfTrue(iff); | 1363 Node* notnull = __ IfTrue(iff); |
1365 Node* isnull = __ IfFalse(iff); | 1364 Node* isnull = __ IfFalse(iff); |