Bug 133832 - Parser statementDepth accounting needs to account for when a function body excludes its braces
Summary: Parser statementDepth accounting needs to account for when a function body ex...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-06-12 17:12 PDT by Mark Lam
Modified: 2014-06-16 16:22 PDT (History)
7 users (show)

See Also:


Attachments
work in progress. The layout test needs some refinement. It is not currently detecting the regression because the harness is not sensitive to it. (14.92 KB, patch)
2014-06-12 18:30 PDT, Mark Lam
no flags Details | Formatted Diff | Diff
perf run 1 (41.73 KB, text/plain)
2014-06-12 18:34 PDT, Mark Lam
no flags Details
perf run 2: (inversed) new patch as Conf#1, baseline as Conf#2. (41.74 KB, text/plain)
2014-06-12 18:34 PDT, Mark Lam
no flags Details
perf run 3 (41.61 KB, text/plain)
2014-06-12 18:35 PDT, Mark Lam
no flags Details
patch 2: fixed tests so that they are more expressive, and can detect the issue in this bug. Still need to look into the JSRegress perf issue. (99.78 KB, patch)
2014-06-13 01:41 PDT, Mark Lam
oliver: review-
Details | Formatted Diff | Diff
patch 3: undo result rephrasing to minimize the diff. Will work on the perf regression next. (46.93 KB, patch)
2014-06-15 13:30 PDT, Mark Lam
no flags Details | Formatted Diff | Diff
patch 4: rebased + Oliver's suggested string change. (46.96 KB, patch)
2014-06-16 15:42 PDT, Mark Lam
oliver: review+
Details | Formatted Diff | Diff
perf run 4 (40.92 KB, text/plain)
2014-06-16 15:43 PDT, Mark Lam
no flags Details
perf run 5 (41.32 KB, text/plain)
2014-06-16 15:43 PDT, Mark Lam
no flags Details
perf run 6 (41.05 KB, text/plain)
2014-06-16 15:43 PDT, Mark Lam
no flags Details
perf run 7: inversed (new code first followed by baseline) (41.28 KB, text/plain)
2014-06-16 15:44 PDT, Mark Lam
no flags Details
perf run 8: inversed (new code first followed by a 2nd build of the baseline) (41.39 KB, text/plain)
2014-06-16 15:45 PDT, Mark Lam
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2014-06-12 17:12:36 PDT
In some cases (e.g. when a Function object is instantiated from a string), the function body source may not include its braces.  The parser needs to account for this when calculating its statementDepth.
Comment 1 Mark Lam 2014-06-12 17:13:32 PDT
<rdar://problem/17056898>
Comment 2 Mark Lam 2014-06-12 18:30:46 PDT
Created attachment 233016 [details]
work in progress.  The layout test needs some refinement.  It is not currently detecting the regression because the harness is not sensitive to it.

This is a work in progress.  The layout test needs some refinement.  Please feel free to provide feedback if so inclined.

The benchmark tests shows that the perf is about the same in aggregate.  However, in 3 separate runs, I'm seeing JSRegress' array-with-double-mul-add showing about a 10% regression.  I will post benchmark results soon, and will investigate the regressions later.
Comment 3 Mark Lam 2014-06-12 18:34:16 PDT
Created attachment 233017 [details]
perf run 1
Comment 4 Mark Lam 2014-06-12 18:34:59 PDT
Created attachment 233018 [details]
perf run 2: (inversed) new patch as Conf#1, baseline as Conf#2.
Comment 5 Mark Lam 2014-06-12 18:35:17 PDT
Created attachment 233019 [details]
perf run 3
Comment 6 Mark Lam 2014-06-13 01:41:04 PDT
Created attachment 233033 [details]
patch 2: fixed tests so that they are more expressive, and can detect the issue in this bug.  Still need to look into the JSRegress perf issue.
Comment 7 Oliver Hunt 2014-06-13 16:49:22 PDT
Comment on attachment 233033 [details]
patch 2: fixed tests so that they are more expressive, and can detect the issue in this bug.  Still need to look into the JSRegress perf issue.

View in context: https://bugs.webkit.org/attachment.cgi?id=233033&action=review

r- due to tests and apparent perf issue

> Source/JavaScriptCore/parser/Parser.cpp:1129
> +        failIfFalseIfStrict(m_statementDepth == 1, "In strict mode, functions may only be declared at top level or immediately within another function");

"Strict mode does not allow function declarations in a lexically nested statement"

> LayoutTests/ChangeLog:4
> +        Parser statementDepth accounting needs to account for when a function body excludes its braces.
> +        <https://webkit.org/b/133832>

Please do the rephrasing in a second patch as it's currently obscuring your meaningful tests invalid vs. valid is fine in our other tests so this rephrasing isn't critical to this patch.
Comment 8 Mark Lam 2014-06-15 13:30:49 PDT
Created attachment 233146 [details]
patch 3: undo result rephrasing to minimize the diff.  Will work on the perf regression next.
Comment 9 Mark Lam 2014-06-16 12:09:05 PDT
(In reply to comment #8)
> Created an attachment (id=233146) [details]
> patch 3: undo result rephrasing to minimize the diff.  Will work on the perf regression next.

The perf issue appears to be a red herring.  I reverted all the "Source" changes and the 10% on array-with-double-mil-add still manifests.  I will rebuild the baseline and redo the test.
Comment 10 Mark Lam 2014-06-16 15:42:38 PDT
Created attachment 233192 [details]
patch 4: rebased + Oliver's suggested string change.

Perf runs shows that the perf is effectively neutral.  The previously supposed regression is just noise.  I'll upload perf results shortly.
Comment 11 Mark Lam 2014-06-16 15:43:13 PDT
Created attachment 233193 [details]
perf run 4
Comment 12 Mark Lam 2014-06-16 15:43:33 PDT
Created attachment 233194 [details]
perf run 5
Comment 13 Mark Lam 2014-06-16 15:43:53 PDT
Created attachment 233195 [details]
perf run 6
Comment 14 Mark Lam 2014-06-16 15:44:36 PDT
Created attachment 233196 [details]
perf run 7: inversed (new code first followed by baseline)
Comment 15 Mark Lam 2014-06-16 15:45:14 PDT
Created attachment 233197 [details]
perf run 8: inversed (new code first followed by a 2nd build of the baseline)
Comment 16 Mark Lam 2014-06-16 16:04:47 PDT
In these new runs of the benchmarks (4 thru 7), the benchmark component that is consistently showing a regression is now bitops-nsieve-bits (in LongSpider) which claims to have about a 1.8x regression.

However, if I do another build of the baseline and run against that (run 8), bitops-nsieve-bits is no longer definitely slower.

If I run just LongSpider, bitops-nsieve-bits shows no difference in perf.
Comment 17 Oliver Hunt 2014-06-16 16:09:55 PDT
Comment on attachment 233192 [details]
patch 4: rebased + Oliver's suggested string change.

r-, please remove the changes to logging in the parser test
Comment 18 Mark Lam 2014-06-16 16:22:49 PDT
Thanks.  Landed in r170034: <http://trac.webkit.org/r170034>.

The logging changes in the parser test was necessary to detect the issues in this bug.  Per Oliver (offline), we'll take the changes as is this time, but in the future, we'll make changes like this in a separate test.