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

Side by Side Diff: test/inspector/cpu-profiler/coverage.js

Issue 2764073004: [debug] do not report unnecessary coverage data. (Closed)
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « src/debug/debug-coverage.cc ('k') | test/inspector/cpu-profiler/coverage-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --allow-natives-syntax 5 // Flags: --allow-natives-syntax
6 6
7 var source = 7 var source =
8 ` 8 `
9 function fib(x) { 9 function fib(x) {
10 if (x < 2) return 1; 10 if (x < 2) return 1;
(...skipping 16 matching lines...) Expand all
27 function f(x) { 27 function f(x) {
28 if (x == 0) g(); 28 if (x == 0) g();
29 else f(x - 1); 29 else f(x - 1);
30 } 30 }
31 function h() { 31 function h() {
32 g(); 32 g();
33 } 33 }
34 f(3); 34 f(3);
35 `; 35 `;
36 36
37 var nested =
38 `
39 var f = (function outer() {
40 function nested_0() {
41 return function nested_1() {
42 return function nested_2() {
43 return function nested_3() {}
44 }
45 }
46 }
47 function nested_4() {}
48 return nested_0();
49 })();
50 f()()();
51 `;
52
37 InspectorTest.log("Test collecting code coverage data with Profiler.collectCover age."); 53 InspectorTest.log("Test collecting code coverage data with Profiler.collectCover age.");
38 54
39 function ClearAndGC() { 55 function ClearAndGC() {
40 return Protocol.Runtime.evaluate({ expression: "fib = g = f = h = is_optimized = null;" }) 56 return Protocol.Runtime.evaluate({ expression: "fib = g = f = h = is_optimized = null;" })
41 .then(GC); 57 .then(GC);
42 } 58 }
43 59
44 function GC() { 60 function GC() {
45 return Protocol.HeapProfiler.enable() 61 return Protocol.HeapProfiler.enable()
46 .then(() => Protocol.HeapProfiler.collectGarbage()) 62 .then(() => Protocol.HeapProfiler.collectGarbage())
(...skipping 24 matching lines...) Expand all
71 .then(ClearAndGC) 87 .then(ClearAndGC)
72 .then(next); 88 .then(next);
73 }, 89 },
74 function testPreciseCountCoverage(next) 90 function testPreciseCountCoverage(next)
75 { 91 {
76 Protocol.Runtime.enable() 92 Protocol.Runtime.enable()
77 .then(Protocol.Profiler.enable) 93 .then(Protocol.Profiler.enable)
78 .then(() => Protocol.Profiler.startPreciseCoverage({callCount: true})) 94 .then(() => Protocol.Profiler.startPreciseCoverage({callCount: true}))
79 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : arguments.callee.name, persistScript: true })) 95 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : arguments.callee.name, persistScript: true }))
80 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId })) 96 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
97 .then(InspectorTest.logMessage)
81 .then(ClearAndGC) 98 .then(ClearAndGC)
82 .then(InspectorTest.logMessage)
83 .then(Protocol.Profiler.takePreciseCoverage) 99 .then(Protocol.Profiler.takePreciseCoverage)
84 .then(LogSorted) 100 .then(LogSorted)
85 .then(Protocol.Profiler.takePreciseCoverage) 101 .then(Protocol.Profiler.takePreciseCoverage)
86 .then(LogSorted) 102 .then(LogSorted)
87 .then(Protocol.Profiler.stopPreciseCoverage) 103 .then(Protocol.Profiler.stopPreciseCoverage)
88 .then(Protocol.Profiler.disable) 104 .then(Protocol.Profiler.disable)
89 .then(Protocol.Runtime.disable) 105 .then(Protocol.Runtime.disable)
90 .then(ClearAndGC) 106 .then(ClearAndGC)
91 .then(next); 107 .then(next);
92 }, 108 },
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 .then(() => Protocol.Runtime.evaluate({ expression: "is_optimized(fib)" }) ) 217 .then(() => Protocol.Runtime.evaluate({ expression: "is_optimized(fib)" }) )
202 .then(message => InspectorTest.logMessage(message)) 218 .then(message => InspectorTest.logMessage(message))
203 .then(Protocol.Profiler.takePreciseCoverage) 219 .then(Protocol.Profiler.takePreciseCoverage)
204 .then(LogSorted) 220 .then(LogSorted)
205 .then(Protocol.Profiler.stopPreciseCoverage) 221 .then(Protocol.Profiler.stopPreciseCoverage)
206 .then(Protocol.Profiler.disable) 222 .then(Protocol.Profiler.disable)
207 .then(Protocol.Runtime.disable) 223 .then(Protocol.Runtime.disable)
208 .then(ClearAndGC) 224 .then(ClearAndGC)
209 .then(next); 225 .then(next);
210 }, 226 },
227 function testPreciseEmptyScriptCoverageEntries(next)
228 {
229 // Enabling the debugger holds onto script objects even though its
230 // functions can be garbage collected. We would get empty ScriptCoverage
231 // entires unless we remove them.
232 Protocol.Debugger.enable()
233 .then(Protocol.Runtime.enable)
234 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : arguments.callee.name, persistScript: true }))
235 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
236 .then(ClearAndGC)
237 .then(Protocol.Profiler.enable)
238 .then(Protocol.Profiler.startPreciseCoverage)
239 .then(Protocol.Profiler.takePreciseCoverage)
240 .then(LogSorted)
241 .then(Protocol.Profiler.stopPreciseCoverage)
242 .then(Protocol.Profiler.disable)
243 .then(Protocol.Runtime.disable)
244 .then(Protocol.Debugger.disable)
245 .then(ClearAndGC)
246 .then(next);
247 },
248 function testPreciseCountCoveragePartial(next)
249 {
250 Protocol.Runtime.enable()
251 .then(Protocol.Profiler.enable)
252 .then(() => Protocol.Profiler.startPreciseCoverage({callCount: true}))
253 .then(() => Protocol.Runtime.compileScript({ expression: nested, sourceURL : arguments.callee.name, persistScript: true }))
254 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
255 .then(InspectorTest.logMessage)
256 .then(Protocol.Profiler.takePreciseCoverage)
257 .then(LogSorted)
258 .then(() => Protocol.Runtime.evaluate({ expression: "f()" }))
259 .then(Protocol.Profiler.takePreciseCoverage)
260 .then(LogSorted)
261 .then(Protocol.Profiler.stopPreciseCoverage)
262 .then(Protocol.Profiler.disable)
263 .then(Protocol.Runtime.disable)
264 .then(ClearAndGC)
265 .then(next);
266 },
211 ]); 267 ]);
OLDNEW
« no previous file with comments | « src/debug/debug-coverage.cc ('k') | test/inspector/cpu-profiler/coverage-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698