dave0 has joined #forth
ovf has quit [Ping timeout: 264 seconds]
ovf has joined #forth
boru` has joined #forth
boru has quit [Disconnected by services]
boru` is now known as boru
dave0 has quit [Quit: dave's not here]
proteusguy has quit [Ping timeout: 264 seconds]
proteusguy has joined #forth
sts-q has quit [Ping timeout: 264 seconds]
sts-q has joined #forth
Zarutian_HTC has joined #forth
Zarutian_HTC has quit [Client Quit]
dave0 has joined #forth
gravicappa has joined #forth
<proteusguy> Anyone seen a forth implemented in C that managed to get around the C calling convention and implement something more akin to next with JMP?
<remexre> unless you count implementing a VM, I don't think you can in standard C
<proteusguy> You would have to create another calling convention or subvert C's.
<proteusguy> some inline asm perhaps.
<remexre> perhaps; you might need "naked functions" too?
<remexre> not sure how much of a win that is over just using assembly at that point though; I suppose you get somewhat more portability
<remexre> but I don't know if you can convince the register allocator to not spill e.g. the forth stack ptr
<proteusguy> Didn't know what naked functions were before now... interesting idea.
<remexre> yeah, though note gcc documents: While using extended asm or a mixture of basic asm and C code may appear to work, they cannot be depended upon to work reliably and are not supported.
<proteusguy> I'm using clang and it appears to only allow inline asm inside a naked function... unfortunately.
<remexre> oh, yeah, clang in particular is gonna fight you hard about this sorta stuff
<remexre> iirc it even tries to translate computed gotos to a normal if-elseif-elseif-else chain
<proteusguy> goodness. :-) too bad you can't just goto a function rather than strictly a local label.
<remexre> yeah, the "C is fast" perception is mainly based on the super-aggressive optimizations that directly combat the "C maps closely to your hardware, and will let you do anything your hardware can do"
<remexre> on the other hand, do you know if tail-call elimination would work for your purposes?
<proteusguy> remexre, it does for a lot of it and I am doing that. but I was trying to make it, in general, as close as possible to what I'd implement in ASM, especially for the inner interpreter.
<remexre> fair; I'd imagine you could just #define NEXT return (++ip)(stack_ptr, rstack_ptr, ip, ...); though
<proteusguy> that's been another thought. I've got to see what the assembly output of the compiler looks like and see how it goes.
<remexre> yeah; if you're not familiar with it, godbolt.org is really nice for that
<proteusguy> remexre, ah yes I have seen this. Haven't used it as I'm pretty comfortable with the -s output on my command line but does look quite handy for testing something that doesn't have many dependencies.
<proteusguy> er and it doesn't compile my code. insists that there's no such thing as std::endian even when I have the correct include for clang10. strange. compiles perfectly on my own platform.
<remexre> huh, you might need to pass -std=c++20 or something?
<proteusguy> Ah likely so.
<proteusguy> yep that did it.
dave0 has quit [Quit: dave's not here]
zolk3ri_ has joined #forth
zolk3ri_ has quit [Quit: leaving]
Guest68228 has quit [Ping timeout: 264 seconds]
Chobbes has quit [Ping timeout: 265 seconds]
<MrMobius> proteusguy, what about function pointers?
Guest68228 has joined #forth
Chobbes has joined #forth
<proteusguy> MrMobius, calling them still invokes the C calling convention. If you JMP to those addresses things have to be setup as the function expects or it'll all crash.
lispmacs[work] has quit [Read error: No route to host]
Gromboli8 has joined #forth
Gromboli has quit [Ping timeout: 264 seconds]
Gromboli8 is now known as Gromboli
gravicappa has quit [Ping timeout: 240 seconds]
inode has joined #forth