inline-exception-1.js 45.9 KB
Newer Older
1 2 3 4 5 6
// Shard 1.

// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

7
// Flags: --allow-natives-syntax --no-always-opt
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

// This test file was generated by tools/gen-inlining-tests.py .

// Global variables
var deopt = undefined; // either true or false
var counter = 0;

function resetState() {
  counter = 0;
}

function warmUp(f) {
  try {
    f();
  } catch (ex) {
    // ok
  }
  try {
    f();
  } catch (ex) {
    // ok
  }
}

function resetOptAndAssertResultEquals(expected, f) {
33
  %PrepareFunctionForOptimization(f);
34 35 36 37 38 39 40 41 42
  warmUp(f);
  resetState();
  // %DebugPrint(f);
  eval("'dont optimize this function itself please, but do optimize f'");
  %OptimizeFunctionOnNextCall(f);
  assertEquals(expected, f());
}

function resetOptAndAssertThrowsWith(expected, f) {
43
  %PrepareFunctionForOptimization(f);
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
  warmUp(f);
  resetState();
  // %DebugPrint(f);
  eval("'dont optimize this function itself please, but do optimize f'");
  %OptimizeFunctionOnNextCall(f);
  try {
    var result = f();
    fail("resetOptAndAssertThrowsWith",
        "exception: " + expected,
        "result: " + result);
  } catch (ex) {
    assertEquals(expected, ex);
  }
}

function increaseAndReturn15() {
  if (deopt) %DeoptimizeFunction(f);
  counter++;
  return 15;
}

function increaseAndThrow42() {
  if (deopt) %DeoptimizeFunction(f);
  counter++;
  throw 42;
}

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
function increaseAndReturn15_noopt_inner() {
  if (deopt) %DeoptimizeFunction(f);
  counter++;
  return 15;
}

%NeverOptimizeFunction(increaseAndReturn15_noopt_inner);

function increaseAndThrow42_noopt_inner() {
  if (deopt) %DeoptimizeFunction(f);
  counter++;
  throw 42;
}

%NeverOptimizeFunction(increaseAndThrow42_noopt_inner);

// Alternative 1

89 90 91 92 93 94 95 96
function returnOrThrow(doReturn) {
  if (doReturn) {
    return increaseAndReturn15();
  } else {
    return increaseAndThrow42();
  }
}

97 98 99 100 101 102 103 104 105 106 107
// Alternative 2

function increaseAndReturn15_calls_noopt() {
  return increaseAndReturn15_noopt_inner();
}

function increaseAndThrow42_calls_noopt() {
  return increaseAndThrow42_noopt_inner();
}

// Alternative 3.
108 109 110 111 112 113 114 115 116 117 118 119
// When passed either {increaseAndReturn15} or {increaseAndThrow42}, it acts
// as the other one.
function invertFunctionCall(f) {
  var result;
  try {
    result = f();
  } catch (ex) {
    return ex - 27;
  }
  throw result + 27;
}

120
// Alternative 4: constructor
121 122 123 124 125 126 127 128 129 130 131 132 133
function increaseAndStore15Constructor() {
  if (deopt) %DeoptimizeFunction(f);
  ++counter;
  this.x = 15;
}

function increaseAndThrow42Constructor() {
  if (deopt) %DeoptimizeFunction(f);
  ++counter;
  this.x = 42;
  throw this.x;
}

134
// Alternative 5: property
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
var magic = {};
Object.defineProperty(magic, 'prop', {
  get: function () {
    if (deopt) %DeoptimizeFunction(f);
    return 15 + 0 * ++counter;
  },

  set: function(x) {
    // argument should be 37
    if (deopt) %DeoptimizeFunction(f);
    counter -= 36 - x; // increments counter
    throw 42;
  }
})

// Generate type feedback.

152 153 154
assertEquals(15, increaseAndReturn15_calls_noopt());
assertThrowsEquals(function() { return increaseAndThrow42_noopt_inner() }, 42);

155 156 157 158 159 160 161 162 163 164
assertEquals(15, (new increaseAndStore15Constructor()).x);
assertThrowsEquals(function() {
        return (new increaseAndThrow42Constructor()).x;
    },
    42);

function runThisShard() {

  // Variant flags: [tryReturns, doFinally]

165 166
  f = function f_______r______f____ () {
    var local = 888;
167 168 169
    deopt = false;
    try {
      counter++;
170
      return 4 + increaseAndReturn15();
171 172 173 174 175 176 177 178
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
179
  resetOptAndAssertResultEquals(19, f);
180 181 182 183
  assertEquals(4, counter);

  // Variant flags: [tryReturns, doFinally, finallyThrows]

184 185
  f = function f_______r______f_t__ () {
    var local = 888;
186 187 188
    deopt = false;
    try {
      counter++;
189
      return 4 + increaseAndReturn15();
190 191 192 193 194 195 196 197 198 199 200 201 202
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryReturns, doFinally, finallyReturns]

203 204
  f = function f_______r______fr___ () {
    var local = 888;
205 206 207
    deopt = false;
    try {
      counter++;
208
      return 4 + increaseAndReturn15();
209 210 211 212 213 214 215 216
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
217
  resetOptAndAssertResultEquals(891, f);
218 219 220 221
  assertEquals(3, counter);

  // Variant flags: [tryReturns, doCatch]

222 223
  f = function f_______r__c________ () {
    var local = 888;
224 225 226
    deopt = false;
    try {
      counter++;
227
      return 4 + increaseAndReturn15();
228 229 230 231 232 233 234
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
235
  resetOptAndAssertResultEquals(19, f);
236 237 238 239
  assertEquals(2, counter);

  // Variant flags: [tryReturns, doCatch, deopt]

240 241
  f = function f_______r__c_______d () {
    var local = 888;
242 243 244
    deopt = true;
    try {
      counter++;
245
      return 4 + increaseAndReturn15();
246 247 248 249 250 251 252
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
253
  resetOptAndAssertResultEquals(19, f);
254 255 256 257
  assertEquals(2, counter);

  // Variant flags: [tryReturns, doCatch, doFinally]

258 259
  f = function f_______r__c___f____ () {
    var local = 888;
260 261 262
    deopt = false;
    try {
      counter++;
263
      return 4 + increaseAndReturn15();
264 265 266 267 268 269 270 271 272 273 274
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
275
  resetOptAndAssertResultEquals(19, f);
276 277 278 279
  assertEquals(4, counter);

  // Variant flags: [tryReturns, doCatch, doFinally, finallyThrows]

280 281
  f = function f_______r__c___f_t__ () {
    var local = 888;
282 283 284
    deopt = false;
    try {
      counter++;
285
      return 4 + increaseAndReturn15();
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryReturns, doCatch, doFinally, finallyReturns]

302 303
  f = function f_______r__c___fr___ () {
    var local = 888;
304 305 306
    deopt = false;
    try {
      counter++;
307
      return 4 + increaseAndReturn15();
308 309 310 311 312 313 314 315 316 317 318
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
319
  resetOptAndAssertResultEquals(891, f);
320 321 322 323
  assertEquals(3, counter);

  // Variant flags: [tryReturns, doCatch, catchThrows]

324 325
  f = function f_______r__c__t_____ () {
    var local = 888;
326 327 328
    deopt = false;
    try {
      counter++;
329
      return 4 + increaseAndReturn15();
330 331 332 333 334 335 336 337
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
338
  resetOptAndAssertResultEquals(19, f);
339 340 341 342
  assertEquals(2, counter);

  // Variant flags: [tryReturns, doCatch, catchThrows, deopt]

343 344
  f = function f_______r__c__t____d () {
    var local = 888;
345 346 347
    deopt = true;
    try {
      counter++;
348
      return 4 + increaseAndReturn15();
349 350 351 352 353 354 355 356
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
357
  resetOptAndAssertResultEquals(19, f);
358 359 360 361
  assertEquals(2, counter);

  // Variant flags: [tryReturns, doCatch, catchThrows, doFinally]

362 363
  f = function f_______r__c__tf____ () {
    var local = 888;
364 365 366
    deopt = false;
    try {
      counter++;
367
      return 4 + increaseAndReturn15();
368 369 370 371 372 373 374 375 376 377 378 379
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
380
  resetOptAndAssertResultEquals(19, f);
381 382 383 384 385
  assertEquals(4, counter);

  // Variant flags: [tryReturns, doCatch, catchThrows, doFinally,
  //   finallyThrows]

386 387
  f = function f_______r__c__tf_t__ () {
    var local = 888;
388 389 390
    deopt = false;
    try {
      counter++;
391
      return 4 + increaseAndReturn15();
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryReturns, doCatch, catchThrows, doFinally,
  //   finallyReturns]

410 411
  f = function f_______r__c__tfr___ () {
    var local = 888;
412 413 414
    deopt = false;
    try {
      counter++;
415
      return 4 + increaseAndReturn15();
416 417 418 419 420 421 422 423 424 425 426 427
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
428
  resetOptAndAssertResultEquals(891, f);
429 430 431 432
  assertEquals(3, counter);

  // Variant flags: [tryReturns, doCatch, catchReturns]

433 434
  f = function f_______r__cr_______ () {
    var local = 888;
435 436 437
    deopt = false;
    try {
      counter++;
438
      return 4 + increaseAndReturn15();
439 440 441 442 443 444 445 446
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
447
  resetOptAndAssertResultEquals(19, f);
448 449 450 451
  assertEquals(2, counter);

  // Variant flags: [tryReturns, doCatch, catchReturns, deopt]

452 453
  f = function f_______r__cr______d () {
    var local = 888;
454 455 456
    deopt = true;
    try {
      counter++;
457
      return 4 + increaseAndReturn15();
458 459 460 461 462 463 464 465
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
466
  resetOptAndAssertResultEquals(19, f);
467 468 469 470
  assertEquals(2, counter);

  // Variant flags: [tryReturns, doCatch, catchReturns, doFinally]

471 472
  f = function f_______r__cr__f____ () {
    var local = 888;
473 474 475
    deopt = false;
    try {
      counter++;
476
      return 4 + increaseAndReturn15();
477 478 479 480 481 482 483 484 485 486 487 488
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
489
  resetOptAndAssertResultEquals(19, f);
490 491 492 493 494
  assertEquals(4, counter);

  // Variant flags: [tryReturns, doCatch, catchReturns, doFinally,
  //   finallyThrows]

495 496
  f = function f_______r__cr__f_t__ () {
    var local = 888;
497 498 499
    deopt = false;
    try {
      counter++;
500
      return 4 + increaseAndReturn15();
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryReturns, doCatch, catchReturns, doFinally,
  //   finallyReturns]

519 520
  f = function f_______r__cr__fr___ () {
    var local = 888;
521 522 523
    deopt = false;
    try {
      counter++;
524
      return 4 + increaseAndReturn15();
525 526 527 528 529 530 531 532 533 534 535 536
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
537
  resetOptAndAssertResultEquals(891, f);
538 539 540 541
  assertEquals(3, counter);

  // Variant flags: [tryThrows, doFinally]

542 543
  f = function f______t_______f____ () {
    var local = 888;
544 545 546
    deopt = false;
    try {
      counter++;
547
      return 4 + increaseAndThrow42();
548 549 550 551 552 553 554 555 556 557 558 559 560
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(42, f);
  assertEquals(4, counter);

  // Variant flags: [tryThrows, doFinally, finallyThrows]

561 562
  f = function f______t_______f_t__ () {
    var local = 888;
563 564 565
    deopt = false;
    try {
      counter++;
566
      return 4 + increaseAndThrow42();
567 568 569 570 571 572 573 574 575 576 577 578 579
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, doFinally, finallyReturns]

580 581
  f = function f______t_______fr___ () {
    var local = 888;
582 583 584
    deopt = false;
    try {
      counter++;
585
      return 4 + increaseAndThrow42();
586 587 588 589 590 591 592 593
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
594
  resetOptAndAssertResultEquals(891, f);
595 596 597 598
  assertEquals(3, counter);

  // Variant flags: [tryThrows, doCatch]

599 600
  f = function f______t___c________ () {
    var local = 888;
601 602 603
    deopt = false;
    try {
      counter++;
604
      return 4 + increaseAndThrow42();
605 606 607 608 609 610 611 612 613 614 615 616
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(undefined, f);
  assertEquals(5, counter);

  // Variant flags: [tryThrows, doCatch, deopt]

617 618
  f = function f______t___c_______d () {
    var local = 888;
619 620 621
    deopt = true;
    try {
      counter++;
622
      return 4 + increaseAndThrow42();
623 624 625 626 627 628 629 630 631 632 633 634
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(undefined, f);
  assertEquals(5, counter);

  // Variant flags: [tryThrows, doCatch, doFinally]

635 636
  f = function f______t___c___f____ () {
    var local = 888;
637 638 639
    deopt = false;
    try {
      counter++;
640
      return 4 + increaseAndThrow42();
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(undefined, f);
  assertEquals(7, counter);

  // Variant flags: [tryThrows, doCatch, doFinally, finallyThrows]

657 658
  f = function f______t___c___f_t__ () {
    var local = 888;
659 660 661
    deopt = false;
    try {
      counter++;
662
      return 4 + increaseAndThrow42();
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(5, counter);

  // Variant flags: [tryThrows, doCatch, doFinally, finallyReturns]

679 680
  f = function f______t___c___fr___ () {
    var local = 888;
681 682 683
    deopt = false;
    try {
      counter++;
684
      return 4 + increaseAndThrow42();
685 686 687 688 689 690 691 692 693 694 695
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
696
  resetOptAndAssertResultEquals(891, f);
697 698 699 700
  assertEquals(5, counter);

  // Variant flags: [tryThrows, doCatch, catchThrows]

701 702
  f = function f______t___c__t_____ () {
    var local = 888;
703 704 705
    deopt = false;
    try {
      counter++;
706
      return 4 + increaseAndThrow42();
707 708 709 710 711 712 713 714 715 716 717 718 719
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(44, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, doCatch, catchThrows, deopt]

720 721
  f = function f______t___c__t____d () {
    var local = 888;
722 723 724
    deopt = true;
    try {
      counter++;
725
      return 4 + increaseAndThrow42();
726 727 728 729 730 731 732 733 734 735 736 737 738
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(44, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, doCatch, catchThrows, doFinally]

739 740
  f = function f______t___c__tf____ () {
    var local = 888;
741 742 743
    deopt = false;
    try {
      counter++;
744
      return 4 + increaseAndThrow42();
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(44, f);
  assertEquals(5, counter);

  // Variant flags: [tryThrows, doCatch, catchThrows, doFinally,
  //   finallyThrows]

763 764
  f = function f______t___c__tf_t__ () {
    var local = 888;
765 766 767
    deopt = false;
    try {
      counter++;
768
      return 4 + increaseAndThrow42();
769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(4, counter);

  // Variant flags: [tryThrows, doCatch, catchThrows, doFinally,
  //   finallyReturns]

787 788
  f = function f______t___c__tfr___ () {
    var local = 888;
789 790 791
    deopt = false;
    try {
      counter++;
792
      return 4 + increaseAndThrow42();
793 794 795 796 797 798 799 800 801 802 803 804
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
805
  resetOptAndAssertResultEquals(891, f);
806 807 808 809
  assertEquals(4, counter);

  // Variant flags: [tryThrows, doCatch, catchReturns]

810 811
  f = function f______t___cr_______ () {
    var local = 888;
812 813 814
    deopt = false;
    try {
      counter++;
815
      return 4 + increaseAndThrow42();
816 817 818 819 820 821 822 823 824 825 826 827 828
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(44, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, doCatch, catchReturns, deopt]

829 830
  f = function f______t___cr______d () {
    var local = 888;
831 832 833
    deopt = true;
    try {
      counter++;
834
      return 4 + increaseAndThrow42();
835 836 837 838 839 840 841 842 843 844 845 846 847
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(44, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, doCatch, catchReturns, doFinally]

848 849
  f = function f______t___cr__f____ () {
    var local = 888;
850 851 852
    deopt = false;
    try {
      counter++;
853
      return 4 + increaseAndThrow42();
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(44, f);
  assertEquals(5, counter);

  // Variant flags: [tryThrows, doCatch, catchReturns, doFinally,
  //   finallyThrows]

872 873
  f = function f______t___cr__f_t__ () {
    var local = 888;
874 875 876
    deopt = false;
    try {
      counter++;
877
      return 4 + increaseAndThrow42();
878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(4, counter);

  // Variant flags: [tryThrows, doCatch, catchReturns, doFinally,
  //   finallyReturns]

896 897
  f = function f______t___cr__fr___ () {
    var local = 888;
898 899 900
    deopt = false;
    try {
      counter++;
901
      return 4 + increaseAndThrow42();
902 903 904 905 906 907 908 909 910 911 912 913
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
914
  resetOptAndAssertResultEquals(891, f);
915 916 917 918
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, doFinally]

919 920
  f = function f______tr______f____ () {
    var local = 888;
921 922 923
    deopt = false;
    try {
      counter++;
924 925
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
926 927 928 929 930 931 932 933 934 935 936 937 938
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(42, f);
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, doFinally, finallyThrows]

939 940
  f = function f______tr______f_t__ () {
    var local = 888;
941 942 943
    deopt = false;
    try {
      counter++;
944 945
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
946 947 948 949 950 951 952 953 954 955 956 957 958
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, doFinally, finallyReturns]

959 960
  f = function f______tr______fr___ () {
    var local = 888;
961 962 963
    deopt = false;
    try {
      counter++;
964 965
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
966 967 968 969 970 971 972 973
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
974
  resetOptAndAssertResultEquals(891, f);
975 976 977 978
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch]

979 980
  f = function f______tr__c________ () {
    var local = 888;
981 982 983
    deopt = false;
    try {
      counter++;
984 985
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
986 987 988 989 990 991 992 993 994 995 996 997
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(undefined, f);
  assertEquals(5, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, doFinally]

998 999
  f = function f______tr__c___f____ () {
    var local = 888;
1000 1001 1002
    deopt = false;
    try {
      counter++;
1003 1004
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(undefined, f);
  assertEquals(7, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, doFinally,
  //   finallyThrows]

1022 1023
  f = function f______tr__c___f_t__ () {
    var local = 888;
1024 1025 1026
    deopt = false;
    try {
      counter++;
1027 1028
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(5, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, doFinally,
  //   finallyReturns]

1046 1047
  f = function f______tr__c___fr___ () {
    var local = 888;
1048 1049 1050
    deopt = false;
    try {
      counter++;
1051 1052
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
1064
  resetOptAndAssertResultEquals(891, f);
1065 1066 1067 1068
  assertEquals(5, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, catchThrows]

1069 1070
  f = function f______tr__c__t_____ () {
    var local = 888;
1071 1072 1073
    deopt = false;
    try {
      counter++;
1074 1075
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(44, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, catchThrows,
  //   doFinally]

1090 1091
  f = function f______tr__c__tf____ () {
    var local = 888;
1092 1093 1094
    deopt = false;
    try {
      counter++;
1095 1096
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(44, f);
  assertEquals(5, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, catchThrows,
  //   doFinally, finallyThrows]

1115 1116
  f = function f______tr__c__tf_t__ () {
    var local = 888;
1117 1118 1119
    deopt = false;
    try {
      counter++;
1120 1121
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, catchThrows,
  //   doFinally, finallyReturns]

1140 1141
  f = function f______tr__c__tfr___ () {
    var local = 888;
1142 1143 1144
    deopt = false;
    try {
      counter++;
1145 1146
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
1159
  resetOptAndAssertResultEquals(891, f);
1160 1161 1162 1163
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, catchReturns]

1164 1165
  f = function f______tr__cr_______ () {
    var local = 888;
1166 1167 1168
    deopt = false;
    try {
      counter++;
1169 1170
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(44, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, catchReturns,
  //   doFinally]

1185 1186
  f = function f______tr__cr__f____ () {
    var local = 888;
1187 1188 1189
    deopt = false;
    try {
      counter++;
1190 1191
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(44, f);
  assertEquals(5, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, catchReturns,
  //   doFinally, finallyThrows]

1210 1211
  f = function f______tr__cr__f_t__ () {
    var local = 888;
1212 1213 1214
    deopt = false;
    try {
      counter++;
1215 1216
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, doCatch, catchReturns,
  //   doFinally, finallyReturns]

1235 1236
  f = function f______tr__cr__fr___ () {
    var local = 888;
1237 1238 1239
    deopt = false;
    try {
      counter++;
1240 1241
      return 4 + increaseAndThrow42();
      return 4 + increaseAndReturn15();
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
1254
  resetOptAndAssertResultEquals(891, f);
1255 1256 1257 1258 1259
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns,
  //   doFinally]

1260 1261
  f = function f______trf_____f____ () {
    var local = 888;
1262 1263 1264
    deopt = false;
    try {
      counter++;
1265 1266
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1267 1268 1269 1270 1271 1272 1273 1274
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
1275
  resetOptAndAssertResultEquals(19, f);
1276 1277 1278 1279 1280
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns,
  //   doFinally, finallyThrows]

1281 1282
  f = function f______trf_____f_t__ () {
    var local = 888;
1283 1284 1285
    deopt = false;
    try {
      counter++;
1286 1287
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns,
  //   doFinally, finallyReturns]

1302 1303
  f = function f______trf_____fr___ () {
    var local = 888;
1304 1305 1306
    deopt = false;
    try {
      counter++;
1307 1308
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1309 1310 1311 1312 1313 1314 1315 1316
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
1317
  resetOptAndAssertResultEquals(891, f);
1318 1319 1320 1321
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch]

1322 1323
  f = function f______trf_c________ () {
    var local = 888;
1324 1325 1326
    deopt = false;
    try {
      counter++;
1327 1328
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1329 1330 1331 1332 1333 1334 1335
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
1336
  resetOptAndAssertResultEquals(19, f);
1337 1338 1339 1340 1341
  assertEquals(2, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   doFinally]

1342 1343
  f = function f______trf_c___f____ () {
    var local = 888;
1344 1345 1346
    deopt = false;
    try {
      counter++;
1347 1348
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
1360
  resetOptAndAssertResultEquals(19, f);
1361 1362 1363 1364 1365
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   doFinally, finallyThrows]

1366 1367
  f = function f______trf_c___f_t__ () {
    var local = 888;
1368 1369 1370
    deopt = false;
    try {
      counter++;
1371 1372
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   doFinally, finallyReturns]

1390 1391
  f = function f______trf_c___fr___ () {
    var local = 888;
1392 1393 1394
    deopt = false;
    try {
      counter++;
1395 1396
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
1408
  resetOptAndAssertResultEquals(891, f);
1409 1410 1411 1412 1413
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   catchThrows]

1414 1415
  f = function f______trf_c__t_____ () {
    var local = 888;
1416 1417 1418
    deopt = false;
    try {
      counter++;
1419 1420
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1421 1422 1423 1424 1425 1426 1427 1428
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
1429
  resetOptAndAssertResultEquals(19, f);
1430 1431 1432 1433 1434
  assertEquals(2, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   catchThrows, doFinally]

1435 1436
  f = function f______trf_c__tf____ () {
    var local = 888;
1437 1438 1439
    deopt = false;
    try {
      counter++;
1440 1441
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
1454
  resetOptAndAssertResultEquals(19, f);
1455 1456 1457 1458 1459
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   catchThrows, doFinally, finallyThrows]

1460 1461
  f = function f______trf_c__tf_t__ () {
    var local = 888;
1462 1463 1464
    deopt = false;
    try {
      counter++;
1465 1466
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   catchThrows, doFinally, finallyReturns]

1485 1486
  f = function f______trf_c__tfr___ () {
    var local = 888;
1487 1488 1489
    deopt = false;
    try {
      counter++;
1490 1491
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
1504
  resetOptAndAssertResultEquals(891, f);
1505 1506 1507 1508 1509
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   catchReturns]

1510 1511
  f = function f______trf_cr_______ () {
    var local = 888;
1512 1513 1514
    deopt = false;
    try {
      counter++;
1515 1516
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1517 1518 1519 1520 1521 1522 1523 1524
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
1525
  resetOptAndAssertResultEquals(19, f);
1526 1527 1528 1529 1530
  assertEquals(2, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   catchReturns, doFinally]

1531 1532
  f = function f______trf_cr__f____ () {
    var local = 888;
1533 1534 1535
    deopt = false;
    try {
      counter++;
1536 1537
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      local += 2;
      counter++;
    }
    counter++;
  }
1550
  resetOptAndAssertResultEquals(19, f);
1551 1552 1553 1554 1555
  assertEquals(4, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   catchReturns, doFinally, finallyThrows]

1556 1557
  f = function f______trf_cr__f_t__ () {
    var local = 888;
1558 1559 1560
    deopt = false;
    try {
      counter++;
1561 1562
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      throw 25;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(25, f);
  assertEquals(3, counter);

  // Variant flags: [tryThrows, tryReturns, tryFirstReturns, doCatch,
  //   catchReturns, doFinally, finallyReturns]

1581 1582
  f = function f______trf_cr__fr___ () {
    var local = 888;
1583 1584 1585
    deopt = false;
    try {
      counter++;
1586 1587
      return 4 + increaseAndReturn15();
      return 4 + increaseAndThrow42();
1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    } finally {
      counter++;
      return 3 + local;
      counter++;
    }
    counter++;
  }
1600
  resetOptAndAssertResultEquals(891, f);
1601 1602 1603 1604
  assertEquals(3, counter);

  // Variant flags: [alternativeFn1, tryReturns, doCatch]

1605 1606
  f = function f_____1_r__c________ () {
    var local = 888;
1607 1608 1609
    deopt = false;
    try {
      counter++;
1610
      return 4 + returnOrThrow(true);
1611 1612 1613 1614 1615 1616 1617
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
1618
  resetOptAndAssertResultEquals(19, f);
1619 1620 1621 1622
  assertEquals(2, counter);

  // Variant flags: [alternativeFn1, tryReturns, doCatch, deopt]

1623 1624
  f = function f_____1_r__c_______d () {
    var local = 888;
1625 1626 1627
    deopt = true;
    try {
      counter++;
1628
      return 4 + returnOrThrow(true);
1629 1630 1631 1632 1633 1634 1635
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
1636
  resetOptAndAssertResultEquals(19, f);
1637 1638 1639 1640
  assertEquals(2, counter);

  // Variant flags: [alternativeFn1, tryReturns, doCatch, catchThrows]

1641 1642
  f = function f_____1_r__c__t_____ () {
    var local = 888;
1643 1644 1645
    deopt = false;
    try {
      counter++;
1646
      return 4 + returnOrThrow(true);
1647 1648 1649 1650 1651 1652 1653 1654
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
1655
  resetOptAndAssertResultEquals(19, f);
1656 1657 1658 1659 1660
  assertEquals(2, counter);

  // Variant flags: [alternativeFn1, tryReturns, doCatch, catchThrows,
  //   deopt]

1661 1662
  f = function f_____1_r__c__t____d () {
    var local = 888;
1663 1664 1665
    deopt = true;
    try {
      counter++;
1666
      return 4 + returnOrThrow(true);
1667 1668 1669 1670 1671 1672 1673 1674
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
1675
  resetOptAndAssertResultEquals(19, f);
1676 1677 1678 1679 1680
  assertEquals(2, counter);

  // Variant flags: [alternativeFn1, tryReturns, doCatch,
  //   catchReturns]

1681 1682
  f = function f_____1_r__cr_______ () {
    var local = 888;
1683 1684 1685
    deopt = false;
    try {
      counter++;
1686
      return 4 + returnOrThrow(true);
1687 1688 1689 1690 1691 1692 1693 1694
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
1695
  resetOptAndAssertResultEquals(19, f);
1696 1697 1698 1699 1700
  assertEquals(2, counter);

  // Variant flags: [alternativeFn1, tryReturns, doCatch,
  //   catchReturns, deopt]

1701 1702
  f = function f_____1_r__cr______d () {
    var local = 888;
1703 1704 1705
    deopt = true;
    try {
      counter++;
1706
      return 4 + returnOrThrow(true);
1707 1708 1709 1710 1711 1712 1713 1714
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
1715
  resetOptAndAssertResultEquals(19, f);
1716 1717 1718 1719
  assertEquals(2, counter);

  // Variant flags: [alternativeFn1, tryThrows, doCatch]

1720 1721
  f = function f_____1t___c________ () {
    var local = 888;
1722 1723 1724
    deopt = false;
    try {
      counter++;
1725
      return 4 + returnOrThrow(false);
1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(undefined, f);
  assertEquals(5, counter);

  // Variant flags: [alternativeFn1, tryThrows, doCatch, deopt]

1738 1739
  f = function f_____1t___c_______d () {
    var local = 888;
1740 1741 1742
    deopt = true;
    try {
      counter++;
1743
      return 4 + returnOrThrow(false);
1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(undefined, f);
  assertEquals(5, counter);

  // Variant flags: [alternativeFn1, tryThrows, doCatch, catchThrows]

1756 1757
  f = function f_____1t___c__t_____ () {
    var local = 888;
1758 1759 1760
    deopt = false;
    try {
      counter++;
1761
      return 4 + returnOrThrow(false);
1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(44, f);
  assertEquals(3, counter);

  // Variant flags: [alternativeFn1, tryThrows, doCatch, catchThrows,
  //   deopt]

1776 1777
  f = function f_____1t___c__t____d () {
    var local = 888;
1778 1779 1780
    deopt = true;
    try {
      counter++;
1781
      return 4 + returnOrThrow(false);
1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertThrowsWith(44, f);
  assertEquals(3, counter);

  // Variant flags: [alternativeFn1, tryThrows, doCatch, catchReturns]

1795 1796
  f = function f_____1t___cr_______ () {
    var local = 888;
1797 1798 1799
    deopt = false;
    try {
      counter++;
1800
      return 4 + returnOrThrow(false);
1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(44, f);
  assertEquals(3, counter);

  // Variant flags: [alternativeFn1, tryThrows, doCatch, catchReturns,
  //   deopt]

1815 1816
  f = function f_____1t___cr______d () {
    var local = 888;
1817 1818 1819
    deopt = true;
    try {
      counter++;
1820
      return 4 + returnOrThrow(false);
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(44, f);
  assertEquals(3, counter);

1832 1833
  // Variant flags: [alternativeFn2, tryReturns, doCatch,
  //   catchWithLocal, endReturnLocal, deopt]
1834

1835 1836 1837
  f = function f____2__r__c_l____ld () {
    var local = 888;
    deopt = true;
1838 1839
    try {
      counter++;
1840
      return 4 + increaseAndReturn15_calls_noopt();
1841 1842 1843
      counter++;
    } catch (ex) {
      counter++;
1844
      local += ex;
1845 1846 1847
      counter++;
    }
    counter++;
1848
    return 5 + local;
1849
  }
1850
  resetOptAndAssertResultEquals(19, f);
1851 1852
  assertEquals(2, counter);

1853 1854
  // Variant flags: [alternativeFn2, tryReturns, tryResultToLocal,
  //   doCatch, endReturnLocal, deopt]
1855

1856 1857
  f = function f____2__r_lc______ld () {
    var local = 888;
1858 1859 1860
    deopt = true;
    try {
      counter++;
1861
      local += 4 + increaseAndReturn15_calls_noopt();
1862 1863 1864 1865 1866 1867
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
1868
    return 5 + local;
1869
  }
1870 1871
  resetOptAndAssertResultEquals(912, f);
  assertEquals(4, counter);
1872

1873 1874
  // Variant flags: [alternativeFn2, tryReturns, tryResultToLocal,
  //   doCatch, catchWithLocal, endReturnLocal, deopt]
1875

1876 1877 1878
  f = function f____2__r_lc_l____ld () {
    var local = 888;
    deopt = true;
1879 1880
    try {
      counter++;
1881
      local += 4 + increaseAndReturn15_calls_noopt();
1882 1883 1884
      counter++;
    } catch (ex) {
      counter++;
1885
      local += ex;
1886 1887 1888
      counter++;
    }
    counter++;
1889
    return 5 + local;
1890
  }
1891 1892
  resetOptAndAssertResultEquals(912, f);
  assertEquals(4, counter);
1893

1894 1895
  // Variant flags: [alternativeFn2, tryThrows, doCatch,
  //   catchWithLocal, endReturnLocal, deopt]
1896

1897 1898
  f = function f____2_t___c_l____ld () {
    var local = 888;
1899 1900 1901
    deopt = true;
    try {
      counter++;
1902
      return 4 + increaseAndThrow42_calls_noopt();
1903 1904 1905
      counter++;
    } catch (ex) {
      counter++;
1906
      local += ex;
1907 1908 1909
      counter++;
    }
    counter++;
1910
    return 5 + local;
1911
  }
1912 1913
  resetOptAndAssertResultEquals(935, f);
  assertEquals(5, counter);
1914

1915 1916
  // Variant flags: [alternativeFn2, tryThrows, tryResultToLocal,
  //   doCatch, endReturnLocal, deopt]
1917

1918 1919 1920
  f = function f____2_t__lc______ld () {
    var local = 888;
    deopt = true;
1921 1922
    try {
      counter++;
1923
      local += 4 + increaseAndThrow42_calls_noopt();
1924 1925 1926 1927 1928 1929
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
1930
    return 5 + local;
1931
  }
1932 1933
  resetOptAndAssertResultEquals(893, f);
  assertEquals(5, counter);
1934

1935 1936
  // Variant flags: [alternativeFn2, tryThrows, tryResultToLocal,
  //   doCatch, catchWithLocal, endReturnLocal, deopt]
1937

1938 1939
  f = function f____2_t__lc_l____ld () {
    var local = 888;
1940 1941 1942
    deopt = true;
    try {
      counter++;
1943
      local += 4 + increaseAndThrow42_calls_noopt();
1944 1945 1946 1947 1948 1949 1950
      counter++;
    } catch (ex) {
      counter++;
      local += ex;
      counter++;
    }
    counter++;
1951
    return 5 + local;
1952
  }
1953 1954
  resetOptAndAssertResultEquals(935, f);
  assertEquals(5, counter);
1955

1956
  // Variant flags: [alternativeFn3, tryReturns, doCatch]
1957

1958 1959
  f = function f___3___r__c________ () {
    var local = 888;
1960 1961 1962
    deopt = false;
    try {
      counter++;
1963
      return 4 + invertFunctionCall(increaseAndThrow42);
1964 1965 1966 1967 1968 1969 1970
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
1971
  resetOptAndAssertResultEquals(19, f);
1972 1973
  assertEquals(2, counter);

1974
  // Variant flags: [alternativeFn3, tryReturns, doCatch, deopt]
1975

1976 1977
  f = function f___3___r__c_______d () {
    var local = 888;
1978 1979 1980
    deopt = true;
    try {
      counter++;
1981
      return 4 + invertFunctionCall(increaseAndThrow42);
1982 1983 1984 1985 1986 1987 1988
      counter++;
    } catch (ex) {
      counter++;
      counter++;
    }
    counter++;
  }
1989
  resetOptAndAssertResultEquals(19, f);
1990 1991
  assertEquals(2, counter);

1992
  // Variant flags: [alternativeFn3, tryReturns, doCatch, catchThrows]
1993

1994 1995
  f = function f___3___r__c__t_____ () {
    var local = 888;
1996 1997 1998
    deopt = false;
    try {
      counter++;
1999
      return 4 + invertFunctionCall(increaseAndThrow42);
2000 2001 2002 2003 2004 2005 2006 2007
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
2008
  resetOptAndAssertResultEquals(19, f);
2009 2010
  assertEquals(2, counter);

2011 2012
  // Variant flags: [alternativeFn3, tryReturns, doCatch, catchThrows,
  //   deopt]
2013

2014 2015
  f = function f___3___r__c__t____d () {
    var local = 888;
2016 2017 2018
    deopt = true;
    try {
      counter++;
2019
      return 4 + invertFunctionCall(increaseAndThrow42);
2020 2021 2022 2023 2024 2025 2026 2027
      counter++;
    } catch (ex) {
      counter++;
      throw 2 + ex;
      counter++;
    }
    counter++;
  }
2028
  resetOptAndAssertResultEquals(19, f);
2029 2030
  assertEquals(2, counter);

2031 2032
  // Variant flags: [alternativeFn3, tryReturns, doCatch,
  //   catchWithLocal]
2033

2034 2035
  f = function f___3___r__c_l______ () {
    var local = 888;
2036 2037 2038
    deopt = false;
    try {
      counter++;
2039
      return 4 + invertFunctionCall(increaseAndThrow42);
2040 2041 2042
      counter++;
    } catch (ex) {
      counter++;
2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083
      local += ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(19, f);
  assertEquals(2, counter);

  // Variant flags: [alternativeFn3, tryReturns, doCatch,
  //   catchWithLocal, deopt]

  f = function f___3___r__c_l_____d () {
    var local = 888;
    deopt = true;
    try {
      counter++;
      return 4 + invertFunctionCall(increaseAndThrow42);
      counter++;
    } catch (ex) {
      counter++;
      local += ex;
      counter++;
    }
    counter++;
  }
  resetOptAndAssertResultEquals(19, f);
  assertEquals(2, counter);

  // Variant flags: [alternativeFn3, tryReturns, doCatch,
  //   catchWithLocal, endReturnLocal]

  f = function f___3___r__c_l____l_ () {
    var local = 888;
    deopt = false;
    try {
      counter++;
      return 4 + invertFunctionCall(increaseAndThrow42);
      counter++;
    } catch (ex) {
      counter++;
      local += ex;
2084 2085 2086 2087 2088
      counter++;
    }
    counter++;
    return 5 + local;
  }
2089
  resetOptAndAssertResultEquals(19, f);
2090 2091
  assertEquals(2, counter);

2092 2093
  // Variant flags: [alternativeFn3, tryReturns, doCatch,
  //   catchWithLocal, endReturnLocal, deopt]
2094

2095 2096
  f = function f___3___r__c_l____ld () {
    var local = 888;
2097 2098 2099
    deopt = true;
    try {
      counter++;
2100
      return 4 + invertFunctionCall(increaseAndThrow42);
2101 2102 2103
      counter++;
    } catch (ex) {
      counter++;
2104
      local += ex;
2105 2106 2107 2108 2109
      counter++;
    }
    counter++;
    return 5 + local;
  }
2110
  resetOptAndAssertResultEquals(19, f);
2111 2112
  assertEquals(2, counter);

2113 2114
  // Variant flags: [alternativeFn3, tryReturns, doCatch,
  //   catchWithLocal, catchThrows]
2115

2116 2117
  f = function f___3___r__c_lt_____ () {
    var local = 888;
2118 2119 2120
    deopt = false;
    try {
      counter++;
2121
      return 4 + invertFunctionCall(increaseAndThrow42);
2122 2123 2124
      counter++;
    } catch (ex) {
      counter++;
2125
      throw 2 + ex;
2126 2127 2128 2129
      counter++;
    }
    counter++;
  }
2130
  resetOptAndAssertResultEquals(19, f);
2131 2132
  assertEquals(2, counter);

2133 2134
  // Variant flags: [alternativeFn3, tryReturns, doCatch,
  //   catchWithLocal, catchThrows, deopt]
2135

2136 2137
  f = function f___3___r__c_lt____d () {
    var local = 888;
2138 2139 2140
    deopt = true;
    try {
      counter++;
2141
      return 4 + invertFunctionCall(increaseAndThrow42);
2142 2143 2144
      counter++;
    } catch (ex) {
      counter++;
2145
      throw 2 + ex;
2146 2147 2148 2149
      counter++;
    }
    counter++;
  }
2150
  resetOptAndAssertResultEquals(19, f);
2151 2152
  assertEquals(2, counter);

2153 2154
  // Variant flags: [alternativeFn3, tryReturns, doCatch,
  //   catchWithLocal, catchThrows, endReturnLocal]
2155

2156 2157
  f = function f___3___r__c_lt___l_ () {
    var local = 888;
2158 2159 2160
    deopt = false;
    try {
      counter++;
2161
      return 4 + invertFunctionCall(increaseAndThrow42);
2162 2163 2164
      counter++;
    } catch (ex) {
      counter++;
2165
      throw 2 + ex;
2166 2167 2168
      counter++;
    }
    counter++;
2169
    return 5 + local;
2170
  }
2171
  resetOptAndAssertResultEquals(19, f);
2172 2173
  assertEquals(2, counter);

2174 2175
  // Variant flags: [alternativeFn3, tryReturns, doCatch,
  //   catchWithLocal, catchThrows, endReturnLocal, deopt]
2176

2177 2178
  f = function f___3___r__c_lt___ld () {
    var local = 888;
2179 2180 2181
    deopt = true;
    try {
      counter++;
2182
      return 4 + invertFunctionCall(increaseAndThrow42);
2183 2184 2185
      counter++;
    } catch (ex) {
      counter++;
2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207
      throw 2 + ex;
      counter++;
    }
    counter++;
    return 5 + local;
  }
  resetOptAndAssertResultEquals(19, f);
  assertEquals(2, counter);

  // Variant flags: [alternativeFn3, tryReturns, doCatch,
  //   catchReturns]

  f = function f___3___r__cr_______ () {
    var local = 888;
    deopt = false;
    try {
      counter++;
      return 4 + invertFunctionCall(increaseAndThrow42);
      counter++;
    } catch (ex) {
      counter++;
      return 2 + ex;
2208 2209 2210 2211
      counter++;
    }
    counter++;
  }
2212
  resetOptAndAssertResultEquals(19, f);
2213 2214 2215 2216 2217
  assertEquals(2, counter);

}
%NeverOptimizeFunction(runThisShard);

2218 2219
// 97 tests in this shard.
// 97 tests up to here.
2220 2221

runThisShard();