Skip to content

Commit

Permalink
whitelist functions which are run by Emterpreter (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jul 16, 2018
1 parent 85ae2e7 commit 2df338e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ to create your own branch and merge `wasm` branch into your branch by `git merge

- WebAssembly nor JavaScript does not provide `sleep()`. By default, emscripten
compiles `sleep()` into a busy loop. So vim.wasm is using [Emterpreter][]
which enables `emscripten_sleep()`. But this feature is not so stable and makes
built binaries larger and compilation longer.
which provides `emscripten_sleep()`. Some whitelisted functions are run with
Emterpreter. But this feature is not so stable. It makes built binaries larger
and compilation longer.
- JavaScript to C does not fully work with Emterpreter. For example, calling
some C APIs breaks Emterpreter stack. This also means that calling C functions
from JavaScript passing a `string` parameter does not work.
Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ run_emcc() {
# TODO: EMCC_DEBUG=1
# TODO: STACK_OVERFLOW_CHECK=1
# TODO: --js-opts 0
extraflags="-O1 -g -s ASSERTIONS=1 --shell-file template_vim.html -o vim.html"
extraflags="-O0 -g -s ASSERTIONS=1 --shell-file template_vim.html -o vim.html"
else
extraflags="-O2 --shell-file template_vim_release.html -o index.html"
fi
Expand All @@ -91,6 +91,7 @@ run_emcc() {
--js-library runtime.js \
-s "EXPORTED_FUNCTIONS=['_main','_gui_wasm_send_key','_gui_wasm_resize_shell']" -s "EXTRA_EXPORTED_RUNTIME_METHODS=['cwrap']" \
-s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s 'EMTERPRETIFY_FILE="emterpretify.data"' \
-s 'EMTERPRETIFY_WHITELIST=["_gui_mch_wait_for_chars", "_flush_buffers", "_vgetorpeek_one", "_vgetorpeek", "_plain_vgetc", "_vgetc", "_safe_vgetc", "_normal_cmd", "_main_loop", "_inchar", "_gui_inchar", "_ui_inchar", "_gui_wait_for_chars", "_gui_wait_for_chars_or_timer", "_vim_main2", "_main", "_gui_wasm_send_key", "_add_to_input_buf", "_simplify_key", "_extract_modifiers", "_edit", "_invoke_edit", "_nv_edit", "_nv_colon", "_n_opencmd", "_nv_open", "_nv_search", "_fsync", "_mf_sync", "_ml_sync_all", "_updatescript", "_before_blocking", "_getcmdline", "_getexline", "_do_cmdline", "_wait_return", "_op_change", "_do_pending_operator", "_get_literal", "_ins_ctrl_v"]' \
--preload-file usr --preload-file tutor \
$extraflags \

Expand Down
13 changes: 4 additions & 9 deletions wasm/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@ const VimWasmRuntime = {
}

WindowResize.prototype.onVimInit = function() {
this.resizeVim = Module.cwrap(
'gui_wasm_resize_shell',
null,
[
'number', // dom_width
'number', // dom_height
],
{ async: true }
);
this.resizeVim = Module.cwrap('gui_wasm_resize_shell', null, [
'number', // dom_width
'number', // dom_height
]);
// XXX: Following is also not working
// this.resizeVim = function(rows, cols) {
// Module.ccall('gui_wasm_resize_shell', null, ['number', 'number'], [rows, cols], { async: true });
Expand Down

0 comments on commit 2df338e

Please sign in to comment.