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

Unified Diff: test/cctest/wasm/test-run-wasm-asmjs.cc

Issue 1968943002: [wasm] Introduce custom asm.js bytecodes for loads and stores. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm_asmjs_convert
Patch Set: Created 4 years, 7 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
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm-asmjs.cc
diff --git a/test/cctest/wasm/test-run-wasm-asmjs.cc b/test/cctest/wasm/test-run-wasm-asmjs.cc
index e948d3524887870a786c74515c31c73f5b538707..89e8945d44d704876b9b8417c8b2c461b1ecc415 100644
--- a/test/cctest/wasm/test-run-wasm-asmjs.cc
+++ b/test/cctest/wasm/test-run-wasm-asmjs.cc
@@ -117,7 +117,7 @@ TEST(Run_Wasm_LoadMemI32_oob_asm) {
WasmRunner<int32_t> r(&module, MachineType::Uint32());
module.RandomizeMemory(1112);
- BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
+ BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0)));
memory[0] = 999999;
CHECK_EQ(999999, r.Call(0u));
@@ -130,3 +130,70 @@ TEST(Run_Wasm_LoadMemI32_oob_asm) {
CHECK_EQ(0, r.Call(offset));
}
}
+
+TEST(Run_Wasm_LoadMemF32_oob_asm) {
+ TestingModule module;
+ module.origin = kAsmJsOrigin;
+ float* memory = module.AddMemoryElems<float>(8);
+ WasmRunner<float> r(&module, MachineType::Uint32());
+ module.RandomizeMemory(1112);
+
+ BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
+
+ memory[0] = 9999.5f;
+ CHECK_EQ(9999.5f, r.Call(0u));
+ // TODO(titzer): offset 29-31 should also be OOB.
+ for (uint32_t offset = 32; offset < 40; offset++) {
+ CHECK(std::isnan(r.Call(offset)));
+ }
+
+ for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
+ CHECK(std::isnan(r.Call(offset)));
+ }
+}
+
+TEST(Run_Wasm_LoadMemF64_oob_asm) {
+ TestingModule module;
+ module.origin = kAsmJsOrigin;
+ double* memory = module.AddMemoryElems<double>(8);
+ WasmRunner<double> r(&module, MachineType::Uint32());
+ module.RandomizeMemory(1112);
+
+ BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
+
+ memory[0] = 9799.5;
+ CHECK_EQ(9799.5, r.Call(0u));
+ memory[1] = 11799.25;
+ CHECK_EQ(11799.25, r.Call(8u));
+ // TODO(titzer): offset 57-63 should also be OOB.
+ for (uint32_t offset = 64; offset < 80; offset++) {
+ CHECK(std::isnan(r.Call(offset)));
+ }
+
+ for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
+ CHECK(std::isnan(r.Call(offset)));
+ }
+}
+
+TEST(Run_Wasm_StoreMemI32_oob_asm) {
ahaas 2016/05/11 11:10:14 Is there a reason why you skip the tests for the o
+ TestingModule module;
+ module.origin = kAsmJsOrigin;
+ int32_t* memory = module.AddMemoryElems<int32_t>(8);
+ WasmRunner<int32_t> r(&module, MachineType::Uint32(), MachineType::Uint32());
+ module.RandomizeMemory(1112);
+
+ BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0),
+ WASM_GET_LOCAL(1)));
+
+ memory[0] = 7777;
+ CHECK_EQ(999999, r.Call(0u, 999999));
+ CHECK_EQ(999999, memory[0]);
+ // TODO(titzer): offset 29-31 should also be OOB.
+ for (uint32_t offset = 32; offset < 40; offset++) {
+ CHECK_EQ(8888, r.Call(offset, 8888));
+ }
+
+ for (uint32_t offset = 0x10000000; offset < 0xF0000000; offset += 0x1000000) {
+ CHECK_EQ(7777, r.Call(offset, 7777));
+ }
+}
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698