Closed Bug 1097694 Opened 5 years ago Closed 5 years ago

js::HasOwnProperty sanity surgery

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: jorendorff, Assigned: jorendorff)

Details

Attachments

(1 file, 1 obsolete file)

* Rename the clownshoes js::HasOwnProperty signature to js::NonProxyLookupOwnProperty, which is what it really is.
* Change the sane js::HasOwnProperty signature to use the hasOwn handler when the argument is a proxy, as that's what it's there for. Gah.
Attachment #8521428 - Flags: review?(efaustbmo)
* Rename the clownshoes js::HasOwnProperty signature to js::NonProxyLookupOwnProperty, which is what it really is.
* Change the sane js::HasOwnProperty signature to use the hasOwn handler when the argument is a proxy, as that's what it's there for.
* Change the DirectProxyHandler::hasOwn implementation to use js::HasOwnProperty, so that when target is also a proxy, we end up calling its hasOwn handler.  Similar changes in ScriptedDirectProxyHandler.cpp.
Attachment #8521935 - Flags: review?(efaustbmo)
Attachment #8521428 - Attachment is obsolete: true
Attachment #8521428 - Flags: review?(efaustbmo)
The first version of the patch caused a bunch of breakage because structured cloning stopped working on WaiveXray proxies. After 30 minutes in GDB, I found myself looking at *obviously* wrong code in DirectProxyHandler::hasOwn. #clownshoes
Comment on attachment 8521935 [details] [diff] [review]
js::HasOwnProperty sanity surgery

Review of attachment 8521935 [details] [diff] [review]:
-----------------------------------------------------------------

This makes good sense to me. Another solid improvement to the property handling.

::: js/src/proxy/DirectProxyHandler.cpp
@@ -220,5 @@
>      RootedObject target(cx, proxy->as<ProxyObject>().target());
> -    Rooted<PropertyDescriptor> desc(cx);
> -    if (!JS_GetPropertyDescriptorById(cx, target, id, &desc))
> -        return false;
> -    *bp = (desc.object() == target);

This is an insidious idiom and I am more than happy to see it go. Own means own.
Attachment #8521935 - Flags: review?(efaustbmo) → review-
Comment on attachment 8521935 [details] [diff] [review]
js::HasOwnProperty sanity surgery

Review of attachment 8521935 [details] [diff] [review]:
-----------------------------------------------------------------

This makes good sense to me. Another solid improvement to the property handling. Clearly intended to + this.

::: js/src/proxy/DirectProxyHandler.cpp
@@ -220,5 @@
>      RootedObject target(cx, proxy->as<ProxyObject>().target());
> -    Rooted<PropertyDescriptor> desc(cx);
> -    if (!JS_GetPropertyDescriptorById(cx, target, id, &desc))
> -        return false;
> -    *bp = (desc.object() == target);

This is an insidious idiom and I am more than happy to see it go. Own means own.
Attachment #8521935 - Flags: review- → review+
https://hg.mozilla.org/mozilla-central/rev/4a897b65fd0e
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.