bug2002982.js (1453B)
1 // Test that script sources are properly registered on consecutive profiler runs. 2 // Bug 2002982: When the profiler is disabled and re-enabled, script sources 3 // need to be re-registered because the profiler's ScriptSources hashset is 4 // cleared on stop. Previously, ensureProfileString would return early if 5 // profileString_ was already set. And that was causing us to never re-insert 6 // the script source. 7 8 // Set a low warmup threshold to trigger baseline compilation. 9 setJitCompilerOption("baseline.warmup.trigger", 5); 10 11 // A simple function that will be JIT'ed. 12 function compute(x) { 13 return x * x; 14 } 15 16 enableGeckoProfiling(); 17 18 // Warm up with the profiler enabled. It creates JitScripts and registers 19 // their sources. 20 for (let i = 0; i < 10; i++) { 21 compute(i); 22 } 23 24 // Get how many sources are registered so far. 25 const countBefore = getGeckoProfilingScriptSourcesCount(); 26 assertEq(countBefore > 0, true, 27 "Expected to have at least one registered script source"); 28 29 disableGeckoProfiling(); 30 enableGeckoProfiling(); 31 32 // Run the same code 33 for (let i = 0; i < 10; i++) { 34 compute(i); 35 } 36 37 // Get how many sources are registered so far again, and compare the before and 38 // after values. The numbers have to be the same. 39 const countAfter = getGeckoProfilingScriptSourcesCount(); 40 assertEq(countAfter, countBefore, 41 `Expected the same amount of script sources to be registered. Before: ${countBefore}, After: ${countAfter}`); 42 43 disableGeckoProfiling();