/js/src/jit-test/tests/basic/testMethodWriteBarrier3.js

http://github.com/zpao/v8monkey · JavaScript · 27 lines · 23 code · 4 blank · 0 comment · 1 complexity · 671df47852cb2a130e261bb445c3c9dd MD5 · raw file

  1. function g() {}
  2. function h() {
  3. for (var i = 0; i < 9; i++)
  4. x.f = i;
  5. }
  6. function j() {
  7. x.f();
  8. }
  9. var x = {f: 0.7, g: g};
  10. x.g(); // interpreter brands x
  11. h();
  12. print(shapeOf(x));
  13. x.f = function (){}; // does not change x's shape
  14. j();
  15. print(shapeOf(x));
  16. h(); // should change x's shape
  17. var thrown = 'none';
  18. try {
  19. j(); // should throw since x.f === 8
  20. } catch (exc) {
  21. thrown = exc.name;
  22. }
  23. assertEq(thrown, 'TypeError');