Yes, it has been done, and all in LUA. I made a script for super metroid and another one for super mario world for this. There is, sadly, considerable work involved in proting these to new games.
The super metroid version can be found here:
http://tasvideos.org/forum/viewtopic.php?t=6539&postdays=0&postorder=asc&start=168 and a video showing it in action can be found here:
http://www.youtube.com/watch?v=0y0-73n5BE8
The super mario world script can be found here:
http://tasvideos.org/forum/viewtopic.php?t=6539&postdays=0&postorder=asc&start=175 and an example video is here:
http://www.youtube.com/watch?v=yEJhrU1EAhk
These scripts aren't supposed to be that hard to use, so I encourage you to give them a try.
Edit: I reread what you said, and I see that your suggestion is much closer to what I first thought I'd do to implement this. What you said can be done, and it wouldn't be too hard, but it requires rewriting the emulator, adding some inter process communication etc to keep them in sync. It would not be quite as good at comparing the runs visually (it is much easier to see where they are relative to each other when they are in the same window), but it would let one have a memory viewer open for each, giving much more information.
It sounds useful, so give it a try if you want. It would especially be nice if you added support for superimposing a (transparent?) version of the sprite layer form one on the other, with proper scrolling offsets taken into account.