WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
160590
JSModuleNamespace object should have IC
https://bugs.webkit.org/show_bug.cgi?id=160590
Summary
JSModuleNamespace object should have IC
Yusuke Suzuki
Reported
2016-08-04 23:02:00 PDT
Once the module is introduced, we can consider that namespace object is used so frequently. import * as ns from './A.js' ns.xxx ns.yyy ns.zzz They should have IC. At that time, the Get IC is necessary. But Put IC is not necessary since ns.xxx = value; does not have any effect.
Attachments
Patch
(50.31 KB, patch)
2017-02-18 10:33 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(53.94 KB, patch)
2017-02-18 10:40 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(54.03 KB, patch)
2017-02-18 10:52 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(54.20 KB, patch)
2017-02-19 18:24 PST
,
Yusuke Suzuki
saam
: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Saam Barati
Comment 1
2016-12-28 16:12:44 PST
***
Bug 166458
has been marked as a duplicate of this bug. ***
Yusuke Suzuki
Comment 2
2017-02-18 10:33:06 PST
Created
attachment 302051
[details]
Patch
Yusuke Suzuki
Comment 3
2017-02-18 10:34:05 PST
***
Bug 165725
has been marked as a duplicate of this bug. ***
WebKit Commit Bot
Comment 4
2017-02-18 10:34:32 PST
Attachment 302051
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:48: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:49: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:50: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:51: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:53: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:54: One space before end of line comments [whitespace/comments] [5] Total errors found: 6 in 22 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 5
2017-02-18 10:40:13 PST
Created
attachment 302052
[details]
Patch
WebKit Commit Bot
Comment 6
2017-02-18 10:41:34 PST
Attachment 302052
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:48: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:49: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:50: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:51: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:53: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:54: One space before end of line comments [whitespace/comments] [5] Total errors found: 6 in 23 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 7
2017-02-18 10:52:59 PST
Created
attachment 302053
[details]
Patch
WebKit Commit Bot
Comment 8
2017-02-18 10:54:30 PST
Attachment 302053
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:48: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:49: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:50: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:51: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:53: One space before end of line comments [whitespace/comments] [5] ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:54: One space before end of line comments [whitespace/comments] [5] Total errors found: 6 in 23 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 9
2017-02-19 18:24:40 PST
Created
attachment 302106
[details]
Patch
Saam Barati
Comment 10
2017-02-20 15:49:21 PST
Comment on
attachment 302106
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=302106&action=review
r=me with comments
> Source/JavaScriptCore/ChangeLog:12 > + When constructing the module namespace object, we already resolves all the resolutions.
"resolve all the resolutions" should be changed to maybe "resolve all the imports"?
> Source/JavaScriptCore/bytecode/GetByIdStatus.cpp:47 > +GetByIdStatus::GetByIdStatus(State state, const AccessCase& accessCase)
This feels weird to assert the only use is a Module namespace. Why not make it a static function that has a name indicating its a module namespace access?
> Source/JavaScriptCore/bytecode/GetByIdStatus.cpp:214 > + case AccessCase::ModuleNamespaceLoad: > + return GetByIdStatus(ModuleNamespace, access);
This is guaranteed to only ever have a single entry in the list? Or this just an optimization to see if this is the only kind of case?
> Source/JavaScriptCore/bytecode/ModuleNamespaceAccessCase.cpp:83 > +#if USE(JSVALUE64) > + state.failAndIgnore.append( > + jit.branchTest64(CCallHelpers::Zero, valueRegs.payloadGPR())); > +#else > + state.failAndIgnore.append( > + jit.branch32(CCallHelpers::Equal, valueRegs.tagGPR(), CCallHelpers::TrustedImm32(JSValue::EmptyValueTag))); > +#endif
You should use AssemblyHelpers::branchIfEmpty here.
> Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp:79 > + { > + unsigned i = 0; > + for (const auto& pair : resolutions) > + moduleRecordAt(i++).set(vm, this, pair.second.moduleRecord); > + m_moduleRecord.set(vm, this, moduleRecord); > + } > + > + { > + unsigned moduleRecordOffset = 0; > + m_names.reserveCapacity(resolutions.size()); > + for (const auto& pair : resolutions) { > + m_names.append(pair.first); > + m_exports.add(pair.first.impl(), ExportEntry { > + pair.second.localName, > + moduleRecordOffset > + }); > + ++moduleRecordOffset; > + } > + }
Why two loops?
> Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp:136 > slot.disableCaching();
Why not remove this? This seems to barely work now just because the ordering of how we do checks inside Repatch.
> JSTests/ChangeLog:1 > +2017-02-19 Yusuke Suzuki <
utatane.tea@gmail.com
>
an you also add tests for: - transitive exports - make sure IC works as the binding changes, so perhaps export some function that changes the binding - Tests for various forms of get_by_id ICs that include more than just a module namespace AccessCase. It'd be good to know what complex get by id status does for these. At a minimum, something like: `let v = (c ? namespace : otherThing).foo)`.
Yusuke Suzuki
Comment 11
2017-02-21 00:45:27 PST
Comment on
attachment 302106
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=302106&action=review
Thanks!
>> Source/JavaScriptCore/ChangeLog:12 >> + When constructing the module namespace object, we already resolves all the resolutions. > > "resolve all the resolutions" should be changed to maybe "resolve all the imports"?
It should be "resolve all the exports". Fixed.
>> Source/JavaScriptCore/bytecode/GetByIdStatus.cpp:47 >> +GetByIdStatus::GetByIdStatus(State state, const AccessCase& accessCase) > > This feels weird to assert the only use is a Module namespace. Why not make it a static function that has a name indicating its a module namespace access?
I planned to extend this to accept various kind of accessCase. But sounds fine. I'll create the static function that creates GetByIdStatus for module namespace load.
>> Source/JavaScriptCore/bytecode/GetByIdStatus.cpp:214 >> + return GetByIdStatus(ModuleNamespace, access); > > This is guaranteed to only ever have a single entry in the list? Or this just an optimization to see if this is the only kind of case?
No, we may encounter multiple access cases. But when we see multiple ModuleNamespace / ModuleNamespace + other types of access cases, this should be TakesSlowPath (and IC should handle it in DFG/FTL). Here, we would like to return special TakesSlowPath (ModuleNamespace) iff accessCases have only one case and it is module namespace load.
>> Source/JavaScriptCore/bytecode/ModuleNamespaceAccessCase.cpp:83 >> +#endif > > You should use AssemblyHelpers::branchIfEmpty here.
Nice! I'll apply the same changes to DFG / JIT.
>> Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp:79 >> + } > > Why two loops?
Oops. This is derived from the previous version of this patch. Merging these loops.
>> Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp:136 >> slot.disableCaching(); > > Why not remove this? This seems to barely work now just because the ordering of how we do checks inside Repatch.
Yeah, we can drop this.
>> JSTests/ChangeLog:1 >> +2017-02-19 Yusuke Suzuki <
utatane.tea@gmail.com
> > > an you also add tests for: > - transitive exports > - make sure IC works as the binding changes, so perhaps export some function that changes the binding > - Tests for various forms of get_by_id ICs that include more than just a module namespace AccessCase. It'd be good to know what complex get by id status does for these. At a minimum, something like: `let v = (c ? namespace : otherThing).foo)`.
Sounds fine.
Yusuke Suzuki
Comment 12
2017-02-21 00:55:19 PST
Comment on
attachment 302106
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=302106&action=review
>>> Source/JavaScriptCore/bytecode/GetByIdStatus.cpp:47 >>> +GetByIdStatus::GetByIdStatus(State state, const AccessCase& accessCase) >> >> This feels weird to assert the only use is a Module namespace. Why not make it a static function that has a name indicating its a module namespace access? > > I planned to extend this to accept various kind of accessCase. But sounds fine. I'll create the static function that creates GetByIdStatus for module namespace load.
Or, just taking const ModuleNamespaceAccessCase& is fine. Fixed.
Saam Barati
Comment 13
2017-02-21 00:55:47 PST
One more suggestion for a test: Test for the result being the empty value. (I'm not even sure if it will be possible to make such a test that causes us to cache).
Yusuke Suzuki
Comment 14
2017-02-21 02:31:47 PST
(In reply to
comment #13
)
> One more suggestion for a test: > Test for the result being the empty value. (I'm not even sure if it will be > possible to make such a test that causes us to cache).
Currently, we do not create the cache for such an empty binding. And once the binding is filled, we can never see the case that this binding becomes empty again.
Yusuke Suzuki
Comment 15
2017-02-21 02:41:05 PST
Committed
r212712
: <
http://trac.webkit.org/changeset/212712
>
Ryan Haddad
Comment 16
2017-02-21 09:19:45 PST
(In reply to
comment #15
)
> Committed
r212712
: <
http://trac.webkit.org/changeset/212712
>
It looks like this change broke the CLoop build:
https://build.webkit.org/builders/Apple%20Sierra%20LLINT%20CLoop%20%28BuildAndTest%29/builds/1637
Ryan Haddad
Comment 17
2017-02-21 10:02:31 PST
Reverted
r212712
for reason: This change broke the CLoop build. Committed
r212717
: <
http://trac.webkit.org/changeset/212717
>
Yusuke Suzuki
Comment 18
2017-02-22 01:24:59 PST
Committed
r212818
: <
http://trac.webkit.org/changeset/212818
>
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