Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: test/mjsunit/wasm/asm-wasm.js

Issue 1677373002: Adding support for asm.js foreign globals. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/wasm/asm-wasm-builder.cc ('K') | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/asm-wasm.js
diff --git a/test/mjsunit/wasm/asm-wasm.js b/test/mjsunit/wasm/asm-wasm.js
index 603ca0124188924ee26bca0866acded3cc7609a8..d1e631094c7fe2df2a5ce1bf83e87a21ea59e92c 100644
--- a/test/mjsunit/wasm/asm-wasm.js
+++ b/test/mjsunit/wasm/asm-wasm.js
@@ -1080,3 +1080,46 @@ function TestForeignFunctionMultipleUse() {
}
TestForeignFunctionMultipleUse();
+
+
+function TestForeignVariables() {
aseemgarg 2016/02/09 02:38:56 Might want to also write test that uses same forei
bradnelson 2016/02/09 04:55:23 Done.
+ function AsmModule(stdlib, foreign, buffer) {
+ "use asm";
+
+ var i1 = foreign.foo | 0;
+ var f1 = +foreign.bar;
+
+ function geti() {
+ return i1|0;
+ }
+
+ function getf() {
+ return +f1;
+ }
+
+ return {geti:geti, getf:getf};
+ }
+
+ // Check normal operation.
+ var module = _WASMEXP_.instantiateModuleFromAsm(
+ AsmModule.toString(), {foo: 123, bar: 234}, null);
+ module.__init__();
+ assertEquals(123, module.geti());
+ assertEquals(234, module.getf());
+
+ // Check that undefined values are converted to zero.
aseemgarg 2016/02/09 02:38:56 As discussed, doubles should flow as NaNs. Please
bradnelson 2016/02/09 04:55:23 Done.
+ var module = _WASMEXP_.instantiateModuleFromAsm(
+ AsmModule.toString(), {baz: 678}, null);
+ module.__init__();
+ assertEquals(0, module.geti());
+ assertEquals(0, module.getf());
+
+ // Check that a missing ffi object is safe.
+ var module = _WASMEXP_.instantiateModuleFromAsm(
+ AsmModule.toString());
+ module.__init__();
+ assertEquals(0, module.geti());
+ assertEquals(0, module.getf());
+}
+
+TestForeignVariables();
« src/wasm/asm-wasm-builder.cc ('K') | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698