keith_miller@apple.com | 85aeabb | 2016-06-03 23:06:39 +0000 | [diff] [blame] | 1 | count = createBuiltin("(function () { return @argumentCount(); })"); |
| 2 | countNoInline = createBuiltin("(function () { return @argumentCount(); })"); |
| 3 | noInline(countNoInline); |
| 4 | |
| 5 | |
| 6 | function inlineCount() { return count(); } |
| 7 | noInline(inlineCount); |
| 8 | |
| 9 | function inlineCount1() { return count(1); } |
| 10 | noInline(inlineCount1); |
| 11 | |
| 12 | function inlineCount2() { return count(1,2); } |
| 13 | noInline(inlineCount2); |
| 14 | |
| 15 | function inlineCountVarArgs(list) { return count(...list); } |
| 16 | noInline(inlineCountVarArgs); |
| 17 | |
| 18 | function assert(condition, message) { |
| 19 | if (!condition) |
| 20 | throw new Error(message); |
| 21 | } |
| 22 | |
| 23 | for (i = 0; i < 1000000; i++) { |
| 24 | assert(count(1,1,2) === 3, i); |
| 25 | assert(count() === 0, i); |
| 26 | assert(count(1) === 1, i); |
| 27 | assert(count(...[1,2,3,4,5]) === 5, i); |
| 28 | assert(count(...[]) === 0, i); |
| 29 | assert(inlineCount() === 0, i); |
| 30 | assert(inlineCount1() === 1, i); |
| 31 | assert(inlineCount2() === 2, i); |
| 32 | assert(inlineCountVarArgs([1,2,3,4]) === 4, i); |
| 33 | assert(inlineCountVarArgs([]) === 0, i); |
| 34 | // Insert extra junk so that inlineCountVarArgs.arguments.length !== count.arguments.length |
| 35 | assert(inlineCountVarArgs([1], 2, 4) === 1, i); |
| 36 | assert(countNoInline(4) === 1, i) |
| 37 | assert(countNoInline() === 0, i); |
| 38 | } |