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

Side by Side Diff: test/unittests/wasm/wasm-macro-gen-unittest.cc

Issue 1830663002: [wasm] Binary 11: AST changes. (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 | « test/unittests/wasm/loop-assignment-analysis-unittest.cc ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "test/unittests/test-utils.h" 5 #include "test/unittests/test-utils.h"
6 6
7 #include "src/wasm/wasm-macro-gen.h" 7 #include "src/wasm/wasm-macro-gen.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 TEST_F(WasmMacroGenTest, Statements) { 52 TEST_F(WasmMacroGenTest, Statements) {
53 EXPECT_SIZE(1, WASM_NOP); 53 EXPECT_SIZE(1, WASM_NOP);
54 54
55 EXPECT_SIZE(4, WASM_SET_LOCAL(0, WASM_ZERO)); 55 EXPECT_SIZE(4, WASM_SET_LOCAL(0, WASM_ZERO));
56 56
57 EXPECT_SIZE(4, WASM_STORE_GLOBAL(0, WASM_ZERO)); 57 EXPECT_SIZE(4, WASM_STORE_GLOBAL(0, WASM_ZERO));
58 58
59 EXPECT_SIZE(7, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO)); 59 EXPECT_SIZE(7, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO));
60 60
61 EXPECT_SIZE(4, WASM_IF(WASM_ZERO, WASM_NOP)); 61 EXPECT_SIZE(5, WASM_IF(WASM_ZERO, WASM_NOP));
62 62
63 EXPECT_SIZE(5, WASM_IF_ELSE(WASM_ZERO, WASM_NOP, WASM_NOP)); 63 EXPECT_SIZE(7, WASM_IF_ELSE(WASM_ZERO, WASM_NOP, WASM_NOP));
64 64
65 EXPECT_SIZE(5, WASM_SELECT(WASM_ZERO, WASM_NOP, WASM_NOP)); 65 EXPECT_SIZE(5, WASM_SELECT(WASM_ZERO, WASM_NOP, WASM_NOP));
66 66
67 EXPECT_SIZE(3, WASM_BR(0)); 67 EXPECT_SIZE(4, WASM_BR(0));
68 EXPECT_SIZE(5, WASM_BR_IF(0, WASM_ZERO)); 68 EXPECT_SIZE(5, WASM_BR_IF(0, WASM_ZERO));
69 69
70 EXPECT_SIZE(3, WASM_BLOCK(1, WASM_NOP)); 70 EXPECT_SIZE(3, WASM_BLOCK(1, WASM_NOP));
71 EXPECT_SIZE(4, WASM_BLOCK(2, WASM_NOP, WASM_NOP)); 71 EXPECT_SIZE(4, WASM_BLOCK(2, WASM_NOP, WASM_NOP));
72 EXPECT_SIZE(5, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_NOP)); 72 EXPECT_SIZE(5, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_NOP));
73 73
74 EXPECT_SIZE(5, WASM_INFINITE_LOOP); 74 EXPECT_SIZE(6, WASM_INFINITE_LOOP);
75 75
76 EXPECT_SIZE(3, WASM_LOOP(1, WASM_NOP)); 76 EXPECT_SIZE(3, WASM_LOOP(1, WASM_NOP));
77 EXPECT_SIZE(4, WASM_LOOP(2, WASM_NOP, WASM_NOP)); 77 EXPECT_SIZE(4, WASM_LOOP(2, WASM_NOP, WASM_NOP));
78 EXPECT_SIZE(5, WASM_LOOP(3, WASM_NOP, WASM_NOP, WASM_NOP)); 78 EXPECT_SIZE(5, WASM_LOOP(3, WASM_NOP, WASM_NOP, WASM_NOP));
79 EXPECT_SIZE(5, WASM_LOOP(1, WASM_BR(0))); 79 EXPECT_SIZE(6, WASM_LOOP(1, WASM_BR(0)));
80 EXPECT_SIZE(7, WASM_LOOP(1, WASM_BR_IF(0, WASM_ZERO))); 80 EXPECT_SIZE(7, WASM_LOOP(1, WASM_BR_IF(0, WASM_ZERO)));
81 81
82 EXPECT_SIZE(1, WASM_RETURN0); 82 EXPECT_SIZE(2, WASM_RETURN0);
83 EXPECT_SIZE(3, WASM_RETURN(WASM_ZERO)); 83 EXPECT_SIZE(4, WASM_RETURN1(WASM_ZERO));
84 EXPECT_SIZE(5, WASM_RETURN(WASM_ZERO, WASM_ZERO));
85 84
86 EXPECT_SIZE(1, WASM_UNREACHABLE); 85 EXPECT_SIZE(1, WASM_UNREACHABLE);
87 } 86 }
88 87
89 88
90 TEST_F(WasmMacroGenTest, MacroStatements) { 89 TEST_F(WasmMacroGenTest, MacroStatements) {
91 EXPECT_SIZE(8, WASM_WHILE(WASM_I8(0), WASM_NOP)); 90 EXPECT_SIZE(10, WASM_WHILE(WASM_I8(0), WASM_NOP));
92 EXPECT_SIZE(7, WASM_INC_LOCAL(0)); 91 EXPECT_SIZE(7, WASM_INC_LOCAL(0));
93 EXPECT_SIZE(7, WASM_INC_LOCAL_BY(0, 3)); 92 EXPECT_SIZE(7, WASM_INC_LOCAL_BY(0, 3));
94 93
95 EXPECT_SIZE(3, WASM_BREAK(0)); 94 EXPECT_SIZE(4, WASM_BREAK(0));
96 EXPECT_SIZE(3, WASM_CONTINUE(0)); 95 EXPECT_SIZE(4, WASM_CONTINUE(0));
97 } 96 }
98 97
99 TEST_F(WasmMacroGenTest, BrTable) { 98 TEST_F(WasmMacroGenTest, BrTable) {
100 EXPECT_SIZE(8, WASM_BR_TABLE(WASM_ZERO, 1, BR_TARGET(1))); 99 EXPECT_SIZE(9, WASM_BR_TABLE(WASM_ZERO, 1, BR_TARGET(1)));
100 EXPECT_SIZE(11, WASM_BR_TABLEV(WASM_ZERO, WASM_ZERO, 1, BR_TARGET(1)));
101 } 101 }
102 102
103 103
104 TEST_F(WasmMacroGenTest, Expressions) { 104 TEST_F(WasmMacroGenTest, Expressions) {
105 EXPECT_SIZE(2, WASM_GET_LOCAL(0)); 105 EXPECT_SIZE(2, WASM_GET_LOCAL(0));
106 EXPECT_SIZE(2, WASM_GET_LOCAL(1)); 106 EXPECT_SIZE(2, WASM_GET_LOCAL(1));
107 EXPECT_SIZE(2, WASM_GET_LOCAL(12)); 107 EXPECT_SIZE(2, WASM_GET_LOCAL(12));
108 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(0)); 108 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(0));
109 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(1)); 109 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(1));
110 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(12)); 110 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(12));
111 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)); 111 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO));
112 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)); 112 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO));
113 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)); 113 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO));
114 114
115 EXPECT_SIZE(3, WASM_NOT(WASM_ZERO)); 115 EXPECT_SIZE(3, WASM_NOT(WASM_ZERO));
116 116
117 EXPECT_SIZE(4, WASM_BRV(1, WASM_ZERO)); 117 EXPECT_SIZE(5, WASM_BRV(1, WASM_ZERO));
118 EXPECT_SIZE(6, WASM_BRV_IF(1, WASM_ZERO, WASM_ZERO)); 118 EXPECT_SIZE(7, WASM_BRV_IF(1, WASM_ZERO, WASM_ZERO));
119 119
120 EXPECT_SIZE(4, WASM_BLOCK(1, WASM_ZERO)); 120 EXPECT_SIZE(4, WASM_BLOCK(1, WASM_ZERO));
121 EXPECT_SIZE(5, WASM_BLOCK(2, WASM_NOP, WASM_ZERO)); 121 EXPECT_SIZE(5, WASM_BLOCK(2, WASM_NOP, WASM_ZERO));
122 EXPECT_SIZE(6, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_ZERO)); 122 EXPECT_SIZE(6, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_ZERO));
123 123
124 EXPECT_SIZE(4, WASM_LOOP(1, WASM_ZERO)); 124 EXPECT_SIZE(4, WASM_LOOP(1, WASM_ZERO));
125 EXPECT_SIZE(5, WASM_LOOP(2, WASM_NOP, WASM_ZERO)); 125 EXPECT_SIZE(5, WASM_LOOP(2, WASM_NOP, WASM_ZERO));
126 EXPECT_SIZE(6, WASM_LOOP(3, WASM_NOP, WASM_NOP, WASM_ZERO)); 126 EXPECT_SIZE(6, WASM_LOOP(3, WASM_NOP, WASM_NOP, WASM_ZERO));
127 } 127 }
128 128
129 TEST_F(WasmMacroGenTest, CallFunction) { 129 TEST_F(WasmMacroGenTest, CallFunction) {
130 EXPECT_SIZE(2, WASM_CALL_FUNCTION0(0)); 130 EXPECT_SIZE(3, WASM_CALL_FUNCTION0(0));
131 EXPECT_SIZE(2, WASM_CALL_FUNCTION0(1)); 131 EXPECT_SIZE(3, WASM_CALL_FUNCTION0(1));
132 EXPECT_SIZE(2, WASM_CALL_FUNCTION0(11)); 132 EXPECT_SIZE(3, WASM_CALL_FUNCTION0(11));
133 133
134 EXPECT_SIZE(4, WASM_CALL_FUNCTION(0, WASM_ZERO)); 134 EXPECT_SIZE(5, WASM_CALL_FUNCTION1(0, WASM_ZERO));
135 EXPECT_SIZE(6, WASM_CALL_FUNCTION(1, WASM_ZERO, WASM_ZERO)); 135 EXPECT_SIZE(7, WASM_CALL_FUNCTION2(1, WASM_ZERO, WASM_ZERO));
136 } 136 }
137 137
138 TEST_F(WasmMacroGenTest, CallImport) { 138 TEST_F(WasmMacroGenTest, CallImport) {
139 EXPECT_SIZE(2, WASM_CALL_IMPORT0(0)); 139 EXPECT_SIZE(3, WASM_CALL_IMPORT0(0));
140 EXPECT_SIZE(2, WASM_CALL_IMPORT0(1)); 140 EXPECT_SIZE(3, WASM_CALL_IMPORT0(1));
141 EXPECT_SIZE(2, WASM_CALL_IMPORT0(11)); 141 EXPECT_SIZE(3, WASM_CALL_IMPORT0(11));
142 142
143 EXPECT_SIZE(4, WASM_CALL_IMPORT(0, WASM_ZERO)); 143 EXPECT_SIZE(5, WASM_CALL_IMPORT1(0, WASM_ZERO));
144 EXPECT_SIZE(6, WASM_CALL_IMPORT(1, WASM_ZERO, WASM_ZERO)); 144 EXPECT_SIZE(7, WASM_CALL_IMPORT2(1, WASM_ZERO, WASM_ZERO));
145 } 145 }
146 146
147 TEST_F(WasmMacroGenTest, CallIndirect) { 147 TEST_F(WasmMacroGenTest, CallIndirect) {
148 EXPECT_SIZE(4, WASM_CALL_INDIRECT0(0, WASM_ZERO)); 148 EXPECT_SIZE(5, WASM_CALL_INDIRECT0(0, WASM_ZERO));
149 EXPECT_SIZE(4, WASM_CALL_INDIRECT0(1, WASM_ZERO)); 149 EXPECT_SIZE(5, WASM_CALL_INDIRECT0(1, WASM_ZERO));
150 EXPECT_SIZE(4, WASM_CALL_INDIRECT0(11, WASM_ZERO)); 150 EXPECT_SIZE(5, WASM_CALL_INDIRECT0(11, WASM_ZERO));
151 151
152 EXPECT_SIZE(6, WASM_CALL_INDIRECT(0, WASM_ZERO, WASM_ZERO)); 152 EXPECT_SIZE(7, WASM_CALL_INDIRECT1(0, WASM_ZERO, WASM_ZERO));
153 EXPECT_SIZE(8, WASM_CALL_INDIRECT(1, WASM_ZERO, WASM_ZERO, WASM_ZERO)); 153 EXPECT_SIZE(9, WASM_CALL_INDIRECT2(1, WASM_ZERO, WASM_ZERO, WASM_ZERO));
154 } 154 }
155 155
156
157 TEST_F(WasmMacroGenTest, Int32Ops) { 156 TEST_F(WasmMacroGenTest, Int32Ops) {
158 EXPECT_SIZE(5, WASM_I32_ADD(WASM_ZERO, WASM_ZERO)); 157 EXPECT_SIZE(5, WASM_I32_ADD(WASM_ZERO, WASM_ZERO));
159 EXPECT_SIZE(5, WASM_I32_SUB(WASM_ZERO, WASM_ZERO)); 158 EXPECT_SIZE(5, WASM_I32_SUB(WASM_ZERO, WASM_ZERO));
160 EXPECT_SIZE(5, WASM_I32_MUL(WASM_ZERO, WASM_ZERO)); 159 EXPECT_SIZE(5, WASM_I32_MUL(WASM_ZERO, WASM_ZERO));
161 EXPECT_SIZE(5, WASM_I32_DIVS(WASM_ZERO, WASM_ZERO)); 160 EXPECT_SIZE(5, WASM_I32_DIVS(WASM_ZERO, WASM_ZERO));
162 EXPECT_SIZE(5, WASM_I32_DIVU(WASM_ZERO, WASM_ZERO)); 161 EXPECT_SIZE(5, WASM_I32_DIVU(WASM_ZERO, WASM_ZERO));
163 EXPECT_SIZE(5, WASM_I32_REMS(WASM_ZERO, WASM_ZERO)); 162 EXPECT_SIZE(5, WASM_I32_REMS(WASM_ZERO, WASM_ZERO));
164 EXPECT_SIZE(5, WASM_I32_REMU(WASM_ZERO, WASM_ZERO)); 163 EXPECT_SIZE(5, WASM_I32_REMU(WASM_ZERO, WASM_ZERO));
165 EXPECT_SIZE(5, WASM_I32_AND(WASM_ZERO, WASM_ZERO)); 164 EXPECT_SIZE(5, WASM_I32_AND(WASM_ZERO, WASM_ZERO));
166 EXPECT_SIZE(5, WASM_I32_IOR(WASM_ZERO, WASM_ZERO)); 165 EXPECT_SIZE(5, WASM_I32_IOR(WASM_ZERO, WASM_ZERO));
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 EXPECT_SIZE(5, WASM_LOAD_MEM_OFFSET(kMemTypes[i], 11, WASM_ZERO)); 322 EXPECT_SIZE(5, WASM_LOAD_MEM_OFFSET(kMemTypes[i], 11, WASM_ZERO));
324 } 323 }
325 for (size_t i = 0; i < arraysize(kMemTypes); i++) { 324 for (size_t i = 0; i < arraysize(kMemTypes); i++) {
326 EXPECT_SIZE(7, WASM_STORE_MEM_OFFSET(kMemTypes[i], 13, WASM_ZERO, 325 EXPECT_SIZE(7, WASM_STORE_MEM_OFFSET(kMemTypes[i], 13, WASM_ZERO,
327 WASM_GET_LOCAL(0))); 326 WASM_GET_LOCAL(0)));
328 } 327 }
329 } 328 }
330 } // namespace wasm 329 } // namespace wasm
331 } // namespace internal 330 } // namespace internal
332 } // namespace v8 331 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/wasm/loop-assignment-analysis-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698