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

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

Issue 2766573003: [debug] introduce precise binary code coverage. (Closed)
Patch Set: 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
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..b50180e69af125f4572efc663f8e196b4c925dec 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() {
@@ -60,9 +66,9 @@ InspectorTest.runTestSuite([
.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)
@@ -78,10 +84,10 @@ 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)
@@ -94,9 +100,9 @@ InspectorTest.runTestSuite([
.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)
@@ -110,8 +116,8 @@ InspectorTest.runTestSuite([
.then(LogSorted)
.then(Protocol.Profiler.getBestEffortCoverage)
.then(LogSorted)
- .then(ClearAndGC)
.then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
.then(next);
},
function testBestEffortCoveragePrecise(next)
@@ -131,6 +137,7 @@ InspectorTest.runTestSuite([
.then(Protocol.Profiler.stopPreciseCoverage)
.then(Protocol.Profiler.disable)
.then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
.then(next);
},
function testEnablePreciseCoverageAtPause(next)
@@ -149,9 +156,36 @@ InspectorTest.runTestSuite([
.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 testPreciseCoverageBinary(next)
+ {
+ Protocol.Runtime.enable()
+ .then(Protocol.Profiler.enable)
+ .then(() => Protocol.Profiler.startPreciseCoverage({binary: true}))
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "6", 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);
},
]);

Powered by Google App Engine
This is Rietveld 408576698