mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 12:34:32 +02:00
8076758: new StringBuilder().append(String).toString() should be recognized by OptimizeStringConcat
Reviewed-by: kvn, thartmann
This commit is contained in:
parent
7b6480cfa4
commit
e3007b79ad
1 changed files with 48 additions and 41 deletions
|
@ -1576,10 +1576,16 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) {
|
||||||
|
|
||||||
Node* result;
|
Node* result;
|
||||||
if (!kit.stopped()) {
|
if (!kit.stopped()) {
|
||||||
|
Node* char_array = NULL;
|
||||||
|
if (sc->num_arguments() == 1 &&
|
||||||
|
(sc->mode(0) == StringConcat::StringMode ||
|
||||||
|
sc->mode(0) == StringConcat::StringNullCheckMode)) {
|
||||||
|
// Handle the case when there is only a single String argument.
|
||||||
|
// In this case, we can just pull the value from the String itself.
|
||||||
|
char_array = kit.load_String_value(kit.control(), sc->argument(0));
|
||||||
|
} else {
|
||||||
// length now contains the number of characters needed for the
|
// length now contains the number of characters needed for the
|
||||||
// char[] so create a new AllocateArray for the char[]
|
// char[] so create a new AllocateArray for the char[]
|
||||||
Node* char_array = NULL;
|
|
||||||
{
|
{
|
||||||
PreserveReexecuteState preexecs(&kit);
|
PreserveReexecuteState preexecs(&kit);
|
||||||
// The original jvms is for an allocation of either a String or
|
// The original jvms is for an allocation of either a String or
|
||||||
|
@ -1623,6 +1629,7 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) {
|
||||||
ShouldNotReachHere();
|
ShouldNotReachHere();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we're not reusing an existing String allocation then allocate one here.
|
// If we're not reusing an existing String allocation then allocate one here.
|
||||||
result = sc->string_alloc();
|
result = sc->string_alloc();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue