Re: Lisp object code versus that of other languages



<j_mckitrick@xxxxxxxxxxx> wrote:
> I've recently gone from Lisp (back) to assembly language to do some
> 'fun' stuff I haven't done in a long time. I've been looking at a few
> samples of Lisp object code (disassemble in sbcl) and found some pretty
> cryptic code.

Since the SBCL code generator basically works by concatenating
assembly templates, and currently doesn't do much post-processing
(like instruction scheduling or peephole optimizing) on the result, I
usually find it more understandable than what an optimizing C compiler
produces. Your mileage may vary.

If some code seems cryptic, you might find the SBCL-specific
:TRACE-FILE keyword to COMPILE-FILE useful. For example (compile-file
"foo.lisp" :trace-file t) will produce a file "foo.trace" that
contains representations of the code in the two intermediate languages
that the compiler uses internally. There's also an annotated
disassembly that shows which intermediate language instructions are
producing the assembly instructions. Like this:

L23:

VOP ALLOCATE-FULL-CALL-FRAME {5} => t32[RBX]
MOV #<TN t32[RBX]>, #<TN t22[RSP]>
SUB #<TN t22[RSP]>, 40

VOP MOVE-ARG 'MOOSE!33[Const7]>t34[RDX] t32[RBX] => t35[RDX]
MOV #<TN t34[RDX]>, #<TN 'MOOSE!33[Const7]>

VOP MOVE-ARG t36[Const6]>t37[RDI] t32[RBX] => t38[RDI]
MOV #<TN t37[RDI]>, #<TN t36[Const6]>

--
Juho Snellman
"Premature profiling is the root of all evil."
.



Relevant Pages

  • Re: after SIMD implementation, is it still a RISC?
    ... to see a handfull of instructions before the faulting one. ... Reverse engineering disassemblers, like the popular OllyDbg, seems to simply start at the closest known entrypoint, or it can disassemble the last 100 bytes or so. ... patch around code sequences designed to make debugging hard, like using the stack pointer as a general pointer register, decrypting code with no valid stack present. ...
    (comp.arch)
  • Re: Code curosity
    ... The instructions the programmer writes are translated (for most ... > apps) into an unreadable but quite concise set of instructions the CPU ... Dedicated hackersdisassemble machine code in an effort to ... Others would do it to learn undocumented methods (like how does ...
    (comp.sys.mac.system)
  • Re: NDISASM: doesnt recognize all Mod/RM extension opcodes?
    ... If NASM supported all undocumented, all obsolete, or cpu specific ... instructions, it wouldn't be able to disassemble the ... You have SALC. ...
    (comp.lang.asm.x86)
  • Re: Table Driven Disassemblers are Slow?
    ... We will see yours the day you will do soemthing, ass-hole. ... Let's say it can disassembled 600,000 instructions in 1/10 ... disassemble each and every instruction more than 10 times? ... be outrageous and completely unnecessary (though a typical artifact of ...
    (alt.lang.asm)