RESOLVED FIXED 190340
[JSC] JSC should have "parseFunction" to optimize Function constructor
https://bugs.webkit.org/show_bug.cgi?id=190340
Summary [JSC] JSC should have "parseFunction" to optimize Function constructor
Yusuke Suzuki
Reported 2018-10-07 12:25:40 PDT
In Function constructor, we parse code three times if we have `Function("p0", "p1", "body")` since we need to ensure 1. parameters are syntax valid 2. body is syntax valid 3. parse all the things together We can optimize this situation by having a special customized function parseFunction, which will take the end position of the parameters.
Attachments
Patch (5.13 MB, patch)
2018-10-07 14:49 PDT, Yusuke Suzuki
no flags
Patch (5.14 MB, patch)
2018-10-07 15:19 PDT, Yusuke Suzuki
ews-watchlist: commit-queue-
Archive of layout-test-results from ews102 for mac-sierra (2.46 MB, application/zip)
2018-10-07 16:40 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews114 for mac-sierra (3.14 MB, application/zip)
2018-10-07 17:30 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews124 for ios-simulator-wk2 (2.37 MB, application/zip)
2018-10-07 19:29 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews115 for mac-sierra (3.10 MB, application/zip)
2018-10-07 19:36 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews104 for mac-sierra-wk2 (2.92 MB, application/zip)
2018-10-07 21:07 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews200 for win-future (12.84 MB, application/zip)
2018-10-07 21:36 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews123 for ios-simulator-wk2 (2.36 MB, application/zip)
2018-10-07 23:29 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews203 for win-future (12.71 MB, application/zip)
2018-10-08 03:54 PDT, EWS Watchlist
no flags
Patch (64.13 KB, patch)
2018-10-08 04:12 PDT, Yusuke Suzuki
no flags
Patch (64.14 KB, patch)
2018-10-08 05:15 PDT, Yusuke Suzuki
no flags
Patch (66.66 KB, patch)
2018-10-08 07:01 PDT, Yusuke Suzuki
mark.lam: review+
Yusuke Suzuki
Comment 1 2018-10-07 13:27:18 PDT
web-tooling-benchmark/uglify-js heavily stresses Function constructor.
Yusuke Suzuki
Comment 2 2018-10-07 14:49:06 PDT
Created attachment 351744 [details] Patch WIP
Yusuke Suzuki
Comment 3 2018-10-07 15:13:47 PDT
OK, ready.
Yusuke Suzuki
Comment 4 2018-10-07 15:19:33 PDT
EWS Watchlist
Comment 5 2018-10-07 16:40:53 PDT
Comment on attachment 351746 [details] Patch Attachment 351746 [details] did not pass mac-ews (mac): Output: https://webkit-queues.webkit.org/results/9484297 New failing tests: fast/events/attribute-listener-deletion-crash.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-late.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/inline-event-handler-ordering.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-attribute.html fast/dom/attribute-event-listener-errors.html fast/events/window-onerror-syntax-error-in-attr.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-body-onerror.html js/dom/invalid-syntax-for-function.html js/dom/script-start-end-locations.html
EWS Watchlist
Comment 6 2018-10-07 16:40:55 PDT
Created attachment 351751 [details] Archive of layout-test-results from ews102 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 7 2018-10-07 17:30:14 PDT
Comment on attachment 351746 [details] Patch Attachment 351746 [details] did not pass mac-debug-ews (mac): Output: https://webkit-queues.webkit.org/results/9484432 New failing tests: fast/events/attribute-listener-deletion-crash.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-late.html js/dom/script-start-end-locations.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/inline-event-handler-ordering.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-attribute.html fast/dom/attribute-event-listener-errors.html fast/events/window-onerror-syntax-error-in-attr.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-body-onerror.html js/dom/invalid-syntax-for-function.html
EWS Watchlist
Comment 8 2018-10-07 17:30:15 PDT
Created attachment 351754 [details] Archive of layout-test-results from ews114 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews114 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 9 2018-10-07 19:29:25 PDT
Comment on attachment 351746 [details] Patch Attachment 351746 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/9484870 New failing tests: imported/w3c/web-platform-tests/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-late.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/inline-event-handler-ordering.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-attribute.html fast/dom/attribute-event-listener-errors.html fast/events/window-onerror-syntax-error-in-attr.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-body-onerror.html js/dom/invalid-syntax-for-function.html js/dom/script-start-end-locations.html
EWS Watchlist
Comment 10 2018-10-07 19:29:26 PDT
Created attachment 351756 [details] Archive of layout-test-results from ews124 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews124 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.6
EWS Watchlist
Comment 11 2018-10-07 19:36:03 PDT
Comment on attachment 351746 [details] Patch Attachment 351746 [details] did not pass mac-debug-ews (mac): Output: https://webkit-queues.webkit.org/results/9485386 New failing tests: fast/events/attribute-listener-deletion-crash.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-late.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/inline-event-handler-ordering.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-attribute.html fast/dom/attribute-event-listener-errors.html fast/events/window-onerror-syntax-error-in-attr.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-body-onerror.html js/dom/invalid-syntax-for-function.html js/dom/script-start-end-locations.html
EWS Watchlist
Comment 12 2018-10-07 19:36:05 PDT
Created attachment 351757 [details] Archive of layout-test-results from ews115 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews115 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 13 2018-10-07 21:07:46 PDT
Comment on attachment 351746 [details] Patch Attachment 351746 [details] did not pass mac-wk2-ews (mac-wk2): Output: https://webkit-queues.webkit.org/results/9486068 New failing tests: fast/events/attribute-listener-deletion-crash.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-late.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/inline-event-handler-ordering.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-attribute.html fast/dom/attribute-event-listener-errors.html fast/events/window-onerror-syntax-error-in-attr.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-body-onerror.html js/dom/invalid-syntax-for-function.html js/dom/script-start-end-locations.html
EWS Watchlist
Comment 14 2018-10-07 21:07:48 PDT
Created attachment 351760 [details] Archive of layout-test-results from ews104 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 15 2018-10-07 21:36:11 PDT
Comment on attachment 351746 [details] Patch Attachment 351746 [details] did not pass win-ews (win): Output: https://webkit-queues.webkit.org/results/9486115 New failing tests: js/dom/invalid-syntax-for-function.html fast/events/attribute-listener-deletion-crash.html js/dom/script-start-end-locations.html fast/dom/attribute-event-listener-errors.html fast/events/window-onerror-syntax-error-in-attr.html
EWS Watchlist
Comment 16 2018-10-07 21:36:23 PDT
Created attachment 351761 [details] Archive of layout-test-results from ews200 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews200 Port: win-future Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
EWS Watchlist
Comment 17 2018-10-07 23:28:58 PDT
Comment on attachment 351746 [details] Patch Attachment 351746 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/9486237 New failing tests: imported/w3c/web-platform-tests/html/webappapis/scripting/events/invalid-uncompiled-raw-handler-compiled-late.html imported/w3c/web-platform-tests/html/webappapis/scripting/events/inline-event-handler-ordering.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-attribute.html fast/dom/attribute-event-listener-errors.html fast/events/window-onerror-syntax-error-in-attr.html imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/compile-error-in-body-onerror.html js/dom/invalid-syntax-for-function.html js/dom/script-start-end-locations.html
EWS Watchlist
Comment 18 2018-10-07 23:29:00 PDT
Created attachment 351762 [details] Archive of layout-test-results from ews123 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.6
EWS Watchlist
Comment 19 2018-10-08 03:54:29 PDT
Comment on attachment 351746 [details] Patch Attachment 351746 [details] did not pass win-ews (win): Output: https://webkit-queues.webkit.org/results/9487240 New failing tests: js/dom/invalid-syntax-for-function.html fast/events/attribute-listener-deletion-crash.html js/dom/script-start-end-locations.html fast/dom/attribute-event-listener-errors.html fast/events/window-onerror-syntax-error-in-attr.html
EWS Watchlist
Comment 20 2018-10-08 03:54:44 PDT
Created attachment 351767 [details] Archive of layout-test-results from ews203 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews203 Port: win-future Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Yusuke Suzuki
Comment 21 2018-10-08 04:12:29 PDT
Yusuke Suzuki
Comment 22 2018-10-08 05:15:48 PDT
Yusuke Suzuki
Comment 23 2018-10-08 07:01:21 PDT
Caio Lima
Comment 24 2018-10-09 05:02:59 PDT
Comment on attachment 351774 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=351774&action=review Nice patch! Giving some comments in the code. > Source/JavaScriptCore/parser/Parser.cpp:2502 > + semanticFailIfFalse(lastTokenEndPosition().offset == *parametersEndPosition, "Parameters should be composed of arguments offered for parameters in Function constructor"); I'm not sure if I'm right here because of some edge cases, but maybe the message "Parameters should match arguments offered as parameters in Function constructor" is more clear about the error. > Source/JavaScriptCore/parser/Parser.cpp:2935 > + failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::Unnamed, parseMode, false, isConstructor ? constructorKind : ConstructorKind::None, SuperBinding::Needed, methodStart, methodInfo, FunctionDefinitionType::Method, std::nullopt)), "Cannot parse this method"); Maybe making ```parametersEndPosition``` default to ```std::nullopt``` in ```parseFunctionInfo``` would make this code more readable. > Source/JavaScriptCore/parser/Parser.cpp:4078 > + failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::Unnamed, parseMode, false, ConstructorKind::None, SuperBinding::Needed, methodStart, methodInfo, FunctionDefinitionType::Method, std::nullopt)), "Cannot parse this method"); Ditto. > Source/JavaScriptCore/parser/Parser.cpp:4113 > + failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::Unnamed, SourceParseMode::GetterMode, false, constructorKind, SuperBinding::Needed, getterOrSetterStartOffset, info, FunctionDefinitionType::Method, std::nullopt)), "Cannot parse getter definition"); Ditto. > Source/JavaScriptCore/parser/Parser.cpp:4116 > + failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::Unnamed, SourceParseMode::SetterMode, false, constructorKind, SuperBinding::Needed, getterOrSetterStartOffset, info, FunctionDefinitionType::Method, std::nullopt)), "Cannot parse setter definition"); Ditto. > Source/JavaScriptCore/parser/Parser.cpp:4368 > + failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::None, parseMode, false, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, functionInfo, FunctionDefinitionType::Expression, std::nullopt)), "Cannot parse function expression"); Ditto. > Source/JavaScriptCore/parser/Parser.cpp:4386 > + failIfFalse(parseFunctionInfo(context, FunctionNameRequirements::None, parseMode, false, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, functionInfo, FunctionDefinitionType::Expression, std::nullopt), parseMode == SourceParseMode::AsyncFunctionMode ? "Cannot parse async function expression" : "Cannot parse async generator function expression"); Ditto. > Source/JavaScriptCore/parser/Parser.cpp:4891 > + failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::Unnamed, parseMode, true, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, info, FunctionDefinitionType::Expression, std::nullopt)), "Cannot parse arrow function expression"); Ditto.
Mark Lam
Comment 25 2018-10-11 13:46:51 PDT
Comment on attachment 351774 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=351774&action=review r=me > Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp:177 > + JSObject*& exception, int overrideLineNumber, std::optional<int> parametersEndPosition) Since parametersEndPosition is only ever used for FunctionConstructors, can you rename it as functionConstructorParametersEndPosition everywhere below? I think that that documents its intent better. > Source/JavaScriptCore/parser/Parser.cpp:247 > + else { > + if (parsingContext == ParsingContext::FunctionConstructor) > + sourceElements = parseSingleFunction(context, parametersEndPosition); > + else > + sourceElements = parseSourceElements(context, CheckForStrictMode); > + } No need to indent this. You can just express this as: else if (parsingContext == ParsingContext::FunctionConstructor) sourceElements = parseSingleFunction(context, parametersEndPosition); else sourceElements = parseSourceElements(context, CheckForStrictMode); >> Source/JavaScriptCore/parser/Parser.cpp:2502 >> + semanticFailIfFalse(lastTokenEndPosition().offset == *parametersEndPosition, "Parameters should be composed of arguments offered for parameters in Function constructor"); > > I'm not sure if I'm right here because of some edge cases, but maybe the message "Parameters should match arguments offered as parameters in Function constructor" is more clear about the error. I like Caio's suggestion "Parameters should match arguments offered as parameters in Function constructor" because it's more concise. >> Source/JavaScriptCore/parser/Parser.cpp:2935 >> + failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::Unnamed, parseMode, false, isConstructor ? constructorKind : ConstructorKind::None, SuperBinding::Needed, methodStart, methodInfo, FunctionDefinitionType::Method, std::nullopt)), "Cannot parse this method"); > > Maybe making ```parametersEndPosition``` default to ```std::nullopt``` in ```parseFunctionInfo``` would make this code more readable. I can go either way with this. There are already places in the code where you're relying on having a default value for the parametersEndPosition. For that reason, I'm slightly more include to prefer using a default value for this case as well. I'll leave this to your discretion.
Yusuke Suzuki
Comment 26 2018-10-11 16:41:53 PDT
Comment on attachment 351774 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=351774&action=review Thanks! >> Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp:177 >> + JSObject*& exception, int overrideLineNumber, std::optional<int> parametersEndPosition) > > Since parametersEndPosition is only ever used for FunctionConstructors, can you rename it as functionConstructorParametersEndPosition everywhere below? I think that that documents its intent better. Changed. >> Source/JavaScriptCore/parser/Parser.cpp:247 >> + } > > No need to indent this. You can just express this as: > > else if (parsingContext == ParsingContext::FunctionConstructor) > sourceElements = parseSingleFunction(context, parametersEndPosition); > else > sourceElements = parseSourceElements(context, CheckForStrictMode); Fixed. >>> Source/JavaScriptCore/parser/Parser.cpp:2502 >>> + semanticFailIfFalse(lastTokenEndPosition().offset == *parametersEndPosition, "Parameters should be composed of arguments offered for parameters in Function constructor"); >> >> I'm not sure if I'm right here because of some edge cases, but maybe the message "Parameters should match arguments offered as parameters in Function constructor" is more clear about the error. > > I like Caio's suggestion "Parameters should match arguments offered as parameters in Function constructor" because it's more concise. OK, changed the message. >>> Source/JavaScriptCore/parser/Parser.cpp:2935 >>> + failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::Unnamed, parseMode, false, isConstructor ? constructorKind : ConstructorKind::None, SuperBinding::Needed, methodStart, methodInfo, FunctionDefinitionType::Method, std::nullopt)), "Cannot parse this method"); >> >> Maybe making ```parametersEndPosition``` default to ```std::nullopt``` in ```parseFunctionInfo``` would make this code more readable. > > I can go either way with this. There are already places in the code where you're relying on having a default value for the parametersEndPosition. For that reason, I'm slightly more include to prefer using a default value for this case as well. I'll leave this to your discretion. Changed to use std::nullopt default value.
Yusuke Suzuki
Comment 27 2018-10-11 16:44:05 PDT
Radar WebKit Bug Importer
Comment 28 2018-10-11 16:45:42 PDT
Saam Barati
Comment 29 2018-10-15 11:37:18 PDT
This is a 6% regression on JetStream 2 on iOS
WebKit Commit Bot
Comment 30 2018-10-15 11:39:21 PDT
Re-opened since this is blocked by bug 190593
Saam Barati
Comment 31 2018-10-15 11:49:32 PDT
ARES6 is also regressed by this. JetStream 2 regressions: - Air 50% worse. - Babylong 10% worse - async-fs 13% worse - acorn-wtb 20% worse - cypto-sha1-sp 37% worse - delta-blue 13% worse
Yusuke Suzuki
Comment 32 2018-10-15 22:35:56 PDT
(In reply to Saam Barati from comment #31) > ARES6 is also regressed by this. > > JetStream 2 regressions: > - Air 50% worse. > - Babylong 10% worse > - async-fs 13% worse > - acorn-wtb 20% worse > - cypto-sha1-sp 37% worse > - delta-blue 13% worse Is it reproducible on non-iOS environments? I've just managed to run ARES6/Air on my MacBook Pro, and it seems perf-neutral. Before this patch. Running... Air ( 1 to go) firstIteration: 56.18 +- 17.03 ms averageWorstCase: 22.78 +- 1.37 ms steadyState: 5.87 +- 0.10 ms summary: 22.96 +- 1.69 ms Running... Basic ( 1 to go) firstIteration: 26.95 +- 3.97 ms averageWorstCase: 13.54 +- 2.63 ms steadyState: 6.88 +- 0.83 ms summary: 22.96 +- 1.69 ms Running... Babylon ( 1 to go) firstIteration: 35.80 +- 5.07 ms averageWorstCase: 17.42 +- 3.28 ms steadyState: 5.67 +- 0.08 ms summary: 22.96 +- 1.69 ms Running... ML ( 1 to go) firstIteration: 95.11 +- 4.23 ms averageWorstCase: 61.22 +- 3.27 ms steadyState: 56.85 +- 2.85 ms summary: 22.89 +- 1.29 ms After this patch. Running... Air ( 1 to go) firstIteration: 55.42 +- 14.54 ms averageWorstCase: 22.96 +- 1.14 ms steadyState: 5.88 +- 0.06 ms summary: 22.98 +- 1.27 ms Running... Basic ( 1 to go) firstIteration: 26.07 +- 3.85 ms averageWorstCase: 12.57 +- 1.10 ms steadyState: 6.64 +- 0.37 ms summary: 22.98 +- 1.27 ms Running... Babylon ( 1 to go) firstIteration: 36.04 +- 5.69 ms averageWorstCase: 18.40 +- 1.15 ms steadyState: 5.80 +- 0.14 ms summary: 22.98 +- 1.27 ms Running... ML ( 1 to go) firstIteration: 95.47 +- 4.10 ms averageWorstCase: 62.02 +- 1.80 ms steadyState: 57.82 +- 2.64 ms summary: 22.89 +- 0.99 ms
Saam Barati
Comment 33 2018-10-16 13:58:04 PDT
Our Mac bots do not show a regression. Unfortunately, our iOS bots went down after your patch landed for ~3 days. I'll need to do some manual testing. Unfortunately, I have some other urgent work I'm doing today. I'll need to help you and run some A/B tests locally, hopefully I'll have time tomorrow.
Saam Barati
Comment 34 2018-10-17 13:24:10 PDT
I just tried to reproduce this locally and could not. Maybe our bots were in a weird state or it was some other revision. Let's reland this and I'll monitor our bots.
Yusuke Suzuki
Comment 35 2018-10-18 05:59:57 PDT
(In reply to Saam Barati from comment #34) > I just tried to reproduce this locally and could not. Maybe our bots were in > a weird state or it was some other revision. Let's reland this and I'll > monitor our bots. Nice! I'll land it :). Let me know if the regression happens!
Yusuke Suzuki
Comment 36 2018-10-18 06:04:27 PDT
WebKit Commit Bot
Comment 37 2018-10-19 13:35:04 PDT
Re-opened since this is blocked by bug 190760
Yusuke Suzuki
Comment 38 2018-10-21 04:56:36 PDT
Comment on attachment 351774 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=351774&action=review > Source/JavaScriptCore/runtime/FunctionConstructor.cpp:129 > + auto body = args.at(args.size() - 1).toString(exec)->viewWithUnderlyingString(exec); Not sure why this patch causes regression in iOS devices, but changing this to ` auto body = args.at(args.size() - 1).toWTFString(exec);` could be one attempt.
Saam Barati
Comment 39 2018-10-21 10:40:29 PDT
(In reply to Yusuke Suzuki from comment #38) > Comment on attachment 351774 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=351774&action=review > > > Source/JavaScriptCore/runtime/FunctionConstructor.cpp:129 > > + auto body = args.at(args.size() - 1).toString(exec)->viewWithUnderlyingString(exec); > > Not sure why this patch causes regression in iOS devices, but changing this > to ` auto body = args.at(args.size() - 1).toWTFString(exec);` could be one > attempt. If you send me a patch (or multiple patches to test) I can kick off A/B tasks.
Saam Barati
Comment 40 2018-10-21 10:40:59 PDT
(In reply to Saam Barati from comment #39) > (In reply to Yusuke Suzuki from comment #38) > > Comment on attachment 351774 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=351774&action=review > > > > > Source/JavaScriptCore/runtime/FunctionConstructor.cpp:129 > > > + auto body = args.at(args.size() - 1).toString(exec)->viewWithUnderlyingString(exec); > > > > Not sure why this patch causes regression in iOS devices, but changing this > > to ` auto body = args.at(args.size() - 1).toWTFString(exec);` could be one > > attempt. > > If you send me a patch (or multiple patches to test) I can kick off A/B > tasks. The patches should be in svn patch format
Yusuke Suzuki
Comment 41 2018-10-25 20:31:27 PDT
(In reply to Saam Barati from comment #40) > (In reply to Saam Barati from comment #39) > > (In reply to Yusuke Suzuki from comment #38) > > > Comment on attachment 351774 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=351774&action=review > > > > > > > Source/JavaScriptCore/runtime/FunctionConstructor.cpp:129 > > > > + auto body = args.at(args.size() - 1).toString(exec)->viewWithUnderlyingString(exec); > > > > > > Not sure why this patch causes regression in iOS devices, but changing this > > > to ` auto body = args.at(args.size() - 1).toWTFString(exec);` could be one > > > attempt. > > > > If you send me a patch (or multiple patches to test) I can kick off A/B > > tasks. > > The patches should be in svn patch format I guess the issue is not directly related to this patch since ARES-6/Air is not heavily using Function constructor (correct?). My guess is that Parser.cpp change involves inline/noinline decision in the compiler and causes the regression. To ensure this, I would like to land the Parser.cpp change separately. In this first attempt, we land the Parser.cpp changes, but we do not use it at all. If it does not cause the regression, it is fine. We should investigate the other issues. But if it causes the regression, we need to add tricky ALWAYS_INLINE / NEVER_INLINE carefully on the actual machine.
Yusuke Suzuki
Comment 42 2018-10-25 21:52:04 PDT
Yusuke Suzuki
Comment 43 2018-10-25 21:59:52 PDT
(In reply to Yusuke Suzuki from comment #42) > Committed r237445: <https://trac.webkit.org/changeset/237445> Attempt to roll in the partial change of the patch. It includes Parser.cpp etc. changes. But FunctionConstructor does not use it at all. If it causes the regression, I think inlining decision of Parser.cpp functions seems culprit. If it does not pose the regression, we can investigate FunctionConstructor's change (it is small).
Saam Barati
Comment 44 2018-10-26 12:26:37 PDT
(In reply to Yusuke Suzuki from comment #43) > (In reply to Yusuke Suzuki from comment #42) > > Committed r237445: <https://trac.webkit.org/changeset/237445> > > Attempt to roll in the partial change of the patch. It includes Parser.cpp > etc. changes. But FunctionConstructor does not use it at all. > If it causes the regression, I think inlining decision of Parser.cpp > functions seems culprit. If it does not pose the regression, we can > investigate FunctionConstructor's change (it is small). This caused a regression
WebKit Commit Bot
Comment 45 2018-10-26 12:29:37 PDT
Re-opened since this is blocked by bug 190972
Yusuke Suzuki
Comment 46 2018-10-26 12:33:35 PDT
(In reply to Saam Barati from comment #44) > (In reply to Yusuke Suzuki from comment #43) > > (In reply to Yusuke Suzuki from comment #42) > > > Committed r237445: <https://trac.webkit.org/changeset/237445> > > > > Attempt to roll in the partial change of the patch. It includes Parser.cpp > > etc. changes. But FunctionConstructor does not use it at all. > > If it causes the regression, I think inlining decision of Parser.cpp > > functions seems culprit. If it does not pose the regression, we can > > investigate FunctionConstructor's change (it is small). > > This caused a regression So, it seems that this regression is due to Parser.cpp's inlining decision change due to the slight code changes, since the added path is not used in the FunctionConstructor.
Yusuke Suzuki
Comment 47 2018-10-26 13:51:34 PDT
(In reply to Yusuke Suzuki from comment #46) > (In reply to Saam Barati from comment #44) > > (In reply to Yusuke Suzuki from comment #43) > > > (In reply to Yusuke Suzuki from comment #42) > > > > Committed r237445: <https://trac.webkit.org/changeset/237445> > > > > > > Attempt to roll in the partial change of the patch. It includes Parser.cpp > > > etc. changes. But FunctionConstructor does not use it at all. > > > If it causes the regression, I think inlining decision of Parser.cpp > > > functions seems culprit. If it does not pose the regression, we can > > > investigate FunctionConstructor's change (it is small). > > > > This caused a regression > > So, it seems that this regression is due to Parser.cpp's inlining decision > change due to the slight code changes, since the added path is not used in > the FunctionConstructor. First I thought that this patch broke the CodeCache thing, but I investigated and it seems working correctly. So, Parser.cpp's inlining decision seems culprit. Is there any way to explore the appropriate `ALWAYS_INLINE` / `NEVER_INLINE` configuration?
Yusuke Suzuki
Comment 48 2018-10-27 07:41:27 PDT
Yusuke Suzuki
Comment 49 2018-10-27 07:42:51 PDT
(In reply to Yusuke Suzuki from comment #48) > Committed r237492: <https://trac.webkit.org/changeset/237492> Landed with -Parser.{h,cpp} changes. I believe this does not cause any regression. And it also ensures that Parser.{h,cpp}'s inlining decision change is the cause of the regression on iOS devices.
Saam Barati
Comment 50 2018-10-29 11:13:50 PDT
(In reply to Yusuke Suzuki from comment #49) > (In reply to Yusuke Suzuki from comment #48) > > Committed r237492: <https://trac.webkit.org/changeset/237492> > > Landed with -Parser.{h,cpp} changes. I believe this does not cause any > regression. > And it also ensures that Parser.{h,cpp}'s inlining decision change is the > cause of the regression on iOS devices. This causes the regression.
Saam Barati
Comment 51 2018-10-29 11:36:34 PDT
(In reply to Saam Barati from comment #50) > (In reply to Yusuke Suzuki from comment #49) > > (In reply to Yusuke Suzuki from comment #48) > > > Committed r237492: <https://trac.webkit.org/changeset/237492> > > > > Landed with -Parser.{h,cpp} changes. I believe this does not cause any > > regression. > > And it also ensures that Parser.{h,cpp}'s inlining decision change is the > > cause of the regression on iOS devices. > > This causes the regression. I'm going to roll it out.
WebKit Commit Bot
Comment 52 2018-10-29 11:37:52 PDT
Re-opened since this is blocked by bug 191035
Yusuke Suzuki
Comment 53 2018-10-30 01:17:11 PDT
(In reply to WebKit Commit Bot from comment #52) > Re-opened since this is blocked by bug 191035 Interesting! Hm, computeHash would be culprit. I'll land the Parser part which does not include the SourceCode caching part.
Yusuke Suzuki
Comment 54 2018-10-30 02:00:25 PDT
Yusuke Suzuki
Comment 55 2018-10-30 02:11:00 PDT
(In reply to Yusuke Suzuki from comment #54) > Committed r237586: <https://trac.webkit.org/changeset/237586> Then, I've just landed the Parser changes, I hope it does not cause any regression.
Yusuke Suzuki
Comment 56 2018-11-09 03:32:48 PST
Saam Barati
Comment 57 2018-11-12 13:21:37 PST
Rolling code cache changes out in: https://bugs.webkit.org/show_bug.cgi?id=191555
Yusuke Suzuki
Comment 58 2018-11-14 10:49:30 PST
Yusuke Suzuki
Comment 59 2018-11-18 11:10:14 PST
Yusuke Suzuki
Comment 60 2018-11-19 07:18:36 PST
https://perf.webkit.org/v3/#/charts?paneList=((19-1))&since=1542035849013 Perf progression in DOM/Event since event handlers use function constructor implementation to materialize a function object.
Note You need to log in before you can comment on or make changes to this bug.