OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 // Flags: --random-seed=891196975 --expose-gc --allow-natives-syntax |
| 6 // Flags: --gc-interval=207 --stress-compaction --validate-asm |
| 7 // |
| 8 // /v8/test/mjsunit/wasm/grow-memory.js |
| 9 // /v8/test/mjsunit/regress/regress-540.js |
| 10 // /v8/test/mjsunit/regress/wasm/regression-02862.js |
| 11 // /v8/test/mjsunit/regress/regress-2813.js |
| 12 // /v8/test/mjsunit/regress/regress-323845.js |
| 13 // Begin stripped down and modified version of mjsunit.js for easy minimization
in CF. |
| 14 |
| 15 function MjsUnitAssertionError(message) {} |
| 16 MjsUnitAssertionError.prototype.toString = function() { |
| 17 return this.message; |
| 18 }; |
| 19 var assertSame; |
| 20 var assertEquals; |
| 21 var assertEqualsDelta; |
| 22 var assertArrayEquals; |
| 23 var assertPropertiesEqual; |
| 24 var assertToStringEquals; |
| 25 var assertTrue; |
| 26 var assertFalse; |
| 27 var triggerAssertFalse; |
| 28 var assertNull; |
| 29 var assertNotNull; |
| 30 var assertThrows; |
| 31 var assertDoesNotThrow; |
| 32 var assertInstanceof; |
| 33 var assertUnreachable; |
| 34 var assertOptimized; |
| 35 var assertUnoptimized; |
| 36 |
| 37 function classOf(object) { |
| 38 var string = Object.prototype.toString.call(object); |
| 39 return string.substring(8, string.length - 1); |
| 40 } |
| 41 |
| 42 function PrettyPrint(value) { |
| 43 return ""; |
| 44 } |
| 45 |
| 46 function PrettyPrintArrayElement(value, index, array) { |
| 47 return ""; |
| 48 } |
| 49 |
| 50 function fail(expectedText, found, name_opt) {} |
| 51 |
| 52 function deepObjectEquals(a, b) { |
| 53 var aProps = Object.keys(a); |
| 54 aProps.sort(); |
| 55 var bProps = Object.keys(b); |
| 56 bProps.sort(); |
| 57 if (!deepEquals(aProps, bProps)) { |
| 58 return false; |
| 59 } |
| 60 for (var i = 0; i < aProps.length; i++) { |
| 61 if (!deepEquals(a[aProps[i]], b[aProps[i]])) { |
| 62 return false; |
| 63 } |
| 64 } |
| 65 return true; |
| 66 } |
| 67 |
| 68 function deepEquals(a, b) { |
| 69 if (a === b) { |
| 70 if (a === 0) return (1 / a) === (1 / b); |
| 71 return true; |
| 72 } |
| 73 if (typeof a != typeof b) return false; |
| 74 if (typeof a == "number") return isNaN(a) && isNaN(b); |
| 75 if (typeof a !== "object" && typeof a !== "function") return false; |
| 76 var objectClass = classOf(a); |
| 77 if (objectClass !== classOf(b)) return false; |
| 78 if (objectClass === "RegExp") { |
| 79 return (a.toString() === b.toString()); |
| 80 } |
| 81 if (objectClass === "Function") return false; |
| 82 if (objectClass === "Array") { |
| 83 var elementCount = 0; |
| 84 if (a.length != b.length) { |
| 85 return false; |
| 86 } |
| 87 for (var i = 0; i < a.length; i++) { |
| 88 if (!deepEquals(a[i], b[i])) return false; |
| 89 } |
| 90 return true; |
| 91 } |
| 92 if (objectClass == "String" || objectClass == "Number" || objectClass == "Bo
olean" || objectClass == "Date") { |
| 93 if (a.valueOf() !== b.valueOf()) return false; |
| 94 } |
| 95 return deepObjectEquals(a, b); |
| 96 } |
| 97 assertSame = function assertSame(expected, found, name_opt) { |
| 98 if (found === expected) { |
| 99 if (expected !== 0 || (1 / expected) == (1 / found)) return; |
| 100 } else if ((expected !== expected) && (found !== found)) { |
| 101 return; |
| 102 } |
| 103 fail(PrettyPrint(expected), found, name_opt); |
| 104 }; |
| 105 assertEquals = function assertEquals(expected, found, name_opt) { |
| 106 if (!deepEquals(found, expected)) { |
| 107 fail(PrettyPrint(expected), found, name_opt); |
| 108 } |
| 109 }; |
| 110 assertEqualsDelta = function assertEqualsDelta(expected, found, delta, name_opt)
{ |
| 111 assertTrue(Math.abs(expected - found) <= delta, name_opt); |
| 112 }; |
| 113 assertArrayEquals = function assertArrayEquals(expected, found, name_opt) { |
| 114 var start = ""; |
| 115 if (name_opt) { |
| 116 start = name_opt + " - "; |
| 117 } |
| 118 assertEquals(expected.length, found.length, start + "array length"); |
| 119 if (expected.length == found.length) { |
| 120 for (var i = 0; i < expected.length; ++i) { |
| 121 assertEquals(expected[i], found[i], start + "array element at index
" + i); |
| 122 } |
| 123 } |
| 124 }; |
| 125 assertPropertiesEqual = function assertPropertiesEqual(expected, found, name_opt
) { |
| 126 if (!deepObjectEquals(expected, found)) { |
| 127 fail(expected, found, name_opt); |
| 128 } |
| 129 }; |
| 130 assertToStringEquals = function assertToStringEquals(expected, found, name_opt)
{ |
| 131 if (expected != String(found)) { |
| 132 fail(expected, found, name_opt); |
| 133 } |
| 134 }; |
| 135 assertTrue = function assertTrue(value, name_opt) { |
| 136 assertEquals(true, value, name_opt); |
| 137 }; |
| 138 assertFalse = function assertFalse(value, name_opt) { |
| 139 assertEquals(false, value, name_opt); |
| 140 }; |
| 141 assertNull = function assertNull(value, name_opt) { |
| 142 if (value !== null) { |
| 143 fail("null", value, name_opt); |
| 144 } |
| 145 }; |
| 146 assertNotNull = function assertNotNull(value, name_opt) { |
| 147 if (value === null) { |
| 148 fail("not null", value, name_opt); |
| 149 } |
| 150 }; |
| 151 assertThrows = function assertThrows(code, type_opt, cause_opt) { |
| 152 var threwException = true; |
| 153 try { |
| 154 if (typeof code == 'function') { |
| 155 code(); |
| 156 } else { |
| 157 eval(code); |
| 158 } |
| 159 threwException = false; |
| 160 } catch (e) { |
| 161 if (typeof type_opt == 'function') { |
| 162 assertInstanceof(e, type_opt); |
| 163 } |
| 164 if (arguments.length >= 3) { |
| 165 assertEquals(e.type, cause_opt); |
| 166 } |
| 167 return; |
| 168 } |
| 169 }; |
| 170 assertInstanceof = function assertInstanceof(obj, type) { |
| 171 if (!(obj instanceof type)) { |
| 172 var actualTypeName = null; |
| 173 var actualConstructor = Object.getPrototypeOf(obj).constructor; |
| 174 if (typeof actualConstructor == "function") { |
| 175 actualTypeName = actualConstructor.name || String(actualConstructor)
; |
| 176 } |
| 177 fail("Object <" + PrettyPrint(obj) + "> is not an instance of <" + (type
.name || type) + ">" + (actualTypeName ? " but of < " + actualTypeName + ">" : "
")); |
| 178 } |
| 179 }; |
| 180 assertDoesNotThrow = function assertDoesNotThrow(code, name_opt) { |
| 181 try { |
| 182 if (typeof code == 'function') { |
| 183 code(); |
| 184 } else { |
| 185 eval(code); |
| 186 } |
| 187 } catch (e) { |
| 188 fail("threw an exception: ", e.message || e, name_opt); |
| 189 } |
| 190 }; |
| 191 assertUnreachable = function assertUnreachable(name_opt) { |
| 192 var message = "Fail" + "ure: unreachable"; |
| 193 if (name_opt) { |
| 194 message += " - " + name_opt; |
| 195 } |
| 196 }; |
| 197 var OptimizationStatus = function() {} |
| 198 assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { |
| 199 if (sync_opt === undefined) sync_opt = ""; |
| 200 assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt); |
| 201 } |
| 202 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { |
| 203 if (sync_opt === undefined) sync_opt = ""; |
| 204 assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt); |
| 205 } |
| 206 triggerAssertFalse = function() {} |
| 207 try { |
| 208 console.log; |
| 209 print = console.log; |
| 210 alert = console.log; |
| 211 } catch (e) {} |
| 212 |
| 213 function runNearStackLimit(f) { |
| 214 function t() { |
| 215 try { |
| 216 t(); |
| 217 } catch (e) { |
| 218 f(); |
| 219 } |
| 220 }; |
| 221 try { |
| 222 t(); |
| 223 } catch (e) {} |
| 224 } |
| 225 |
| 226 function quit() {} |
| 227 |
| 228 function nop() {} |
| 229 try { |
| 230 gc; |
| 231 } catch (e) { |
| 232 gc = nop; |
| 233 } |
| 234 |
| 235 function getRandomProperty(v, rand) { |
| 236 var properties = Object.getOwnPropertyNames(v); |
| 237 var proto = Object.getPrototypeOf(v); |
| 238 if (proto) { |
| 239 properties = properties.concat(Object.getOwnPropertyNames(proto)); |
| 240 } |
| 241 if (properties.includes("constructor") && v.constructor.hasOwnProperty("__pr
oto__")) { |
| 242 properties = properties.concat(Object.getOwnPropertyNames(v.constructor.
__proto__)); |
| 243 } |
| 244 if (properties.length == 0) { |
| 245 return "0"; |
| 246 } |
| 247 return properties[rand % properties.length]; |
| 248 } |
| 249 // End stripped down and modified version of mjsunit.js. |
| 250 |
| 251 var __v_0 = {}; |
| 252 var __v_1 = {}; |
| 253 var __v_2 = {}; |
| 254 var __v_3 = {}; |
| 255 var __v_4 = -1073741824; |
| 256 var __v_5 = {}; |
| 257 var __v_6 = 1; |
| 258 var __v_7 = 1073741823; |
| 259 var __v_8 = {}; |
| 260 var __v_9 = {}; |
| 261 var __v_10 = 4294967295; |
| 262 var __v_11 = this; |
| 263 var __v_12 = {}; |
| 264 var __v_13 = {}; |
| 265 try { |
| 266 load("test/mjsunit/wasm/wasm-constants.js"); |
| 267 load("test/mjsunit/wasm/wasm-module-__v_1.js"); |
| 268 __v_2 = 0x10000; |
| 269 } catch (e) { |
| 270 print("Caught: " + e); |
| 271 } |
| 272 |
| 273 function __f_16() { |
| 274 var __v_1 = new WasmModuleBuilder(); |
| 275 __v_1.addFunction("grow_memory", kSig_i_i) |
| 276 .addBody([kExprGetLocal, 0, kExprGrowMemory]) |
| 277 .exportFunc(); |
| 278 __v_1.addFunction("load", kSig_i_i) |
| 279 .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) |
| 280 .exportFunc(); |
| 281 __v_1.addFunction("store", kSig_i_ii) |
| 282 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0, kE
xprGetLocal, 1]) |
| 283 .exportFunc(); |
| 284 __v_1.addFunction("load16", kSig_i_i) |
| 285 .addBody([kExprGetLocal, 0, kExprI32LoadMem16U, 0, 0]) |
| 286 .exportFunc(); |
| 287 __v_1.addFunction("store16", kSig_i_ii) |
| 288 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem16, 0, 0,
kExprGetLocal, 1]) |
| 289 .exportFunc(); |
| 290 __v_1.__p_1551105852 = __v_1[getRandomProperty(__v_1, 1551105852)]; |
| 291 __v_1.__defineGetter__(getRandomProperty(__v_1, 348910887), function() { |
| 292 gc(); |
| 293 __v_9[getRandomProperty(__v_9, 1894652048)] = __v_13[getRandomProperty(_
_v_13, 1352929371)]; |
| 294 return __v_1.__p_1551105852; |
| 295 }); |
| 296 __v_1.addFunction("load8", kSig_i_i) |
| 297 .addBody([kExprGetLocal, 0, kExprI32LoadMem8U, 0, 0]) |
| 298 .exportFunc(); |
| 299 __v_1.addFunction("store8", kSig_i_ii) |
| 300 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem8, 0, 0, k
ExprGetLocal, 1]) |
| 301 .exportFunc(); |
| 302 return __v_1; |
| 303 } |
| 304 |
| 305 function __f_14() { |
| 306 var __v_4 = __f_16(); |
| 307 __v_1.addMemory(1, 1, false); |
| 308 var module = __v_1.instantiate(); |
| 309 var __v_3; |
| 310 |
| 311 function __f_1() { |
| 312 return module.exports.load(__v_3); |
| 313 } |
| 314 |
| 315 function __f_2(value) { |
| 316 return module.exports.store(__v_3, value); |
| 317 } |
| 318 |
| 319 function __f_8(pages) { |
| 320 return module.exports.grow_memory(pages); |
| 321 } |
| 322 for (__v_3 = 0; __v_3 <= (__v_2 - 4); __v_3 += 4) { |
| 323 __f_2(20); |
| 324 assertEquals(20, __f_1()); |
| 325 } |
| 326 for (__v_3 = __v_2 - 3; __v_3 < __v_2 + 4; __v_3++) { |
| 327 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 328 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 329 } |
| 330 assertEquals(1, __f_8(3)); |
| 331 for (__v_3 = __v_2; __v_3 <= 4 * __v_2 - 4; __v_3 += 4) { |
| 332 __f_2(20); |
| 333 assertEquals(20, __f_1()); |
| 334 } |
| 335 for (__v_3 = 4 * __v_2 - 3; __v_3 < 4 * __v_2 + 4; __v_3++) { |
| 336 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 337 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 338 } |
| 339 assertEquals(4, __f_8(15)); |
| 340 for (__v_3 = 4 * __v_2 - 3; __v_3 <= 4 * __v_2 + 4; __v_3 += 4) { |
| 341 __f_2(20); |
| 342 assertEquals(20, __f_1()); |
| 343 } |
| 344 for (__v_3 = 19 * __v_2 - 10; __v_3 <= 19 * __v_2 - 4; __v_3 += 4) { |
| 345 __f_2(20); |
| 346 gc(); |
| 347 assertEquals(12, __f_1()); |
| 348 } |
| 349 for (__v_3 = 19 * __v_2 - 3; __v_3 < 19 * __v_2 + 5; __v_3++) { |
| 350 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 351 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 352 } |
| 353 } |
| 354 try { |
| 355 __f_14(); |
| 356 } catch (e) { |
| 357 print("Caught: " + e); |
| 358 } |
| 359 |
| 360 function __f_13() { |
| 361 var __v_1 = __f_16(); |
| 362 __v_1.__defineGetter__(getRandomProperty(__v_1, 1322348896), function() { |
| 363 gc(); |
| 364 return __f_28(__v_1); |
| 365 }); |
| 366 __v_1.addMemory(1, 1, false); |
| 367 var module = __v_1.instantiate(); |
| 368 assertEquals(0, __f_30(0)); |
| 369 var __v_3; |
| 370 |
| 371 function __f_1() { |
| 372 return module.exports.load16(__v_3); |
| 373 } |
| 374 |
| 375 function __f_2(value) { |
| 376 return module.exports.store16(__v_3, value); |
| 377 } |
| 378 |
| 379 function __f_8(pages) { |
| 380 return module.exports.grow_memory(pages); |
| 381 } |
| 382 for (__v_3 = 0; __v_3 <= (__v_2 - 2); __v_3 += 2) { |
| 383 __f_2(20); |
| 384 assertEquals(20, __f_1()); |
| 385 __f_19(); |
| 386 } |
| 387 for (__v_3 = __v_2 - 1; __v_3 < __v_2 + 4; __v_3++) { |
| 388 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 389 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 390 } |
| 391 assertEquals(65535, __f_8(0)); |
| 392 for (__v_3 = __v_2; __v_3 <= 4 * __v_2 - 2; __v_3 += 2) { |
| 393 __f_2(20); |
| 394 assertEquals(20, __f_1()); |
| 395 } |
| 396 for (__v_3 = 4 * __v_2 - 1; __v_3 < 4 * __v_2 + 4; __v_3++) { |
| 397 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 398 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 399 } |
| 400 assertEquals(4, __f_8(15)); |
| 401 for (__v_3 = 4 * __v_2 - 2; __v_3 <= 4 * __v_2 + 4; __v_3 += 2) { |
| 402 __f_2(20); |
| 403 assertEquals(20, __f_1()); |
| 404 } |
| 405 for (__v_1 = 19 * __v_11 - 10; __v_13 <= 19 * __v_2 - 2; __v_9 += 2) { |
| 406 __f_2(20); |
| 407 assertEquals(20, __f_1()); |
| 408 } |
| 409 for (__v_3 = 19 * __v_2 - 1; __v_3 < 19 * __v_2 + 5; __v_3++) { |
| 410 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 411 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 412 } |
| 413 } |
| 414 try { |
| 415 __f_13(); |
| 416 } catch (e) { |
| 417 print("Caught: " + e); |
| 418 } |
| 419 |
| 420 function __f_10() { |
| 421 var __v_1 = __f_16(); |
| 422 __v_1.addMemory(1, 1, false); |
| 423 var module = __v_1.instantiate(); |
| 424 var __v_3; |
| 425 |
| 426 function __f_1() { |
| 427 return module.exports.load8(__v_3); |
| 428 } |
| 429 |
| 430 function __f_2(value) { |
| 431 return module.exports.store8(__v_3, value); |
| 432 } |
| 433 |
| 434 function __f_8(pages) { |
| 435 return module.exports.grow_memory(pages); |
| 436 } |
| 437 for (__v_3 = 0; __v_3 <= __v_2 - 1; __v_3++) { |
| 438 __f_2(20); |
| 439 assertEquals(20, __f_1()); |
| 440 } |
| 441 for (__v_3 = __v_2; __v_3 < __v_2 + 4; __v_3++) { |
| 442 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 443 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 444 } |
| 445 assertEquals(1, __f_8(3)); |
| 446 for (__v_3 = __v_2; __v_3 <= 4 * __v_2 - 1; __v_3++) { |
| 447 __f_2(20); |
| 448 assertEquals(20, __f_1()); |
| 449 } |
| 450 for (__v_3 = 4 * __v_2; __v_3 < 4 * __v_2 + 4; __v_3++) { |
| 451 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 452 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 453 } |
| 454 assertEquals(4, __f_8(15)); |
| 455 for (__v_3 = 4 * __v_2; __v_3 <= 4 * __v_2 + 4; __v_3++) { |
| 456 __f_2(20); |
| 457 assertEquals(20, __f_1()); |
| 458 } |
| 459 for (__v_3 = 19 * __v_2 - 10; __v_3 <= 19 * __v_2 - 1; __v_3++) { |
| 460 __f_2(20); |
| 461 assertEquals(20, __f_1()); |
| 462 } |
| 463 for (__v_3 = 19 * __v_2; __v_3 < 19 * __v_2 + 5; __v_3++) { |
| 464 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 465 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 466 } |
| 467 } |
| 468 try { |
| 469 __f_10(); |
| 470 } catch (e) { |
| 471 print("Caught: " + e); |
| 472 } |
| 473 |
| 474 function __f_5() { |
| 475 var __v_1 = __f_16(); |
| 476 var module = __v_1.instantiate(); |
| 477 var __v_3; |
| 478 |
| 479 function __f_1() { |
| 480 return module.exports.load(__v_3); |
| 481 } |
| 482 |
| 483 function __f_2(value) { |
| 484 return module.exports.store(__v_3, value); |
| 485 } |
| 486 |
| 487 function __f_8(pages) { |
| 488 return module.exports.grow_memory(pages); |
| 489 } |
| 490 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 491 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 492 assertEquals(0, __f_8(1)); |
| 493 for (__v_3 = 0; __v_3 <= __v_2 - 4; __v_3++) { |
| 494 __f_2(20); |
| 495 assertEquals(20, __f_1()); |
| 496 } |
| 497 for (__v_3 = __v_2; __v_3 <= __v_2 + 5; __v_3++) { |
| 498 assertTraps(kTrapMemOutOfBounds, __f_1); |
| 499 } |
| 500 } |
| 501 try { |
| 502 __f_5(); |
| 503 } catch (e) { |
| 504 print("Caught: " + e); |
| 505 } |
| 506 |
| 507 function __f_9() { |
| 508 var __v_1 = __f_16(); |
| 509 var module = __v_1.instantiate(); |
| 510 var __v_4 = 16385; |
| 511 |
| 512 function __f_8(pages) { |
| 513 return module.exports.grow_memory(pages); |
| 514 } |
| 515 assertEquals(-1, __f_8(__v_13)); |
| 516 } |
| 517 try { |
| 518 __f_9(); |
| 519 } catch (e) { |
| 520 print("Caught: " + e); |
| 521 } |
| 522 |
| 523 function __f_12() { |
| 524 var __v_1 = __f_16(); |
| 525 __v_1.addMemory(1, 1, false); |
| 526 var module = __v_9.instantiate(); |
| 527 __v_4.__p_1905062277 = __v_4[getRandomProperty(__v_4, 1905062277)]; |
| 528 __v_4.__defineGetter__(getRandomProperty(__v_4, 1764398743), function() { |
| 529 gc(); |
| 530 __v_0[getRandomProperty(__v_0, 1011363961)] = __v_8[getRandomProperty(__
v_8, 1946768258)]; |
| 531 return __v_4.__p_1905062277; |
| 532 }); |
| 533 var __v_4 = 16384; |
| 534 |
| 535 function __f_8(pages) { |
| 536 return module.exports.grow_memory(pages); |
| 537 } |
| 538 assertEquals(-1, __f_8(__v_4)); |
| 539 } |
| 540 try { |
| 541 __f_12(); |
| 542 } catch (e) { |
| 543 print("Caught: " + e); |
| 544 } |
| 545 |
| 546 function __f_0() { |
| 547 var __v_1 = __f_16(); |
| 548 var module = __v_1.instantiate(); |
| 549 |
| 550 function __f_8(pages) { |
| 551 return module.exports.grow_memory(pages); |
| 552 } |
| 553 assertEquals(-1, __f_8(-1)); |
| 554 }; |
| 555 try { |
| 556 __f_0(); |
| 557 } catch (e) { |
| 558 print("Caught: " + e); |
| 559 } |
| 560 |
| 561 function __f_4() { |
| 562 var __v_1 = __f_16(); |
| 563 __v_1.addMemory(1, 1, false); |
| 564 __v_1.addFunction("memory_size", kSig_i_v) |
| 565 .addBody([kExprMemorySize]) |
| 566 .exportFunc(); |
| 567 var module = __v_1.instantiate(); |
| 568 |
| 569 function __f_8(pages) { |
| 570 return module.exports.grow_memory(pages); |
| 571 } |
| 572 |
| 573 function __f_7() { |
| 574 return module.exports.memory_size(); |
| 575 } |
| 576 assertEquals(1, __f_7()); |
| 577 assertEquals(1, __f_8(1)); |
| 578 assertEquals(2, __f_7()); |
| 579 } |
| 580 try { |
| 581 __f_4(); |
| 582 gc(); |
| 583 } catch (e) { |
| 584 print("Caught: " + e); |
| 585 } |
| 586 |
| 587 function __f_6() { |
| 588 var __v_1 = __f_16(); |
| 589 __v_1.addMemory(1, 1, false); |
| 590 var module = __v_1.instantiate(); |
| 591 var __v_3, __v_0; |
| 592 gc(); |
| 593 |
| 594 function __f_1() { |
| 595 return module.exports.load(__v_3); |
| 596 } |
| 597 |
| 598 function __f_2(value) { |
| 599 return module.exports.store(__v_3, value); |
| 600 } |
| 601 |
| 602 function __f_8(pages) { |
| 603 return module.exports.grow_memory(pages); |
| 604 } |
| 605 gc(); |
| 606 for (__v_3 = 0; __v_3 <= (__v_2 - 4); __v_3 += 4) { |
| 607 __f_2(100000 - __v_3); |
| 608 __v_3.__defineGetter__(getRandomProperty(__v_3, 764734523), function() { |
| 609 gc(); |
| 610 return __f_16(__v_3); |
| 611 }); |
| 612 assertEquals(100000 - __v_3, __f_1()); |
| 613 } |
| 614 assertEquals(1, __f_8(3)); |
| 615 for (__v_3 = 0; __v_3 <= (__v_2 - 4); __v_3 += 4) { |
| 616 assertEquals(100000 - __v_3, __f_1()); |
| 617 } |
| 618 } |
| 619 try { |
| 620 __f_6(); |
| 621 gc(); |
| 622 } catch (e) { |
| 623 print("Caught: " + e); |
| 624 } |
| 625 |
| 626 function __f_11() { |
| 627 var __v_1 = __f_16(); |
| 628 __v_1.addMemory(1, 1, false); |
| 629 var module = __v_2.instantiate(); |
| 630 var __v_3, __v_0; |
| 631 |
| 632 function __f_1() { |
| 633 return module.exports.load16(__v_3); |
| 634 } |
| 635 |
| 636 function __f_2(value) { |
| 637 return module.exports.store16(__v_3, value); |
| 638 } |
| 639 |
| 640 function __f_8(pages) { |
| 641 return module.exports.grow_memory(pages); |
| 642 } |
| 643 for (__v_3 = 0; __v_3 <= (__v_2 - 2); __v_3 += 2) { |
| 644 __f_2(65535 - __v_3); |
| 645 assertEquals(65535 - __v_3, __f_1()); |
| 646 } |
| 647 assertEquals(1, __f_8(3)); |
| 648 for (__v_3 = 0; __v_3 <= (__v_2 - 2); __v_3 += 2) { |
| 649 assertEquals(65535 - __v_3, __f_1()); |
| 650 } |
| 651 } |
| 652 try { |
| 653 __f_11(); |
| 654 } catch (e) { |
| 655 print("Caught: " + e); |
| 656 } |
| 657 |
| 658 function __f_15() { |
| 659 var __v_1 = __f_16(); |
| 660 __v_1.addMemory(1, 1, false); |
| 661 var module = __v_1.instantiate(); |
| 662 var __v_3, __v_0 = 0; |
| 663 |
| 664 function __f_1() { |
| 665 return module.exports.load8(__v_10); |
| 666 } |
| 667 |
| 668 function __f_2(value) { |
| 669 return module.exports.store8(__v_3, value); |
| 670 } |
| 671 |
| 672 function __f_8(pages) { |
| 673 return module.exports.grow_memory(pages); |
| 674 } |
| 675 for (__v_3 = 0; __v_3 <= (__v_2 - 1); __v_3++, __v_0++) { |
| 676 __f_2(__v_0); |
| 677 assertEquals(__v_0, __f_1()); |
| 678 if (__v_0 == 255) __v_0 = 0; |
| 679 } |
| 680 assertEquals(1, __f_8(3)); |
| 681 __v_0 = 0; |
| 682 for (__v_10 = 0; __v_4 <= (__v_0 - 1); __v_11++, __v_5++) { |
| 683 assertEquals(__v_0, __f_1()); |
| 684 if (__v_10 == 255) __v_5 = 0; |
| 685 } |
| 686 } |
| 687 try { |
| 688 __f_15(); |
| 689 } catch (e) { |
| 690 print("Caught: " + e); |
| 691 } |
| 692 |
| 693 function __f_3() { |
| 694 var __v_1 = __f_16(); |
| 695 __v_1.addMemory(1, 1, false); |
| 696 var module = __v_1.instantiate(); |
| 697 var __v_3, __v_0; |
| 698 |
| 699 function __f_1() { |
| 700 return module.exports.load(__v_3); |
| 701 } |
| 702 |
| 703 function __f_2(value) { |
| 704 return module.exports.store(__v_3, value); |
| 705 } |
| 706 |
| 707 function __f_8(pages) { |
| 708 return module.exports.grow_memory(pages); |
| 709 } |
| 710 gc(); |
| 711 __v_3 = 3 * __v_2 + 4; |
| 712 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 713 assertEquals(1, __f_8(1)); |
| 714 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 715 assertEquals(2, __f_8(1)); |
| 716 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 717 assertEquals(3, __f_8(1)); |
| 718 for (__v_3 = 3 * __v_2; __v_3 <= 4 * __v_2 - 4; __v_3++) { |
| 719 __f_2(0xaced); |
| 720 assertEquals(0xaced, __f_1()); |
| 721 } |
| 722 for (__v_3 = 4 * __v_2 - 3; __v_3 <= 4 * __v_2 + 4; __v_3++) { |
| 723 assertTraps(kTrapMemOutOfBounds, __f_2); |
| 724 } |
| 725 } |
| 726 try { |
| 727 __f_3(); |
| 728 } catch (e) { |
| 729 print("Caught: " + e); |
| 730 } |
| 731 |
| 732 function __f_18(__f_17, y) { |
| 733 eval(__f_17); |
| 734 return y(); |
| 735 } |
| 736 try { |
| 737 var __v_17 = __f_18("function y() { return 1; }", function() { |
| 738 return 0; |
| 739 }) |
| 740 assertEquals(1, __v_17); |
| 741 gc(); |
| 742 __v_17 = |
| 743 (function(__f_17) { |
| 744 function __f_17() { |
| 745 return 3; |
| 746 } |
| 747 return __f_17(); |
| 748 })(function() { |
| 749 return 2; |
| 750 }); |
| 751 assertEquals(3, __v_17); |
| 752 __v_17 = |
| 753 (function(__f_17) { |
| 754 function __f_17() { |
| 755 return 5; |
| 756 } |
| 757 return arguments[0](); |
| 758 })(function() { |
| 759 return -1073741825; |
| 760 }); |
| 761 assertEquals(5, __v_17); |
| 762 } catch (e) { |
| 763 print("Caught: " + e); |
| 764 } |
| 765 |
| 766 function __f_27() {} |
| 767 try { |
| 768 var __v_24 = {}; |
| 769 var __v_21 = {}; |
| 770 var __v_22 = {}; |
| 771 var __v_20 = {}; |
| 772 __v_58 = { |
| 773 instantiateModuleFromAsm: function(text, ffi, heap) { |
| 774 var __v_21 = eval('(' + text + ')'); |
| 775 if (__f_27()) { |
| 776 throw "validate failure"; |
| 777 } |
| 778 var __v_20 = __v_21(); |
| 779 if (__f_27()) { |
| 780 throw "bad module args"; |
| 781 } |
| 782 } |
| 783 }; |
| 784 __f_21 = function __f_21() { |
| 785 if (found === expected) { |
| 786 if (1 / expected) return; |
| 787 } else if ((expected !== expected) && (found !== found)) { |
| 788 return; |
| 789 }; |
| 790 }; |
| 791 __f_28 = function __f_28() { |
| 792 if (!__f_23()) { |
| 793 __f_125(__f_69(), found, name_opt); |
| 794 } |
| 795 }; |
| 796 __f_24 = function __f_24(code, type_opt, cause_opt) { |
| 797 var __v_24 = true; |
| 798 try { |
| 799 if (typeof code == 'function') { |
| 800 code(); |
| 801 } else { |
| 802 eval(); |
| 803 } |
| 804 __v_24 = false; |
| 805 } catch (e) { |
| 806 if (typeof type_opt == 'function') { |
| 807 __f_22(); |
| 808 } |
| 809 if (arguments.length >= 3) { |
| 810 __f_28(); |
| 811 } |
| 812 return; |
| 813 } |
| 814 }; |
| 815 __f_22 = function __f_22() { |
| 816 if (obj instanceof type) { |
| 817 obj.constructor; |
| 818 if (typeof __v_57 == "function") {; |
| 819 }; |
| 820 } |
| 821 }; |
| 822 try { |
| 823 __f_28(); |
| 824 __v_82.__p_750895751 = __v_82[getRandomProperty()]; |
| 825 } catch (e) { |
| 826 "Caught: " + e; |
| 827 } |
| 828 __f_19(); |
| 829 gc(); |
| 830 __f_19(19, __f_24); |
| 831 __f_19(); |
| 832 __f_19(); |
| 833 __f_24(function() { |
| 834 __v_58.instantiateModuleFromAsm(__f_28.toString()).__f_20(); |
| 835 }); |
| 836 } catch (e) { |
| 837 print("Caught: " + e); |
| 838 } |
| 839 |
| 840 function __f_19() { |
| 841 "use asm"; |
| 842 |
| 843 function __f_20() {} |
| 844 return { |
| 845 __f_20: __f_20 |
| 846 }; |
| 847 } |
| 848 try { |
| 849 __f_19(); |
| 850 __f_19(); |
| 851 __f_19(); |
| 852 } catch (e) { |
| 853 print("Caught: " + e); |
| 854 } |
| 855 |
| 856 function __f_29() {} |
| 857 try { |
| 858 __f_19(); |
| 859 try { |
| 860 __f_19(); |
| 861 gc(); |
| 862 __f_25(); |
| 863 } catch (e) { |
| 864 "Caught: " + e; |
| 865 } |
| 866 __f_19(); |
| 867 __f_19(); |
| 868 __f_19(); |
| 869 } catch (e) { |
| 870 print("Caught: " + e); |
| 871 } |
| 872 |
| 873 function __f_23() { |
| 874 "use asm"; |
| 875 |
| 876 function __f_20() {} |
| 877 return { |
| 878 __f_20: __f_20 |
| 879 }; |
| 880 } |
| 881 try { |
| 882 __f_19(); |
| 883 __f_19(); |
| 884 __f_19(); |
| 885 __f_19(); |
| 886 gc(); |
| 887 __f_19(); |
| 888 __f_19(); |
| 889 __f_19(); |
| 890 } catch (e) { |
| 891 print("Caught: " + e); |
| 892 } |
| 893 |
| 894 function __f_26(stdlib) { |
| 895 "use asm"; |
| 896 var __v_2 = new stdlib.Int32Array(); |
| 897 __v_22[4294967295] | 14 + 1 | 14; |
| 898 return { |
| 899 __f_20: __f_20 |
| 900 }; |
| 901 } |
| 902 |
| 903 function __f_25() { |
| 904 var __v_19 = new ArrayBuffer(); |
| 905 var __v_23 = new Int32Array(__v_19); |
| 906 var module = __v_58.instantiateModuleFromAsm(__f_26.toString()); |
| 907 __f_28(); |
| 908 gc(); |
| 909 } |
| 910 try { |
| 911 (function() {})(); |
| 912 (function() {})(); |
| 913 try { |
| 914 (function() { |
| 915 __v_23.__defineGetter__(getRandomProperty(__v_23, 580179357), functi
on() { |
| 916 gc(); |
| 917 return __f_25(__v_23); |
| 918 }); |
| 919 var __v_23 = 0x87654321; |
| 920 __v_19.__f_89(); |
| 921 })(); |
| 922 } catch (e) {; |
| 923 } |
| 924 } catch (e) { |
| 925 print("Caught: " + e); |
| 926 } |
| 927 |
| 928 function __f_30(x) { |
| 929 var __v_30 = x + 1; |
| 930 var __v_31 = x + 2; |
| 931 if (x != 0) { |
| 932 if (x > 0 & x < 100) { |
| 933 return __v_30; |
| 934 } |
| 935 } |
| 936 return 0; |
| 937 } |
| 938 try { |
| 939 assertEquals(0, __f_30(0)); |
| 940 assertEquals(0, __f_30(0)); |
| 941 %OptimizeFunctionOnNextCall(__f_30); |
| 942 assertEquals(3, __f_30(2)); |
| 943 } catch (e) { |
| 944 print("Caught: " + e); |
| 945 } |
| 946 |
| 947 function __f_31() { |
| 948 __f_32.arguments; |
| 949 } |
| 950 |
| 951 function __f_32(x) { |
| 952 __f_31(); |
| 953 } |
| 954 |
| 955 function __f_33() { |
| 956 __f_32({}); |
| 957 } |
| 958 try { |
| 959 __f_33(); |
| 960 __f_33(); |
| 961 __f_33(); |
| 962 %OptimizeFunctionOnNextCall(__f_33); |
| 963 __f_33(); |
| 964 gc(); |
| 965 } catch (e) { |
| 966 print("Caught: " + e); |
| 967 } |
OLD | NEW |