Re: ClassReader.readUtf and compact strings

"Remi Forax" (via asm Mailing List) <[email protected]> Sat, 6 Feb 2021 12:39:45 +0100 (CET)
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
This is a multi-part message in MIME format...

------------=_1612612030-15976-9
Content-Type: multipart/alternative; 
	boundary="=_1cb2ad99-8afc-436e-a7a4-3d84a0e4f3e4"

--=_1cb2ad99-8afc-436e-a7a4-3d84a0e4f3e4
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Eirik,=20
the UTF String format used by the constant pool and UTF8 are not exactly th=
e same because the class file format predate the publication of UTF8 [1].=20

Furthermore, String class since Java 9 can use either a char[] or a byte[] =
depending if the COMPACT STRING representation is used or not, you can acti=
vate/deactivate that flag when starting the VM,=20
so we may to able to to provide a fast path for JDK 11+ but this will requi=
re extensive tests to be sure that it doesn't introduce regression with the=
 JDK 8-=20

I don't think we, the ASM team, have the cycles to do that now, but feel fr=
ee to contribute :)=20

regards,=20
R=C3=A9mi=20

[1] https://stackoverflow.com/questions/7921016/what-does-it-mean-to-say-ja=
va-modified-utf-8-encoding=20

> De: "asm" <[email protected]>
> =C3=80: "asm" <[email protected]>
> Envoy=C3=A9: Samedi 6 F=C3=A9vrier 2021 10:31:03
> Objet: [asm] ClassReader.readUtf and compact strings

> Hi,
> ClassReader.readUtf currently parses UTF-8 bytes into a char[] which it t=
hen
> uses to construct a String.

> The String(char[]) constructor then calls StringUTF16.compress(char[]..) =
which
> nicely packs the char[] back into a byte[].

> I imagine there could be a performance win of not doing this byte[] -> ch=
ar[] ->
> byte[] dance, given that most class strings are ASCII anyway.

> WDYT?

> Eirik.

> --
> You receive this message as a subscriber of the [email protected] mailing list.
> To unsubscribe: mailto:[email protected]
> For general help: mailto:[email protected]?subject=3Dhelp
> OW2 mailing lists service home page: http://www.ow2.org/wws

--=_1cb2ad99-8afc-436e-a7a4-3d84a0e4f3e4
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><body><div style=3D"font-family: arial, helvetica, sans-serif; font-s=
ize: 12pt; color: #000000"><div>Hi Eirik,<br></div><div>the UTF String form=
at used by the constant pool and UTF8 are not exactly the same because the =
class file format predate the publication of UTF8 [1].<br data-mce-bogus=3D=
"1"></div><div><br data-mce-bogus=3D"1"></div><div>Furthermore, String clas=
s since Java 9 can use either a char[] or a byte[] depending if the COMPACT=
 STRING representation is used or not, you can activate/deactivate that fla=
g when starting the VM,<br data-mce-bogus=3D"1"></div><div>so we may to abl=
e to to provide a fast path for JDK 11+ but this will require extensive tes=
ts to be sure that it doesn't introduce regression with the JDK 8-<br></div=
><div><br></div><div>I don't think we, the ASM team, have the cycles to do =
that now, but feel free to contribute :)<br data-mce-bogus=3D"1"></div><div=
><br data-mce-bogus=3D"1"></div><div>regards,<br data-mce-bogus=3D"1"></div=
><div>R=C3=A9mi<br data-mce-bogus=3D"1"></div><div><br data-mce-bogus=3D"1"=
></div><div>[1] https://stackoverflow.com/questions/7921016/what-does-it-me=
an-to-say-java-modified-utf-8-encoding<br data-mce-bogus=3D"1"></div><div><=
br data-mce-bogus=3D"1"></div><hr id=3D"zwchr" data-marker=3D"__DIVIDER__">=
<div data-marker=3D"__HEADERS__"><blockquote style=3D"border-left:2px solid=
 #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;fon=
t-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;=
font-size:12pt;"><b>De: </b>"asm" &lt;[email protected]&gt;<br><b>=C3=80: </b>"as=
m" &lt;[email protected]&gt;<br><b>Envoy=C3=A9: </b>Samedi 6 F=C3=A9vrier 2021 10=
:31:03<br><b>Objet: </b>[asm] ClassReader.readUtf and compact strings<br></=
blockquote></div><div data-marker=3D"__QUOTED_TEXT__"><blockquote style=3D"=
border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;f=
ont-weight:normal;font-style:normal;text-decoration:none;font-family:Helvet=
ica,Arial,sans-serif;font-size:12pt;"><div dir=3D"ltr">Hi,<br><div>ClassRea=
der.readUtf currently parses UTF-8 bytes into a char[] which it then uses t=
o construct a String.</div><br><div>The String(char[]) constructor then cal=
ls&nbsp;StringUTF16.compress(char[]..) which nicely packs the char[] back i=
nto a byte[].</div><br><div>I imagine there could be a performance win of n=
ot doing this byte[] -&gt; char[] -&gt; byte[] dance, given that most class=
 strings&nbsp;are ASCII anyway.</div><br><div>WDYT?</div><br><div>Eirik.</d=
iv></div>
<br><br>-- <br>You receive this message as a subscriber of the [email protected] =
mailing list.<br>To unsubscribe: mailto:[email protected]<br>For gene=
ral help: mailto:[email protected]?subject=3Dhelp<br>OW2 mailing lists service =
home page: http://www.ow2.org/wws<br></blockquote></div></div></body></html=
>=

--=_1cb2ad99-8afc-436e-a7a4-3d84a0e4f3e4--

------------=_1612612030-15976-9
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

------------=_1612612030-15976-9--