You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to improve the encoding performed in TastyString. With the encoding found in the discussion.
@lrytz 5 days ago • Owner
It took me a while to find it.. Need to clean this up / document. Method parseScalaSigBytes calls ConstantPool.getBytes which goes through ByteCodecs.decode.
first map all 8-bit bytes to 7 bits (shifting the rest)
then increment all by 1 (in 7 bits), so 0x7f becomes 0x00
then encode 0x00 as 0xc0 0x80, which is an overlong utf 8 encoding for zero. it's what the jvm classfile spec uses to avoid having 0x00 in strings. it's called "modified utf 8".
the reason for the incrementing by 1 that 0x7f is expected to be less common than 0x00, so the two byte encoding hits less often.
The confusing part is that the class ScalaSigBytes used in the backend to encode the signature uses ByteCodecs.encode8to7, but does the +1 itself. It doesn't need to map 0x00 to the two byte version because ASM will do it when writing the annotation to the classfile. However, in the unpickler, we don't use ASM to read the annotation, but just get the bytes from the classfile directly. So there we'll see the two byte encoding. ByteCodecs.decode does the necessary work.
The text was updated successfully, but these errors were encountered:
Improves scala#3877
`'{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } }`
was reduced from 206 bytes to 172 bytes
`'{ ~x * ~powerCode(n - 1, x) }`
was reduced from 143 bytes to 128 bytes
Improves scala#3877
`'{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } }`
was reduced from 206 bytes to 172 bytes
`'{ ~x * ~powerCode(n - 1, x) }`
was reduced from 143 bytes to 128 bytes
We need to improve the encoding performed in TastyString. With the encoding found in the discussion.
The text was updated successfully, but these errors were encountered: