RFR: 8260198: TypeInstPtr::dump2() emits multiple lines if Verbose is set [v4]
Evgeny Astigeevich
github.com+42899633+eastig at openjdk.java.net
Wed Feb 17 19:20:42 UTC 2021
On Wed, 17 Feb 2021 12:04:56 GMT, Evgeny Astigeevich <github.com+42899633+eastig at openjdk.org> wrote:
>> Xin Liu has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains five commits:
>>
>> - 8260198: TypeInstPtr::dump2() emits multiple lines if Verbose is set
>>
>> reimplement this feature. withdraw my intrusive change in outputStream.
>> use stringStream only for the constant OopPtr. after oop->print_on(st),
>> delete all appearances of '\n'
>> - Merge branch 'master' into JDK-8260198
>> - 8260198: TypeInstPtr::dump2() emits multiple lines if Verbose is set
>>
>> fix merge conflict.
>> - Merge branch 'master' into JDK-8260198
>> - 8260198: TypeInstPtr::dump2() emits multiple lines if Verbose is set
>>
>> 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 *
>
> src/hotspot/share/opto/type.cpp line 4049:
>
>> 4047: ss.print(" ");
>> 4048: const_oop()->print_oop(&ss);
>> 4049: ss.tr_delete('\n');
>
> `tr_delete` is expensive. Also deleting something in a stream does not fit into a concept of streams.
> I see that the content of `ss` is traversed many times.
> What about this code:
> for (const char *str = ss.base(); *str; ) {
> size_t i = 0;
> while (str[i] && str[i] != '\n' ) {
> ++i;
> }
> st->print_raw(str, i);
> str += i;
> while (*str == '\n') {
> ++str;
> }
> }
Another option:
class filterStringStream: public stringStream {
private:
char ch;
public:
filterStringStream(char ch_to_filter, size_t initial_bufsize = 256) : stringStream(initial_bufsize), ch(ch_to_filter) {}
virtual void write(const char* c, size_t len) override {
const char* e = c + len;
while (c != e) {
size_t i = 0;
while ((c+i) != e && c[i] != ch ) {
++i;
}
stringStream::write(c, i);
c += i;
while (c != e && *ch == ch) {
++c;
}
}
}
};
Your code will be:
filterStringStream ss('\n');
ss.print(" ");
const_oop->print_oop(&ss);
st->print_raw(ss.base(), ss,size());
-------------
PR: https://git.openjdk.java.net/jdk/pull/2178
More information about the hotspot-compiler-dev
mailing list