newLisp compile to webassembly (newlisp-js)

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE

newLisp compile to webassembly (newlisp-js)

Postby iNPRwANG » Mon Feb 12, 2018 3:11 am

Use this makefile can compile newLisp to newlisp-js in emscripten v1.37 by enable webassembly support.
Notice of the "-s WASM=1" option let the emscripten generate webassembly, and should use the " -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' " for function exporting (the "ccall" and "cwrap" not export by default in emscripten version above 1.3)

The approximate performance about webassembly enabled newlisp-js is 5% faster than asm.js version (tested in Firefox 58.0.1), and the total file size is less than the asm.js version about 20%.

Code: Select all
# makefile for newLISP v. 10.5.x and after with UTF8 support for the Emscripten SDK
#
# With Emscripten version v1.22.0 all execption handling related problems
# known have been solved. (November 2014)
#
# see also: https://github.com/kripken/emscripten/wiki
#
# Uses custom random() and srandom() in nl-filesys.c
#
# Does not implement the newLISP functions:
# semaphore, net-packet, net-service, fork, spawn, sync, abort
#
# Will not do file and network I/O functions in the sandboxed JavaScript
# environment
#
# Generates newlisp-js-lib.js and newlisp-js-lib.html.
# The html file can be discarded use newlisp-js/newlisp-js.html instead
#
# this makefile has been tested on a MAC OSX 10.9/10 platforms

OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
 nl-sock.o nl-web.o nl-xml-json.o nl-matrix.o nl-debug.o pcre.o nl-utf8.o unix-lib.o

CFLAGS = -m32 -Wall -c -DMAC_OSX -DLIBRARY -DEMSCRIPTEN -DSUPPORT_UTF8

CC = emcc

default: $(OBJS)
 cp qa-specific-tests/qa-bench newlisp-js
 cp modules/canvas.lsp newlisp-js
 $(CC) $(OBJS) -m32 -O2 -s WASM=1 -o newlisp-js-lib.html -s EXPORTED_FUNCTIONS="['_newlispEvalStr']" \
 -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' \
 -s TOTAL_MEMORY=33554432 --closure 1 \
 --embed-file newlisp-js/readme.txt --embed-file newlisp-js/qa-bench --embed-file newlisp-js/canvas.lsp
 rm newlisp-js/qa-bench newlisp-js/canvas.lsp

.c.o:
 $(CC) -O2 --closure 1 $(CFLAGS) $<

$(OBJS): primes.h protos.h makefile_emscripten_lib_utf8

iNPRwANG
 
Posts: 32
Joined: Sun May 08, 2011 1:45 pm

Re: newLisp compile to webassembly (newlisp-js)

Postby Lutz » Tue Feb 13, 2018 11:56 pm

Thanks, it is now included in the distribution as 'makefile_emscripten_wasm_utf8' here:

http://www.newlisp.org/downloads/develo ... nprogress/
Lutz
 
Posts: 5242
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP Graphics & Sound

Who is online

Users browsing this forum: No registered users and 0 guests

cron