This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
pkg/compiler/lib/src/inferrer/typemasks Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -756,10 +756,28 @@ class CommonMasks implements AbstractValueDomain {
756756
757757 @override
758758 AbstractBool isInterceptor (TypeMask value) {
759+ // TODO(39874): Remove cache when [TypeMask.isDisjoint] is faster.
760+ var result = _isInterceptorCache[value];
761+ if (result == null ) {
762+ result = _isInterceptorCacheSecondChance[value] ?? _isInterceptor (value);
763+ if (_isInterceptorCache.length >= _kIsInterceptorCacheLimit) {
764+ _isInterceptorCacheSecondChance = _isInterceptorCache;
765+ _isInterceptorCache = {};
766+ }
767+ _isInterceptorCache[value] = result;
768+ }
769+ return result;
770+ }
771+
772+ AbstractBool _isInterceptor (TypeMask value) {
759773 return AbstractBool .maybeOrFalse (
760774 ! interceptorType.isDisjoint (value, _closedWorld));
761775 }
762776
777+ static const _kIsInterceptorCacheLimit = 500 ;
778+ Map <TypeMask , AbstractBool > _isInterceptorCache = {};
779+ Map <TypeMask , AbstractBool > _isInterceptorCacheSecondChance = {};
780+
763781 @override
764782 bool isMap (TypeMask value) {
765783 return value.isMap;
You can’t perform that action at this time.
0 commit comments