CmPeeps.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. function foo0(o,i)
  6. {
  7. if (o==10 && i++,o)
  8. {
  9. }
  10. else
  11. {
  12. WScript.Echo("FAILED");
  13. }
  14. }
  15. foo0(9, 0);
  16. // - At 'o.p && 1', 'BrTrue 1' is const-folded to 'Br' to the loop exit block with the 'break'
  17. // - 'a' becomes live as a float on the right side of '||' and is only live as an int on the left side
  18. // - Since both of those blocks are predecessors to the loop exit block with the 'break', 'a' is kept live as a float on exit
  19. // out of the loop
  20. // - When compensating in the 'BrTrue 1' block, we don't need an airlock block to convert 'a' to a float only on exit out of the
  21. // loop because that branch was already const-folded into 'Br' and always flows into the exit block
  22. function foo1() {
  23. var o = { p: 0 };
  24. var a = 0;
  25. for(var i = 0; i < 2; ++i) {
  26. a = 1;
  27. if(o.p && 1 || (a /= 2))
  28. break;
  29. }
  30. }
  31. foo1();
  32. foo1();
  33. function foo2(){
  34. var ary = new Array(10);
  35. var c = -1;
  36. var e = 1;
  37. var g = 1;
  38. ary[ary.length-1] = 1;
  39. ary.length = 100;
  40. g =((e < c)||(g < c));
  41. if(g)
  42. c=((e < c));
  43. c =((e < c)) + g;
  44. ary[ary.length-1];
  45. };
  46. foo2();
  47. foo2();
  48. foo2();
  49. WScript.Echo("Passed");