freenode/#sicl - IRC Chatlog
Search
16:55:14
beach
So, yesterday (or the day before, I forget) I decided to visualize the result of HIR-to-MIR for the first time, using the IR visualizer, of course. It turns out that it was very wrong. Mainly due to some :AROUND methods on SHARED-INITIALIZE that I should have seen would not work the way I planned.
16:55:54
beach
So I spent some time fixing things up, and improving the visualizer so that I can see more stuff, including raw integers.
16:57:49
beach
There are a few quirks left, but I think I am close to done with HIR-to-MIR. I need to convince the visualizer to show me nested functions which are no longer represented by ENCLOSE-INSTRUCTIONs in MIR, so that I can view the guts of the code, as opposed to just the code that gets executed at load (or "tie") time.
16:59:40
beach
Once I am done with HIR-to-MIR, I'll work some more on MIR-to-LIR. Recall that MIR is where address calculations become explicit, and LIR is where registers are introduced.
17:00:53
beach
So in MIR, AREF and STANDARD-INSTANCE-ACESS and such have been replaced by memory references. And tags are eliminated before memory is addressed.
17:27:45
beach
The pink inputs are fixnums, and should be replaced by yellow ones which are immediate machine integers.
17:29:02
beach
The last yellow 0 represents an entry point, and the FUNCALL calls ENCLOSE to create a closure. that it then returns.
17:29:44
beach
The yellow 0 is an immediate integer, but it's a subclass that contains the ENTER-INSTRUCTION for the entry point.
17:30:29
beach
I need to teach the visualizer to show me the contents of an entry point of such an immediate integer.
17:31:25
beach
Everything that precedes is basically filling up the static environment of the closure it creates with constants and global functions.
17:45:32
beach
I'm off to have dinner with my (admittedly small) family, and then spend some time with her.
18:03:18
alandipert
very cool, thanks for sharing. it motivates me to keep visualization in mind as i proceed with my increasingly complicated thing
18:03:39
alandipert
when you have a chance i'd be curious to see the code that corresponds to the picture, if you have it handy
19:25:41
beach
But what you see is constants used in the error messages of the argument-parsing code.
19:27:09
beach
Or rather, you see those constants being fetched from the static environment of the top-level function, and you see cells being allocated to store those constants, and you see those cells being stored in the static environment of the closure that is eventually created.
22:01:56
Bike
ran into something possibly interesting. When the compiler finds sequence function calls it doesn't know the types of the sequence arguments of, we have to do some kind of type testing at runtime. Sometimes it might make sense to have a different version for every type of sequence (lists, vectors of various element type and simplicity) but
22:01:57
Bike
sometimes that might get explosive, like when MAP has an indefinite or unknown number of arguments
22:02:29
Bike
in that case clasp uses a sequence iterator protocol that's roughly like the extensible protocol. i'm currently fixing clasp's to be the extensible protocol
22:03:28
Bike
the core of that protocol is make-sequence-iterator, which is a generic function that returns a bunch of values. the values represent the state of the iteration and also, what i didn't fully appreciate before, functions for doing the traversal
22:04:16
Bike
this means that in the body of the loop, you just call those functions, instead of including a type discrimination. avoiding the branch is like a 2x speedup in some quick tests, and that's clasp's dumb version
22:05:30
Bike
plus, in clasp's and sbcl's iterators, vectors are all treated the same, so you call a dispatching aref of some kind during the loop. but if you just specialized make-sequence-iterator for different vector types, the returned functions could be low level array accessors, without losing safety
22:10:41
Bike
...and then i guess we could teach the compiler a little about make-sequence-iterator, so that it's rewritten to include the functions in a way the compiler can see, if the type of the sequence is known. and then it just inlines those.