jit-module-loop-body.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Copyright (c) ChakraCore Project Contributors. All rights reserved.
  4. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  5. //-------------------------------------------------------------------------------------------------------
  6. let bar = [];
  7. let j = 0, a = 3, b = 2;
  8. function printif (text, x, mod) {
  9. if (x % mod == 0) {
  10. print (text + x);
  11. }
  12. }
  13. await b;
  14. var foo = [0.1, 0.2, 0.3, 0.4, 0];
  15. while (a < 200) { // Loop 0 - should be jitted
  16. foo[a] = Math.random();
  17. printif("Loop 0 a = ", a, 40);
  18. for (let k in foo) { bar[k] = a - k;} // Loop 1 - shuld be jitted
  19. ++a;
  20. }
  21. while (true){ // Loop 2 - should not be jitted
  22. for (j = 0; j < 100; ++j) { // Loop 3 - should not be jitted
  23. await j;
  24. foo[j] = j;
  25. }
  26. print("Loop 3 completed");
  27. for (let k of bar) { // Loop 4 - should be jitted
  28. printif("Loop 4 k = ", k, 40);
  29. foo[0] = foo[1] + 1;
  30. }
  31. print("Loop 4 completed");
  32. await j;
  33. break;
  34. }