Bug 20155 - Web Inspector: profiler lumps together anonymous functions created by "new Function" and unnamed evals
Summary: Web Inspector: profiler lumps together anonymous functions created by "new Fu...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction, InRadar
: 25175 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-24 04:39 PDT by Oliver Hunt
Modified: 2016-04-20 17:13 PDT (History)
12 users (show)

See Also:


Attachments
sample named/unnamed and source/eval functions for debugging/profiling (3.24 KB, text/html)
2010-03-17 12:38 PDT, Patrick Mueller
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2008-07-24 04:39:51 PDT
Create multiple functions with the same name, say
f1 = new Function("return 1;")
f2 = new Function("return 2;")

And call them lots of times.  Both functions will be called anonymous, and will get the same entry in the profiler.
Comment 1 Kevin McCullough 2008-07-24 10:57:23 PDT
The title is wrong, if you have two functions with the same name they will not get the same entry in the profiler.  Two anonymous function functions will, because they don't have any line number information or other data to distinguish them.

This would be fixed if we fix https://bugs.webkit.org/show_bug.cgi?id=19229
Comment 2 Timothy Hatcher 2008-07-24 11:01:22 PDT
Why don't we have line numbers? I guess the reason is more specific. If the anonymous function is made with new Function() it seems. Because we do the right things for:

f1 = function() { return 1; }
f2 = function() { return 2; }
Comment 3 Oliver Hunt 2008-07-24 12:02:57 PDT
I suspect that the profiler should be comparing sourceId (or whatever that property is) because
eval("function(){1}") and eval("function(){2}") will both have the same line number, and url (eg. no url)

--Oliver
Comment 4 Kevin McCullough 2008-07-24 14:45:00 PDT
It's dependent on what information is available at the time of execution.  Previously filename and line number were not known.  Can we know the sourceId at execution time?
Comment 5 Oliver Hunt 2008-07-24 14:51:26 PDT
Do we not provide such info?  we do for exceptions and the debugger, so the info is actually available to us.
Comment 6 Timothy Hatcher 2010-02-03 09:19:45 PST
*** Bug 25175 has been marked as a duplicate of this bug. ***
Comment 7 Patrick Mueller 2010-03-17 12:38:23 PDT
Created attachment 50934 [details]
sample named/unnamed and source/eval functions for debugging/profiling

I had put this sample together to submit a new bug regarding lack of source information provided to the profiler, but then found this bug, so thought I'd just paste it on here, since it seems relevant enough.

What it basically shows is that using the latest bits available (including displayName property on Functions to name them, and //@sourceURL= to name eval()'d chunks), the profiler still doesn't provide the source information for eval()'d functions.  But the debugger does.  One of my users has requested that the //@sourceURL bit be supported for profiling as well as debugging.
Comment 8 Radar WebKit Bug Importer 2014-12-17 11:21:40 PST
<rdar://problem/19281484>
Comment 9 Timothy Hatcher 2016-02-04 20:24:23 PST
Is this an issue with the new sampling profiler?
Comment 10 Saam Barati 2016-02-25 11:51:22 PST
(In reply to comment #9)
> Is this an issue with the new sampling profiler?

I'm not sure. I will look into it.
Comment 11 Timothy Hatcher 2016-04-20 17:13:01 PDT
This works as expected in WebKit now with the attached test case.