@@ -469,47 +469,50 @@ bool StackFrame::FindExceptionHandler(Thread* thread,
469469 descriptors = code.pc_descriptors ();
470470 *is_optimized = code.is_optimized ();
471471 }
472- HandlerInfoCache* cache = thread->isolate ()->handler_info_cache ();
473- ExceptionHandlerInfo* info = cache->Lookup (pc ());
474- if (info != nullptr ) {
475- *handler_pc = start + info->handler_pc_offset ;
476- *needs_stacktrace = (info->needs_stacktrace != 0 );
477- *has_catch_all = (info->has_catch_all != 0 );
478- return true ;
479- }
472+ {
473+ SafepointMutexLocker ml (thread->isolate_group ()->cache_mutex ());
474+ HandlerInfoCache* cache = thread->isolate_group ()->handler_info_cache ();
475+ ExceptionHandlerInfo* info = cache->Lookup (pc ());
476+ if (info != nullptr ) {
477+ *handler_pc = start + info->handler_pc_offset ;
478+ *needs_stacktrace = (info->needs_stacktrace != 0 );
479+ *has_catch_all = (info->has_catch_all != 0 );
480+ return true ;
481+ }
480482
481- intptr_t try_index = -1 ;
482- if (handlers.num_entries () != 0 ) {
483- if (is_interpreted ()) {
484- try_index = bytecode.GetTryIndexAtPc (pc ());
485- } else {
486- uword pc_offset = pc () - code.PayloadStart ();
487- PcDescriptors::Iterator iter (descriptors,
488- UntaggedPcDescriptors::kAnyKind );
489- while (iter.MoveNext ()) {
490- const intptr_t current_try_index = iter.TryIndex ();
491- if ((iter.PcOffset () == pc_offset) && (current_try_index != -1 )) {
492- try_index = current_try_index;
493- break ;
483+ intptr_t try_index = -1 ;
484+ if (handlers.num_entries () != 0 ) {
485+ if (is_interpreted ()) {
486+ try_index = bytecode.GetTryIndexAtPc (pc ());
487+ } else {
488+ uword pc_offset = pc () - code.PayloadStart ();
489+ PcDescriptors::Iterator iter (descriptors,
490+ UntaggedPcDescriptors::kAnyKind );
491+ while (iter.MoveNext ()) {
492+ const intptr_t current_try_index = iter.TryIndex ();
493+ if ((iter.PcOffset () == pc_offset) && (current_try_index != -1 )) {
494+ try_index = current_try_index;
495+ break ;
496+ }
494497 }
495498 }
496499 }
497- }
498- if (try_index == -1 ) {
499- if (handlers.has_async_handler ()) {
500- *handler_pc = StubCode::AsyncExceptionHandler ().EntryPoint ();
501- *needs_stacktrace = true ;
502- *has_catch_all = true ;
503- return true ;
500+ if (try_index == -1 ) {
501+ if (handlers.has_async_handler ()) {
502+ *handler_pc = StubCode::AsyncExceptionHandler ().EntryPoint ();
503+ *needs_stacktrace = true ;
504+ *has_catch_all = true ;
505+ return true ;
506+ }
507+ return false ;
504508 }
505- return false ;
509+ ExceptionHandlerInfo handler_info;
510+ handlers.GetHandlerInfo (try_index, &handler_info);
511+ *handler_pc = start + handler_info.handler_pc_offset ;
512+ *needs_stacktrace = (handler_info.needs_stacktrace != 0 );
513+ *has_catch_all = (handler_info.has_catch_all != 0 );
514+ cache->Insert (pc (), handler_info);
506515 }
507- ExceptionHandlerInfo handler_info;
508- handlers.GetHandlerInfo (try_index, &handler_info);
509- *handler_pc = start + handler_info.handler_pc_offset ;
510- *needs_stacktrace = (handler_info.needs_stacktrace != 0 );
511- *has_catch_all = (handler_info.has_catch_all != 0 );
512- cache->Insert (pc (), handler_info);
513516 return true ;
514517}
515518
0 commit comments