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

Side by Side Diff: test/mjsunit/wasm/asm-wasm.js

Issue 1692713006: Allow looser heap accesses historically emitted by Emscripten. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-asm-validator.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 // Flags: --expose-wasm 5 // Flags: --expose-wasm
6 6
7 function EmptyTest() { 7 function EmptyTest() {
8 "use asm"; 8 "use asm";
9 function caller() { 9 function caller() {
10 empty(); 10 empty();
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 valueOf: function() { return 99; } 1163 valueOf: function() { return 99; }
1164 }; 1164 };
1165 TestCase({foo: o, bar: o, baz: o}, 99, 99, 99, 99); 1165 TestCase({foo: o, bar: o, baz: o}, 99, 99, 99, 99);
1166 // Check that function values are converted properly. 1166 // Check that function values are converted properly.
1167 TestCase({foo: TestCase, bar: TestCase, qux: TestCase}, 0, NaN, 0, NaN); 1167 TestCase({foo: TestCase, bar: TestCase, qux: TestCase}, 0, NaN, 0, NaN);
1168 // Check that a missing ffi object is safe. 1168 // Check that a missing ffi object is safe.
1169 TestCase(undefined, 0, NaN, 0, NaN); 1169 TestCase(undefined, 0, NaN, 0, NaN);
1170 } 1170 }
1171 1171
1172 TestForeignVariables(); 1172 TestForeignVariables();
1173
1174
1175 (function() {
1176 function TestByteHeapAccessCompat(stdlib, foreign, buffer) {
1177 "use asm";
1178
1179 var HEAP8 = new stdlib.Uint8Array(buffer);
1180 var HEAP32 = new stdlib.Int32Array(buffer);
1181
1182 function store(i, v) {
1183 i = i | 0;
1184 v = v | 0;
1185 HEAP32[i >> 2] = v;
1186 }
1187
1188 function storeb(i, v) {
1189 i = i | 0;
1190 v = v | 0;
1191 HEAP8[i | 0] = v;
1192 }
1193
1194 function load(i) {
1195 i = i | 0;
1196 return HEAP8[i] | 0;
1197 }
1198
1199 function iload(i) {
1200 i = i | 0;
1201 return HEAP8[HEAP32[i >> 2] | 0] | 0;
1202 }
1203
1204 return {load: load, iload: iload, store: store, storeb: storeb};
1205 }
1206
1207 var m = _WASMEXP_.instantiateModuleFromAsm(
1208 TestByteHeapAccessCompat.toString());
1209 m.store(0, 20);
1210 m.store(4, 21);
1211 m.store(8, 22);
1212 m.storeb(20, 123);
1213 m.storeb(21, 42);
1214 m.storeb(22, 77);
1215 assertEquals(123, m.load(20));
1216 assertEquals(42, m.load(21));
1217 assertEquals(77, m.load(22));
1218 assertEquals(123, m.iload(0));
1219 assertEquals(42, m.iload(4));
1220 assertEquals(77, m.iload(8));
1221 })();
OLDNEW
« no previous file with comments | « test/cctest/test-asm-validator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698