@@ -322,7 +322,7 @@ jl_datatype_t *jl_mk_builtin_func(jl_datatype_t *dt, const char *name, jl_fptr_a
322
322
323
323
jl_code_instance_t * codeinst = jl_new_codeinst (mi , jl_nothing ,
324
324
(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 );
326
326
jl_mi_cache_insert (mi , codeinst );
327
327
jl_atomic_store_relaxed (& codeinst -> specptr .fptr1 , fptr );
328
328
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)
480
480
481
481
JL_DLLEXPORT jl_code_instance_t * jl_get_method_inferred (
482
482
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 )
484
484
{
485
485
jl_value_t * owner = jl_nothing ; // TODO: owner should be arg
486
486
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(
489
489
jl_atomic_load_relaxed (& codeinst -> max_world ) == max_world &&
490
490
jl_egal (codeinst -> owner , owner ) &&
491
491
jl_egal (codeinst -> rettype , rettype )) {
492
- if (edges == NULL )
492
+ if (di == NULL )
493
493
return codeinst ;
494
494
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 ))
500
503
return codeinst ;
501
504
}
502
505
codeinst = jl_atomic_load_relaxed (& codeinst -> next );
503
506
}
504
507
codeinst = jl_new_codeinst (
505
508
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 );
507
510
jl_mi_cache_insert (mi , codeinst );
508
511
return codeinst ;
509
512
}
510
513
511
514
JL_DLLEXPORT int jl_mi_cache_has_ci (jl_method_instance_t * mi ,
512
- jl_code_instance_t * ci )
515
+ jl_code_instance_t * ci )
513
516
{
514
517
jl_code_instance_t * codeinst = jl_atomic_load_relaxed (& mi -> cache );
515
518
while (codeinst ) {
@@ -527,14 +530,15 @@ JL_DLLEXPORT jl_code_instance_t *jl_new_codeinst(
527
530
int32_t const_flags , size_t min_world , size_t max_world ,
528
531
uint32_t effects , jl_value_t * analysis_results ,
529
532
uint8_t relocatability ,
530
- jl_debuginfo_t * edges /* , int absolute_max*/ )
533
+ jl_debuginfo_t * di , jl_svec_t * edges /*, int absolute_max*/ )
531
534
{
532
535
jl_task_t * ct = jl_current_task ;
533
536
assert (min_world <= max_world && "attempting to set invalid world constraints" );
534
537
jl_code_instance_t * codeinst = (jl_code_instance_t * )jl_gc_alloc (ct -> ptls , sizeof (jl_code_instance_t ),
535
538
jl_code_instance_type );
536
539
codeinst -> def = mi ;
537
540
codeinst -> owner = owner ;
541
+ jl_atomic_store_relaxed (& codeinst -> edges , edges );
538
542
jl_atomic_store_relaxed (& codeinst -> min_world , min_world );
539
543
jl_atomic_store_relaxed (& codeinst -> max_world , max_world );
540
544
codeinst -> rettype = rettype ;
@@ -543,7 +547,7 @@ JL_DLLEXPORT jl_code_instance_t *jl_new_codeinst(
543
547
if ((const_flags & 2 ) == 0 )
544
548
inferred_const = NULL ;
545
549
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 );
547
551
jl_atomic_store_relaxed (& codeinst -> specptr .fptr , NULL );
548
552
jl_atomic_store_relaxed (& codeinst -> invoke , NULL );
549
553
if ((const_flags & 1 ) != 0 ) {
@@ -563,13 +567,15 @@ JL_DLLEXPORT void jl_update_codeinst(
563
567
jl_code_instance_t * codeinst , jl_value_t * inferred ,
564
568
int32_t const_flags , size_t min_world , size_t max_world ,
565
569
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*/ )
567
571
{
568
572
codeinst -> relocatability = relocatability ;
569
573
codeinst -> analysis_results = analysis_results ;
570
574
jl_gc_wb (codeinst , analysis_results );
571
575
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 );
573
579
jl_gc_wb (codeinst , edges );
574
580
if ((const_flags & 1 ) != 0 ) {
575
581
assert (codeinst -> rettype_const );
@@ -587,7 +593,7 @@ JL_DLLEXPORT void jl_fill_codeinst(
587
593
jl_value_t * inferred_const ,
588
594
int32_t const_flags , size_t min_world , size_t max_world ,
589
595
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*/ )
591
597
{
592
598
assert (min_world <= max_world && "attempting to set invalid world constraints" );
593
599
codeinst -> rettype = rettype ;
@@ -598,8 +604,12 @@ JL_DLLEXPORT void jl_fill_codeinst(
598
604
codeinst -> rettype_const = inferred_const ;
599
605
jl_gc_wb (codeinst , inferred_const );
600
606
}
601
- jl_atomic_store_relaxed (& codeinst -> debuginfo , ( jl_value_t * ) edges == jl_nothing ? NULL : edges );
607
+ jl_atomic_store_relaxed (& codeinst -> edges , edges );
602
608
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
+ }
603
613
if ((const_flags & 1 ) != 0 ) {
604
614
// TODO: may want to follow ordering restrictions here (see jitlayers.cpp)
605
615
assert (const_flags & 2 );
@@ -616,7 +626,7 @@ JL_DLLEXPORT void jl_fill_codeinst(
616
626
617
627
JL_DLLEXPORT jl_code_instance_t * jl_new_codeinst_uninit (jl_method_instance_t * mi , jl_value_t * owner )
618
628
{
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 );
620
630
jl_atomic_store_relaxed (& codeinst -> min_world , 1 ); // make temporarily invalid before returning, so that jl_fill_codeinst is valid later
621
631
return codeinst ;
622
632
}
@@ -2566,8 +2576,10 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
2566
2576
jl_code_instance_t * codeinst2 = jl_compile_method_internal (mi2 , world );
2567
2577
jl_code_instance_t * codeinst = jl_get_method_inferred (
2568
2578
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 ));
2571
2583
if (jl_atomic_load_relaxed (& codeinst -> invoke ) == NULL ) {
2572
2584
codeinst -> rettype_const = codeinst2 -> rettype_const ;
2573
2585
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
2626
2638
if (unspec && (unspec_invoke = jl_atomic_load_acquire (& unspec -> invoke ))) {
2627
2639
jl_code_instance_t * codeinst = jl_new_codeinst (mi , jl_nothing ,
2628
2640
(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 );
2630
2642
void * unspec_fptr = jl_atomic_load_relaxed (& unspec -> specptr .fptr );
2631
2643
if (unspec_fptr ) {
2632
2644
// 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
2653
2665
if (!jl_code_requires_compiler (src , 0 )) {
2654
2666
jl_code_instance_t * codeinst = jl_new_codeinst (mi , jl_nothing ,
2655
2667
(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 );
2657
2669
jl_atomic_store_release (& codeinst -> invoke , jl_fptr_interpret_call );
2658
2670
jl_mi_cache_insert (mi , codeinst );
2659
2671
record_precompile_statement (mi , 0 );
@@ -2713,7 +2725,7 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
2713
2725
jl_method_instance_t * unspec = jl_get_unspecialized (def );
2714
2726
if (unspec == NULL )
2715
2727
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 );
2717
2729
// ask codegen to make the fptr for unspec
2718
2730
jl_callptr_t ucache_invoke = jl_atomic_load_acquire (& ucache -> invoke );
2719
2731
if (ucache_invoke == NULL ) {
@@ -2733,7 +2745,7 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
2733
2745
}
2734
2746
codeinst = jl_new_codeinst (mi , jl_nothing ,
2735
2747
(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 );
2737
2749
void * unspec_fptr = jl_atomic_load_relaxed (& ucache -> specptr .fptr );
2738
2750
if (unspec_fptr ) {
2739
2751
// wait until invoke and specsigflags are properly set
0 commit comments