NonFixedFieldHoist.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 foo(a,b){ return a + b; }
  6. function bar(a,b){ return a - b; }
  7. var obj = {};
  8. obj.foo = foo;
  9. function test(obj)
  10. {
  11. var count = 0;
  12. for (var i = 0; i < 1000; i++)
  13. {
  14. count += obj.foo(10, i);
  15. }
  16. return count;
  17. }
  18. obj.foo = bar;
  19. WScript.Echo(test(obj));
  20. obj.foo = 10;
  21. try
  22. {
  23. WScript.Echo(test(obj));
  24. }
  25. catch(e)
  26. {
  27. WScript.Echo(e);
  28. }
  29. var obj2 = {};
  30. try
  31. {
  32. WScript.Echo(test(obj2));
  33. }
  34. catch(e)
  35. {
  36. WScript.Echo(e);
  37. }
  38. // Will hoist CheckFuncInfo instr
  39. // and then GC its BailOutInfo.
  40. function test0() {
  41. var obj0 = {};
  42. var obj1 = {};
  43. var func2 = function () {
  44. };
  45. var func4 = function () {
  46. for (var _strvar2 in ary) {
  47. function v0() {
  48. throw '';
  49. }
  50. function v2() {
  51. var v3 = 0;
  52. for (var _strvar0 in f32) {
  53. if (v3++) {
  54. func2.apply(obj1, arguments);
  55. v0();
  56. }
  57. }
  58. }
  59. try {
  60. v2();
  61. } catch (ex) {
  62. }
  63. }
  64. };
  65. obj0.method0 = func4;
  66. var ary = Array();
  67. var f32 = new Float32Array(256);
  68. ary[0] = 1;
  69. ary[1] = 1;
  70. function v14() {
  71. var v15 = obj0.method0();
  72. }
  73. v14();
  74. }
  75. test0();