@@ -270,21 +270,23 @@ RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
270270 HandleScope scope (isolate);
271271 Handle<Object> property = args.at (1 );
272272
273+ // The spec says we must look at the key first, which is why we can't
274+ // use LookupIterator::PropertyOrElement here but have to duplicate its
275+ // functionality instead.
273276 Handle<Name> key;
274- uint32_t index;
275- bool key_is_array_index = property->ToArrayIndex (&index);
276-
277- if (!key_is_array_index) {
277+ size_t index;
278+ bool key_is_index = property->ToIntegerIndex (&index);
279+ if (!key_is_index) {
278280 ASSIGN_RETURN_FAILURE_ON_EXCEPTION (isolate, key,
279281 Object::ToName (isolate, property));
280- key_is_array_index = key->AsArrayIndex (&index);
282+ key_is_index = key->AsIntegerIndex (&index);
281283 }
282284
283285 Handle<Object> object = args.at (0 );
284286
285287 if (object->IsJSModuleNamespace ()) {
286288 if (key.is_null ()) {
287- DCHECK (key_is_array_index );
289+ DCHECK (key_is_index );
288290 // Namespace objects can't have indexed properties.
289291 return ReadOnlyRoots (isolate).false_value ();
290292 }
@@ -304,8 +306,8 @@ RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
304306 {
305307 LookupIterator::Configuration c = LookupIterator::OWN_SKIP_INTERCEPTOR ;
306308 LookupIterator it =
307- key_is_array_index ? LookupIterator (isolate, js_obj, index, js_obj, c)
308- : LookupIterator (js_obj, key, js_obj, c);
309+ key_is_index ? LookupIterator (isolate, js_obj, index, js_obj, c)
310+ : LookupIterator (js_obj, key, js_obj, c);
309311 Maybe<bool > maybe = JSReceiver::HasProperty (&it);
310312 if (maybe.IsNothing ()) return ReadOnlyRoots (isolate).exception ();
311313 DCHECK (!isolate->has_pending_exception ());
@@ -314,14 +316,15 @@ RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
314316
315317 Map map = js_obj->map ();
316318 if (!map.IsJSGlobalProxyMap () &&
317- (key_is_array_index ? !map.has_indexed_interceptor ()
318- : !map.has_named_interceptor ())) {
319+ (key_is_index && index <= JSArray::kMaxArrayIndex
320+ ? !map.has_indexed_interceptor ()
321+ : !map.has_named_interceptor ())) {
319322 return ReadOnlyRoots (isolate).false_value ();
320323 }
321324
322325 // Slow case.
323326 LookupIterator::Configuration c = LookupIterator::OWN ;
324- LookupIterator it = key_is_array_index
327+ LookupIterator it = key_is_index
325328 ? LookupIterator (isolate, js_obj, index, js_obj, c)
326329 : LookupIterator (js_obj, key, js_obj, c);
327330
@@ -332,19 +335,18 @@ RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
332335
333336 } else if (object->IsJSProxy ()) {
334337 if (key.is_null ()) {
335- DCHECK (key_is_array_index );
336- key = isolate->factory ()->Uint32ToString (index);
338+ DCHECK (key_is_index );
339+ key = isolate->factory ()->SizeToString (index);
337340 }
338-
339341 Maybe<bool > result =
340342 JSReceiver::HasOwnProperty (Handle<JSProxy>::cast (object), key);
341343 if (result.IsNothing ()) return ReadOnlyRoots (isolate).exception ();
342344 return isolate->heap ()->ToBoolean (result.FromJust ());
343345
344346 } else if (object->IsString ()) {
345347 return isolate->heap ()->ToBoolean (
346- key_is_array_index
347- ? index < static_cast <uint32_t >(String::cast (*object).length ())
348+ key_is_index
349+ ? index < static_cast <size_t >(String::cast (*object).length ())
348350 : key->Equals (ReadOnlyRoots (isolate).length_string ()));
349351 } else if (object->IsNullOrUndefined (isolate)) {
350352 THROW_NEW_ERROR_RETURN_FAILURE (
0 commit comments