freenode/#lisp - IRC Chatlog
Search
6:02:09
beach
HiRE: There are specific channels for Mezzano and other projects, in case you are interested.
6:43:03
LdBeth
Is there any source on how to use Lisp as a macro assembler/how to design a macro assembler?
6:55:03
beach
LdBeth: I have no information for you, but I am interested in knowing more about your project. I wrote an assembler in Common Lisp, but it is not a macro assembler, and it is quite different from others in that it does not have any surface syntax defined.
6:57:01
beach
For x86-64 (the current target), an interesting problem is that of selecting the appropriate machine instruction for a given desired effect. There are often several instructions that will have the same effect, so there is not a 1-1 mapping between source and machine code.
7:04:04
LdBeth
beach: DEK's MMIX has demonstrated some different instruction that shares the same op code. I have limited knowledge and little interests on AMD64, for that it is a very sophisticated arch.
7:08:22
LdBeth
for example, to run a PPC assembler, I might need to setup a complete MacOS in a emulator first
7:11:04
LdBeth
I wish to write and assemble some "bare metal" program using the native OS I'm currently using, then run them using qemu or something
10:16:40
beach
It would be great if you would acknowledge when you have seen an answer, and even better if you would tell the person giving it whether it was of any help to you.
10:17:32
harovali
beach: I agree. Sorry indeed. Thanks for asking back and yielding the oportunity of apologizing to me.
10:20:03
beach
Having a parameter named X and then funcalling a global function that also happens to be named X.
10:23:34
harovali
I had a reboot session back then , including upgrading to sbcl 2.0.0 , just after you answered, my chat session got closed and later I forgot to come back
10:26:07
pjb
beach: I beg to differ: you can write a garbage collector in conforming Common Lisp. Perhaps not one that garbage its own memory, but one good metalinguistic garbage collector, definitely!
10:28:25
beach
HiRE: Speaking of which, you can't write a low-level garbage collector in conforming C either.
10:29:30
pjb
HiRE: for an example of a GC written in CL, have a look at https://github.com/informatimago/lisp/blob/master/common-lisp/heap/heap.lisp#L1824
10:30:26
aeth
I think the SBCL team stance is that SBCL's GC is C so they can debug it iirc (I can't speak for them directly, I'm just remembering)
10:31:05
beach
I guess if you make all of memory look like a huge array of unsigned bytes, you can write a GC in Common Lisp.
10:31:30
pjb
LdBeth: there are examples… See: https://www.informatimago.com/articles/usenet.html#Compilation
10:32:02
aeth
You can write large parts of a program in non-consing CL, at least in SBCL. The profiling's good enough. So you should be able to write a GC in it. It'd be tricky, I guess. Especially debugging, since the non-consing style usually assumes that it's, well, working.
10:32:02
pjb
HiRE: or a simpler example of GC: https://groups.google.com/forum/#!msg/comp.lang.lisp/Ac-Vj8UJpZ8/s6-kmPmKQIIJ
10:32:56
pjb
LdBeth: since assembler is often used as a HIR for a compiler: https://groups.google.com/forum/#!msg/comp.lang.lisp/QMakibYYZRg/fgQulr5b4BwJ
10:33:03
aeth
What I mean is, yes, your GC program is non-consing (just preallocating what it needs, declaring dynamic-extent most of the rest, and using a special heap data structure that's a huge array), but is e.g. your condition system? Probably not. So once you get an error...
10:33:54
pjb
aeth: If you wanted to do that in a real implementation or system, you would have to define a non-consing subset…
10:34:22
aeth
pjb: You don't have to define a non-consing subset because you can profile SBCL enough just to make sure you accidentally don't introduce consing.
10:34:35
aeth
I mean, I guess you could have your compiler enforce it instead of just relying on the profilers.
10:35:34
pjb
aeth: Yes, like the button astronauts shouldn't press if they wanted to get back to Earth from the Moon… Right.
10:35:37
aeth
But, anyway, that subset does exist and I think it's probably large enough to write a GC in it, if you allow preallocating.
10:36:04
aeth
At least in SBCL. Other implementations might cons more, and seem to be harder to check.
10:38:04
aeth
Non-consing is not as hard as it seems because it's not really non-consing, it's cons-up-front, and then use dynamic-extent for the rare rest.
10:38:20
pjb
aeth: https://www.smithsonianmag.com/smithsonian-institution/margaret-hamilton-led-nasa-software-team-landed-astronauts-moon-180971575/
10:41:09
no-defun-allowed
"The astronauts had access to only 72 kilobytes of computer memory (a 64-gigabyte cell phone today carries almost a million times more storage space)." Conflating primary and secondary memory (where such a barrier does exist due to software limitations) is always a sign the author is proficient in writing about computers.
10:52:45
harovali
https://pastebin.com/iKxDh2Sc if you wanna see my code. For some reaseon beyond my understanding and my research abilities, the funcalls (especially the first one , in line 72 ) fail miserably with the error ' evaluation stopped on nil'
10:54:18
no-defun-allowed
You would probably also be better served by a class instead of a set of six closures that represent a state.
10:55:09
no-defun-allowed
Then I'm not sure how much I can suggest without a backtrace to see how you got there.
13:25:48
|3b|
are there any "best practices" for compiling a set of code a few times, with different package each time? if i just put the file in the .asd 3 times, it will get the same .fasl each time, which won't work
13:27:06
|3b|
ACTION 's ideas so far are: convince asdf to change the .fasl name for each instance. "include" the code file into 3 separate wrapper file that set the package etc. write some ugly defining macros to duplicate the definitions with package prefixes
13:30:22
|3b|
end-goal is to implement some code once and have versions specialized on single-float, double-float, or real. user code would then specify which it wants with package local nicknames
13:56:54
|3b|
or if it is unsigned-byte 8 array, maybe use nibbles to copy 4 or 8 bytes at a time, depending on length and alignment
14:03:36
|3b|
if you can use static-vectors to avoid copying at all, that might be better, though it requires manual memory management which makes it annoying for some things
14:04:10
|3b|
ACTION usually does element-by-element copies for lisp->foreign though, if static-vectors isn't applicable
14:05:33
asdf_asdf_asdf
Hi. I do C-M-s and typed regex. It marked words. How changing marked to "selection", that able copy more than one marked words?
14:06:18
varjag
this is is in my alsa code… worked fine on faster systems, but on an arm target beginning to get underruns with sample rates at 32k+
14:08:16
|3b|
might see if ccl has some way to get a pointer to the vector data, and call memcpy or similar on it
14:08:53
|3b|
(wrapping it in some portability thing that copies if it has to, if you care about other implementations)
14:10:25
|3b|
or just use cffi:with-pointer-to-vector-data, but then you might pay double copy cost on implementations that don't have a way to get a pointer
14:13:12
|3b|
looks like there is also a make-shareable-byte-vector you should use with it for complete portability, but the extra copy on some implementations usually means i don't want full portability when i use it anyway
14:13:49
varjag
we're moving to lispworks for prod but would really like to sort it out with ccl first
14:14:26
|3b|
looks like lispworks might want make-shareable-byte-vector for use with with-pointer-to-vector-data
14:16:48
_death
for sbcl I implemented (a POC) mmaped memory as lisp arrays, so you can use shared memory naturally
14:17:58
|3b|
looks like cffi uses http://www.lispworks.com/documentation/lw71/FLI/html/fli-122.htm on lw, which wants special allocation
14:21:23
|3b|
sbcl and ccl can apparently get pointers to any vector, so it just makes a normal array
14:26:36
beach
I am looking at the LispWorks manual, specifically the section about the debugger. It looks to me like the LispWorks debugger is no more sophisticated than the one in SBCL/SLIME. Am I right? In particular, I don't see a way to set a breakpoint before a program is started. Can anyone who has used LispWorks confirm this interpretation of mine?
14:27:27
Xach
beach: I don't know, but I do know that the lisp-hug mailing list is always very helpful.
14:45:43
p_l
beach: also macro tracing (this switches code to evaluator instead of compiled, afaik) and working Who Calls database
14:47:24
beach
I am mostly interested in breakpoints and how they work. Specifically if you can set a breakpoint in system code, like CONS or POSITION.
14:54:48
p_l
(can't test right now, as personal edition no longer works on mac, and I'm too lazy to take a trip for the other laptop)
14:55:06
p_l
beach: it's hooked into "dspec system" according to http://www.lispworks.com/documentation/lw70/IDE-W/html/ide-w-207.htm
14:55:56
p_l
http://www.lispworks.com/documentation/lw70/LW/html/lw-39.htm#41682 <-- this is dspec docs
15:09:22
pjb
|3b|: I would have different files that would each define the current package, and include the common file (eg. with com.informatimago.common-lisp.cesarum.utility:include-file).
15:17:11
pjb
beach: the way break points work depends on the level of the code you're trying to suspend. You can have breakpoints at the source level (eg. inserting (break) forms. You can have breakpoints at the microcode level, either by live-patching the instructions, replacing them by a jump or a software interrupt, a trap, or even an invalid instruction if you can handle it and resume, or by stepping all the execution setting a flag to do
15:18:07
pjb
You could also set break points by configuring the MMU to prevent access to the specfied instructions.
15:19:40
pjb
Working at the source level can be easier: you directly know where the break point occurs, while if you break (or step) low level instructions you have to map their addresses to source expressions (which may be difficult or impossible, depending on the compiler optimizations)
15:20:35
pjb
Indeed, since modifying the code has its difficulties. It may be complicated to do or even prevented by the system…
15:21:25
p_l
or simply you might not want to deal with the trouble of arranging possibly complex jump chain to get the original instruction continued
15:22:02
p_l
debug registers let you create a hw breakpoint that has separate configuration from what application might have used for itself
15:23:07
pjb
One easy way to do it, is to "instrument" the code. It's easy to do at the compilation level (eg. with high debug level). You just insert the instructions needed to step/break.
15:24:21
pjb
You don't need support from the system or the processor, it can work portably and conformingly, and it can give very good results source-wise. The only problem is that the instrumentation changes the generated code, so bugs may appear or disappear when you do that… (should not be a problem if the compiler is bug free!).
15:30:02
beach
pjb: I am specifically interested in the mechanism used by LispWorks. But I see now that breakpoints are part of the stepper, so that should give me some hints.
15:35:29
splittist
one day I will remember the correct order of arguments to get-hash. Today is not that day.
15:37:02
jackdaniel
splittist: you may arrange it as English sequence: "get eggs from the store" is more natural than "get from the store eggs"
15:45:34
p_l
beach: given the list of places that a breakpoint can be declared, I'd say there's good chance that they replace call sequence
16:07:33
p_l
why would it be possible only in the stepper, if they can hijack the call by simply changing the address?
16:23:28
p_l
beach: Rainer Joswig had also made an interesting set of twitter posts of various debug features in LW