Live data from Hacker News

Bytecode VMs in surprising places (2024)

dubroy.com

21–30 of 74 posts

Re: Bytecode VMs in surprising places (2024)

#21
post #15

Some other examples: - ACPI configuration for power management and platform stuff [1] - Bitcoin transactions [2] - TrueType fonts [3] [1] https://wiki.osdev.org/AML [2] https://en.bitcoin.it/wiki/Script [3] https://learn.microsoft.com/en-us/typography/opentype/spec/t...

Since ACPI was mentioned, let's not forget about EFI!

https://uefi.org/specs/UEFI/2.10/22_EFI_Byte_Code_Virtual_Ma...

Re: Bytecode VMs in surprising places (2024)

#22
post #16

SBus peripherals use the Forth language in their PROMs to initialize themselves[1]. [1] https://docs.oracle.com/cd/E19957-01/802-3239-10/sbusandfc.h...

Good call! (Whether it's a directly threaded, indirectly threaded, subroutine threaded, token threaded, Huffman threaded, or string threaded call.) https://en.wikipedia.org/wiki/Threaded_code#Token_threading Mitch Bradley created OpenFirmware. It started at Sun as OpenBoot (informally "SunForth") on the SPARCstation 1 in 1989, was standardized as IEEE 1275-1994, and was renamed OpenFirmware at that time. Its lineage…

I ran EForth under the Subleq from Howe R.J at https://github.com/howerj/muxleq (the subleq one) first at QuickJS (trivial tasks, almost a 1:1 map from the C code, made in a hurry) and under... jsinterp.py from the infamous yt-dlp but using arrays instead of printing functions. But... if yt-dlp's "mini-JS" implements some captcha input functions... you can add I/O with ease and run EForth with what they call (not me) a "Not totally functional interpreter".

Not totally... until people there run the 110 rule program, Conway's Life, Subleq+EForth...

Re: Bytecode VMs in surprising places (2024)

#23
post #22

Earlier quoted context omitted.

Good call! (Whether it's a directly threaded, indirectly threaded, subroutine threaded, token threaded, Huffman threaded, or string threaded call.) https://en.wikipedia.org/wiki/Threaded_code#Token_threading Mitch Bradley created OpenFirmware. It started at Sun as OpenBoot (informally "SunForth") on the SPARCstation 1 in 1989, was standardized as IEEE 1275-1994, and was renamed OpenFirmware at that time. Its lineage…

I ran EForth under the Subleq from Howe R.J at https://github.com/howerj/muxleq (the subleq one) first at QuickJS (trivial tasks, almost a 1:1 map from the C code, made in a hurry) and under... jsinterp.py from the infamous yt-dlp but using arrays instead of printing functions. But... if yt-dlp's "mini-JS" implements some captcha input functions... you can add I/O with ease and run EForth with what they call (not me)…

You may need to write a WebGPU shader and run it in a Beowulf Cluster to make that run fast!

Re: Bytecode VMs in surprising places (2024)

#24
On one hand, all these mini interpreters and compilers are cool. I have a soft spot for extensible systems. On the other hand, all these things are a huge security problem. When every subsystem and data format is carrying around its own Turing complete bytecode and JIT, they all need to be secure and bug free for the system to be secure and bug free. And that far more code surface to keep clean.

Re: Bytecode VMs in surprising places (2024)

#27
Busicom 141 PF calculator (1971). This was a product built on the Intel 4004 processor. It was not programmed using Intel 4004 machine langauge directly, but using a more powerful machine language for which the 4004 ran an intepreter included in the image.

Re: Bytecode VMs in surprising places (2024)

#28
These little VMs in applications are everywhere. Apple Mach-O binaries have built in opcodes for binding and rebasing symbols interpreted by (numerous) little VMs in dyld:

https://github.com/apple-oss-distributions/dyld/blob/e9da5ae...

https://github.com/apple-oss-distributions/dyld/blob/e9da5ae...

Their use is less common now since the introduction of the mach-o load command LC_DYLD_CHAINED_FIXUPS, but these opcodes still have to be supported for older binaries. Also, some popular compilers including Zig still emit these opcodes for LC_DYLD_INFO and LC_DYLD_INFO_ONLY.

Re: Bytecode VMs in surprising places (2024)

#30
References for the Quake virtual machines:

Quake 1 had QuakeC: [1] https://en.wikipedia.org/wiki/QuakeC [2] Hello world in QuakeC - https://www.leonrische.me/pages/quakec_bytecode_hello_world....

Quake 2 moved to native binaries.

Quake 3 had a new VM that enabled compiling regular C using LCC: [1] https://fabiensanglard.net/quake3/qvm.php [2] Spec - https://www.icculus.org/~phaethon/q3mc/q3vm_specs.html

Post reply on HN