Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: test/inspector/cpu-profiler/coverage.js

Issue 2766573003: [debug] introduce precise binary code coverage. (Closed)
Patch Set: fix test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/inspector/cpu-profiler/coverage-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/cpu-profiler/coverage.js
diff --git a/test/inspector/cpu-profiler/coverage.js b/test/inspector/cpu-profiler/coverage.js
index 495b53699531f56ee4c489a14e6178094fbc51b9..00d9b3b09f3c0a7d6bd16b3d09ea6c2eaf9121ab 100644
--- a/test/inspector/cpu-profiler/coverage.js
+++ b/test/inspector/cpu-profiler/coverage.js
@@ -2,12 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// Flags: --allow-natives-syntax
+
var source =
`
function fib(x) {
if (x < 2) return 1;
return fib(x-1) + fib(x-2);
}
+function is_optimized(f) {
+ return (%GetOptimizationStatus(f) & 16) ? "optimized" : "unoptimized";
+}
(function iife() {
return 1;
})();
@@ -32,7 +37,8 @@ f(3);
InspectorTest.log("Test collecting code coverage data with Profiler.collectCoverage.");
function ClearAndGC() {
- return Protocol.Runtime.evaluate({ expression: "fib = null;" }).then(GC);
+ return Protocol.Runtime.evaluate({ expression: "fib = g = f = h = is_optimized = null;" })
+ .then(GC);
}
function GC() {
@@ -47,30 +53,30 @@ function LogSorted(message) {
}
InspectorTest.runTestSuite([
- function testPreciseBaseline(next)
+ function testPreciseCountBaseline(next)
{
Protocol.Runtime.enable()
- .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "0", persistScript: true }))
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: arguments.callee.name, persistScript: true }))
.then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
.then(GC)
.then(Protocol.Profiler.enable)
- .then(Protocol.Profiler.startPreciseCoverage)
+ .then(() => Protocol.Profiler.startPreciseCoverage({callCount: true}))
.then(Protocol.Profiler.takePreciseCoverage)
.then(LogSorted)
.then(Protocol.Profiler.takePreciseCoverage)
.then(LogSorted)
.then(Protocol.Profiler.stopPreciseCoverage)
- .then(ClearAndGC)
.then(Protocol.Profiler.disable)
.then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
.then(next);
},
- function testPreciseCoverage(next)
+ function testPreciseCountCoverage(next)
{
Protocol.Runtime.enable()
.then(Protocol.Profiler.enable)
- .then(Protocol.Profiler.startPreciseCoverage)
- .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "1", persistScript: true }))
+ .then(() => Protocol.Profiler.startPreciseCoverage({callCount: true}))
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: arguments.callee.name, persistScript: true }))
.then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
.then(ClearAndGC)
.then(InspectorTest.logMessage)
@@ -78,31 +84,31 @@ InspectorTest.runTestSuite([
.then(LogSorted)
.then(Protocol.Profiler.takePreciseCoverage)
.then(LogSorted)
- .then(ClearAndGC)
.then(Protocol.Profiler.stopPreciseCoverage)
.then(Protocol.Profiler.disable)
.then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
.then(next);
},
function testPreciseCoverageFail(next)
{
Protocol.Runtime.enable()
.then(Protocol.Profiler.enable)
- .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "2", persistScript: true }))
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: arguments.callee.name, persistScript: true }))
.then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
.then(InspectorTest.logMessage)
.then(ClearAndGC)
.then(Protocol.Profiler.takePreciseCoverage)
.then(InspectorTest.logMessage)
- .then(ClearAndGC)
.then(Protocol.Profiler.disable)
.then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
.then(next);
},
function testBestEffortCoverage(next)
{
Protocol.Runtime.enable()
- .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "3", persistScript: true }))
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: arguments.callee.name, persistScript: true }))
.then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
.then(InspectorTest.logMessage)
.then(ClearAndGC)
@@ -110,16 +116,36 @@ InspectorTest.runTestSuite([
.then(LogSorted)
.then(Protocol.Profiler.getBestEffortCoverage)
.then(LogSorted)
- .then(ClearAndGC)
.then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
.then(next);
},
- function testBestEffortCoveragePrecise(next)
+ function testBestEffortCoverageWithPreciseBinaryEnabled(next)
+ {
+ Protocol.Runtime.enable()
+ .then(Protocol.Profiler.enable)
+ .then(Protocol.Profiler.startPreciseCoverage)
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: arguments.callee.name, persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
+ .then(InspectorTest.logMessage)
+ .then(ClearAndGC)
+ .then(Protocol.Profiler.getBestEffortCoverage)
+ .then(LogSorted)
+ .then(Protocol.Profiler.getBestEffortCoverage)
+ .then(LogSorted)
+ .then(ClearAndGC)
+ .then(Protocol.Profiler.stopPreciseCoverage)
+ .then(Protocol.Profiler.disable)
+ .then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
+ .then(next);
+ },
+ function testBestEffortCoverageWithPreciseCountEnabled(next)
{
Protocol.Runtime.enable()
.then(Protocol.Profiler.enable)
- .then(Protocol.Profiler.startPreciseCoverage)
- .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "4", persistScript: true }))
+ .then(() => Protocol.Profiler.startPreciseCoverage({callCount: true}))
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: arguments.callee.name, persistScript: true }))
.then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
.then(InspectorTest.logMessage)
.then(ClearAndGC)
@@ -131,27 +157,55 @@ InspectorTest.runTestSuite([
.then(Protocol.Profiler.stopPreciseCoverage)
.then(Protocol.Profiler.disable)
.then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
.then(next);
},
- function testEnablePreciseCoverageAtPause(next)
+ function testEnablePreciseCountCoverageAtPause(next)
{
function handleDebuggerPause() {
Protocol.Profiler.enable()
- .then(Protocol.Profiler.startPreciseCoverage)
+ .then(() => Protocol.Profiler.startPreciseCoverage({callCount: true}))
.then(Protocol.Debugger.resume)
}
Protocol.Debugger.enable();
Protocol.Debugger.oncePaused().then(handleDebuggerPause);
Protocol.Runtime.enable()
- .then(() => Protocol.Runtime.compileScript({ expression: break_source, sourceURL: "5", persistScript: true }))
+ .then(() => Protocol.Runtime.compileScript({ expression: break_source, sourceURL: arguments.callee.name, persistScript: true }))
.then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
.then(InspectorTest.logMessage)
.then(ClearAndGC)
.then(Protocol.Profiler.takePreciseCoverage)
.then(LogSorted)
+ .then(ClearAndGC)
.then(Protocol.Profiler.stopPreciseCoverage)
.then(Protocol.Profiler.disable)
.then(Protocol.Runtime.disable)
+ .then(Protocol.Debugger.disable)
+ .then(ClearAndGC)
+ .then(next);
+ },
+ function testPreciseBinaryCoverage(next)
+ {
+ Protocol.Runtime.enable()
+ .then(Protocol.Profiler.enable)
+ .then(Protocol.Profiler.startPreciseCoverage)
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: arguments.callee.name, persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
+ .then(InspectorTest.logMessage)
+ .then(Protocol.Profiler.takePreciseCoverage)
+ .then(LogSorted)
+ .then(() => Protocol.Runtime.evaluate({ expression: "is_optimized(fib)" }))
+ .then(message => InspectorTest.logMessage(message))
+ .then(() => Protocol.Runtime.evaluate({ expression: "fib(20)" }))
+ .then(message => InspectorTest.logMessage(message))
+ .then(() => Protocol.Runtime.evaluate({ expression: "is_optimized(fib)" }))
+ .then(message => InspectorTest.logMessage(message))
+ .then(Protocol.Profiler.takePreciseCoverage)
+ .then(LogSorted)
+ .then(Protocol.Profiler.stopPreciseCoverage)
+ .then(Protocol.Profiler.disable)
+ .then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
.then(next);
},
]);
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/inspector/cpu-profiler/coverage-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698