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

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

Issue 2769063004: Revert of [debug] do not report unnecessary coverage data. (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 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
53 InspectorTest.log("Test collecting code coverage data with Profiler.collectCover age."); 37 InspectorTest.log("Test collecting code coverage data with Profiler.collectCover age.");
54 38
55 function ClearAndGC() { 39 function ClearAndGC() {
56 return Protocol.Runtime.evaluate({ expression: "fib = g = f = h = is_optimized = null;" }) 40 return Protocol.Runtime.evaluate({ expression: "fib = g = f = h = is_optimized = null;" })
57 .then(GC); 41 .then(GC);
58 } 42 }
59 43
60 function GC() { 44 function GC() {
61 return Protocol.HeapProfiler.enable() 45 return Protocol.HeapProfiler.enable()
62 .then(() => Protocol.HeapProfiler.collectGarbage()) 46 .then(() => Protocol.HeapProfiler.collectGarbage())
(...skipping 24 matching lines...) Expand all
87 .then(ClearAndGC) 71 .then(ClearAndGC)
88 .then(next); 72 .then(next);
89 }, 73 },
90 function testPreciseCountCoverage(next) 74 function testPreciseCountCoverage(next)
91 { 75 {
92 Protocol.Runtime.enable() 76 Protocol.Runtime.enable()
93 .then(Protocol.Profiler.enable) 77 .then(Protocol.Profiler.enable)
94 .then(() => Protocol.Profiler.startPreciseCoverage({callCount: true})) 78 .then(() => Protocol.Profiler.startPreciseCoverage({callCount: true}))
95 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : arguments.callee.name, persistScript: true })) 79 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : arguments.callee.name, persistScript: true }))
96 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId })) 80 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
81 .then(ClearAndGC)
97 .then(InspectorTest.logMessage) 82 .then(InspectorTest.logMessage)
98 .then(ClearAndGC)
99 .then(Protocol.Profiler.takePreciseCoverage) 83 .then(Protocol.Profiler.takePreciseCoverage)
100 .then(LogSorted) 84 .then(LogSorted)
101 .then(Protocol.Profiler.takePreciseCoverage) 85 .then(Protocol.Profiler.takePreciseCoverage)
102 .then(LogSorted) 86 .then(LogSorted)
103 .then(Protocol.Profiler.stopPreciseCoverage) 87 .then(Protocol.Profiler.stopPreciseCoverage)
104 .then(Protocol.Profiler.disable) 88 .then(Protocol.Profiler.disable)
105 .then(Protocol.Runtime.disable) 89 .then(Protocol.Runtime.disable)
106 .then(ClearAndGC) 90 .then(ClearAndGC)
107 .then(next); 91 .then(next);
108 }, 92 },
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 .then(() => Protocol.Runtime.evaluate({ expression: "is_optimized(fib)" }) ) 201 .then(() => Protocol.Runtime.evaluate({ expression: "is_optimized(fib)" }) )
218 .then(message => InspectorTest.logMessage(message)) 202 .then(message => InspectorTest.logMessage(message))
219 .then(Protocol.Profiler.takePreciseCoverage) 203 .then(Protocol.Profiler.takePreciseCoverage)
220 .then(LogSorted) 204 .then(LogSorted)
221 .then(Protocol.Profiler.stopPreciseCoverage) 205 .then(Protocol.Profiler.stopPreciseCoverage)
222 .then(Protocol.Profiler.disable) 206 .then(Protocol.Profiler.disable)
223 .then(Protocol.Runtime.disable) 207 .then(Protocol.Runtime.disable)
224 .then(ClearAndGC) 208 .then(ClearAndGC)
225 .then(next); 209 .then(next);
226 }, 210 },
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 },
267 ]); 211 ]);
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