10
10
#include "julia_assert.h"
11
11
12
12
#define MAX_METHLIST_COUNT 12 // this can strongly affect the sysimg size and speed!
13
- #define INIT_CACHE_SIZE 8 // must be a power-of-two
14
13
15
14
#ifdef __cplusplus
16
15
extern "C" {
@@ -354,14 +353,19 @@ int jl_typemap_intersection_visitor(jl_typemap_t *map, int offs,
354
353
//}
355
354
if (jl_typeof (map ) == (jl_value_t * )jl_typemap_level_type ) {
356
355
jl_typemap_level_t * cache = (jl_typemap_level_t * )map ;
357
- jl_value_t * ty = NULL ;
356
+ jl_value_t * ty ;
358
357
size_t l = jl_nparams (ttypes );
359
358
if (closure -> va && l <= offs + 1 ) {
360
359
ty = closure -> va ;
361
360
}
362
361
else if (l > offs ) {
363
362
ty = jl_tparam (ttypes , offs );
364
363
}
364
+ else {
365
+ ty = NULL ;
366
+ }
367
+ if (ty == (jl_value_t * )jl_typeofbottom_type )
368
+ ty = (jl_value_t * )jl_assume (jl_typeofbottom_type )-> super ;
365
369
if (ty ) {
366
370
while (jl_is_typevar (ty ))
367
371
ty = ((jl_tvar_t * )ty )-> ub ;
@@ -551,7 +555,7 @@ jl_typemap_entry_t *jl_typemap_assoc_by_type(
551
555
if (jl_typeof (ml_or_cache ) == (jl_value_t * )jl_typemap_level_type ) {
552
556
jl_typemap_level_t * cache = (jl_typemap_level_t * )ml_or_cache ;
553
557
// called object is the primary key for constructors, otherwise first argument
554
- jl_value_t * ty = NULL ;
558
+ jl_value_t * ty ;
555
559
jl_value_t * ttypes = jl_unwrap_unionall ((jl_value_t * )search -> types );
556
560
JL_GC_PROMISE_ROOTED (ttypes );
557
561
assert (jl_is_datatype (ttypes ));
@@ -571,9 +575,14 @@ jl_typemap_entry_t *jl_typemap_assoc_by_type(
571
575
else if (l > offs ) {
572
576
ty = jl_tparam (ttypes , offs );
573
577
}
574
- // If there is a type at offs, look in the optimized caches
575
- if (!subtype ) {
576
- if (ty && jl_is_any (ty ))
578
+ else {
579
+ ty = NULL ;
580
+ }
581
+ if (ty == (jl_value_t * )jl_typeofbottom_type )
582
+ ty = (jl_value_t * )jl_assume (jl_typeofbottom_type )-> super ;
583
+ // If there is a type at offs, look in the optimized leaf type caches
584
+ if (ty && !subtype ) {
585
+ if (jl_is_any (ty ))
577
586
return jl_typemap_assoc_by_type (cache -> any , search , offs + 1 , subtype );
578
587
if (isva ) // in lookup mode, want to match Vararg exactly, not as a subtype
579
588
ty = NULL ;
@@ -836,7 +845,7 @@ static void jl_typemap_level_insert_(
836
845
jl_value_t * ttypes = jl_unwrap_unionall ((jl_value_t * )newrec -> sig );
837
846
size_t l = jl_nparams (ttypes );
838
847
// compute the type at offset `offs` into `sig`, which may be a Vararg
839
- jl_value_t * t1 = NULL ;
848
+ jl_value_t * t1 ;
840
849
int isva = 0 ;
841
850
if (l <= offs + 1 ) {
842
851
t1 = jl_tparam (ttypes , l - 1 );
@@ -851,6 +860,11 @@ static void jl_typemap_level_insert_(
851
860
else if (l > offs ) {
852
861
t1 = jl_tparam (ttypes , offs );
853
862
}
863
+ else {
864
+ t1 = NULL ;
865
+ }
866
+ if (t1 == (jl_value_t * )jl_typeofbottom_type )
867
+ t1 = (jl_value_t * )jl_assume (jl_typeofbottom_type )-> super ;
854
868
// If the type at `offs` is Any, put it in the Any list
855
869
if (t1 && jl_is_any (t1 )) {
856
870
jl_typemap_insert_generic (map , & cache -> any , (jl_value_t * )cache , newrec , offs + 1 , tparams );
0 commit comments