polymorphictest.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. // jshost.exe -trace:perfhint -off:simplejit -maxinterpretcount:5 polymorphictest.js
  6. var arg = "arg";
  7. var iter = 100;
  8. function foo1(arg1) {
  9. var string = "that: " + this.that1 + ", arg: " + arg1;
  10. return string;
  11. }
  12. function foo2(arg2) {
  13. var string = "that: " + this.that2 + ", arg: " + arg2;
  14. return string;
  15. }
  16. function foo3(arg3) {
  17. var string = "that: " + this.that3 + ", arg: " + arg3;
  18. return string;
  19. }
  20. function foo4(arg4) {
  21. var string = "that: " + this.that4 + ", arg: " + arg4;
  22. return string;
  23. }
  24. function foo5(arg5) {
  25. var string = "that: " + this.that5 + ", arg: " + arg5;
  26. return string;
  27. }
  28. function Test1() {
  29. var o1 = { foo: foo1, that1: "that1"};
  30. var o2 = { foo: foo2, that2: "that2"};
  31. var o3 = { foo: foo3, that3: "that3"};
  32. var o4 = { foo: foo4, that4: "that4"};
  33. var o5 = { foo: foo5, that5: "that5"};
  34. function test(obj) {
  35. arg += "foo";
  36. obj.foo(arg);
  37. }
  38. test(o1);
  39. test(o2);
  40. test(o3);
  41. test(o4);
  42. for (var i = 0; i < iter; i++) {
  43. result = test(o5);
  44. }
  45. }
  46. Test1();