OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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: --allow-natives-syntax --expose-gc |
| 6 |
| 7 var assertDoesNotThrow; |
| 8 var assertInstanceof; |
| 9 var assertUnreachable; |
| 10 var assertOptimized; |
| 11 var assertUnoptimized; |
| 12 function classOf(object) { var string = Object.prototype.toString.call(object);
return string.substring(8, string.length - 1); } |
| 13 function PrettyPrint(value) { return ""; } |
| 14 function PrettyPrintArrayElement(value, index, array) { return ""; } |
| 15 function fail(expectedText, found, name_opt) { } |
| 16 function deepObjectEquals(a, b) { var aProps = Object.keys(a); aProps.sort(); va
r bProps = Object.keys(b); bProps.sort(); if (!deepEquals(aProps, bProps)) { ret
urn false; } for (var i = 0; i < aProps.length; i++) { if (!deepEquals(a[aProps[
i]], b[aProps[i]])) { return false; } } return true; } |
| 17 function deepEquals(a, b) { if (a === b) { if (a === 0) return (1 / a) === (1 /
b); return true; } if (typeof a != typeof b) return false; if (typeof a == "numb
er") return isNaN(a) && isNaN(b); if (typeof a !== "object" && typeof a !== "fun
ction") return false; var objectClass = classOf(a); if (objectClass !== classOf(
b)) return false; if (objectClass === "RegExp") { return (a.toString() === b.toS
tring()); } if (objectClass === "Function") return false; if (objectClass === "A
rray") { var elementCount = 0; if (a.length != b.length) { return false; } for (
var i = 0; i < a.length; i++) { if (!deepEquals(a[i], b[i])) return false; } ret
urn true; } if (objectClass == "String" || objectClass == "Number" || objectClas
s == "Boolean" || objectClass == "Date") { if (a.valueOf() !== b.valueOf()) retu
rn false; } return deepObjectEquals(a, b); } |
| 18 assertSame = function assertSame(expected, found, name_opt) { if (found === expe
cted) { if (expected !== 0 || (1 / expected) == (1 / found)) return; } else if (
(expected !== expected) && (found !== found)) { return; } fail(PrettyPrint(expec
ted), found, name_opt); }; assertEquals = function assertEquals(expected, found,
name_opt) { if (!deepEquals(found, expected)) { fail(PrettyPrint(expected), fou
nd, name_opt); } }; |
| 19 assertEqualsDelta = function assertEqualsDelta(expected, found, delta, name_opt)
{ assertTrue(Math.abs(expected - found) <= delta, name_opt); }; |
| 20 assertArrayEquals = function assertArrayEquals(expected, found, name_opt) { var
start = ""; if (name_opt) { start = name_opt + " - "; } assertEquals(expected.le
ngth, found.length, start + "array length"); if (expected.length == found.length
) { for (var i = 0; i < expected.length; ++i) { assertEquals(expected[i], found[
i], start + "array element at index " + i); } } }; |
| 21 assertPropertiesEqual = function assertPropertiesEqual(expected, found, name_opt
) { if (!deepObjectEquals(expected, found)) { fail(expected, found, name_opt); }
}; |
| 22 assertToStringEquals = function assertToStringEquals(expected, found, name_opt)
{ if (expected != String(found)) { fail(expected, found, name_opt); } }; |
| 23 assertTrue = function assertTrue(value, name_opt) { assertEquals(true, value, na
me_opt); }; |
| 24 assertFalse = function assertFalse(value, name_opt) { assertEquals(false, value,
name_opt); }; |
| 25 assertNull = function assertNull(value, name_opt) { if (value !== null) { fail("
null", value, name_opt); } }; |
| 26 assertNotNull = function assertNotNull(value, name_opt) { if (value === null) {
fail("not null", value, name_opt); } }; |
| 27 var __v_39 = {}; |
| 28 var __v_40 = {}; |
| 29 var __v_41 = {}; |
| 30 var __v_42 = {}; |
| 31 var __v_43 = {}; |
| 32 var __v_44 = {}; |
| 33 try { |
| 34 __v_0 = [1.5,,1.7]; |
| 35 __v_1 = {__v_0:1.8}; |
| 36 } catch(e) { print("Caught: " + e); } |
| 37 function __f_0(__v_1,__v_0,i) { |
| 38 __v_1.a = __v_0[i]; |
| 39 gc(); |
| 40 } |
| 41 try { |
| 42 __f_0(__v_1,__v_0,0); |
| 43 __f_0(__v_1,__v_0,0); |
| 44 %OptimizeFunctionOnNextCall(__f_0); |
| 45 __f_0(__v_1,__v_0,1); |
| 46 assertEquals(undefined, __v_1.a); |
| 47 __v_0 = [1,,3]; |
| 48 __v_1 = {ab:5}; |
| 49 } catch(e) { print("Caught: " + e); } |
| 50 function __f_1(__v_1,__v_0,i) { |
| 51 __v_1.ab = __v_0[i]; |
| 52 } |
| 53 try { |
| 54 __f_1(__v_1,__v_0,1); |
| 55 } catch(e) { print("Caught: " + e); } |
| 56 function __f_5(x) { |
| 57 return ~x; |
| 58 } |
| 59 try { |
| 60 __f_5(42); |
| 61 assertEquals(~12, __f_5(12.45)); |
| 62 assertEquals(~46, __f_5(42.87)); |
| 63 __v_2 = 1, __v_4 = 2, __v_3 = 4, __v_6 = 8; |
| 64 } catch(e) { print("Caught: " + e); } |
| 65 function __f_4() { |
| 66 return __v_2 | (__v_4 | (__v_3 | __v_6)); |
| 67 } |
| 68 try { |
| 69 __f_4(); |
| 70 __v_3 = "16"; |
| 71 assertEquals(17 | -13 | 0 | -5, __f_4()); |
| 72 } catch(e) { print("Caught: " + e); } |
| 73 function __f_6() { |
| 74 return __f_4(); |
| 75 } |
| 76 try { |
| 77 assertEquals(1 | 2 | 16 | 8, __f_6()); |
| 78 __f_4 = function() { return 42; }; |
| 79 assertEquals(42, __f_6()); |
| 80 __v_5 = {}; |
| 81 __v_5.__f_4 = __f_4; |
| 82 } catch(e) { print("Caught: " + e); } |
| 83 function __f_7(o) { |
| 84 return o.__f_4(); |
| 85 } |
| 86 try { |
| 87 for (var __v_7 = 0; __v_7 < 5; __v_7++) __f_7(__v_5); |
| 88 %OptimizeFunctionOnNextCall(__f_7); |
| 89 __f_7(__v_5); |
| 90 assertEquals(42, __f_7(__v_5)); |
| 91 assertEquals(87, __f_7({__f_4: function() { return 87; }})); |
| 92 } catch(e) { print("Caught: " + e); } |
| 93 function __f_8(x,y) { |
| 94 x = 42; |
| 95 y = 1; |
| 96 y = y << "0"; |
| 97 return x | y; |
| 98 } |
| 99 try { |
| 100 assertEquals(43, __f_8(0,0)); |
| 101 } catch(e) { print("Caught: " + e); } |
| 102 function __f_2(x) { |
| 103 return 'lit[' + (x + ']'); |
| 104 } |
| 105 try { |
| 106 assertEquals('lit[-87]', __f_2(-87)); |
| 107 assertEquals('lit[0]', __f_2(0)); |
| 108 assertEquals('lit[42]', __f_2(42)); |
| 109 __v_9 = "abc"; |
| 110 gc(); |
| 111 var __v_8; |
| 112 } catch(e) { print("Caught: " + e); } |
| 113 function __f_9(n) { return __v_9.charAt(n); } |
| 114 try { |
| 115 for (var __v_7 = 0; __v_7 < 5; __v_7++) { |
| 116 __v_8 = __f_9(0); |
| 117 } |
| 118 %OptimizeFunctionOnNextCall(__f_9); |
| 119 __v_8 = __f_9(0); |
| 120 } catch(e) { print("Caught: " + e); } |
| 121 function __f_3(__v_2,__v_4,__v_3,__v_6) { |
| 122 return __v_2+__v_4+__v_3+__v_6; |
| 123 } |
| 124 try { |
| 125 assertEquals(0x40000003, __f_3(1,1,2,0x3fffffff)); |
| 126 } catch(e) { print("Caught: " + e); } |
| 127 try { |
| 128 __v_19 = { |
| 129 fast_smi_only : 'fast smi only elements', |
| 130 fast : 'fast elements', |
| 131 fast_double : 'fast double elements', |
| 132 dictionary : 'dictionary elements', |
| 133 external_int32 : 'external int8 elements', |
| 134 external_uint8 : 'external uint8 elements', |
| 135 external_int16 : 'external int16 elements', |
| 136 external_uint16 : 'external uint16 elements', |
| 137 external_int32 : 'external int32 elements', |
| 138 external_uint32 : 'external uint32 elements', |
| 139 external_float32 : 'external float32 elements', |
| 140 external_float64 : 'external float64 elements', |
| 141 external_uint8_clamped : 'external uint8_clamped elements', |
| 142 fixed_int32 : 'fixed int8 elements', |
| 143 fixed_uint8 : 'fixed uint8 elements', |
| 144 fixed_int16 : 'fixed int16 elements', |
| 145 fixed_uint16 : 'fixed uint16 elements', |
| 146 fixed_int32 : 'fixed int32 elements', |
| 147 fixed_uint32 : 'fixed uint32 elements', |
| 148 fixed_float32 : 'fixed float32 elements', |
| 149 fixed_float64 : 'fixed float64 elements', |
| 150 fixed_uint8_clamped : 'fixed uint8_clamped elements' |
| 151 } |
| 152 } catch(e) { print("Caught: " + e); } |
| 153 function __f_12() { |
| 154 } |
| 155 __v_10 = {}; |
| 156 __v_10.dance = 0xD15C0; |
| 157 __v_10.drink = 0xC0C0A; |
| 158 __f_12(__v_19.fast, __v_10); |
| 159 __v_24 = [1,2,3]; |
| 160 __f_12(__v_19.fast_smi_only, __v_24); |
| 161 __v_24.dance = 0xD15C0; |
| 162 __v_24.drink = 0xC0C0A; |
| 163 __f_12(__v_19.fast_smi_only, __v_24); |
| 164 function __f_18() { |
| 165 var __v_27 = new Array(); |
| 166 __f_12(__v_19.fast_smi_only, __v_27); |
| 167 for (var __v_18 = 0; __v_18 < 1337; __v_18++) { |
| 168 var __v_16 = __v_18; |
| 169 if (__v_18 == 1336) { |
| 170 __f_12(__v_19.fast_smi_only, __v_27); |
| 171 __v_16 = new Object(); |
| 172 } |
| 173 __v_27[__v_18] = __v_16; |
| 174 } |
| 175 __f_12(__v_19.fast, __v_27); |
| 176 var __v_15 = []; |
| 177 __v_15[912570] = 7; |
| 178 __f_12(__v_19.dictionary, __v_15); |
| 179 var __v_26 = new Array(912561); |
| 180 %SetAllocationTimeout(100000000, 10000000); |
| 181 for (var __v_18 = 0; __v_18 < 0x20000; __v_18++) { |
| 182 __v_26[0] = __v_18 / 2; |
| 183 } |
| 184 __f_12(__v_19.fixed_int8, new Int8Array(007)); |
| 185 __f_12(__v_19.fixed_uint8, new Uint8Array(007)); |
| 186 __f_12(__v_19.fixed_int16, new Int16Array(666)); |
| 187 __f_12(__v_19.fixed_uint16, new Uint16Array(42)); |
| 188 __f_12(__v_19.fixed_int32, new Int32Array(0xF)); |
| 189 __f_12(__v_19.fixed_uint32, new Uint32Array(23)); |
| 190 __f_12(__v_19.fixed_float32, new Float32Array(7)); |
| 191 __f_12(__v_19.fixed_float64, new Float64Array(0)); |
| 192 __f_12(__v_19.fixed_uint8_clamped, new Uint8ClampedArray(512)); |
| 193 var __v_13 = new ArrayBuffer(128); |
| 194 __f_12(__v_19.external_int8, new Int8Array(__v_13)); |
| 195 __f_12(__v_37.external_uint8, new Uint8Array(__v_13)); |
| 196 __f_12(__v_19.external_int16, new Int16Array(__v_13)); |
| 197 __f_12(__v_19.external_uint16, new Uint16Array(__v_13)); |
| 198 __f_12(__v_19.external_int32, new Int32Array(__v_13)); |
| 199 __f_12(__v_19.external_uint32, new Uint32Array(__v_13)); |
| 200 __f_12(__v_19.external_float32, new Float32Array(__v_13)); |
| 201 __f_12(__v_19.external_float64, new Float64Array(__v_13)); |
| 202 __f_12(__v_19.external_uint8_clamped, new Uint8ClampedArray(__v_13)); |
| 203 } |
| 204 try { |
| 205 __f_18(); |
| 206 } catch(e) { } |
OLD | NEW |