diff --git a/doc/site/static/wren_try.js b/doc/site/static/wren_try.js index dddff40c..19d00c12 100644 --- a/doc/site/static/wren_try.js +++ b/doc/site/static/wren_try.js @@ -607,8 +607,8 @@ var wasmMemory; // In the wasm backend, we polyfill the WebAssembly object, // so this creates a (non-native-wasm) table for us. var wasmTable = new WebAssembly.Table({ - 'initial': 205, - 'maximum': 205 + 0, + 'initial': 203, + 'maximum': 203 + 0, 'element': 'anyfunc' }); @@ -1229,11 +1229,11 @@ function updateGlobalBufferAndViews(buf) { } var STATIC_BASE = 1024, - STACK_BASE = 5271616, + STACK_BASE = 5271552, STACKTOP = STACK_BASE, - STACK_MAX = 28736, - DYNAMIC_BASE = 5271616, - DYNAMICTOP_PTR = 28576; + STACK_MAX = 28672, + DYNAMIC_BASE = 5271552, + DYNAMICTOP_PTR = 28512; assert(STACK_BASE % 16 === 0, 'stack must start aligned'); assert(DYNAMIC_BASE % 16 === 0, 'heap must start aligned'); @@ -1817,7 +1817,7 @@ var ASM_CONSTS = { -// STATICTOP = STATIC_BASE + 27712; +// STATICTOP = STATIC_BASE + 27648; /* global initializers */ __ATINIT__.push({ func: function() { ___wasm_call_ctors() } }); @@ -1869,12 +1869,36 @@ var ASM_CONSTS = { abort('stack overflow') } - - function ___setErrNo(value) { - if (Module['___errno_location']) HEAP32[((Module['___errno_location']())>>2)]=value; - else err('failed to set errno from JS'); - return value; + function _clock() { + if (_clock.start === undefined) _clock.start = Date.now(); + return ((Date.now() - _clock.start) * (1000000 / 1000))|0; } + + function _emscripten_get_sbrk_ptr() { + return 28512; + } + + function _emscripten_memcpy_big(dest, src, num) { + HEAPU8.copyWithin(dest, src, src + num); + } + + + function _emscripten_get_heap_size() { + return HEAPU8.length; + } + + function abortOnCannotGrowMemory(requestedSize) { + abort('Cannot enlarge memory arrays to size ' + requestedSize + ' bytes (OOM). Either (1) compile with -s INITIAL_MEMORY=X with X higher than the current value ' + HEAP8.length + ', (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 '); + }function _emscripten_resize_heap(requestedSize) { + abortOnCannotGrowMemory(requestedSize); + } + + function _exit(status) { + // void _exit(int status); + // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html + exit(status); + } + var PATH={splitPath:function(filename) { @@ -1963,62 +1987,11 @@ var ASM_CONSTS = { if (low >= 0) assert(high === 0); else assert(high === -1); return low; - }};function ___sys_fcntl64(fd, cmd, varargs) {SYSCALLS.varargs = varargs; - - return 0; - } - - function ___sys_ioctl(fd, op, varargs) {SYSCALLS.varargs = varargs; - - return 0; - } - - function ___sys_open(path, flags, varargs) {SYSCALLS.varargs = varargs; - - abort('it should not be possible to operate on streams when !SYSCALLS_REQUIRE_FILESYSTEM')} - - function _clock() { - if (_clock.start === undefined) _clock.start = Date.now(); - return ((Date.now() - _clock.start) * (1000000 / 1000))|0; - } - - function _emscripten_get_sbrk_ptr() { - return 28576; - } - - function _emscripten_memcpy_big(dest, src, num) { - HEAPU8.copyWithin(dest, src, src + num); - } - - - function _emscripten_get_heap_size() { - return HEAPU8.length; - } - - function abortOnCannotGrowMemory(requestedSize) { - abort('Cannot enlarge memory arrays to size ' + requestedSize + ' bytes (OOM). Either (1) compile with -s INITIAL_MEMORY=X with X higher than the current value ' + HEAP8.length + ', (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 '); - }function _emscripten_resize_heap(requestedSize) { - abortOnCannotGrowMemory(requestedSize); - } - - function _exit(status) { - // void _exit(int status); - // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html - exit(status); - } - - function _fd_close(fd) { + }};function _fd_close(fd) { abort('it should not be possible to operate on streams when !SYSCALLS_REQUIRE_FILESYSTEM'); return 0; } - function _fd_read(fd, iov, iovcnt, pnum) { - var stream = SYSCALLS.getStreamFromFD(fd); - var num = SYSCALLS.doReadv(stream, iov, iovcnt); - HEAP32[((pnum)>>2)]=num - return 0; - } - function _fd_seek(fd, offset_low, offset_high, whence, newOffset) { abort('it should not be possible to operate on streams when !SYSCALLS_REQUIRE_FILESYSTEM')} @@ -2097,7 +2070,7 @@ function intArrayToString(array) { // ASM_LIBRARY EXTERN PRIMITIVES: Math_floor,Math_ceil var asmGlobalArg = {}; -var asmLibraryArg = { "__handle_stack_overflow": ___handle_stack_overflow, "__sys_fcntl64": ___sys_fcntl64, "__sys_ioctl": ___sys_ioctl, "__sys_open": ___sys_open, "clock": _clock, "emscripten_get_sbrk_ptr": _emscripten_get_sbrk_ptr, "emscripten_memcpy_big": _emscripten_memcpy_big, "emscripten_resize_heap": _emscripten_resize_heap, "exit": _exit, "fd_close": _fd_close, "fd_read": _fd_read, "fd_seek": _fd_seek, "fd_write": _fd_write, "memory": wasmMemory, "round": _round, "setTempRet0": _setTempRet0, "table": wasmTable, "time": _time }; +var asmLibraryArg = { "__handle_stack_overflow": ___handle_stack_overflow, "clock": _clock, "emscripten_get_sbrk_ptr": _emscripten_get_sbrk_ptr, "emscripten_memcpy_big": _emscripten_memcpy_big, "emscripten_resize_heap": _emscripten_resize_heap, "exit": _exit, "fd_close": _fd_close, "fd_seek": _fd_seek, "fd_write": _fd_write, "memory": wasmMemory, "round": _round, "setTempRet0": _setTempRet0, "table": wasmTable, "time": _time }; var asm = createWasm(); Module["asm"] = asm; /** @type {function(...*):?} */ @@ -2212,13 +2185,6 @@ var dynCall_vi = Module["dynCall_vi"] = function() { return Module["asm"]["dynCall_vi"].apply(null, arguments) }; -/** @type {function(...*):?} */ -var dynCall_jiji = Module["dynCall_jiji"] = function() { - assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)'); - assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)'); - return Module["asm"]["dynCall_jiji"].apply(null, arguments) -}; - /** @type {function(...*):?} */ var dynCall_ii = Module["dynCall_ii"] = function() { assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)'); @@ -2226,6 +2192,13 @@ var dynCall_ii = Module["dynCall_ii"] = function() { return Module["asm"]["dynCall_ii"].apply(null, arguments) }; +/** @type {function(...*):?} */ +var dynCall_jiji = Module["dynCall_jiji"] = function() { + assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)'); + assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)'); + return Module["asm"]["dynCall_jiji"].apply(null, arguments) +}; + /** @type {function(...*):?} */ var dynCall_iidiiii = Module["dynCall_iidiiii"] = function() { assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)'); diff --git a/doc/site/static/wren_try.wasm b/doc/site/static/wren_try.wasm index a73925c6..777c338c 100644 Binary files a/doc/site/static/wren_try.wasm and b/doc/site/static/wren_try.wasm differ diff --git a/test/test.c b/test/test.c index ae3799eb..1d314c9a 100644 --- a/test/test.c +++ b/test/test.c @@ -374,6 +374,12 @@ WrenLoadModuleResult readModule(WrenVM* vm, const char* module) { + //source may or may not be null + WrenLoadModuleResult result = {0}; + + #ifdef WREN_TRY + return result; + #endif Path* filePath = pathNew(module); @@ -383,8 +389,6 @@ char* source = readFile(filePath->chars); pathFree(filePath); - //source may or may not be null - WrenLoadModuleResult result; result.source = source; result.onComplete = readModuleComplete; return result; diff --git a/try/make.emscripten/wren.make b/try/make.emscripten/wren.make index 66bc3075..3eed301f 100644 --- a/try/make.emscripten/wren.make +++ b/try/make.emscripten/wren.make @@ -1,6 +1,6 @@ # Copied from projects/make and modified for emscripten -DEFINES += -D WREN_OPT_RANDOM -D WREN_OPT_META +DEFINES += -DWREN_OPT_RANDOM -DWREN_OPT_META LDFLAGS += " -s WASM=1 -s FILESYSTEM=0" ifndef config diff --git a/try/make.emscripten/wren_try.make b/try/make.emscripten/wren_try.make index 35e05990..3bc3c5e0 100644 --- a/try/make.emscripten/wren_try.make +++ b/try/make.emscripten/wren_try.make @@ -1,6 +1,6 @@ # Copied from projects/make and modified for emscripten -DEFINES += -D WREN_OPT_RANDOM -D WREN_OPT_META +DEFINES += -DWREN_OPT_RANDOM -DWREN_OPT_META -DWREN_TRY LDFLAGS += -s WASM=1 -s FILESYSTEM=0 -s EXIT_RUNTIME=0 -s ENVIRONMENT='web' LDFLAGS += -s EXPORTED_FUNCTIONS='["_main", "_wren_compile"]' LDFLAGS += -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'