2
0

MissingPropertyCache3.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  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. // Make sure we invalidate missing property caches, if the property is shadowed on the proto chain. Also verify it all works with object type specialization.
  6. var SimpleObject = function () {
  7. this.a = 1;
  8. this.b = 2;
  9. }
  10. var p = {};
  11. SimpleObject.prototype = p;
  12. var o = new SimpleObject();
  13. function test() {
  14. var a = o.a;
  15. var b = o.b;
  16. var m = o.m;
  17. WScript.Echo("o.m = " + m);
  18. }
  19. // Run once, walk the proto chain on the slow path not finding property v anywhere, cache it.
  20. test();
  21. // Time to do simple JIT
  22. // From JIT-ed code retrieve the value of v (undefined) from the missing property cache.
  23. test();
  24. // Time to do full JIT (including object type specialization).
  25. // From JIT-ed code retrieve the value of v (undefined) from the missing property cache.
  26. test();
  27. // Now add the property to the prototype, which should invalidate the cache, and force bailout from JIT-ed code.
  28. p.m = 0;
  29. // Verify we get the new value now.
  30. test();