implicitCallSwitchExpr.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. /*
  6. *******************************UNIT TEST FOR SWITCH CASE OPTIMIZATION*******************************
  7. * Test for Bug 232738
  8. * Exprgen:CAS: JIT is causing a bad code gen with Switches: -maxinterpretcount:1 -bgjit- -loopinterpretcount:1
  9. *
  10. */
  11. var shouldBailout = false;
  12. function test0(){
  13. var g = 1;
  14. if(shouldBailout)
  15. {
  16. g = { valueOf: function() { WScript.Echo('g value1Of'); return 3; } }
  17. }
  18. var __loopvar2 = 1;
  19. do {
  20. switch(g) {
  21. case 1:
  22. d = 1;
  23. case 2:
  24. d = 2;
  25. case 3:
  26. d = 3;
  27. case 4:
  28. d = 4;
  29. default:
  30. d = -1;
  31. }
  32. } while(__loopvar2 < 1)
  33. return d;
  34. };
  35. WScript.Echo(test0());
  36. shouldBailout = true;
  37. WScript.Echo(test0());