@@ -130,7 +130,7 @@ type access =
130
130
| AStaticFun of fundecl index
131
131
| AInstanceFun of texpr * fundecl index
132
132
| AInstanceProto of texpr * field index
133
- | AInstanceField of texpr * field index
133
+ | AInstanceField of texpr * field index * bool
134
134
| AArray of reg * (ttype * ttype ) * reg
135
135
| ACArray of reg * ttype * reg
136
136
| AVirtualMethod of texpr * field index
@@ -1326,11 +1326,12 @@ and object_access ctx eobj t f =
1326
1326
match t with
1327
1327
| HObj p | HStruct p ->
1328
1328
(try
1329
- let fid = fst ( get_index f.cf_name p) in
1329
+ let fid, t = get_index f.cf_name p in
1330
1330
if f.cf_kind = Method MethNormal then
1331
1331
AInstanceProto (eobj, - fid-1 )
1332
1332
else
1333
- AInstanceField (eobj, fid)
1333
+ let is_packed = match t with | HPacked _ -> true | _ -> false in
1334
+ AInstanceField (eobj, fid, is_packed)
1334
1335
with Not_found ->
1335
1336
ADynamic (eobj, alloc_string ctx f.cf_name))
1336
1337
| HVirtual v ->
@@ -1339,7 +1340,7 @@ and object_access ctx eobj t f =
1339
1340
if f.cf_kind = Method MethNormal then
1340
1341
AVirtualMethod (eobj, fid)
1341
1342
else
1342
- AInstanceField (eobj, fid)
1343
+ AInstanceField (eobj, fid, false )
1343
1344
with Not_found ->
1344
1345
ADynamic (eobj, alloc_string ctx f.cf_name))
1345
1346
| HDyn ->
@@ -2175,7 +2176,7 @@ and eval_expr ctx e =
2175
2176
| _ -> abort " Constant mode required" e.epos
2176
2177
) in
2177
2178
(match get_access ctx value with
2178
- | AInstanceField (f , index ) -> op ctx (OPrefetch (eval_expr ctx f, index + 1 , mode))
2179
+ | AInstanceField (f , index , _ ) -> op ctx (OPrefetch (eval_expr ctx f, index + 1 , mode))
2179
2180
| _ -> op ctx (OPrefetch (eval_expr ctx value, 0 , mode)));
2180
2181
alloc_tmp ctx HVoid
2181
2182
| "$unsafecast" , [value] ->
@@ -2323,7 +2324,7 @@ and eval_expr ctx e =
2323
2324
op ctx (OStaticClosure (r,f));
2324
2325
| AInstanceFun (ethis , f ) ->
2325
2326
op ctx (OInstanceClosure (r, f, eval_null_check ctx ethis))
2326
- | AInstanceField (ethis ,fid ) ->
2327
+ | AInstanceField (ethis , fid , _ ) ->
2327
2328
let robj = eval_null_check ctx ethis in
2328
2329
op ctx (match ethis.eexpr with TConst TThis -> OGetThis (r,fid) | _ -> OField (r,robj,fid));
2329
2330
| AInstanceProto (ethis ,fid ) | AVirtualMethod (ethis , fid ) ->
@@ -2521,15 +2522,17 @@ and eval_expr ctx e =
2521
2522
op ctx (OGetGlobal (o, g));
2522
2523
op ctx (OSetField (o, fid, r));
2523
2524
r
2524
- | AInstanceField ({ eexpr = TConst TThis } , fid ) ->
2525
+ | AInstanceField ({ eexpr = TConst TThis } , fid , is_packed ) ->
2525
2526
let r = value() in
2527
+ if is_packed then op ctx (ONullCheck r);
2526
2528
op ctx (OSetThis (fid,r));
2527
2529
r
2528
- | AInstanceField (ethis , fid ) ->
2530
+ | AInstanceField (ethis , fid , is_packed ) ->
2529
2531
let rthis = eval_null_check ctx ethis in
2530
2532
hold ctx rthis;
2531
2533
let r = value() in
2532
2534
free ctx rthis;
2535
+ if is_packed then op ctx (ONullCheck r);
2533
2536
op ctx (OSetField (rthis, fid, r));
2534
2537
r
2535
2538
| ALocal (v ,l ) ->
@@ -3087,7 +3090,7 @@ and gen_assign_op ctx acc e1 f =
3087
3090
f r
3088
3091
in
3089
3092
match acc with
3090
- | AInstanceField (eobj , findex ) ->
3093
+ | AInstanceField (eobj , findex , _ ) ->
3091
3094
let robj = eval_null_check ctx eobj in
3092
3095
hold ctx robj;
3093
3096
let t = real_type ctx e1 in
0 commit comments