WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
206368
[JSC] add DFG/FTL support for op_to_property_key
https://bugs.webkit.org/show_bug.cgi?id=206368
Summary
[JSC] add DFG/FTL support for op_to_property_key
Caitlin Potter (:caitp)
Reported
2020-01-16 12:20:35 PST
Add tiered JIT support for op_to_property_key, used by computed class fields. One small part of
https://bugs.webkit.org/show_bug.cgi?id=195619
Attachments
Patch
(23.81 KB, patch)
2020-01-16 12:25 PST
,
Caitlin Potter (:caitp)
no flags
Details
Formatted Diff
Diff
Patch v2
(27.76 KB, patch)
2020-01-17 09:37 PST
,
Caitlin Potter (:caitp)
no flags
Details
Formatted Diff
Diff
Patch for landing
(28.89 KB, patch)
2020-01-17 15:59 PST
,
Caitlin Potter (:caitp)
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Caitlin Potter (:caitp)
Comment 1
2020-01-16 12:25:57 PST
Created
attachment 387942
[details]
Patch
Yusuke Suzuki
Comment 2
2020-01-16 13:41:16 PST
Comment on
attachment 387942
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=387942&action=review
Looks really nice. I would like to have StringObject handling, which is implemented in ToPrimitive too. Then looks perfect.
> Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:1394 > + case ToPropertyKey: {
Let's handle StringObject case as it is done in ToPrimitive (and add tests). If we detect the input is StringObject and m_graph.canOptimizeStringObjectAccess is true, let's insert a check, and convert it to ToString<>.
> Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:583 > + }
Let's handle StringObject case too, as it is done in ToPrimitive case.
Saam Barati
Comment 3
2020-01-16 23:52:24 PST
Comment on
attachment 387942
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=387942&action=review
LGTM too. I found one minor perf bug
> Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h:2530 > + m_state.setShouldTryConstantFolding(true);
You need to write the code inside DFGConstantFoldingPhase that corresponds to this and actually does the identity conversion.
Caitlin Potter (:caitp)
Comment 4
2020-01-17 09:37:08 PST
Created
attachment 388049
[details]
Patch v2
Caitlin Potter (:caitp)
Comment 5
2020-01-17 09:43:28 PST
Comment on
attachment 387942
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=387942&action=review
Thanks very much for the review. I'd like Caio to get the chance to review this as well, and there is probably some room for improvement before I set CQ+
>> Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h:2530 >> + m_state.setShouldTryConstantFolding(true); > > You need to write the code inside DFGConstantFoldingPhase that corresponds to this and actually does the identity conversion.
Done
>> Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:1394 >> + case ToPropertyKey: { > > Let's handle StringObject case as it is done in ToPrimitive (and add tests). > If we detect the input is StringObject and m_graph.canOptimizeStringObjectAccess is true, let's insert a check, and convert it to ToString<>.
Done, but I'm not super confident on it, so please take another look
>> Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:583 >> + } > > Let's handle StringObject case too, as it is done in ToPrimitive case.
Done (but again, please take another look to make sure the logic I came up with is sound)
Caio Lima
Comment 6
2020-01-17 09:52:10 PST
Comment on
attachment 388049
[details]
Patch v2 View in context:
https://bugs.webkit.org/attachment.cgi?id=388049&action=review
Sorry for the delay here. I just have one minor comment about Prediction propagation.
> Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:580 > + if (child)
I think we should be able to predict `SpecString | SpecSymbol` even when `child == SpecNone`, given those are the only possible output for `ToPropertyKey`.
Yusuke Suzuki
Comment 7
2020-01-17 14:59:48 PST
Comment on
attachment 388049
[details]
Patch v2 View in context:
https://bugs.webkit.org/attachment.cgi?id=388049&action=review
>> Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:580 >> + if (child) > > I think we should be able to predict `SpecString | SpecSymbol` even when `child == SpecNone`, given those are the only possible output for `ToPropertyKey`.
No. Prediction propagation phase is iterative. So, getting SpecNone here is not meaning that this is the final result (let's consider loops etc.). Returning `SpecString | SpecSymbol` for SpecNone pollutes type prediction information unnecessarily and produces inefficient generic code. And, we should return SpecNone for SpecNone, this is better. This phase is not AbstractInterpreter: AI needs to offer proven all possible type, on the other hand, prediction propagation needs to offer "prediction" for efficient execution. The input = SpecNone typically means this code is never executed. Even though, this type prediction could be merged into the active path later (due to the control flow), and in that case, we pollute the prediction accidentally, and leading to the inefficient code.
Yusuke Suzuki
Comment 8
2020-01-17 15:10:54 PST
Comment on
attachment 388049
[details]
Patch v2 View in context:
https://bugs.webkit.org/attachment.cgi?id=388049&action=review
r=me
> Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:1412 > + if (node->child1()->shouldSpeculateStringObject() > + && m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) { > + addCheckStructureForOriginalStringObjectUse(StringObjectUse, node->origin, node->child1().node()); > + fixEdge<StringObjectUse>(node->child1()); > + node->convertToToString(); > + return;
Looks nice.
> Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:1414 > + break;
You can also add `node->child1()->shouldSpeculateStringOrStringObject()` case as ToPrimitive is doing.
> Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:1449 > + if (type & SpecStringObject && m_graph.canOptimizeStringObjectAccess(m_currentNode->origin.semantic)) > + return mergeSpeculations(type & SpecSymbol, SpecString);
Nice.
Yusuke Suzuki
Comment 9
2020-01-17 15:14:08 PST
Comment on
attachment 388049
[details]
Patch v2 View in context:
https://bugs.webkit.org/attachment.cgi?id=388049&action=review
>>> Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:580 >>> + if (child) >> >> I think we should be able to predict `SpecString | SpecSymbol` even when `child == SpecNone`, given those are the only possible output for `ToPropertyKey`. > > No. Prediction propagation phase is iterative. So, getting SpecNone here is not meaning that this is the final result (let's consider loops etc.). Returning `SpecString | SpecSymbol` for SpecNone pollutes type prediction information unnecessarily and produces inefficient generic code. > And, we should return SpecNone for SpecNone, this is better. This phase is not AbstractInterpreter: AI needs to offer proven all possible type, on the other hand, prediction propagation needs to offer "prediction" for efficient execution. > The input = SpecNone typically means this code is never executed. Even though, this type prediction could be merged into the active path later (due to the control flow), and in that case, we pollute the prediction accidentally, and leading to the inefficient code.
One way to consider about this phase is, "Given this prediction input, what is the minimal possible type prediction which covers the input prediction's use case?" So, if the prediction input is saying SpecNone, SpecNone is the minimal possible type prediction output which covers the code producing the input's prediction.
Caio Lima
Comment 10
2020-01-17 15:32:14 PST
(In reply to Yusuke Suzuki from
comment #9
)
> Comment on
attachment 388049
[details]
> Patch v2 > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=388049&action=review
> > >>> Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:580 > >>> + if (child) > >> > >> I think we should be able to predict `SpecString | SpecSymbol` even when `child == SpecNone`, given those are the only possible output for `ToPropertyKey`. > > > > No. Prediction propagation phase is iterative. So, getting SpecNone here is not meaning that this is the final result (let's consider loops etc.). Returning `SpecString | SpecSymbol` for SpecNone pollutes type prediction information unnecessarily and produces inefficient generic code. > > And, we should return SpecNone for SpecNone, this is better. This phase is not AbstractInterpreter: AI needs to offer proven all possible type, on the other hand, prediction propagation needs to offer "prediction" for efficient execution. > > The input = SpecNone typically means this code is never executed. Even though, this type prediction could be merged into the active path later (due to the control flow), and in that case, we pollute the prediction accidentally, and leading to the inefficient code. > > One way to consider about this phase is, "Given this prediction input, what > is the minimal possible type prediction which covers the input prediction's > use case?" > So, if the prediction input is saying SpecNone, SpecNone is the minimal > possible type prediction output which covers the code producing the input's > prediction.
Right! Thanks for the clarification.
Caitlin Potter (:caitp)
Comment 11
2020-01-17 15:59:46 PST
Created
attachment 388103
[details]
Patch for landing
Caitlin Potter (:caitp)
Comment 12
2020-01-17 16:02:30 PST
Comment on
attachment 388049
[details]
Patch v2 View in context:
https://bugs.webkit.org/attachment.cgi?id=388049&action=review
>> Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:1414 >> + break; > > You can also add `node->child1()->shouldSpeculateStringOrStringObject()` case as ToPrimitive is doing.
Done in the patch for landing. I've added a test, which I hope exercises this path, but hard to be sure.
>>>>> Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:580 >>>>> + if (child) >>>> >>>> I think we should be able to predict `SpecString | SpecSymbol` even when `child == SpecNone`, given those are the only possible output for `ToPropertyKey`. >>> >>> No. Prediction propagation phase is iterative. So, getting SpecNone here is not meaning that this is the final result (let's consider loops etc.). Returning `SpecString | SpecSymbol` for SpecNone pollutes type prediction information unnecessarily and produces inefficient generic code. >>> And, we should return SpecNone for SpecNone, this is better. This phase is not AbstractInterpreter: AI needs to offer proven all possible type, on the other hand, prediction propagation needs to offer "prediction" for efficient execution. >>> The input = SpecNone typically means this code is never executed. Even though, this type prediction could be merged into the active path later (due to the control flow), and in that case, we pollute the prediction accidentally, and leading to the inefficient code. >> >> One way to consider about this phase is, "Given this prediction input, what is the minimal possible type prediction which covers the input prediction's use case?" >> So, if the prediction input is saying SpecNone, SpecNone is the minimal possible type prediction output which covers the code producing the input's prediction. > > Right! Thanks for the clarification.
+1, thanks a lot for the explanation here.
Caitlin Potter (:caitp)
Comment 13
2020-01-17 16:13:39 PST
Comment on
attachment 388049
[details]
Patch v2 View in context:
https://bugs.webkit.org/attachment.cgi?id=388049&action=review
>>> Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:1414 >>> + break; >> >> You can also add `node->child1()->shouldSpeculateStringOrStringObject()` case as ToPrimitive is doing. > > Done in the patch for landing. I've added a test, which I hope exercises this path, but hard to be sure.
well, I've just now verified that the path is taken in the test, so that's promising. This doesn't seem like something that would likely be hit in practice, but I guess it's not too expensive to support it. ¯\(°_o)/¯
Caitlin Potter (:caitp)
Comment 14
2020-01-18 09:11:34 PST
I flipped cq+ last night, and reflipped today, but doesn’t seem to be going anywhere
Yusuke Suzuki
Comment 15
2020-01-18 13:45:49 PST
Comment on
attachment 388103
[details]
Patch for landing Reflipped.
Yusuke Suzuki
Comment 16
2020-01-18 13:46:38 PST
cq is currently in migration state from High Sierra => Mojave IIUC. And maybe, in some trouble, not sure whether this is fixed already. Try refliping again now.
WebKit Commit Bot
Comment 17
2020-01-18 14:43:20 PST
The commit-queue encountered the following flaky tests while processing
attachment 388103
[details]
: editing/spelling/spellcheck-attribute.html
bug 206178
(authors:
g.czajkowski@samsung.com
,
mark.lam@apple.com
, and
rniwa@webkit.org
) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 18
2020-01-18 14:43:43 PST
The commit-queue encountered the following flaky tests while processing
attachment 388103
[details]
: editing/spelling/spellcheck-async-remove-frame.html
bug 158401
(authors:
morrita@google.com
,
rniwa@webkit.org
, and
tony@chromium.org
) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 19
2020-01-18 15:14:02 PST
The commit-queue encountered the following flaky tests while processing
attachment 388103
[details]
: editing/spelling/spellcheck-async-remove-frame.html
bug 158401
(authors:
morrita@google.com
,
rniwa@webkit.org
, and
tony@chromium.org
) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 20
2020-01-18 15:14:35 PST
Comment on
attachment 388103
[details]
Patch for landing Clearing flags on attachment: 388103 Committed
r254801
: <
https://trac.webkit.org/changeset/254801
>
WebKit Commit Bot
Comment 21
2020-01-18 15:14:37 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 22
2020-01-18 15:15:13 PST
<
rdar://problem/58713990
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug