@@ -40,7 +40,25 @@ static arraylist_t methtable_list;
40
40
static htable_t fptr_to_id ;
41
41
// array of definitions for the predefined function pointers
42
42
// (reverse of fptr_to_id)
43
- static htable_t id_to_fptr ;
43
+ static jl_fptr_t id_to_fptrs [] = {
44
+ NULL , NULL ,
45
+ jl_f_throw , jl_f_is ,
46
+ jl_f_no_function , jl_f_typeof ,
47
+ jl_f_subtype , jl_f_isa ,
48
+ jl_f_typeassert , jl_f_apply ,
49
+ jl_f_top_eval , jl_f_isdefined ,
50
+ jl_f_tuple , jl_f_tupleref ,
51
+ jl_f_tuplelen , jl_f_get_field ,
52
+ jl_f_set_field , jl_f_field_type ,
53
+ jl_f_arraylen , jl_f_arrayref ,
54
+ jl_f_arrayset , jl_f_arraysize ,
55
+ jl_f_instantiate_type , jl_f_kwcall ,
56
+ jl_trampoline , jl_f_union ,
57
+ jl_f_methodexists , jl_f_applicable ,
58
+ jl_f_invoke , jl_apply_generic ,
59
+ jl_unprotect_stack ,
60
+ jl_f_yieldto , jl_f_sizeof , jl_f_new_expr ,
61
+ NULL };
44
62
45
63
// pointers to non-AST-ish objects in a compressed tree
46
64
static jl_array_t * tree_literal_values = NULL ; // (only used in MODE_AST)
@@ -789,12 +807,12 @@ void jl_serialize_lambdas_from_mod(ios_t *s, jl_module_t *m)
789
807
static jl_fptr_t jl_deserialize_fptr (ios_t * s )
790
808
{
791
809
int fptr = read_uint16 (s );
792
- if (fptr == 0 )
810
+ if (fptr < 2 )
793
811
return NULL ;
794
- void * * pbp = ptrhash_bp ( & id_to_fptr , ( void * )( ptrint_t ) fptr );
795
- if (* pbp == HT_NOTFOUND )
812
+
813
+ if (fptr >= sizeof ( id_to_fptrs )/ sizeof ( * id_to_fptrs ) )
796
814
jl_error ("unknown function pointer ID" );
797
- return * ( jl_fptr_t * ) pbp ;
815
+ return id_to_fptrs [ fptr ] ;
798
816
}
799
817
800
818
static jl_value_t * jl_deserialize_datatype (ios_t * s , int pos , jl_value_t * * loc )
@@ -1669,8 +1687,7 @@ jl_module_t *jl_restore_new_module(char *fname)
1669
1687
void jl_init_serializer (void )
1670
1688
{
1671
1689
htable_new (& ser_tag , 0 );
1672
- htable_new (& fptr_to_id , 0 );
1673
- htable_new (& id_to_fptr , 0 );
1690
+ htable_new (& fptr_to_id , sizeof (id_to_fptrs )/sizeof (* id_to_fptrs ));
1674
1691
htable_new (& backref_table , 50000 );
1675
1692
1676
1693
void * tags [] = { jl_symbol_type , jl_datatype_type ,
@@ -1794,27 +1811,9 @@ void jl_init_serializer(void)
1794
1811
assert (i <= Null_tag );
1795
1812
VALUE_TAGS = (ptrint_t )ptrhash_get (& ser_tag , jl_null );
1796
1813
1797
- jl_fptr_t fptrs [] = { jl_f_throw , jl_f_is ,
1798
- jl_f_no_function , jl_f_typeof ,
1799
- jl_f_subtype , jl_f_isa ,
1800
- jl_f_typeassert , jl_f_apply ,
1801
- jl_f_top_eval , jl_f_isdefined ,
1802
- jl_f_tuple , jl_f_tupleref ,
1803
- jl_f_tuplelen , jl_f_get_field ,
1804
- jl_f_set_field , jl_f_field_type ,
1805
- jl_f_arraylen , jl_f_arrayref ,
1806
- jl_f_arrayset , jl_f_arraysize ,
1807
- jl_f_instantiate_type , jl_f_kwcall ,
1808
- jl_trampoline , jl_f_union ,
1809
- jl_f_methodexists , jl_f_applicable ,
1810
- jl_f_invoke , jl_apply_generic ,
1811
- jl_unprotect_stack ,
1812
- jl_f_yieldto , jl_f_sizeof , jl_f_new_expr ,
1813
- NULL };
1814
1814
i = 2 ;
1815
- while (fptrs [i - 2 ] != NULL ) {
1816
- ptrhash_put (& fptr_to_id , (void * )fptrs [i - 2 ], (void * )i );
1817
- ptrhash_put (& id_to_fptr , (void * )i , (void * )fptrs [i - 2 ]);
1815
+ while (id_to_fptrs [i ] != NULL ) {
1816
+ ptrhash_put (& fptr_to_id , (void * )id_to_fptrs [i ], (void * )i );
1818
1817
i += 1 ;
1819
1818
}
1820
1819
}
0 commit comments