@@ -322,7 +322,7 @@ jl_datatype_t *jl_mk_builtin_func(jl_datatype_t *dt, const char *name, jl_fptr_a
322322
323323 jl_code_instance_t * codeinst = jl_new_codeinst (mi , jl_nothing ,
324324 (jl_value_t * )jl_any_type , (jl_value_t * )jl_any_type , jl_nothing , jl_nothing ,
325- 0 , 1 , ~(size_t )0 , 0 , jl_nothing , 0 , NULL );
325+ 0 , 1 , ~(size_t )0 , 0 , jl_nothing , 0 , NULL , NULL );
326326 jl_mi_cache_insert (mi , codeinst );
327327 jl_atomic_store_relaxed (& codeinst -> specptr .fptr1 , fptr );
328328 jl_atomic_store_relaxed (& codeinst -> invoke , jl_fptr_args );
@@ -480,7 +480,7 @@ JL_DLLEXPORT jl_value_t *jl_call_in_typeinf_world(jl_value_t **args, int nargs)
480480
481481JL_DLLEXPORT jl_code_instance_t * jl_get_method_inferred (
482482 jl_method_instance_t * mi JL_PROPAGATES_ROOT , jl_value_t * rettype ,
483- size_t min_world , size_t max_world , jl_debuginfo_t * edges )
483+ size_t min_world , size_t max_world , jl_debuginfo_t * di , jl_svec_t * edges )
484484{
485485 jl_value_t * owner = jl_nothing ; // TODO: owner should be arg
486486 jl_code_instance_t * codeinst = jl_atomic_load_relaxed (& mi -> cache );
@@ -489,27 +489,30 @@ JL_DLLEXPORT jl_code_instance_t *jl_get_method_inferred(
489489 jl_atomic_load_relaxed (& codeinst -> max_world ) == max_world &&
490490 jl_egal (codeinst -> owner , owner ) &&
491491 jl_egal (codeinst -> rettype , rettype )) {
492- if (edges == NULL )
492+ if (di == NULL )
493493 return codeinst ;
494494 jl_debuginfo_t * debuginfo = jl_atomic_load_relaxed (& codeinst -> debuginfo );
495- if (edges == debuginfo )
496- return codeinst ;
497- if (debuginfo == NULL && jl_atomic_cmpswap_relaxed (& codeinst -> debuginfo , & debuginfo , edges ))
498- return codeinst ;
499- if (debuginfo && jl_egal ((jl_value_t * )debuginfo , (jl_value_t * )edges ))
495+ if (di != debuginfo ) {
496+ if (!(debuginfo == NULL && jl_atomic_cmpswap_relaxed (& codeinst -> debuginfo , & debuginfo , di )))
497+ if (!(debuginfo && jl_egal ((jl_value_t * )debuginfo , (jl_value_t * )di )))
498+ continue ;
499+ }
500+ // TODO: this is implied by the matching worlds, since it is intrinsic, so do we really need to verify it?
501+ jl_svec_t * e = jl_atomic_load_relaxed (& codeinst -> edges );
502+ if (e && jl_egal ((jl_value_t * )e , (jl_value_t * )edges ))
500503 return codeinst ;
501504 }
502505 codeinst = jl_atomic_load_relaxed (& codeinst -> next );
503506 }
504507 codeinst = jl_new_codeinst (
505508 mi , owner , rettype , (jl_value_t * )jl_any_type , NULL , NULL ,
506- 0 , min_world , max_world , 0 , jl_nothing , 0 , edges );
509+ 0 , min_world , max_world , 0 , jl_nothing , 0 , di , edges );
507510 jl_mi_cache_insert (mi , codeinst );
508511 return codeinst ;
509512}
510513
511514JL_DLLEXPORT int jl_mi_cache_has_ci (jl_method_instance_t * mi ,
512- jl_code_instance_t * ci )
515+ jl_code_instance_t * ci )
513516{
514517 jl_code_instance_t * codeinst = jl_atomic_load_relaxed (& mi -> cache );
515518 while (codeinst ) {
@@ -527,14 +530,15 @@ JL_DLLEXPORT jl_code_instance_t *jl_new_codeinst(
527530 int32_t const_flags , size_t min_world , size_t max_world ,
528531 uint32_t effects , jl_value_t * analysis_results ,
529532 uint8_t relocatability ,
530- jl_debuginfo_t * edges /* , int absolute_max*/ )
533+ jl_debuginfo_t * di , jl_svec_t * edges /*, int absolute_max*/ )
531534{
532535 jl_task_t * ct = jl_current_task ;
533536 assert (min_world <= max_world && "attempting to set invalid world constraints" );
534537 jl_code_instance_t * codeinst = (jl_code_instance_t * )jl_gc_alloc (ct -> ptls , sizeof (jl_code_instance_t ),
535538 jl_code_instance_type );
536539 codeinst -> def = mi ;
537540 codeinst -> owner = owner ;
541+ jl_atomic_store_relaxed (& codeinst -> edges , edges );
538542 jl_atomic_store_relaxed (& codeinst -> min_world , min_world );
539543 jl_atomic_store_relaxed (& codeinst -> max_world , max_world );
540544 codeinst -> rettype = rettype ;
@@ -543,7 +547,7 @@ JL_DLLEXPORT jl_code_instance_t *jl_new_codeinst(
543547 if ((const_flags & 2 ) == 0 )
544548 inferred_const = NULL ;
545549 codeinst -> rettype_const = inferred_const ;
546- jl_atomic_store_relaxed (& codeinst -> debuginfo , (jl_value_t * )edges == jl_nothing ? NULL : edges );
550+ jl_atomic_store_relaxed (& codeinst -> debuginfo , (jl_value_t * )di == jl_nothing ? NULL : di );
547551 jl_atomic_store_relaxed (& codeinst -> specptr .fptr , NULL );
548552 jl_atomic_store_relaxed (& codeinst -> invoke , NULL );
549553 if ((const_flags & 1 ) != 0 ) {
@@ -563,13 +567,15 @@ JL_DLLEXPORT void jl_update_codeinst(
563567 jl_code_instance_t * codeinst , jl_value_t * inferred ,
564568 int32_t const_flags , size_t min_world , size_t max_world ,
565569 uint32_t effects , jl_value_t * analysis_results ,
566- uint8_t relocatability , jl_debuginfo_t * edges /* , int absolute_max*/ )
570+ uint8_t relocatability , jl_debuginfo_t * di , jl_svec_t * edges /* , int absolute_max*/ )
567571{
568572 codeinst -> relocatability = relocatability ;
569573 codeinst -> analysis_results = analysis_results ;
570574 jl_gc_wb (codeinst , analysis_results );
571575 jl_atomic_store_relaxed (& codeinst -> ipo_purity_bits , effects );
572- jl_atomic_store_relaxed (& codeinst -> debuginfo , edges );
576+ jl_atomic_store_relaxed (& codeinst -> debuginfo , di );
577+ jl_gc_wb (codeinst , di );
578+ jl_atomic_store_relaxed (& codeinst -> edges , edges );
573579 jl_gc_wb (codeinst , edges );
574580 if ((const_flags & 1 ) != 0 ) {
575581 assert (codeinst -> rettype_const );
@@ -587,7 +593,7 @@ JL_DLLEXPORT void jl_fill_codeinst(
587593 jl_value_t * inferred_const ,
588594 int32_t const_flags , size_t min_world , size_t max_world ,
589595 uint32_t effects , jl_value_t * analysis_results ,
590- jl_debuginfo_t * edges /* , int absolute_max*/ )
596+ jl_debuginfo_t * di , jl_svec_t * edges /* , int absolute_max*/ )
591597{
592598 assert (min_world <= max_world && "attempting to set invalid world constraints" );
593599 codeinst -> rettype = rettype ;
@@ -598,8 +604,12 @@ JL_DLLEXPORT void jl_fill_codeinst(
598604 codeinst -> rettype_const = inferred_const ;
599605 jl_gc_wb (codeinst , inferred_const );
600606 }
601- jl_atomic_store_relaxed (& codeinst -> debuginfo , ( jl_value_t * ) edges == jl_nothing ? NULL : edges );
607+ jl_atomic_store_relaxed (& codeinst -> edges , edges );
602608 jl_gc_wb (codeinst , edges );
609+ if ((jl_value_t * )di != jl_nothing ) {
610+ jl_atomic_store_relaxed (& codeinst -> debuginfo , di );
611+ jl_gc_wb (codeinst , di );
612+ }
603613 if ((const_flags & 1 ) != 0 ) {
604614 // TODO: may want to follow ordering restrictions here (see jitlayers.cpp)
605615 assert (const_flags & 2 );
@@ -616,7 +626,7 @@ JL_DLLEXPORT void jl_fill_codeinst(
616626
617627JL_DLLEXPORT jl_code_instance_t * jl_new_codeinst_uninit (jl_method_instance_t * mi , jl_value_t * owner )
618628{
619- jl_code_instance_t * codeinst = jl_new_codeinst (mi , owner , NULL , NULL , NULL , NULL , 0 , 0 , 0 , 0 , NULL , 0 , NULL );
629+ jl_code_instance_t * codeinst = jl_new_codeinst (mi , owner , NULL , NULL , NULL , NULL , 0 , 0 , 0 , 0 , NULL , 0 , NULL , NULL );
620630 jl_atomic_store_relaxed (& codeinst -> min_world , 1 ); // make temporarily invalid before returning, so that jl_fill_codeinst is valid later
621631 return codeinst ;
622632}
@@ -2566,8 +2576,10 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
25662576 jl_code_instance_t * codeinst2 = jl_compile_method_internal (mi2 , world );
25672577 jl_code_instance_t * codeinst = jl_get_method_inferred (
25682578 mi , codeinst2 -> rettype ,
2569- jl_atomic_load_relaxed (& codeinst2 -> min_world ), jl_atomic_load_relaxed (& codeinst2 -> max_world ),
2570- jl_atomic_load_relaxed (& codeinst2 -> debuginfo ));
2579+ jl_atomic_load_relaxed (& codeinst2 -> min_world ),
2580+ jl_atomic_load_relaxed (& codeinst2 -> max_world ),
2581+ jl_atomic_load_relaxed (& codeinst2 -> debuginfo ),
2582+ jl_atomic_load_relaxed (& codeinst2 -> edges ));
25712583 if (jl_atomic_load_relaxed (& codeinst -> invoke ) == NULL ) {
25722584 codeinst -> rettype_const = codeinst2 -> rettype_const ;
25732585 jl_gc_wb (codeinst , codeinst -> rettype_const );
@@ -2626,7 +2638,7 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
26262638 if (unspec && (unspec_invoke = jl_atomic_load_acquire (& unspec -> invoke ))) {
26272639 jl_code_instance_t * codeinst = jl_new_codeinst (mi , jl_nothing ,
26282640 (jl_value_t * )jl_any_type , (jl_value_t * )jl_any_type , NULL , NULL ,
2629- 0 , 1 , ~(size_t )0 , 0 , jl_nothing , 0 , NULL );
2641+ 0 , 1 , ~(size_t )0 , 0 , jl_nothing , 0 , NULL , NULL );
26302642 void * unspec_fptr = jl_atomic_load_relaxed (& unspec -> specptr .fptr );
26312643 if (unspec_fptr ) {
26322644 // wait until invoke and specsigflags are properly set
@@ -2653,7 +2665,7 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
26532665 if (!jl_code_requires_compiler (src , 0 )) {
26542666 jl_code_instance_t * codeinst = jl_new_codeinst (mi , jl_nothing ,
26552667 (jl_value_t * )jl_any_type , (jl_value_t * )jl_any_type , NULL , NULL ,
2656- 0 , 1 , ~(size_t )0 , 0 , jl_nothing , 0 , NULL );
2668+ 0 , 1 , ~(size_t )0 , 0 , jl_nothing , 0 , NULL , NULL );
26572669 jl_atomic_store_release (& codeinst -> invoke , jl_fptr_interpret_call );
26582670 jl_mi_cache_insert (mi , codeinst );
26592671 record_precompile_statement (mi , 0 );
@@ -2713,7 +2725,7 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
27132725 jl_method_instance_t * unspec = jl_get_unspecialized (def );
27142726 if (unspec == NULL )
27152727 unspec = mi ;
2716- jl_code_instance_t * ucache = jl_get_method_inferred (unspec , (jl_value_t * )jl_any_type , 1 , ~(size_t )0 , NULL );
2728+ jl_code_instance_t * ucache = jl_get_method_inferred (unspec , (jl_value_t * )jl_any_type , 1 , ~(size_t )0 , NULL , NULL );
27172729 // ask codegen to make the fptr for unspec
27182730 jl_callptr_t ucache_invoke = jl_atomic_load_acquire (& ucache -> invoke );
27192731 if (ucache_invoke == NULL ) {
@@ -2733,7 +2745,7 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
27332745 }
27342746 codeinst = jl_new_codeinst (mi , jl_nothing ,
27352747 (jl_value_t * )jl_any_type , (jl_value_t * )jl_any_type , NULL , NULL ,
2736- 0 , 1 , ~(size_t )0 , 0 , jl_nothing , 0 , NULL );
2748+ 0 , 1 , ~(size_t )0 , 0 , jl_nothing , 0 , NULL , NULL );
27372749 void * unspec_fptr = jl_atomic_load_relaxed (& ucache -> specptr .fptr );
27382750 if (unspec_fptr ) {
27392751 // wait until invoke and specsigflags are properly set
0 commit comments