nativearray_gen7.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. var shouldBailout = false;
  6. var reuseObjects = false;
  7. var PolymorphicFuncObjArr = [];
  8. var PolyFuncArr = [];
  9. function GetPolymorphicFunction()
  10. {
  11. if(PolyFuncArr.length > 1 )
  12. {
  13. var myFunc = PolyFuncArr.shift();
  14. PolyFuncArr.push(myFunc);
  15. return myFunc;
  16. }
  17. else
  18. {
  19. return PolyFuncArr[0];
  20. }
  21. }
  22. function GetObjectwithPolymorphicFunction(){
  23. if (reuseObjects)
  24. {
  25. if(PolymorphicFuncObjArr.length > 1 )
  26. {
  27. var myFunc = PolymorphicFuncObjArr.shift();
  28. PolymorphicFuncObjArr.push(myFunc);
  29. return myFunc
  30. }
  31. else
  32. {
  33. return PolymorphicFuncObjArr[0];
  34. }
  35. }
  36. else
  37. {
  38. var obj = {};
  39. obj.polyfunc = GetPolymorphicFunction();
  40. PolymorphicFuncObjArr.push(obj)
  41. return obj
  42. }
  43. };
  44. function InitPolymorphicFunctionArray()
  45. {
  46. for(var i=0;i<arguments.length;i++)
  47. {
  48. PolyFuncArr.push(arguments[i])
  49. }
  50. }
  51. ;
  52. function test0(){
  53. var obj0 = {};
  54. var obj1 = {};
  55. var arrObj0 = {};
  56. var func0 = function(argMath0){
  57. (ary[((shouldBailout ? (ary[5] = "x") : undefined ), 5)]);
  58. }
  59. var func2 = function(argArr3,argArr4,argFunc5,argArr6){
  60. // Snippet: Array check hoist where we set an index property to an accessor.
  61. function v274686(o)
  62. {
  63. for (var v274687 = 0 ; v274687 < 8 ; v274687++)
  64. {
  65. obj0.prop0 = o[v274687];
  66. o[v274687] = v274687;
  67. }
  68. WScript.Echo(o[3]);
  69. }
  70. v274686(argArr3);
  71. if(shouldBailout) {
  72. try {
  73. Object.defineProperty(argArr3,"5",{set: function(x){ WScript.Echo("inside");this[3] = -3;}, configurable: true})
  74. }
  75. catch(e) {
  76. }
  77. v274686(argArr3);
  78. }
  79. func0.call(obj0 , 1);
  80. }
  81. obj0.method0 = func2;
  82. var ary = new Array(10);
  83. function bar0 (){
  84. }
  85. function bar1 (){
  86. }
  87. function bar2 (){
  88. return 1.1;
  89. }
  90. InitPolymorphicFunctionArray(bar0,bar1,bar2);
  91. var __polyobj = GetObjectwithPolymorphicFunction();
  92. obj1.prop0 = (__polyobj.polyfunc.call(arrObj0 ) ? Math.pow(1, obj0.method0.call(obj1 , ary, 1, 1, 1)) : 1);
  93. func2(1, 1, 1, 1);
  94. };
  95. // generate profile
  96. test0();
  97. test0();
  98. test0();
  99. // run JITted code
  100. runningJITtedCode = true;
  101. test0();
  102. test0();
  103. test0();
  104. // run code with bailouts enabled
  105. shouldBailout = true;
  106. test0();
  107. // Test output:
  108. // undefined
  109. // undefined
  110. // 3
  111. // undefined
  112. // undefined
  113. // undefined
  114. // undefined
  115. // 3
  116. // inside
  117. // -3
  118. // inside
  119. // inside
  120. // undefined
  121. // JavaScript runtime error: Object.defineProperty: argument is not an Object