@@ -754,82 +754,6 @@ static void jl_eval_errorf(jl_module_t *m, const char *filename, int lineno, con
754
754
JL_GC_POP ();
755
755
}
756
756
757
- JL_DLLEXPORT jl_binding_partition_t * jl_declare_constant_val3 (
758
- jl_binding_t * b , jl_module_t * mod , jl_sym_t * var , jl_value_t * val ,
759
- enum jl_partition_kind constant_kind , size_t new_world )
760
- {
761
- JL_GC_PUSH1 (& val );
762
- if (!b ) {
763
- b = jl_get_module_binding (mod , var , 1 );
764
- }
765
- jl_binding_partition_t * new_bpart = NULL ;
766
- jl_binding_partition_t * bpart = jl_get_binding_partition (b , new_world );
767
- jl_ptr_kind_union_t pku = jl_atomic_load_relaxed (& bpart -> restriction );
768
- while (!new_bpart ) {
769
- enum jl_partition_kind kind = decode_restriction_kind (pku );
770
- if (jl_bkind_is_some_constant (kind )) {
771
- if (!val ) {
772
- new_bpart = bpart ;
773
- break ;
774
- }
775
- jl_value_t * old = decode_restriction_value (pku );
776
- JL_GC_PROMISE_ROOTED (old );
777
- if (jl_egal (val , old )) {
778
- new_bpart = bpart ;
779
- break ;
780
- }
781
- } else if (jl_bkind_is_some_import (kind ) && kind != BINDING_KIND_IMPLICIT ) {
782
- jl_errorf ("cannot declare %s.%s constant; it was already declared as an import" ,
783
- jl_symbol_name (mod -> name ), jl_symbol_name (var ));
784
- } else if (kind == BINDING_KIND_GLOBAL ) {
785
- jl_errorf ("cannot declare %s.%s constant; it was already declared global" ,
786
- jl_symbol_name (mod -> name ), jl_symbol_name (var ));
787
- }
788
- if (bpart -> min_world == new_world ) {
789
- if (!jl_atomic_cmpswap (& bpart -> restriction , & pku , encode_restriction (val , constant_kind ))) {
790
- continue ;
791
- }
792
- jl_gc_wb (bpart , val );
793
- new_bpart = bpart ;
794
- } else {
795
- new_bpart = jl_replace_binding_locked (b , bpart , val , constant_kind , new_world );
796
- }
797
- int need_backdate = new_world && val ;
798
- if (need_backdate ) {
799
- // We will backdate as long as this partition was never explicitly
800
- // declared const, global, or imported.
801
- jl_binding_partition_t * prev_bpart = bpart ;
802
- for (;;) {
803
- jl_ptr_kind_union_t prev_pku = jl_atomic_load_relaxed (& prev_bpart -> restriction );
804
- enum jl_partition_kind prev_kind = decode_restriction_kind (prev_pku );
805
- if (jl_bkind_is_some_constant (prev_kind ) || prev_kind == BINDING_KIND_GLOBAL ||
806
- (jl_bkind_is_some_import (prev_kind ))) {
807
- need_backdate = 0 ;
808
- break ;
809
- }
810
- if (prev_bpart -> min_world == 0 )
811
- break ;
812
- prev_bpart = jl_get_binding_partition (b , prev_bpart -> min_world - 1 );
813
- }
814
- }
815
- // If backdate is required, rewrite all previous binding partitions to
816
- // backdated const
817
- if (need_backdate ) {
818
- // We will backdate as long as this partition was never explicitly
819
- // declared const, global, or *explicitly* imported.
820
- jl_binding_partition_t * prev_bpart = bpart ;
821
- for (;;) {
822
- jl_atomic_store_relaxed (& prev_bpart -> restriction , encode_restriction (val , BINDING_KIND_BACKDATED_CONST ));
823
- if (prev_bpart -> min_world == 0 )
824
- break ;
825
- prev_bpart = jl_get_binding_partition (b , prev_bpart -> min_world - 1 );
826
- }
827
- }
828
- }
829
- JL_GC_POP ();
830
- return new_bpart ;
831
- }
832
-
833
757
JL_DLLEXPORT jl_binding_partition_t * jl_declare_constant_val2 (
834
758
jl_binding_t * b , jl_module_t * mod , jl_sym_t * var , jl_value_t * val ,
835
759
enum jl_partition_kind constant_kind )
0 commit comments