RFR: 8260198: TypeInstPtr::dump2() emits multiple lines if Verbose is set [v6]

Evgeny Astigeevich github.com+42899633+eastig at openjdk.java.net
Tue Feb 23 16:01:40 UTC 2021


On Sun, 21 Feb 2021 02:07:59 GMT, Xin Liu <xliu at openjdk.org> wrote:

>> Add a flag _suppress_cr to outputStream. outstream objects won't emit any CR if it's set.
>> Correct TypeInstPtr::dump2 to make sure it only emits klass name once.
>> Remove the comment because Klass::oop_print_on() has emitted the address of oop.
>> 
>> Before:
>> 689  ConP  ===  0  [[ 821 ]]   Oop:java/lang/Stringjava.lang.String
>> {0x000000010159d7c8} - klass: public final synchronized 'java/lang/String'
>> - string: "a"
>> :Constant:exact *
>> 
>> After:
>> 689  ConP  ===  0  [[ 821 ]]   Oop:java.lang.String {0x000000010159d7c8} - klass: public final synchronized 'java/lang/String' - string: "a":Constant:exact *
>
> Xin Liu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8260198: TypeInstPtr::dump2() emits multiple lines if Verbose is set
>   
>   fix build failures on Windows. StringUtils::tr_delete returns size_of.

Changes requested by eastig at github.com (no known OpenJDK username).

src/hotspot/share/opto/type.cpp line 4056:

> 4054:         StringUtils::tr_delete(buf, "\n");
> 4055:         st->print_raw(buf);
> 4056:         os::free(buf);

There is no need to use `os::strdup` because `as_string` creates a copy.
I've looked in stringUtils.cpp and found `replace_no_expand`.  The code can be rewritten:
char *buf = ss.as_string();
StringUtils::replace_no_expand(buf, "\n", "");
st->print_raw(buf);
With this code, `tr_delete` is redundant.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2178


More information about the hotspot-compiler-dev mailing list