archives

« Bugzilla Issues Index

#3618 — 9.4.3.2 [[HasProperty]]: Don't traverse prototype chain for string indices


9.4.3.2 [[HasProperty]](P)

Call StringGetIndexProperty before OrdinaryHasProperty to avoid performing a prototype traversal for own string indices.


I think to avoid a breaking change from ES5 the first step has to be an OrdinaryGetOwnProperty and then [[HasProperty]] on the prototype.

I'd actually like to take your suggestion and the breaking change. Do you know if any browsers don't conform to the ES5 behavior?


(In reply to Allen Wirfs-Brock from comment #1)
> I think to avoid a breaking change from ES5 the first step has to be an
> OrdinaryGetOwnProperty and then [[HasProperty]] on the prototype.

Is there any observable difference between the two alternatives? Exotic string objects will never have an own property named `p` where `p` is in an integer indexed property the range `[0, [[StringData]].length[`.


> I'd actually like to take your suggestion and the breaking change. Do you
> know if any browsers don't conform to the ES5 behavior?

I don't quite understand the question. Do you want to know if there is an implementation which does not implement 15.5.5.2 [[GetOwnProperty]] from ES5.1 by first calling the default [[GetOwnProperty]] internal method and then checking string indices?


Nashorn and JSC first check string indices and then call the default [[GetOwnProperty]] method:

Nashorn
http://hg.openjdk.java.net/nashorn/jdk9/nashorn/file/4e97628f17be/src/jdk/nashorn/internal/objects/NativeString.java#l381

JSC
https://github.com/WebKit/webkit/blob/f6ee57e0a00262f5cf0a0c86a89600dfb288db4e/Source/JavaScriptCore/runtime/StringObject.cpp#L47



SpiderMonkey and V8 first call [[GetOwnProperty]] and then check string indices:

SpiderMonkey
https://dxr.mozilla.org/mozilla-central/source/js/src/vm/NativeObject-inl.h#489
https://dxr.mozilla.org/mozilla-central/source/js/src/jsstr.cpp#400

V8
https://chromium.googlesource.com/v8/v8.git/+/43fa6bd41853e53d21cccbea66508c1f9b0f9ac2/src/objects.cc#4092


fixed in rev36 editor's draft

in Comment #1 I was thinking about [[GetOwnProperty]] rather than [[HasProperty]]


in rev36