Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upOrdinary* methods inconsistent in invoking [[*]] vs Ordinary* in their steps #394
Comments
annevk
referenced this issue
Feb 17, 2016
Merged
Define security around Window, WindowProxy, and Location properly #638
bterlson
added
the
question
label
Feb 17, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Feb 22, 2016
Contributor
It seems to be doable to replace OrdinaryGetOwnProperty with [[GetOwnProperty]] in OrdinaryHasProperty. The internal methods for String and Arguments objects only require two simple changes:
-
String objects
- [[HasProperty]] can be removed
- StringGetIndexProperty can be inlined into [[GetOwnProperty]]
-
Arguments objects
- [[HasProperty]] needs to be added to avoid throwing a TypeError for
"caller" in arguments(when the legacycallerproperty is supported)
[[HasProperty]](P) 1. Let _args_ be the arguments object. 1. If _P_ is `"caller"`, then 1. Let _desc_ be OrdinaryGetOwnProperty(_args_, _P_). 1. If IsDataDescriptor(_desc_) is *true*, return *true*. 1. Return OrdinaryHasProperty(_args_, _P_). NOTE: If an implementation does not provide a built-in caller property for argument exotic objects then step 2 of this algorithm must be skipped.
- [[HasProperty]] needs to be added to avoid throwing a TypeError for
|
It seems to be doable to replace
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Feb 24, 2016
Member
The change suggested by @anba seems fine.
I'm not sure this is an invariant per se - I could still imagine calling an ordinary object method's abstract operation directly at some point if needed. But since we wouldn't at all after this change, I would be ok including this as a note of sorts in 9.1, stating something like:
Each ordinary object internal method delegates to a similarly-named abstract operation. If such an abstract operation depends on another internal method, then the internal method it is invoked by referencing the slot on O rather than calling the abstract operation directly. This semantics ensures that exotic objects have their overridden internal methods invoked when ordinary object internal methods are applied to them.
|
The change suggested by @anba seems fine. I'm not sure this is an invariant per se - I could still imagine calling an ordinary object method's abstract operation directly at some point if needed. But since we wouldn't at all after this change, I would be ok including this as a note of sorts in 9.1, stating something like:
|
annevk commentedFeb 15, 2016
OrdinaryHasPropertyinvokesOrdinaryGetOwnPropertydirectly, not[[GetOwnProperty]].The other
Ordinary*methods we introduced invoke[[*]]rather thanOrdinary*in their algorithms. The former is more useful for reuse by theWindowProxyandLocationexotic objects, but I can imagine the latter being important for some cases too. Is there a reasonOrdinaryHasPropertybehaves the way it does?Even if
OrdinaryHasPropertyremains the way it is, can I be sure that we will not changeOrdinaryGetet al from invoking[[*]]to invokingOrdinary*?