@@ -389,6 +389,7 @@ class HandleScopeImplementer {
389
389
call_depth_(0 ),
390
390
microtasks_depth_(0 ),
391
391
microtasks_suppressions_(0 ),
392
+ entered_context_count_during_microtasks_(0 ),
392
393
#ifdef DEBUG
393
394
debug_microtasks_depth_ (0 ),
394
395
#endif
@@ -454,6 +455,11 @@ class HandleScopeImplementer {
454
455
inline void EnterMicrotaskContext (Handle<Context> context);
455
456
inline void LeaveMicrotaskContext ();
456
457
inline Handle<Context> MicrotaskContext ();
458
+ inline bool MicrotaskContextIsLastEnteredContext () const {
459
+ return microtask_context_ &&
460
+ entered_context_count_during_microtasks_ ==
461
+ entered_contexts_.length ();
462
+ }
457
463
458
464
inline void SaveContext (Context* context);
459
465
inline Context* RestoreContext ();
@@ -474,6 +480,7 @@ class HandleScopeImplementer {
474
480
entered_contexts_.Initialize (0 );
475
481
saved_contexts_.Initialize (0 );
476
482
microtask_context_ = nullptr ;
483
+ entered_context_count_during_microtasks_ = 0 ;
477
484
spare_ = NULL ;
478
485
last_handle_before_deferred_block_ = NULL ;
479
486
call_depth_ = 0 ;
@@ -508,6 +515,7 @@ class HandleScopeImplementer {
508
515
int call_depth_;
509
516
int microtasks_depth_;
510
517
int microtasks_suppressions_;
518
+ int entered_context_count_during_microtasks_;
511
519
#ifdef DEBUG
512
520
int debug_microtasks_depth_;
513
521
#endif
@@ -579,11 +587,13 @@ Handle<Context> HandleScopeImplementer::LastEnteredContext() {
579
587
void HandleScopeImplementer::EnterMicrotaskContext (Handle<Context> context) {
580
588
DCHECK (!microtask_context_);
581
589
microtask_context_ = *context;
590
+ entered_context_count_during_microtasks_ = entered_contexts_.length ();
582
591
}
583
592
584
593
void HandleScopeImplementer::LeaveMicrotaskContext () {
585
594
DCHECK (microtask_context_);
586
595
microtask_context_ = nullptr ;
596
+ entered_context_count_during_microtasks_ = 0 ;
587
597
}
588
598
589
599
Handle<Context> HandleScopeImplementer::MicrotaskContext () {
0 commit comments