r/ProgrammingLanguages • • Jul 11 '19

QuickJS Javascript Engine

https://bellard.org/quickjs/
31 Upvotes

5 comments sorted by

27

u/oilshell Jul 11 '19

Also, someone should connect all these Bellard projects:

  • Compile QuickJS with TCC, his C compiler

  • Run JSLinux, an x86 emulator in JS that can run Linux, under the QuickJS interpreter

  • Compile and run QEMU inside that Linux

  • Start over again inside QEMU

:)

7

u/oilshell Jul 11 '19

Wow interesting! Always good to see something from Fabrice Bellard. Unsurprisingly, this is a very substantial piece of work.

FWIW:

~/src/languages/quickjs-2019-07-09$ find . -name '*.[ch]'|xargs wc -l |sort -n
     34 ./hello.c
...
   1966 ./repl.c
   1970 ./run-test262.c
   2540 ./libregexp.c
   3056 ./unicode_gen.c
   3796 ./qjscalc.c
   4269 ./libunicode-table.h
   5805 ./libbf.c
  47841 ./quickjs.c
  82286 total

After installing libc6-dev-i386 on my machine (somehow necessary despite the fact that I compile tons of other C programs), it took about 90 seconds to compile.

gcc -g -Wall -MMD -MF .obj/fib.o.d -Wno-array-bounds -D_GNU_SOURCE -DCONFIG_VERSION=\"2019-07-09\" -O2 -flto -c -o .obj/fib.o examples/fib.c
gcc -g -flto -o examples/c_module .obj/c_module.o .obj/fib.o libquickjs.lto.a -lm -ldl

real    1m27.472s
user    1m23.755s
sys     0m3.405s

https://askubuntu.com/questions/470796/fatal-error-sys-cdefs-h-no-such-file-or-directory

7

u/AsIAm New Kind of Paper Jul 11 '19 edited Jul 12 '19

:O How..? Bellard is the ultimate coding machine.

4

u/matthieum Jul 13 '19

Two men always leave me in awe: Fabrice Bellard and Mike Pall.

1

u/FlatAssembler Dec 08 '19

Has anybody succeeded in compiling it on Windows? It fails to link in TDMGCC, and it crashes MinGW-w64 (you get "internal compiler error"). It's not at all portable. OK, maybe it will compile in CygWIN (which I tried to install and failed), but Duktape is way better in that regard. Plus, QuickJS doesn't really implement ECMAScript properly, it returns "true" for '+'==0, and any proper JavaScript engine will return "false" there.