Closed
Bug 1368963
Opened 6 years ago
Closed 6 years ago
Can we remove the GetPropertyKeys call in SetIntegrityLevel when we iterate over shapes?
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla55
Tracking | Status | |
---|---|---|
firefox55 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(1 file, 1 obsolete file)
4.36 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
SetIntegrityLevel() calls GetPropertyKeys() to retrieve the property keys, but the keys aren't used when we iterate over the properties using the shapes. The GetPropertyKeys() call is also not necessary to resolve lazy properties, because PreventExtensions() also calls GetPropertyKeys() to resolve lazy properties. So it looks like to me, we could move the GetPropertyKeys() call into the else-branch in SetIntegrityLevel().
Assignee | ||
Comment 1•6 years ago
|
||
Changes PreventExtensions to directly use getClass()->getEnumerate() to create lazy properties instead of doing this indirectly through GetPropertyKeys(). In case obj->getOpsEnumerate() is defined and the JSNewEnumerateOp hook is allowed to create properties, this patch needs to be updated to handle this case. Do you know if JSNewEnumerateOp is allowed to this kind of side-effect? Similarly update SetIntegrityLevel to only call GetPropertyKeys() when we actually use the keys to iterate over the properties. And furthermore use a vector with a bit of inline-storage, so we don't waste time in malloc when freezing an object with non-zero properties.
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #8873787 -
Flags: review?(jdemooij)
Comment 2•6 years ago
|
||
Comment on attachment 8873787 [details] [diff] [review] bug1368963.patch Review of attachment 8873787 [details] [diff] [review]: ----------------------------------------------------------------- Great! ::: js/src/jsobj.cpp @@ +2767,5 @@ > // element can be added without a call to isExtensible, at the cost of > // performance. > if (obj->isNative()) { > + // Force lazy properties to be resolved. > + if (JSEnumerateOp enumerate = obj->getClass()->getEnumerate()) { I think this is okay. The newEnumerate hook on window can resolve properties but that's not an issue because Object.preventExtensions(window) throws an exception. Once we convert more code to the new hook we should probably call newEnumerate here and then resolve all properties it returns. We can cross that bridge when we get there though.
Attachment #8873787 -
Flags: review?(jdemooij) → review+
Comment 3•6 years ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #2) > Once we convert more code to the new hook we should probably call > newEnumerate here and then resolve all properties it returns. We can cross > that bridge when we get there though. I can do that as part of bug 1370608. I hope we can change JS_EnumerateStandardClasses to JS_NewEnumerateStandardClasses but Object.freeze(this) still has to work in the shell, so we will have to add the "resolve lazy props" logic for that.
Assignee | ||
Comment 4•6 years ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #3) > (In reply to Jan de Mooij [:jandem] from comment #2) > > Once we convert more code to the new hook we should probably call > > newEnumerate here and then resolve all properties it returns. We can cross > > that bridge when we get there though. > > I can do that as part of bug 1370608. I hope we can change > JS_EnumerateStandardClasses to JS_NewEnumerateStandardClasses but > Object.freeze(this) still has to work in the shell, so we will have to add > the "resolve lazy props" logic for that. Okay, great!
Assignee | ||
Comment 5•6 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=5c2f4711c9d7c5e898216a8a1a893dded9170aa5
Keywords: checkin-needed
Assignee | ||
Comment 7•6 years ago
|
||
Rebased patch for checkin.
Attachment #8873787 -
Attachment is obsolete: true
Attachment #8875262 -
Flags: review+
Assignee | ||
Comment 8•6 years ago
|
||
New Try just to be sure: https://treeherder.mozilla.org/#/jobs?repo=try&revision=0852e59493a1fcd73f9c80229f633f3770caebe9
Keywords: checkin-needed
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/48078fb0fcc2 Avoid extra calls to GetPropertyKeys() in Object.freeze/seal/preventExtensions. r=jandem
Keywords: checkin-needed
Comment 10•6 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/48078fb0fcc2
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox55:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in
before you can comment on or make changes to this bug.
Description
•