New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WebIDL] maplike<> and setlike<> declarations should be resilient to tampered prototypes #1523
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented
@@ -54,11 +54,11 @@ std::pair<bool, std::reference_wrapper<JSC::JSObject>> getBackingMap(JSC::JSGlob | |||
void clearBackingMap(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSObject& backingMap) | |||
{ | |||
auto& vm = JSC::getVM(&lexicalGlobalObject); | |||
auto function = backingMap.get(&lexicalGlobalObject, vm.propertyNames->clear); | |||
auto function = lexicalGlobalObject.mapPrototype()->getDirect(vm, vm.propertyNames->builtinNames().clearPrivateName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about storing these functions in JSGlobalObject's field? Some of the functions are initialized and stored in JSGlobalObject, and used in prototype definition. We can make this kind of initialization ordering graph via LazyProperty. For example, we can check JSGlobalObject::arrayProtoToStringFunction()
.
|
||
JSFunction* valuesFunc = JSFunction::create(vm, globalObject, 0, vm.propertyNames->builtinNames().valuesPublicName().string(), mapProtoFuncValues, JSMapValuesIntrinsic); | ||
putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().valuesPublicName(), valuesFunc, static_cast<unsigned>(PropertyAttribute::DontEnum)); | ||
putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().valuesPrivateName(), valuesFunc, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we initialize these functions in JSGlobalObject, then we do not need to have most of these private properties. (except for forEach). See review comment on JSDOMMapLike.cpp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me and follow-up is OK.
Can you add FIXME about future optimizations?
This all looks good, but I am curious, with you looking at the maplike and setlike implementation if you think using Map and Set underneath is a good idea. The last time I looked, it seemed like in most cases it caused an unnecessary extra copy of the mapping data in most cases as the DOM C++ code usually already had a HashMap or HashSet backing things. |
762bdbc
to
e5fa443
Compare
@weinig That's a very good point, Sam. Noted that in https://bugs.webkit.org/show_bug.cgi?id=241639. I've checked existing The only edge case that needs to handled is converting |
e5fa443
to
af1cc85
Compare
af1cc85
to
e860a23
Compare
Committed r295602 (251607@main): https://commits.webkit.org/251607@main Reviewed commits have been landed. Closing PR #1523 and removing active labels. |
e860a23