diff --git a/base/serialize.jl b/base/serialize.jl index b8e2387e98d00..401676abf4c72 100644 --- a/base/serialize.jl +++ b/base/serialize.jl @@ -943,6 +943,9 @@ function deserialize_typename(s::AbstractSerializer, number) maxa = deserialize(s)::Int if makenew tn.mt = ccall(:jl_new_method_table, Any, (Any, Any), name, tn.module) + if isempty(parameters) + tn.mt.offs = 1 + end tn.mt.name = mtname tn.mt.max_args = maxa for def in defs diff --git a/src/datatype.c b/src/datatype.c index f91d9331dff66..ab0192a1deeed 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -46,6 +46,7 @@ JL_DLLEXPORT jl_methtable_t *jl_new_method_table(jl_sym_t *name, jl_module_t *mo mt->kwsorter = NULL; mt->backedges = NULL; JL_MUTEX_INIT(&mt->writelock); + mt->offs = 0; return mt; } @@ -378,6 +379,8 @@ JL_DLLEXPORT jl_datatype_t *jl_new_datatype( if (!abstract) { tn->mt = jl_new_method_table(name, module); jl_gc_wb(tn, tn->mt); + if (jl_svec_len(parameters) == 0) + tn->mt->offs = 1; } } t->name = tn; diff --git a/src/dump.c b/src/dump.c index 31c0fa6541add..265de495d6245 100644 --- a/src/dump.c +++ b/src/dump.c @@ -2003,8 +2003,7 @@ static void jl_reinit_item(jl_value_t *v, int how, arraylist_t *tracee_list) case 3: { // rehash MethodTable jl_methtable_t *mt = (jl_methtable_t*)v; jl_typemap_rehash(mt->defs, 0); - // TODO: consider reverting this when we can split on Type{...} better - jl_typemap_rehash(mt->cache, 1); //(mt == jl_type_typename->mt) ? 0 : 1); + jl_typemap_rehash(mt->cache, mt->offs); if (tracee_list) arraylist_push(tracee_list, mt); break; @@ -2674,7 +2673,7 @@ void jl_init_serializer(void) jl_emptysvec, jl_emptytuple, jl_false, jl_true, jl_nothing, jl_any_type, call_sym, invoke_sym, goto_ifnot_sym, return_sym, body_sym, line_sym, - lambda_sym, jl_symbol("tuple"), assign_sym, isdefined_sym, + lambda_sym, jl_symbol("tuple"), assign_sym, isdefined_sym, jl_box_uint8(0), jl_box_uint8(1), // empirical list of very common symbols #include "common_symbols1.inc" @@ -2692,7 +2691,6 @@ void jl_init_serializer(void) jl_box_int32(30), jl_box_int32(31), jl_box_int32(32), #ifndef _P64 jl_box_int32(33), jl_box_int32(34), jl_box_int32(35), - jl_box_int32(36), jl_box_int32(37), #endif jl_box_int64(0), jl_box_int64(1), jl_box_int64(2), jl_box_int64(3), jl_box_int64(4), jl_box_int64(5), @@ -2707,7 +2705,6 @@ void jl_init_serializer(void) jl_box_int64(30), jl_box_int64(31), jl_box_int64(32), #ifdef _P64 jl_box_int64(33), jl_box_int64(34), jl_box_int64(35), - jl_box_int64(36), jl_box_int64(37), #endif jl_labelnode_type, jl_linenumbernode_type, jl_gotonode_type, jl_quotenode_type, jl_type_type, jl_bottom_type, jl_ref_type, diff --git a/src/gf.c b/src/gf.c index 1247383b24c47..998050ba2ced0 100644 --- a/src/gf.c +++ b/src/gf.c @@ -134,8 +134,7 @@ const struct jl_typemap_info tfunc_cache = { static int8_t jl_cachearg_offset(jl_methtable_t *mt) { - // TODO: consider reverting this when we can split on Type{...} better - return 1; //(mt == jl_type_type_mt) ? 0 : 1; + return mt->offs; } /// ----- Insertion logic for special entries ----- /// diff --git a/src/jltypes.c b/src/jltypes.c index da03382e549d2..95a1c63957c9f 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -1613,6 +1613,7 @@ void jl_init_types(void) jl_typename_type->name = jl_new_typename_in(jl_symbol("TypeName"), core); jl_typename_type->name->wrapper = (jl_value_t*)jl_typename_type; jl_typename_type->name->mt = jl_new_method_table(jl_typename_type->name->name, core); + jl_typename_type->name->mt->offs = 1; jl_typename_type->super = jl_any_type; jl_typename_type->parameters = jl_emptysvec; jl_typename_type->name->names = jl_perm_symsvec(8, "name", "module", @@ -1633,15 +1634,17 @@ void jl_init_types(void) jl_methtable_type->name = jl_new_typename_in(jl_symbol("MethodTable"), core); jl_methtable_type->name->wrapper = (jl_value_t*)jl_methtable_type; jl_methtable_type->name->mt = jl_new_method_table(jl_methtable_type->name->name, core); + jl_methtable_type->name->mt->offs = 1; jl_methtable_type->super = jl_any_type; jl_methtable_type->parameters = jl_emptysvec; - jl_methtable_type->name->names = jl_perm_symsvec(9, "name", "defs", + jl_methtable_type->name->names = jl_perm_symsvec(10, "name", "defs", "cache", "max_args", "kwsorter", "module", - "backedges", "", ""); - jl_methtable_type->types = jl_svec(9, jl_sym_type, jl_any_type, jl_any_type, jl_any_type/*jl_long*/, + "backedges", "", "", "offs"); + jl_methtable_type->types = jl_svec(10, jl_sym_type, jl_any_type, jl_any_type, jl_any_type/*jl_long*/, jl_any_type, jl_any_type/*module*/, - jl_any_type/*any vector*/, jl_any_type/*long*/, jl_any_type/*int32*/); + jl_any_type/*any vector*/, jl_any_type/*long*/, jl_any_type/*int32*/, + jl_any_type/*uint8*/); jl_methtable_type->uid = jl_assign_type_uid(); jl_methtable_type->instance = NULL; jl_methtable_type->struct_decl = NULL; @@ -1653,6 +1656,7 @@ void jl_init_types(void) jl_sym_type->name = jl_new_typename_in(jl_symbol("Symbol"), core); jl_sym_type->name->wrapper = (jl_value_t*)jl_sym_type; jl_sym_type->name->mt = jl_new_method_table(jl_sym_type->name->name, core); + jl_sym_type->name->mt->offs = 1; jl_sym_type->super = jl_any_type; jl_sym_type->parameters = jl_emptysvec; jl_sym_type->name->names = jl_emptysvec; @@ -1669,6 +1673,7 @@ void jl_init_types(void) jl_simplevector_type->name = jl_new_typename_in(jl_symbol("SimpleVector"), core); jl_simplevector_type->name->wrapper = (jl_value_t*)jl_simplevector_type; jl_simplevector_type->name->mt = jl_new_method_table(jl_simplevector_type->name->name, core); + jl_simplevector_type->name->mt->offs = 1; jl_simplevector_type->super = jl_any_type; jl_simplevector_type->parameters = jl_emptysvec; jl_simplevector_type->name->names = jl_emptysvec; @@ -2058,10 +2063,12 @@ void jl_init_types(void) jl_svecset(jl_methtable_type->types, 6, jl_array_any_type); #ifdef __LP64__ jl_svecset(jl_methtable_type->types, 7, jl_int64_type); // unsigned long + jl_svecset(jl_methtable_type->types, 8, jl_int64_type); // uint32_t plus alignment #else jl_svecset(jl_methtable_type->types, 7, jl_int32_type); // DWORD -#endif jl_svecset(jl_methtable_type->types, 8, jl_int32_type); // uint32_t +#endif + jl_svecset(jl_methtable_type->types, 9, jl_uint8_type); jl_svecset(jl_method_type->types, 11, jl_method_instance_type); jl_svecset(jl_method_type->types, 12, jl_method_instance_type); jl_svecset(jl_method_instance_type->types, 12, jl_voidpointer_type); diff --git a/src/julia.h b/src/julia.h index 0b433057e5e01..f369464186617 100644 --- a/src/julia.h +++ b/src/julia.h @@ -463,6 +463,7 @@ typedef struct _jl_methtable_t { jl_module_t *module; // used for incremental serialization to locate original binding jl_array_t *backedges; jl_mutex_t writelock; + uint8_t offs; // 0, or 1 to skip splitting typemap on first (function) argument } jl_methtable_t; typedef struct {