@@ -212,7 +212,7 @@ void LookupIterator::ReloadPropertyInformation() {
212
212
213
213
namespace {
214
214
215
- bool IsTypedArrayFunctionInAnyContext (Isolate* isolate, JSReceiver holder ) {
215
+ bool IsTypedArrayFunctionInAnyContext (Isolate* isolate, HeapObject object ) {
216
216
static uint32_t context_slots[] = {
217
217
#define TYPED_ARRAY_CONTEXT_SLOTS (Type, type, TYPE, ctype ) \
218
218
Context::TYPE##_ARRAY_FUN_INDEX,
@@ -221,17 +221,19 @@ bool IsTypedArrayFunctionInAnyContext(Isolate* isolate, JSReceiver holder) {
221
221
#undef TYPED_ARRAY_CONTEXT_SLOTS
222
222
};
223
223
224
- if (!holder .IsJSFunction (isolate)) return false ;
224
+ if (!object .IsJSFunction (isolate)) return false ;
225
225
226
226
return std::any_of (
227
227
std::begin (context_slots), std::end (context_slots),
228
- [=](uint32_t slot) { return isolate->IsInAnyContext (holder , slot); });
228
+ [=](uint32_t slot) { return isolate->IsInAnyContext (object , slot); });
229
229
}
230
230
231
231
} // namespace
232
232
233
233
void LookupIterator::InternalUpdateProtector () {
234
234
if (isolate_->bootstrapper ()->IsActive ()) return ;
235
+ if (!receiver_->IsHeapObject ()) return ;
236
+ Handle <HeapObject> receiver = Handle <HeapObject>::cast (receiver_);
235
237
236
238
Handle <NativeContext> native_context = isolate_->native_context ();
237
239
@@ -244,70 +246,74 @@ void LookupIterator::InternalUpdateProtector() {
244
246
return ;
245
247
}
246
248
// Setting the constructor property could change an instance's @@species
247
- if (holder_ ->IsJSArray (isolate_)) {
249
+ if (receiver ->IsJSArray (isolate_)) {
248
250
if (!isolate_->IsArraySpeciesLookupChainIntact ()) return ;
249
251
isolate_->CountUsage (
250
252
v8::Isolate::UseCounterFeature::kArrayInstanceConstructorModified );
251
253
isolate_->InvalidateArraySpeciesProtector ();
252
254
return ;
253
- } else if (holder_ ->IsJSPromise (isolate_)) {
255
+ } else if (receiver ->IsJSPromise (isolate_)) {
254
256
if (!isolate_->IsPromiseSpeciesLookupChainIntact ()) return ;
255
257
isolate_->InvalidatePromiseSpeciesProtector ();
256
258
return ;
257
- } else if (holder_ ->IsJSRegExp (isolate_)) {
259
+ } else if (receiver ->IsJSRegExp (isolate_)) {
258
260
if (!isolate_->IsRegExpSpeciesLookupChainIntact (native_context)) return ;
259
261
isolate_->InvalidateRegExpSpeciesProtector (native_context);
260
262
return ;
261
- } else if (holder_ ->IsJSTypedArray (isolate_)) {
263
+ } else if (receiver ->IsJSTypedArray (isolate_)) {
262
264
if (!isolate_->IsTypedArraySpeciesLookupChainIntact ()) return ;
263
265
isolate_->InvalidateTypedArraySpeciesProtector ();
264
266
return ;
265
267
}
266
- if (holder_ ->map (isolate_).is_prototype_map ()) {
268
+ if (receiver ->map (isolate_).is_prototype_map ()) {
267
269
DisallowHeapAllocation no_gc;
268
270
// Setting the constructor of any prototype with the @@species protector
269
271
// (of any realm) also needs to invalidate the protector.
270
- // For typed arrays, we check a prototype of this holder since TypedArrays
271
- // have different prototypes for each type, and their parent prototype is
272
- // pointing the same TYPED_ARRAY_PROTOTYPE.
273
- if (isolate_->IsInAnyContext (*holder_ ,
272
+ // For typed arrays, we check a prototype of this receiver since
273
+ // TypedArrays have different prototypes for each type, and their parent
274
+ // prototype is pointing the same TYPED_ARRAY_PROTOTYPE.
275
+ if (isolate_->IsInAnyContext (*receiver ,
274
276
Context::INITIAL_ARRAY_PROTOTYPE_INDEX)) {
275
277
if (!isolate_->IsArraySpeciesLookupChainIntact ()) return ;
276
278
isolate_->CountUsage (
277
279
v8::Isolate::UseCounterFeature::kArrayPrototypeConstructorModified );
278
280
isolate_->InvalidateArraySpeciesProtector ();
279
- } else if (isolate_->IsInAnyContext (*holder_ ,
281
+ } else if (isolate_->IsInAnyContext (*receiver ,
280
282
Context::PROMISE_PROTOTYPE_INDEX)) {
281
283
if (!isolate_->IsPromiseSpeciesLookupChainIntact ()) return ;
282
284
isolate_->InvalidatePromiseSpeciesProtector ();
283
- } else if (isolate_->IsInAnyContext (*holder_ ,
285
+ } else if (isolate_->IsInAnyContext (*receiver ,
284
286
Context::REGEXP_PROTOTYPE_INDEX)) {
285
287
if (!isolate_->IsRegExpSpeciesLookupChainIntact (native_context)) return ;
286
288
isolate_->InvalidateRegExpSpeciesProtector (native_context);
287
289
} else if (isolate_->IsInAnyContext (
288
- holder_ ->map (isolate_).prototype (isolate_),
290
+ receiver ->map (isolate_).prototype (isolate_),
289
291
Context::TYPED_ARRAY_PROTOTYPE_INDEX)) {
290
292
if (!isolate_->IsTypedArraySpeciesLookupChainIntact ()) return ;
291
293
isolate_->InvalidateTypedArraySpeciesProtector ();
292
294
}
293
295
}
294
296
} else if (*name_ == roots.next_string ()) {
295
- if (isolate_->IsInAnyContext (
296
- *holder_, Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX)) {
297
+ if (receiver->IsJSArrayIterator () ||
298
+ isolate_->IsInAnyContext (
299
+ *receiver, Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX)) {
297
300
// Setting the next property of %ArrayIteratorPrototype% also needs to
298
301
// invalidate the array iterator protector.
299
302
if (!isolate_->IsArrayIteratorLookupChainIntact ()) return ;
300
303
isolate_->InvalidateArrayIteratorProtector ();
301
- } else if (isolate_->IsInAnyContext (
302
- *holder_, Context::INITIAL_MAP_ITERATOR_PROTOTYPE_INDEX)) {
304
+ } else if (receiver->IsJSMapIterator () ||
305
+ isolate_->IsInAnyContext (
306
+ *receiver, Context::INITIAL_MAP_ITERATOR_PROTOTYPE_INDEX)) {
303
307
if (!isolate_->IsMapIteratorLookupChainIntact ()) return ;
304
308
isolate_->InvalidateMapIteratorProtector ();
305
- } else if (isolate_->IsInAnyContext (
306
- *holder_, Context::INITIAL_SET_ITERATOR_PROTOTYPE_INDEX)) {
309
+ } else if (receiver->IsJSSetIterator () ||
310
+ isolate_->IsInAnyContext (
311
+ *receiver, Context::INITIAL_SET_ITERATOR_PROTOTYPE_INDEX)) {
307
312
if (!isolate_->IsSetIteratorLookupChainIntact ()) return ;
308
313
isolate_->InvalidateSetIteratorProtector ();
309
- } else if (isolate_->IsInAnyContext (
310
- *receiver_,
314
+ } else if (receiver->IsJSStringIterator () ||
315
+ isolate_->IsInAnyContext (
316
+ *receiver,
311
317
Context::INITIAL_STRING_ITERATOR_PROTOTYPE_INDEX)) {
312
318
// Setting the next property of %StringIteratorPrototype% invalidates the
313
319
// string iterator protector.
@@ -323,44 +329,54 @@ void LookupIterator::InternalUpdateProtector() {
323
329
}
324
330
// Setting the Symbol.species property of any Array, Promise or TypedArray
325
331
// constructor invalidates the @@species protector
326
- if (isolate_->IsInAnyContext (*holder_ , Context::ARRAY_FUNCTION_INDEX)) {
332
+ if (isolate_->IsInAnyContext (*receiver , Context::ARRAY_FUNCTION_INDEX)) {
327
333
if (!isolate_->IsArraySpeciesLookupChainIntact ()) return ;
328
334
isolate_->CountUsage (
329
335
v8::Isolate::UseCounterFeature::kArraySpeciesModified );
330
336
isolate_->InvalidateArraySpeciesProtector ();
331
- } else if (isolate_->IsInAnyContext (*holder_ ,
337
+ } else if (isolate_->IsInAnyContext (*receiver ,
332
338
Context::PROMISE_FUNCTION_INDEX)) {
333
339
if (!isolate_->IsPromiseSpeciesLookupChainIntact ()) return ;
334
340
isolate_->InvalidatePromiseSpeciesProtector ();
335
- } else if (isolate_->IsInAnyContext (*holder_ ,
341
+ } else if (isolate_->IsInAnyContext (*receiver ,
336
342
Context::REGEXP_FUNCTION_INDEX)) {
337
343
if (!isolate_->IsRegExpSpeciesLookupChainIntact (native_context)) return ;
338
344
isolate_->InvalidateRegExpSpeciesProtector (native_context);
339
- } else if (IsTypedArrayFunctionInAnyContext (isolate_, *holder_ )) {
345
+ } else if (IsTypedArrayFunctionInAnyContext (isolate_, *receiver )) {
340
346
if (!isolate_->IsTypedArraySpeciesLookupChainIntact ()) return ;
341
347
isolate_->InvalidateTypedArraySpeciesProtector ();
342
348
}
343
349
} else if (*name_ == roots.is_concat_spreadable_symbol ()) {
344
350
if (!isolate_->IsIsConcatSpreadableLookupChainIntact ()) return ;
345
351
isolate_->InvalidateIsConcatSpreadableProtector ();
346
352
} else if (*name_ == roots.iterator_symbol ()) {
347
- if (holder_ ->IsJSArray (isolate_)) {
353
+ if (receiver ->IsJSArray (isolate_)) {
348
354
if (!isolate_->IsArrayIteratorLookupChainIntact ()) return ;
349
355
isolate_->InvalidateArrayIteratorProtector ();
356
+ } else if (receiver->IsJSSet (isolate_) || receiver->IsJSSetIterator () ||
357
+ isolate_->IsInAnyContext (
358
+ *receiver, Context::INITIAL_SET_ITERATOR_PROTOTYPE_INDEX) ||
359
+ isolate_->IsInAnyContext (*receiver,
360
+ Context::INITIAL_SET_PROTOTYPE_INDEX)) {
361
+ if (isolate_->IsSetIteratorLookupChainIntact ()) {
362
+ isolate_->InvalidateSetIteratorProtector ();
363
+ }
364
+ } else if (receiver->IsJSMapIterator () ||
365
+ isolate_->IsInAnyContext (
366
+ *receiver, Context::INITIAL_MAP_ITERATOR_PROTOTYPE_INDEX)) {
367
+ if (isolate_->IsMapIteratorLookupChainIntact ()) {
368
+ isolate_->InvalidateMapIteratorProtector ();
369
+ }
350
370
} else if (isolate_->IsInAnyContext (
351
- *holder_ , Context::INITIAL_ITERATOR_PROTOTYPE_INDEX)) {
371
+ *receiver , Context::INITIAL_ITERATOR_PROTOTYPE_INDEX)) {
352
372
if (isolate_->IsMapIteratorLookupChainIntact ()) {
353
373
isolate_->InvalidateMapIteratorProtector ();
354
374
}
355
375
if (isolate_->IsSetIteratorLookupChainIntact ()) {
356
376
isolate_->InvalidateSetIteratorProtector ();
357
377
}
358
- } else if (isolate_->IsInAnyContext (*holder_,
359
- Context::INITIAL_SET_PROTOTYPE_INDEX)) {
360
- if (!isolate_->IsSetIteratorLookupChainIntact ()) return ;
361
- isolate_->InvalidateSetIteratorProtector ();
362
378
} else if (isolate_->IsInAnyContext (
363
- *receiver_ , Context::INITIAL_STRING_PROTOTYPE_INDEX)) {
379
+ *receiver , Context::INITIAL_STRING_PROTOTYPE_INDEX)) {
364
380
// Setting the Symbol.iterator property of String.prototype invalidates
365
381
// the string iterator protector. Symbol.iterator can also be set on a
366
382
// String wrapper, but not on a primitive string. We only support
@@ -372,7 +388,7 @@ void LookupIterator::InternalUpdateProtector() {
372
388
if (!isolate_->IsPromiseResolveLookupChainIntact ()) return ;
373
389
// Setting the "resolve" property on any %Promise% intrinsic object
374
390
// invalidates the Promise.resolve protector.
375
- if (isolate_->IsInAnyContext (*holder_ , Context::PROMISE_FUNCTION_INDEX)) {
391
+ if (isolate_->IsInAnyContext (*receiver , Context::PROMISE_FUNCTION_INDEX)) {
376
392
isolate_->InvalidatePromiseResolveProtector ();
377
393
}
378
394
} else if (*name_ == roots.then_string ()) {
@@ -384,10 +400,10 @@ void LookupIterator::InternalUpdateProtector() {
384
400
// to guard the fast-path in AsyncGeneratorResolve, where we can skip
385
401
// the ResolvePromise step and go directly to FulfillPromise if we
386
402
// know that the Object.prototype doesn't contain a "then" method.
387
- if (holder_ ->IsJSPromise (isolate_) ||
388
- isolate_->IsInAnyContext (*holder_ ,
403
+ if (receiver ->IsJSPromise (isolate_) ||
404
+ isolate_->IsInAnyContext (*receiver ,
389
405
Context::INITIAL_OBJECT_PROTOTYPE_INDEX) ||
390
- isolate_->IsInAnyContext (*holder_ , Context::PROMISE_PROTOTYPE_INDEX)) {
406
+ isolate_->IsInAnyContext (*receiver , Context::PROMISE_PROTOTYPE_INDEX)) {
391
407
isolate_->InvalidatePromiseThenProtector ();
392
408
}
393
409
}
0 commit comments