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

Issue 62146: Add name inference for anonymous functions to facilitate debugging and profiling of JS code. (Closed)

Created:
11 years, 8 months ago by Mikhail Naganov
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Add name inference for anonymous functions to facilitate debugging and profiling of JS code. Currently function name inference is wired with AST optimization pass to avoid introducing another pass over AST. A better solution would be to rewrite AST visitors so they can be naturally combined together in a single pass, as their current implementation doesn't allow it. For examples of cases where function names can be inferred, see the tests file. Committed: http://code.google.com/p/v8/source/detail?r=1696

Patch Set 1 #

Patch Set 2 : updated VStudio projects #

Patch Set 3 : Synced up, updated XCode project file #

Total comments: 11

Patch Set 4 : Addressed Ivan's comments #

Patch Set 5 : updated v8_base_arm project #

Unified diffs Side-by-side diffs Delta from patch set Stats (+572 lines, -41 lines) Patch
M src/SConscript View 1 chunk +2 lines, -1 line 0 comments Download
M src/ast.h View 3 chunks +8 lines, -1 line 0 comments Download
M src/codegen.cc View 3 chunks +5 lines, -2 lines 0 comments Download
M src/codegen-arm.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/codegen-ia32.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/compiler.cc View 2 chunks +8 lines, -5 lines 0 comments Download
M src/frames.h View 2 chunks +2 lines, -9 lines 0 comments Download
M src/frames.cc View 4 chunks +7 lines, -4 lines 0 comments Download
M src/frames-arm.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/frames-ia32.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/frames-inl.h View 1 chunk +13 lines, -0 lines 0 comments Download
A src/func-name-inferrer.h View 1 2 3 1 chunk +125 lines, -0 lines 0 comments Download
A src/func-name-inferrer.cc View 1 chunk +74 lines, -0 lines 0 comments Download
M src/heap.cc View 1 chunk +1 line, -0 lines 0 comments Download
M src/objects.h View 2 chunks +9 lines, -1 line 0 comments Download
M src/objects.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/objects-inl.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/prettyprinter.cc View 2 chunks +2 lines, -0 lines 0 comments Download
M src/rewriter.cc View 1 2 3 10 chunks +39 lines, -10 lines 0 comments Download
M src/runtime.h View 2 chunks +6 lines, -0 lines 0 comments Download
M src/runtime.cc View 3 chunks +11 lines, -3 lines 0 comments Download
M test/cctest/SConscript View 1 chunk +1 line, -0 lines 0 comments Download
A test/cctest/test-func-name-inference.cc View 1 chunk +223 lines, -0 lines 0 comments Download
M tools/v8.xcodeproj/project.pbxproj View 3 5 chunks +8 lines, -0 lines 0 comments Download
M tools/visual_studio/v8_base.vcproj View 1 chunk +8 lines, -0 lines 0 comments Download
M tools/visual_studio/v8_base_arm.vcproj View 1 chunk +8 lines, -0 lines 0 comments Download
M tools/visual_studio/v8_cctest.vcproj View 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Mikhail Naganov
This is an implementation of name inference for anonymous functions which I discussed previously. I ...
11 years, 8 months ago (2009-04-08 14:18:35 UTC) #1
Mikhail Naganov
On 2009/04/08 14:18:35, Mikhail Naganov wrote: > This is an implementation of name inference for ...
11 years, 8 months ago (2009-04-13 17:49:39 UTC) #2
iposva
I have only looked at the Xcode project. Please address the comments before submitting. Thanks, ...
11 years, 8 months ago (2009-04-13 20:49:42 UTC) #3
iposva
Another comment which hopefully will make your code easier to maintain. -Ivan http://codereview.chromium.org/62146/diff/4001/4015 File src/rewriter.cc ...
11 years, 8 months ago (2009-04-13 21:12:30 UTC) #4
Søren Thygesen Gjesse
LGTM Please update the v8_base_arm.vcproj Visual Studio project file as well. http://codereview.chromium.org/62146/diff/4001/4008 File src/func-name-inferrer.cc (right): ...
11 years, 8 months ago (2009-04-13 23:50:11 UTC) #5
Mikhail Naganov
Ivan, thanks for comments! http://codereview.chromium.org/62146/diff/4001/4015 File src/rewriter.cc (right): http://codereview.chromium.org/62146/diff/4001/4015#newcode278 Line 278: bool must_leave_inferrer = false; ...
11 years, 8 months ago (2009-04-13 23:51:37 UTC) #6
Mikhail Naganov
http://codereview.chromium.org/62146/diff/4001/4008 File src/func-name-inferrer.cc (right): http://codereview.chromium.org/62146/diff/4001/4008#newcode39 Line 39: // and starts with a capital letter. On ...
11 years, 8 months ago (2009-04-14 00:18:30 UTC) #7
iposva
11 years, 8 months ago (2009-04-14 00:36:03 UTC) #8
http://codereview.chromium.org/62146/diff/4001/4015
File src/rewriter.cc (left):

http://codereview.chromium.org/62146/diff/4001/4015#oldcode798
Line 798: if (!scope->is_global_scope()) {
On 2009/04/14 00:18:30, Mikhail Naganov wrote:
> On 2009/04/13 23:50:11, Søren Gjesse wrote:
> > Any idea why the global scope used to be skipped here?
> 
> Kevin said that "The AstOptimizer was originally intended as an analysis pass
> that would allow us to make inlining decisions in generated code. Since we
> didn't intend to do any inlining at the global scope anyway, there was no
need."
> 
> I suggest that it makes no harm running it for the global scope, except for
some
> performance penalty in parsing. As I said, I'm avoiding adding another pass,
and
> no other AstVisitor suits better for doing name inference. Let's wait for
Kasper
> before submitting. 

Since I put the AstOptimizer in initially here was the reasoning:
Originally the AstOptimizer was only tracking likely types through the code and
did advise the backend for which operations to emit inline Smi checks. At the
time this optimization was deemed unneeded for global code that runs only once.
We have since added additional functionality to the AstOptimizer and already
seen bugs because it was not run on global code. I strongly suggest that my
initial decision was a premature optimization and that we should always run the
AstOptimizer. When you do, please file a reminder bug for Kevin to remove his
special handling of global code in the backend. In any case you should verify
that compilation speed of global code is not impacted severely, but on the other
hand we are already running this optimization step on all other code (which is
the majority of the source in well-written code anyway.)

I don't think there is a need to wait for Kasper's input for this particular
question as he is still on holiday.

Powered by Google App Engine
This is Rietveld 408576698