mraleph / irhydra

Tool for displaying IR used by V8 and Dart VM optimizing compilers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix \r\n line ending handling for the source

mraleph opened this issue · comments

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.

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.)

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

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

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.