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

Side by Side Diff: test/cctest/wasm/test-run-wasm-asmjs.cc

Issue 1971693002: [wasm] Introduce custom asm.js bytecodes for double->int conversions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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 unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 63 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
64 BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 64 BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
65 const int32_t kMin = std::numeric_limits<int32_t>::min(); 65 const int32_t kMin = std::numeric_limits<int32_t>::min();
66 CHECK_EQ(17, r.Call(217, 100)); 66 CHECK_EQ(17, r.Call(217, 100));
67 CHECK_EQ(0, r.Call(100, 0)); 67 CHECK_EQ(0, r.Call(100, 0));
68 CHECK_EQ(0, r.Call(-1001, 0)); 68 CHECK_EQ(0, r.Call(-1001, 0));
69 CHECK_EQ(0, r.Call(kMin, 0)); 69 CHECK_EQ(0, r.Call(kMin, 0));
70 CHECK_EQ(kMin, r.Call(kMin, -1)); 70 CHECK_EQ(kMin, r.Call(kMin, -1));
71 } 71 }
72 72
73 TEST(Run_Wasm_I32AsmjsSConvertF32) {
74 WasmRunner<int32_t> r(MachineType::Float32());
75 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0)));
76
77 FOR_FLOAT32_INPUTS(i) {
78 int32_t expected = DoubleToInt32(*i);
79 CHECK_EQ(expected, r.Call(*i));
80 }
81 }
82
83 TEST(Run_Wasm_I32AsmjsSConvertF64) {
84 WasmRunner<int32_t> r(MachineType::Float64());
85 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0)));
86
87 FOR_FLOAT64_INPUTS(i) {
88 int32_t expected = DoubleToInt32(*i);
89 CHECK_EQ(expected, r.Call(*i));
90 }
91 }
92
93 TEST(Run_Wasm_I32AsmjsUConvertF32) {
94 WasmRunner<uint32_t> r(MachineType::Float32());
95 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0)));
96
97 FOR_FLOAT32_INPUTS(i) {
98 uint32_t expected = DoubleToUint32(*i);
99 CHECK_EQ(expected, r.Call(*i));
100 }
101 }
102
103 TEST(Run_Wasm_I32AsmjsUConvertF64) {
104 WasmRunner<uint32_t> r(MachineType::Float64());
105 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0)));
106
107 FOR_FLOAT64_INPUTS(i) {
108 uint32_t expected = DoubleToUint32(*i);
109 CHECK_EQ(expected, r.Call(*i));
110 }
111 }
112
73 TEST(Run_Wasm_LoadMemI32_oob_asm) { 113 TEST(Run_Wasm_LoadMemI32_oob_asm) {
74 TestingModule module; 114 TestingModule module;
75 module.origin = kAsmJsOrigin; 115 module.origin = kAsmJsOrigin;
76 int32_t* memory = module.AddMemoryElems<int32_t>(8); 116 int32_t* memory = module.AddMemoryElems<int32_t>(8);
77 WasmRunner<int32_t> r(&module, MachineType::Uint32()); 117 WasmRunner<int32_t> r(&module, MachineType::Uint32());
78 module.RandomizeMemory(1112); 118 module.RandomizeMemory(1112);
79 119
80 BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))); 120 BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
81 121
82 memory[0] = 999999; 122 memory[0] = 999999;
83 CHECK_EQ(999999, r.Call(0u)); 123 CHECK_EQ(999999, r.Call(0u));
84 // TODO(titzer): offset 29-31 should also be OOB. 124 // TODO(titzer): offset 29-31 should also be OOB.
85 for (uint32_t offset = 32; offset < 40; offset++) { 125 for (uint32_t offset = 32; offset < 40; offset++) {
86 CHECK_EQ(0, r.Call(offset)); 126 CHECK_EQ(0, r.Call(offset));
87 } 127 }
88 128
89 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { 129 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
90 CHECK_EQ(0, r.Call(offset)); 130 CHECK_EQ(0, r.Call(offset));
91 } 131 }
92 } 132 }
OLDNEW
« 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