WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
195901
[JSC] Generator should not create JSLexicalEnvironment if it is not necessary
https://bugs.webkit.org/show_bug.cgi?id=195901
Summary
[JSC] Generator should not create JSLexicalEnvironment if it is not necessary
Yusuke Suzuki
Reported
2019-03-18 11:58:38 PDT
When looking into the cells allocated in JetStream2 Basic, I found that so many empty JSLexicalEnvironments are allocated. I think this is because the current implementation of ES6 Generators always allocates JSLexicalEnvironments for their suspend and resume. However it seems that fair amount of generators do not load and store registers, and we are allocating empty JSLexicalEnvironments. Currently, still I'm investigating, but if it is true, we should emit op_create_lexical_environment only when the generatorification says it is required.
Attachments
Patch
(11.74 KB, patch)
2019-03-18 18:00 PDT
,
Yusuke Suzuki
saam
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2019-03-18 11:59:12 PDT
(In reply to Yusuke Suzuki from
comment #0
)
> When looking into the cells allocated in JetStream2 Basic, I found that so > many empty JSLexicalEnvironments are allocated. > I think this is because the current implementation of ES6 Generators always > allocates JSLexicalEnvironments for their suspend and resume. > However it seems that fair amount of generators do not load and store > registers, and we are allocating empty JSLexicalEnvironments. > Currently, still I'm investigating, but if it is true, we should emit > op_create_lexical_environment only when the generatorification says it is > required.
In addition to memory footprint improvement, it potentially brings performance improvement.
Yusuke Suzuki
Comment 2
2019-03-18 12:04:05 PDT
(In reply to Yusuke Suzuki from
comment #1
)
> (In reply to Yusuke Suzuki from
comment #0
) > > When looking into the cells allocated in JetStream2 Basic, I found that so > > many empty JSLexicalEnvironments are allocated. > > I think this is because the current implementation of ES6 Generators always > > allocates JSLexicalEnvironments for their suspend and resume. > > However it seems that fair amount of generators do not load and store > > registers, and we are allocating empty JSLexicalEnvironments.=
Hmm, it seems this is not correct. But it seems that it is correct that Basic allocates so many empty JSLexicalEnvironments. I'm investigating what is going on.
Yusuke Suzuki
Comment 3
2019-03-18 12:08:06 PDT
(In reply to Yusuke Suzuki from
comment #2
)
> (In reply to Yusuke Suzuki from
comment #1
) > > (In reply to Yusuke Suzuki from
comment #0
) > > > When looking into the cells allocated in JetStream2 Basic, I found that so > > > many empty JSLexicalEnvironments are allocated. > > > I think this is because the current implementation of ES6 Generators always > > > allocates JSLexicalEnvironments for their suspend and resume. > > > However it seems that fair amount of generators do not load and store > > > registers, and we are allocating empty JSLexicalEnvironments.= > > Hmm, it seems this is not correct. But it seems that it is correct that > Basic allocates so many empty JSLexicalEnvironments. I'm investigating what > is going on.
No, it was correct. We are allocating empty JSLexicalEnvironment due to empty generator.
Yusuke Suzuki
Comment 4
2019-03-18 18:00:02 PDT
Created
attachment 365095
[details]
Patch
Saam Barati
Comment 5
2019-03-18 18:22:24 PDT
Comment on
attachment 365095
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=365095&action=review
> Source/JavaScriptCore/ChangeLog:11 > + are allocated in RAMification Basic test.
"RAMification Basic" => "RAMification's Basic"
> Source/JavaScriptCore/bytecode/BytecodeGeneratorification.cpp:286 > + rewriter.insertFragmentAfter(instruction, [&](BytecodeRewriter::Fragment& fragment) {
style nit: I think space between "]" and "("
> Source/JavaScriptCore/bytecode/BytecodeGeneratorification.cpp:288 > + // Generator frame is not necessary. Let's remove it if we can.
Let's rename this comment to say something like: "This will cause us to put jsUndefined() into the generator frame's scope value."
> Source/JavaScriptCore/bytecode/BytecodeUseDef.h:160 > + USES(OpCreateGeneratorFrameEnvironment, scope)
Do we not need to use initialValue/SymbolTable here?
> Source/JavaScriptCore/bytecode/BytecodeUseDef.h:368 > + USES(OpCreateGeneratorFrameEnvironment, dst)
This needs to be DEFS
Yusuke Suzuki
Comment 6
2019-03-18 18:35:44 PDT
Comment on
attachment 365095
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=365095&action=review
Thanks!
>> Source/JavaScriptCore/ChangeLog:11 >> + are allocated in RAMification Basic test. > > "RAMification Basic" => "RAMification's Basic"
Fixed.
>> Source/JavaScriptCore/bytecode/BytecodeGeneratorification.cpp:286 >> + rewriter.insertFragmentAfter(instruction, [&](BytecodeRewriter::Fragment& fragment) { > > style nit: I think space between "]" and "("
Fixed.
>> Source/JavaScriptCore/bytecode/BytecodeGeneratorification.cpp:288 >> + // Generator frame is not necessary. Let's remove it if we can. > > Let's rename this comment to say something like: > "This will cause us to put jsUndefined() into the generator frame's scope value."
Sounds nice. Fixed.
>> Source/JavaScriptCore/bytecode/BytecodeUseDef.h:160 >> + USES(OpCreateGeneratorFrameEnvironment, scope) > > Do we not need to use initialValue/SymbolTable here?
Since op_create_lexical_environment / op_create_generator_frame_environment require that symbolTable / initialValue are constant, it will not affect on the correctness. But we can add them anyway, added.
>> Source/JavaScriptCore/bytecode/BytecodeUseDef.h:368 >> + USES(OpCreateGeneratorFrameEnvironment, dst) > > This needs to be DEFS
Fixed.
Yusuke Suzuki
Comment 7
2019-03-18 19:21:18 PDT
Committed
r243127
: <
https://trac.webkit.org/changeset/243127
>
Radar WebKit Bug Importer
Comment 8
2019-03-18 19:22:16 PDT
<
rdar://problem/49004255
>
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