mraleph / irhydra

Tool for displaying IR used by V8 and Dart VM optimizing compilers
Apache License 2.0
433 stars 32 forks source link

Fix \r\n line ending handling for the source #41

Closed mraleph closed 8 years ago

mraleph commented 9 years ago

We force normalize line endings in files when loading, this however does not work for the source.

If original source use \r\n endings source positions will no longer match the original source.

This leads to random breakage inside the source_annotator which is very hard to diagnose.

mraleph commented 9 years ago

This was originally done because readAsText apparently normalizes all line endings to native.

The web UI cannot load .cfg and .asm correctly on Windows Chrome. The reason is that FileReader.readAsText returns the native end of line \r\n, which is different from Linux \n. Therefore cannot match the regular expression r"(begin|end)_(compilation|cfg)\n".

https://code.google.com/p/irhydra/issues/detail?id=23

Needs investigation on Windows. Maybe we should be loading as binary instead to prevent line endings normalization.

(maybe endings are already normalized by IO functions? this brings us to an unfortunately situation.)

mraleph commented 9 years ago

Indeed output in code.asm has line endings normalized because CodeTracer opens file in "a" mode instead of "ab" mode.

mraleph commented 9 years ago

Now displaying more meaningful errors (instead of raw obfuscated stack traces) 137ccaf1facc8a6f78157d9e62603b6832c2383b

mraleph commented 8 years ago

I just dropped support for older V8, switched to using readAsBinaryString and removed line endings normalization entirely.

V8's CodeTracer has been fixed back in February.