From ef1054ef74a53f269b2df3f77ae510cbf305b5f1 Mon Sep 17 00:00:00 2001 From: Kai Zhu Date: Wed, 21 Oct 2020 12:13:42 -0500 Subject: [PATCH 1/3] merge sql-asm-memory-growth.js into sql-asm.js Co-authored-by: Yan Li Co-authored-by: kai zhu --- Makefile | 12 ++---------- README.md | 3 +-- examples/requireJS.html | 2 +- package.json | 3 +-- test/test_worker.js | 2 +- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 287de6fd..64504952 100644 --- a/Makefile +++ b/Makefile @@ -40,10 +40,8 @@ EMFLAGS = \ -s NODEJS_CATCH_REJECTION=0 EMFLAGS_ASM = \ - -s WASM=0 - -EMFLAGS_ASM_MEMORY_GROWTH = \ -s WASM=0 \ + -s LEGACY_VM_SUPPORT=1 \ -s ALLOW_MEMORY_GROWTH=1 EMFLAGS_WASM = \ @@ -90,7 +88,7 @@ dist/sql-wasm-debug.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FI rm out/tmp-raw.js .PHONY: optimized -optimized: dist/sql-asm.js dist/sql-wasm.js dist/sql-asm-memory-growth.js +optimized: dist/sql-asm.js dist/sql-wasm.js dist/sql-asm.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FILES) $(EXPORTED_METHODS_JSON_FILES) $(EMCC) $(EMFLAGS) $(EMFLAGS_OPTIMIZED) $(EMFLAGS_ASM) $(BITCODE_FILES) $(EMFLAGS_PRE_JS_FILES) -o $@ @@ -104,12 +102,6 @@ dist/sql-wasm.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FILES) $ cat src/shell-pre.js out/tmp-raw.js src/shell-post.js > $@ rm out/tmp-raw.js -dist/sql-asm-memory-growth.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FILES) $(EXPORTED_METHODS_JSON_FILES) - $(EMCC) $(EMFLAGS) $(EMFLAGS_OPTIMIZED) $(EMFLAGS_ASM_MEMORY_GROWTH) $(BITCODE_FILES) $(EMFLAGS_PRE_JS_FILES) -o $@ - mv $@ out/tmp-raw.js - cat src/shell-pre.js out/tmp-raw.js src/shell-post.js > $@ - rm out/tmp-raw.js - # Web worker API .PHONY: worker worker: dist/worker.sql-asm.js dist/worker.sql-asm-debug.js dist/worker.sql-wasm.js dist/worker.sql-wasm-debug.js diff --git a/README.md b/README.md index 8ce3066b..966a497f 100644 --- a/README.md +++ b/README.md @@ -276,8 +276,7 @@ You can always find the latest published artifacts on https://github.com/sql-js/ For each [release](https://github.com/sql-js/sql.js/releases/), you will find a file called `sqljs.zip` in the *release assets*. It will contain: - `sql-wasm.js` : The Web Assembly version of Sql.js. Minified and suitable for production. Use this. If you use this, you will need to include/ship `sql-wasm.wasm` as well. - `sql-wasm-debug.js` : The Web Assembly, Debug version of Sql.js. Larger, with assertions turned on. Useful for local development. You will need to include/ship `sql-wasm-debug.wasm` if you use this. - - `sql-asm.js` : The older asm.js version of Sql.js. Slower and larger. Provided for compatibility reasons. - - `sql-asm-memory-growth.js` : Asm.js doesn't allow for memory to grow by default, because it is slower and de-optimizes. If you are using sql-asm.js and you see this error (`Cannot enlarge memory arrays`), use this file. + - `sql-asm.js` : The older asm.js version of Sql.js. Slower and larger. Provided for compatibility reasons. Includes memory-growth patch. - `sql-asm-debug.js` : The _Debug_ asm.js version of Sql.js. Use this for local development. - `worker.*` - Web Worker versions of the above libraries. More limited API. See [examples/GUI/gui.js](examples/GUI/gui.js) for a good example of this. diff --git a/examples/requireJS.html b/examples/requireJS.html index bc1f6b2b..c97e8900 100644 --- a/examples/requireJS.html +++ b/examples/requireJS.html @@ -8,7 +8,7 @@ baseUrl: baseUrl }); - // Options: 'sql-wasm', 'sql-asm', 'sql-asm-memory-growth.js', 'sql-wasm-debug', 'sql-asm-debug' + // Options: 'sql-wasm', 'sql-asm', 'sql-wasm-debug', 'sql-asm-debug' require(['sql-wasm'], function success(initSqlJs) { console.log(typeof initSqlJs); diff --git a/package.json b/package.json index de41e1fc..2358c41e 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,11 @@ "scripts": { "build": "make", "rebuild": "make clean && make", - "test": "npm run lint && npm run test-asm && npm run test-asm-debug && npm run test-wasm && npm run test-wasm-debug && npm run test-asm-memory-growth", + "test": "npm run lint && npm run test-asm && npm run test-asm-debug && npm run test-wasm && npm run test-wasm-debug", "lint": "eslint .", "prettify": "eslint . --fix", "test-asm": "node test/all.js asm", "test-asm-debug": "node test/all.js asm-debug", - "test-asm-memory-growth": "node test/all.js asm-memory-growth", "test-wasm": "node test/all.js wasm", "test-wasm-debug": "node test/all.js wasm-debug", "doc": "jsdoc -c .jsdoc.config.json" diff --git a/test/test_worker.js b/test/test_worker.js index 5e37f91d..76fcb3e6 100644 --- a/test/test_worker.js +++ b/test/test_worker.js @@ -36,7 +36,7 @@ class Worker { exports.test = async function test(SQL, assert) { var target = process.argv[2]; var file = target ? "sql-" + target : "sql-wasm"; - if (file.indexOf('wasm') > -1 || file.indexOf('memory-growth') > -1) { + if (file.indexOf('wasm') > -1) { console.error("Skipping worker test for " + file + ". Not implemented yet"); return; }; From 21c9beebba3b8bde52ca81237c19d448b6a38cd3 Mon Sep 17 00:00:00 2001 From: Kai Zhu Date: Mon, 26 Oct 2020 14:45:42 -0500 Subject: [PATCH 2/3] deprecate sql-asm-memory-growth.js in favor of sql-asm.js, which now includes memory-growth and ie11 support. --- Makefile | 18 +++++++++++++++--- README.md | 3 ++- examples/requireJS.html | 2 +- package.json | 3 ++- test/test_worker.js | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 64504952..cc1370cb 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,13 @@ EMFLAGS = \ EMFLAGS_ASM = \ -s WASM=0 \ - -s LEGACY_VM_SUPPORT=1 \ - -s ALLOW_MEMORY_GROWTH=1 + -s ALLOW_MEMORY_GROWTH=1 \ + -s LEGACY_VM_SUPPORT=1 + +EMFLAGS_ASM_MEMORY_GROWTH = \ + -s WASM=0 \ + -s ALLOW_MEMORY_GROWTH=1 \ + -s LEGACY_VM_SUPPORT=1 EMFLAGS_WASM = \ -s WASM=1 \ @@ -88,7 +93,7 @@ dist/sql-wasm-debug.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FI rm out/tmp-raw.js .PHONY: optimized -optimized: dist/sql-asm.js dist/sql-wasm.js +optimized: dist/sql-asm.js dist/sql-wasm.js dist/sql-asm-memory-growth.js dist/sql-asm.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FILES) $(EXPORTED_METHODS_JSON_FILES) $(EMCC) $(EMFLAGS) $(EMFLAGS_OPTIMIZED) $(EMFLAGS_ASM) $(BITCODE_FILES) $(EMFLAGS_PRE_JS_FILES) -o $@ @@ -102,6 +107,13 @@ dist/sql-wasm.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FILES) $ cat src/shell-pre.js out/tmp-raw.js src/shell-post.js > $@ rm out/tmp-raw.js +dist/sql-asm-memory-growth.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FILES) $(EXPORTED_METHODS_JSON_FILES) + $(EMCC) $(EMFLAGS) $(EMFLAGS_OPTIMIZED) $(EMFLAGS_ASM_MEMORY_GROWTH) $(BITCODE_FILES) $(EMFLAGS_PRE_JS_FILES) -o $@ + mv $@ out/tmp-raw.js + printf 'console.error(\n "\\n\\nDEPRECATION WARNING.\\n"\n + "sql-asm-memory-growth.js will be removed in future releases.\\n"\n + "Use sql-asm.js instead, which now includes memory-growth support.\\n\\n"\n);\n' > $@ + cat src/shell-pre.js out/tmp-raw.js src/shell-post.js >> $@ + rm out/tmp-raw.js + # Web worker API .PHONY: worker worker: dist/worker.sql-asm.js dist/worker.sql-asm-debug.js dist/worker.sql-wasm.js dist/worker.sql-wasm-debug.js diff --git a/README.md b/README.md index 966a497f..f74b9d48 100644 --- a/README.md +++ b/README.md @@ -276,7 +276,8 @@ You can always find the latest published artifacts on https://github.com/sql-js/ For each [release](https://github.com/sql-js/sql.js/releases/), you will find a file called `sqljs.zip` in the *release assets*. It will contain: - `sql-wasm.js` : The Web Assembly version of Sql.js. Minified and suitable for production. Use this. If you use this, you will need to include/ship `sql-wasm.wasm` as well. - `sql-wasm-debug.js` : The Web Assembly, Debug version of Sql.js. Larger, with assertions turned on. Useful for local development. You will need to include/ship `sql-wasm-debug.wasm` if you use this. - - `sql-asm.js` : The older asm.js version of Sql.js. Slower and larger. Provided for compatibility reasons. Includes memory-growth patch. + - `sql-asm.js` : The older asm.js version of Sql.js. Slower and larger. Provided for compatibility reasons. Includes memory-growth and IE 11 compatibility. + - `sql-asm-memory-growth.js` : DEPRECATED and will be removed in future releases. Use sql-asm.js instead, which now includes memory-growth support. - `sql-asm-debug.js` : The _Debug_ asm.js version of Sql.js. Use this for local development. - `worker.*` - Web Worker versions of the above libraries. More limited API. See [examples/GUI/gui.js](examples/GUI/gui.js) for a good example of this. diff --git a/examples/requireJS.html b/examples/requireJS.html index c97e8900..bc1f6b2b 100644 --- a/examples/requireJS.html +++ b/examples/requireJS.html @@ -8,7 +8,7 @@ baseUrl: baseUrl }); - // Options: 'sql-wasm', 'sql-asm', 'sql-wasm-debug', 'sql-asm-debug' + // Options: 'sql-wasm', 'sql-asm', 'sql-asm-memory-growth.js', 'sql-wasm-debug', 'sql-asm-debug' require(['sql-wasm'], function success(initSqlJs) { console.log(typeof initSqlJs); diff --git a/package.json b/package.json index 2358c41e..de41e1fc 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,12 @@ "scripts": { "build": "make", "rebuild": "make clean && make", - "test": "npm run lint && npm run test-asm && npm run test-asm-debug && npm run test-wasm && npm run test-wasm-debug", + "test": "npm run lint && npm run test-asm && npm run test-asm-debug && npm run test-wasm && npm run test-wasm-debug && npm run test-asm-memory-growth", "lint": "eslint .", "prettify": "eslint . --fix", "test-asm": "node test/all.js asm", "test-asm-debug": "node test/all.js asm-debug", + "test-asm-memory-growth": "node test/all.js asm-memory-growth", "test-wasm": "node test/all.js wasm", "test-wasm-debug": "node test/all.js wasm-debug", "doc": "jsdoc -c .jsdoc.config.json" diff --git a/test/test_worker.js b/test/test_worker.js index 76fcb3e6..5e37f91d 100644 --- a/test/test_worker.js +++ b/test/test_worker.js @@ -36,7 +36,7 @@ class Worker { exports.test = async function test(SQL, assert) { var target = process.argv[2]; var file = target ? "sql-" + target : "sql-wasm"; - if (file.indexOf('wasm') > -1) { + if (file.indexOf('wasm') > -1 || file.indexOf('memory-growth') > -1) { console.error("Skipping worker test for " + file + ". Not implemented yet"); return; }; From 47dd311ca2b1abfa166cbc113a2b1be86e73cf59 Mon Sep 17 00:00:00 2001 From: Kai Zhu Date: Tue, 27 Oct 2020 17:20:04 -0500 Subject: [PATCH 3/3] remove build/test references to sql-asm-memory-growth.js, since its now essentially a copy of sql-asm.js --- Makefile | 17 ++++------------- examples/requireJS.html | 2 +- package.json | 3 +-- test/test_worker.js | 2 +- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index cc1370cb..89a42ed0 100644 --- a/Makefile +++ b/Makefile @@ -44,11 +44,6 @@ EMFLAGS_ASM = \ -s ALLOW_MEMORY_GROWTH=1 \ -s LEGACY_VM_SUPPORT=1 -EMFLAGS_ASM_MEMORY_GROWTH = \ - -s WASM=0 \ - -s ALLOW_MEMORY_GROWTH=1 \ - -s LEGACY_VM_SUPPORT=1 - EMFLAGS_WASM = \ -s WASM=1 \ -s ALLOW_MEMORY_GROWTH=1 @@ -93,7 +88,7 @@ dist/sql-wasm-debug.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FI rm out/tmp-raw.js .PHONY: optimized -optimized: dist/sql-asm.js dist/sql-wasm.js dist/sql-asm-memory-growth.js +optimized: dist/sql-asm.js dist/sql-wasm.js dist/sql-asm.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FILES) $(EXPORTED_METHODS_JSON_FILES) $(EMCC) $(EMFLAGS) $(EMFLAGS_OPTIMIZED) $(EMFLAGS_ASM) $(BITCODE_FILES) $(EMFLAGS_PRE_JS_FILES) -o $@ @@ -106,13 +101,9 @@ dist/sql-wasm.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FILES) $ mv $@ out/tmp-raw.js cat src/shell-pre.js out/tmp-raw.js src/shell-post.js > $@ rm out/tmp-raw.js - -dist/sql-asm-memory-growth.js: $(BITCODE_FILES) $(OUTPUT_WRAPPER_FILES) $(SOURCE_API_FILES) $(EXPORTED_METHODS_JSON_FILES) - $(EMCC) $(EMFLAGS) $(EMFLAGS_OPTIMIZED) $(EMFLAGS_ASM_MEMORY_GROWTH) $(BITCODE_FILES) $(EMFLAGS_PRE_JS_FILES) -o $@ - mv $@ out/tmp-raw.js - printf 'console.error(\n "\\n\\nDEPRECATION WARNING.\\n"\n + "sql-asm-memory-growth.js will be removed in future releases.\\n"\n + "Use sql-asm.js instead, which now includes memory-growth support.\\n\\n"\n);\n' > $@ - cat src/shell-pre.js out/tmp-raw.js src/shell-post.js >> $@ - rm out/tmp-raw.js + # TODO - remove code below in future releases to sunset sql-asm-memory-growth.js + printf 'console.error(\n "\\n\\nDEPRECATION WARNING.\\n"\n + "sql-asm-memory-growth.js will be removed in future releases.\\n"\n + "Use sql-asm.js instead, which now includes memory-growth support.\\n\\n"\n);\n' > dist/sql-asm-memory-growth.js + cat $@ >> dist/sql-asm-memory-growth.js # Web worker API .PHONY: worker diff --git a/examples/requireJS.html b/examples/requireJS.html index bc1f6b2b..c97e8900 100644 --- a/examples/requireJS.html +++ b/examples/requireJS.html @@ -8,7 +8,7 @@ baseUrl: baseUrl }); - // Options: 'sql-wasm', 'sql-asm', 'sql-asm-memory-growth.js', 'sql-wasm-debug', 'sql-asm-debug' + // Options: 'sql-wasm', 'sql-asm', 'sql-wasm-debug', 'sql-asm-debug' require(['sql-wasm'], function success(initSqlJs) { console.log(typeof initSqlJs); diff --git a/package.json b/package.json index de41e1fc..2358c41e 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,11 @@ "scripts": { "build": "make", "rebuild": "make clean && make", - "test": "npm run lint && npm run test-asm && npm run test-asm-debug && npm run test-wasm && npm run test-wasm-debug && npm run test-asm-memory-growth", + "test": "npm run lint && npm run test-asm && npm run test-asm-debug && npm run test-wasm && npm run test-wasm-debug", "lint": "eslint .", "prettify": "eslint . --fix", "test-asm": "node test/all.js asm", "test-asm-debug": "node test/all.js asm-debug", - "test-asm-memory-growth": "node test/all.js asm-memory-growth", "test-wasm": "node test/all.js wasm", "test-wasm-debug": "node test/all.js wasm-debug", "doc": "jsdoc -c .jsdoc.config.json" diff --git a/test/test_worker.js b/test/test_worker.js index 5e37f91d..76fcb3e6 100644 --- a/test/test_worker.js +++ b/test/test_worker.js @@ -36,7 +36,7 @@ class Worker { exports.test = async function test(SQL, assert) { var target = process.argv[2]; var file = target ? "sql-" + target : "sql-wasm"; - if (file.indexOf('wasm') > -1 || file.indexOf('memory-growth') > -1) { + if (file.indexOf('wasm') > -1) { console.error("Skipping worker test for " + file + ". Not implemented yet"); return; };