summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/track-allocation-sites.js
blob: fb329b70022a3383152a090eb9197d521c230d9d (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
// Test that we can track allocation sites.

enableTrackAllocations();

const tests = [
  { name: "object literal",  object: {},                    line: Error().lineNumber },
  { name: "array literal",   object: [],                    line: Error().lineNumber },
  { name: "regexp literal",  object: /(two|2)\s*problems/,  line: Error().lineNumber },
  { name: "new constructor", object: new function Ctor(){}, line: Error().lineNumber },
  { name: "new Object",      object: new Object(),          line: Error().lineNumber },
  { name: "new Array",       object: new Array(),           line: Error().lineNumber },
  { name: "new Date",        object: new Date(),            line: Error().lineNumber }
];

disableTrackAllocations();

for (let { name, object, line } of tests) {
  print("Entering test: " + name);

  let allocationSite = getAllocationMetadata(object);
  print(allocationSite);

  assertEq(allocationSite.line, line);
}