summaryrefslogtreecommitdiff
path: root/js/src/jit-test/tests/profiler/AutoEntryMonitor-01.js
blob: d6654868036d926dacc03041dc6b508ca2b598e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// AutoEntryMonitor should catch all entry points into JavaScript.

load(libdir + 'array-compare.js');

function cold_and_warm(f, params, expected) {
  print(uneval(params));
  print(uneval(entryPoints(params)));
  assertEq(arraysEqual(entryPoints(params), expected), true);

  // Warm up the function a bit, so the JITs will compile it, and try again.
  if (f)
    for (i = 0; i < 10; i++)
      f();

  assertEq(arraysEqual(entryPoints(params), expected), true);
}

function entry1() { }
cold_and_warm(entry1, { function: entry1 }, [ "entry1" ]);

var getx = { get x() { } };
cold_and_warm(Object.getOwnPropertyDescriptor(getx, 'x').get,
              { object: getx, property: 'x' }, [ "get x" ]);

var sety = { set y(v) { } };
cold_and_warm(Object.getOwnPropertyDescriptor(sety, 'y').set,
              { object: sety, property: 'y', value: 'glerk' }, [ "set y" ]);

cold_and_warm(Object.prototype.toString, { ToString: {} }, []);

var toS = { toString: function myToString() { return "string"; } };
cold_and_warm(toS.toString, { ToString: toS }, [ "myToString" ]);

cold_and_warm(undefined, { ToNumber: {} }, []);

var vOf = { valueOf: function myValueOf() { return 42; } };
cold_and_warm(vOf.valueOf, { ToNumber: vOf }, [ "myValueOf" ]);

var toSvOf = { toString: function relations() { return Object; },
               valueOf: function wallpaper() { return 17; } };
cold_and_warm(() => {  toSvOf.toString(); toSvOf.valueOf(); },
              { ToString: toSvOf }, [ "relations", "wallpaper" ]);

var vOftoS = { toString: function ettes() { return "6-inch lengths"; },
               valueOf: function deathBy() { return Math; } };
cold_and_warm(() => {  vOftoS.valueOf(); vOftoS.toString(); },
              { ToNumber: vOftoS }, [ "deathBy", "ettes" ]);


cold_and_warm(() => 0, { eval: "Math.atan2(1,1);" }, [ "eval:entryPoint eval" ]);