es5array_arrayproto_opt.js 954 B

123456789101112131415161718192021222324252627282930313233
  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 test(obj, i)
  6. {
  7. obj[i] = 1;
  8. WScript.Echo(obj[i]);
  9. }
  10. function test2(obj)
  11. {
  12. obj[0] = 1;
  13. WScript.Echo(obj[0]);
  14. }
  15. // Populate the profile with any array that we are growing a segment length
  16. test2([]);
  17. Object.defineProperty(Array.prototype, "0", { value:"blah", writable: false });
  18. // Test the jitted code with the array type check elimination
  19. test2([]);
  20. var arr = [];
  21. arr[1] = 2;
  22. // Populate the profile to not filling a missing value.
  23. test(arr, 1);
  24. // Test the jitted code with the array type check elimitation
  25. test(arr, 0);