PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/deps/v8/test/mjsunit/regress/regress-hoist-load-named-field.js

http://github.com/joyent/node
JavaScript | 66 lines | 30 code | 6 blank | 30 comment | 2 complexity | d1741e65519cc5e8bbb5d52cf990fb01 MD5 | raw file
Possible License(s): 0BSD, BSD-3-Clause, MPL-2.0-no-copyleft-exception, GPL-2.0, ISC, Apache-2.0, MIT, AGPL-3.0
  1. // Copyright 2013 the V8 project authors. All rights reserved.
  2. // Redistribution and use in source and binary forms, with or without
  3. // modification, are permitted provided that the following conditions are
  4. // met:
  5. //
  6. // * Redistributions of source code must retain the above copyright
  7. // notice, this list of conditions and the following disclaimer.
  8. // * Redistributions in binary form must reproduce the above
  9. // copyright notice, this list of conditions and the following
  10. // disclaimer in the documentation and/or other materials provided
  11. // with the distribution.
  12. // * Neither the name of Google Inc. nor the names of its
  13. // contributors may be used to endorse or promote products derived
  14. // from this software without specific prior written permission.
  15. //
  16. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  17. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  19. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  20. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  21. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  22. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. // Flags: --allow-natives-syntax
  28. // Load fields should not be hoisted beyond their check maps when the check maps
  29. // cannot be hoisted due to changes in elements kinds.
  30. function f(o, a) {
  31. var v;
  32. var i = 1;
  33. while (i < 2) {
  34. v = o.y;
  35. a[0] = 1.5;
  36. i++;
  37. }
  38. return v;
  39. }
  40. f({y:1.4}, [1]);
  41. f({y:1.6}, [1]);
  42. %OptimizeFunctionOnNextCall(f);
  43. f({x:1}, [1]);
  44. // Polymorphic loads should not be hoisted beyond their compare maps.
  45. function f2(o) {
  46. var i = 0;
  47. var v;
  48. while (i < 1) {
  49. v = o.x;
  50. i++;
  51. }
  52. return v;
  53. }
  54. var o1 = { x: 1.5 };
  55. var o2 = { y: 1, x: 1 };
  56. f2(o1);
  57. f2(o1);
  58. f2(o2);
  59. %OptimizeFunctionOnNextCall(f2);
  60. f2(o2);