freenode/#sicl - IRC Chatlog
Search
13:17:55
beach
I am intrigued by the possibility of executing SICL code in the host by translating the AST to host Common Lisp code. It would not have the problem that the HIR-to-CL translation did in that the size of the resulting Common Lisp code would be closer to that of the original source.
13:18:04
beach
So, in itself, this thing is not hard to do, but I also want the AST to be used for translation to HIR. I think this restriction means that I must do closure conversion at the ATS level, so that each nested function is independent.
13:18:06
beach
If so, I would need to do closure conversion, of course, but also inlining, since inlining is done before closure conversion. In fact, inlining could be simpler at the AST level than at the HIR level. Now, the main question: Are there any optimizations that can't be accomplished if I do it this way?
13:24:19
beach
Yes, I want HIR to be constructed from the same AST that I translate to host Common Lisp code.
13:24:55
beach
But with this system, HIR code would be part of code generation, and not of the code executed by the host.
13:26:07
beach
and it may be harder to accomplish optimizations at the HIR level if these transformations are done on the AST level first.
13:27:15
beach
So if we do any optimizations, or plan to do any, at the HIR level that require this nesting to be intact, they may be harder or impossible to accomplish.
13:28:34
beach
Closure conversion in the literature means to turn a closure into a top-level function with a static environment.
13:30:13
beach
I would have to do that conversion at the AST level, because such a closure will often become a global function in the SICL system.
13:37:19
beach
Currently, I turn the AST to HIR, then I "preprocess" a certain number of instructions that are going to be turned into function calls, like catch, bind, initialize-values, symbol-value, etc. and I hoist fdefinitions and constant inputs to the top level.
13:42:48
beach
What I was worried about when I contemplated this possibility in the past was that there would be duplicate code for doing similar transformations both at the AST level and at the HIR level.
13:43:14
beach
But if I can move transformations from HIR to AST, then there would be no duplication.
13:55:21
Harag
just out of curiosity when you say "translating the AST to host Common Lisp codne" is that what you did in translate-ast in Sandbox?
13:57:02
beach
So heisig is working on a way to turn each HIR instruction into a small Common Lisp function so as to avoid some overhead in the HIR interpreter.
13:58:05
beach
At this point, only SICL bootstrapping requires the execution of target code in the host.
13:59:02
beach
Every other cross-compiling Common Lisp implementation that I am aware of, just executes the file compiler in the host.
14:03:48
Harag
on an aside how far is cleavir from living on its own? Or must that wait for the first class environment thingy
14:05:41
Bike
it is in the same repo but yeah clasp doesn't use any of the rest of sicl, and that works fine
14:06:32
Bike
i haven't checked the logs for this channel. karlosz has some stuff to merge, i can do that
14:10:14
Bike
though some of it is eliminating redundant checks that aren't only generated for thread safety reasons
14:11:50
Bike
i mean, it won't be eliminating any if doing so would reduce thread safety. just on variables that don't turn out ot be closed over, and stuff
14:24:51
beach
Anyway, I am not going to pursue the AST-to-CL idea any further right now. The HIR interpreter is fast enough for what I am doing, and I estimate heisig's work is going to speed up host execution by at least a factor 2. Besides, I am busy with the condition system.
14:49:10
beach
Bike: Before I start trying to understand your technique for type inference, can you remind me what it was with my initial idea (TYPEQ, etc.) that didn't work out?
14:58:15
Bike
it ties the abstract indication that a value is of a type to the concrete operation of performing a type test - an operation that can get pretty complicated even with simple types, e.g. if integer is a union of two classes
14:58:15
Bike
adding typew decouples this, so that typew can indicate the type, and typeq can continue being the low level operation, if that's needed
14:58:15
froggey
beach: I've spent today and yesterday getting familiar with Cleavir and I'll be getting started with your task now
14:58:15
froggey
it should just a case of bringing the code in Cleavir 1 forward to Cleavir 2, not too much trouble
14:58:16
froggey
"<beach> I also need to separate the ENCLOSE-INSTRUCTION into two parts, as Bike did for Cleavir 1."
15:00:24
beach
Bike: OK, I don't understand that (yet), but I'll keep in mind what you said when I try to understand TYPEW.
15:02:26
beach
So, yes, froggey is going to help out with some SICL/Cleavir stuff, at least for a while. We hope there will be some dual benefit for Mezzano as well.
16:30:40
beach
I think I'll call it a day. I'll hang out here until my (admittedly small) family announces that dinner is served, which should be in less than 30 minutes. I made good progress on the condition system today. I expect to have something acceptable in a day or two.
16:37:30
Harag
but then instead of looking for say defmacro the conversion end up wanting some internal sbcl %defmacro
16:41:09
beach
I just imported all the macros as they are. That's just for the demo. Some of them must be adapted.
16:43:40
beach
In the environment, there is nothing sbcl specific. So if any of the macros expand to something SBCL specific, that something has to be imported too, or the macro must be redefined.
16:44:12
beach
In this case, you want to redefine the macro defmacro so that it calls (setf (sicl-genv:macro-function ...))
16:46:09
beach
So the compiler expands the defmacro macro call, and then tries to compile the expansion.
16:47:24
beach
So you can either modify the defmacro macro, or import the missing functions and macros. I recommend the first solution.
16:49:38
beach
My (admittedly small) family just announced that dinner is served. So I'll be back tomorrow morning as usual.