comparison src/share/vm/opto/stringopts.cpp @ 7421:ad5dd04754ee

8005031: Some cleanup in c2 to prepare for incremental inlining support Summary: collection of small changes to prepare for incremental inlining. Reviewed-by: twisti, kvn
author roland
date Tue, 18 Dec 2012 14:55:25 +0100
parents 2aff40cb4703
children d092d1b31229
comparison
equal deleted inserted replaced
7420:18d56ca3e901 7421:ad5dd04754ee
742 if (n->is_Call()) { 742 if (n->is_Call()) {
743 CallNode* cn = n->as_Call(); 743 CallNode* cn = n->as_Call();
744 ctrl_path.push(cn); 744 ctrl_path.push(cn);
745 ctrl_path.push(cn->proj_out(0)); 745 ctrl_path.push(cn->proj_out(0));
746 ctrl_path.push(cn->proj_out(0)->unique_out()); 746 ctrl_path.push(cn->proj_out(0)->unique_out());
747 ctrl_path.push(cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0)); 747 if (cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0) != NULL) {
748 ctrl_path.push(cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0));
749 }
748 } else { 750 } else {
749 ShouldNotReachHere(); 751 ShouldNotReachHere();
750 } 752 }
751 } 753 }
752 754
760 ptr = ptr->in(0)->in(0)->in(0); 762 ptr = ptr->in(0)->in(0)->in(0);
761 assert(ctrl_path.member(ptr), "should be a known piece of control"); 763 assert(ctrl_path.member(ptr), "should be a known piece of control");
762 } else if (ptr->is_IfTrue()) { 764 } else if (ptr->is_IfTrue()) {
763 IfNode* iff = ptr->in(0)->as_If(); 765 IfNode* iff = ptr->in(0)->as_If();
764 BoolNode* b = iff->in(1)->isa_Bool(); 766 BoolNode* b = iff->in(1)->isa_Bool();
767
768 if (b == NULL) {
769 fail = true;
770 break;
771 }
772
765 Node* cmp = b->in(1); 773 Node* cmp = b->in(1);
766 Node* v1 = cmp->in(1); 774 Node* v1 = cmp->in(1);
767 Node* v2 = cmp->in(2); 775 Node* v2 = cmp->in(2);
768 Node* otherproj = iff->proj_out(1 - ptr->as_Proj()->_con); 776 Node* otherproj = iff->proj_out(1 - ptr->as_Proj()->_con);
769 777
1406 C->record_for_igvn(overflow); 1414 C->record_for_igvn(overflow);
1407 kit.uncommon_trap(Deoptimization::Reason_intrinsic, 1415 kit.uncommon_trap(Deoptimization::Reason_intrinsic,
1408 Deoptimization::Action_make_not_entrant); 1416 Deoptimization::Action_make_not_entrant);
1409 } 1417 }
1410 1418
1411 // length now contains the number of characters needed for the 1419 Node* result;
1412 // char[] so create a new AllocateArray for the char[] 1420 if (!kit.stopped()) {
1413 Node* char_array = NULL; 1421
1414 { 1422 // length now contains the number of characters needed for the
1415 PreserveReexecuteState preexecs(&kit); 1423 // char[] so create a new AllocateArray for the char[]
1416 // The original jvms is for an allocation of either a String or 1424 Node* char_array = NULL;
1417 // StringBuffer so no stack adjustment is necessary for proper 1425 {
1418 // reexecution. If we deoptimize in the slow path the bytecode 1426 PreserveReexecuteState preexecs(&kit);
1419 // will be reexecuted and the char[] allocation will be thrown away. 1427 // The original jvms is for an allocation of either a String or
1420 kit.jvms()->set_should_reexecute(true); 1428 // StringBuffer so no stack adjustment is necessary for proper
1421 char_array = kit.new_array(__ makecon(TypeKlassPtr::make(ciTypeArrayKlass::make(T_CHAR))), 1429 // reexecution. If we deoptimize in the slow path the bytecode
1422 length, 1); 1430 // will be reexecuted and the char[] allocation will be thrown away.
1423 } 1431 kit.jvms()->set_should_reexecute(true);
1424 1432 char_array = kit.new_array(__ makecon(TypeKlassPtr::make(ciTypeArrayKlass::make(T_CHAR))),
1425 // Mark the allocation so that zeroing is skipped since the code 1433 length, 1);
1426 // below will overwrite the entire array 1434 }
1427 AllocateArrayNode* char_alloc = AllocateArrayNode::Ideal_array_allocation(char_array, _gvn); 1435
1428 char_alloc->maybe_set_complete(_gvn); 1436 // Mark the allocation so that zeroing is skipped since the code
1429 1437 // below will overwrite the entire array
1430 // Now copy the string representations into the final char[] 1438 AllocateArrayNode* char_alloc = AllocateArrayNode::Ideal_array_allocation(char_array, _gvn);
1431 Node* start = __ intcon(0); 1439 char_alloc->maybe_set_complete(_gvn);
1432 for (int argi = 0; argi < sc->num_arguments(); argi++) { 1440
1433 Node* arg = sc->argument(argi); 1441 // Now copy the string representations into the final char[]
1434 switch (sc->mode(argi)) { 1442 Node* start = __ intcon(0);
1435 case StringConcat::IntMode: { 1443 for (int argi = 0; argi < sc->num_arguments(); argi++) {
1436 Node* end = __ AddI(start, string_sizes->in(argi)); 1444 Node* arg = sc->argument(argi);
1437 // getChars words backwards so pass the ending point as well as the start 1445 switch (sc->mode(argi)) {
1438 int_getChars(kit, arg, char_array, start, end); 1446 case StringConcat::IntMode: {
1439 start = end; 1447 Node* end = __ AddI(start, string_sizes->in(argi));
1440 break; 1448 // getChars words backwards so pass the ending point as well as the start
1441 } 1449 int_getChars(kit, arg, char_array, start, end);
1442 case StringConcat::StringNullCheckMode: 1450 start = end;
1443 case StringConcat::StringMode: { 1451 break;
1444 start = copy_string(kit, arg, char_array, start); 1452 }
1445 break; 1453 case StringConcat::StringNullCheckMode:
1446 } 1454 case StringConcat::StringMode: {
1447 case StringConcat::CharMode: { 1455 start = copy_string(kit, arg, char_array, start);
1448 __ store_to_memory(kit.control(), kit.array_element_address(char_array, start, T_CHAR), 1456 break;
1449 arg, T_CHAR, char_adr_idx); 1457 }
1450 start = __ AddI(start, __ intcon(1)); 1458 case StringConcat::CharMode: {
1451 break; 1459 __ store_to_memory(kit.control(), kit.array_element_address(char_array, start, T_CHAR),
1452 } 1460 arg, T_CHAR, char_adr_idx);
1453 default: 1461 start = __ AddI(start, __ intcon(1));
1454 ShouldNotReachHere(); 1462 break;
1455 } 1463 }
1456 } 1464 default:
1457 1465 ShouldNotReachHere();
1458 // If we're not reusing an existing String allocation then allocate one here. 1466 }
1459 Node* result = sc->string_alloc(); 1467 }
1460 if (result == NULL) { 1468
1461 PreserveReexecuteState preexecs(&kit); 1469 // If we're not reusing an existing String allocation then allocate one here.
1462 // The original jvms is for an allocation of either a String or 1470 result = sc->string_alloc();
1463 // StringBuffer so no stack adjustment is necessary for proper 1471 if (result == NULL) {
1464 // reexecution. 1472 PreserveReexecuteState preexecs(&kit);
1465 kit.jvms()->set_should_reexecute(true); 1473 // The original jvms is for an allocation of either a String or
1466 result = kit.new_instance(__ makecon(TypeKlassPtr::make(C->env()->String_klass()))); 1474 // StringBuffer so no stack adjustment is necessary for proper
1467 } 1475 // reexecution.
1468 1476 kit.jvms()->set_should_reexecute(true);
1469 // Intialize the string 1477 result = kit.new_instance(__ makecon(TypeKlassPtr::make(C->env()->String_klass())));
1470 if (java_lang_String::has_offset_field()) { 1478 }
1471 kit.store_String_offset(kit.control(), result, __ intcon(0)); 1479
1472 kit.store_String_length(kit.control(), result, length); 1480 // Intialize the string
1473 } 1481 if (java_lang_String::has_offset_field()) {
1474 kit.store_String_value(kit.control(), result, char_array); 1482 kit.store_String_offset(kit.control(), result, __ intcon(0));
1475 1483 kit.store_String_length(kit.control(), result, length);
1484 }
1485 kit.store_String_value(kit.control(), result, char_array);
1486 } else {
1487 result = C->top();
1488 }
1476 // hook up the outgoing control and result 1489 // hook up the outgoing control and result
1477 kit.replace_call(sc->end(), result); 1490 kit.replace_call(sc->end(), result);
1478 1491
1479 // Unhook any hook nodes 1492 // Unhook any hook nodes
1480 string_sizes->disconnect_inputs(NULL, C); 1493 string_sizes->disconnect_inputs(NULL, C);