@@ -933,12 +933,12 @@ static MDNode *best_tbaa(jl_value_t *jt) {
933933// note that this includes jl_isbits, although codegen should work regardless
934934static bool jl_is_concrete_immutable (jl_value_t * t)
935935{
936- return jl_is_immutable_datatype (t) && ((jl_datatype_t *)t)->layout ;
936+ return jl_is_immutable_datatype (t) && ((jl_datatype_t *)t)->isconcretetype ;
937937}
938938
939939static bool jl_is_pointerfree (jl_value_t * t)
940940{
941- if (!jl_is_immutable_datatype (t))
941+ if (!jl_is_concrete_immutable (t))
942942 return 0 ;
943943 const jl_datatype_layout_t *layout = ((jl_datatype_t *)t)->layout ;
944944 return layout && layout->npointers == 0 ;
@@ -3033,9 +3033,9 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
30333033 return true ;
30343034 }
30353035
3036- if (jl_is_datatype (utt) && utt-> layout ) {
3036+ if (jl_is_datatype (utt) && jl_struct_try_layout ( utt) ) {
30373037 ssize_t idx = jl_field_index (utt, name, 0 );
3038- if (idx != -1 ) {
3038+ if (idx != -1 && ! jl_has_free_typevars ( jl_field_type (utt, idx)) ) {
30393039 *ret = emit_getfield_knownidx (ctx, obj, idx, utt, order);
30403040 return true ;
30413041 }
@@ -3063,14 +3063,16 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
30633063 }
30643064
30653065 if (jl_is_datatype (utt)) {
3066- if (jl_is_structtype (utt) && utt-> layout ) {
3066+ if (jl_struct_try_layout (utt)) {
30673067 size_t nfields = jl_datatype_nfields (utt);
30683068 // integer index
30693069 size_t idx;
30703070 if (fld.constant && (idx = jl_unbox_long (fld.constant ) - 1 ) < nfields) {
3071- // known index
3072- *ret = emit_getfield_knownidx (ctx, obj, idx, utt, order);
3073- return true ;
3071+ if (!jl_has_free_typevars (jl_field_type (utt, idx))) {
3072+ // known index
3073+ *ret = emit_getfield_knownidx (ctx, obj, idx, utt, order);
3074+ return true ;
3075+ }
30743076 }
30753077 else {
30763078 // unknown index
@@ -3115,8 +3117,6 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
31153117 }
31163118 }
31173119 }
3118- // TODO: attempt better codegen for approximate types, if the types
3119- // and offsets of some fields are independent of parameters.
31203120 // TODO: generic getfield func with more efficient calling convention
31213121 return false ;
31223122 }
@@ -3155,7 +3155,7 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
31553155 }
31563156
31573157 jl_datatype_t *uty = (jl_datatype_t *)jl_unwrap_unionall (obj.typ );
3158- if (jl_is_structtype (uty) && uty-> layout ) {
3158+ if (jl_is_datatype (uty) && jl_struct_try_layout ( uty) ) {
31593159 ssize_t idx = -1 ;
31603160 if (fld.constant && fld.typ == (jl_value_t *)jl_symbol_type) {
31613161 idx = jl_field_index (uty, (jl_sym_t *)fld.constant , 0 );
0 commit comments