Skip to content

Commit

Permalink
Make physical comparison aware of promotion duplication.
Browse files Browse the repository at this point in the history
Promoting an object duplicates the object in the major heap and uses
write barriers to ensure that the copies are in sync. However, physical
comparison breaks due to this. Physical comparison is essential for
pattern matching polymorphic and extensible variants. See ocaml#7 for
example. The fix ensures that the major heap object is always used when
comparing promoted objects.
  • Loading branch information
kayceesrk committed Jun 8, 2015
1 parent 0e7f0a7 commit 0d111fd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions byterun/interp.c
Expand Up @@ -1061,8 +1061,20 @@ value caml_interprete(code_t prog, asize_t prog_size)
accu = (value)((((intnat) accu - 1) >> Long_val(*sp++)) | 1); Next;

#define Integer_comparison(typ,opname,tst) \
Instruct(opname): \
accu = Val_int((typ) accu tst (typ) *sp++); Next;
Instruct(opname): { \
if (Is_long (accu) || Is_long(*sp)) { \
accu = Val_int((typ) accu tst (typ) *sp++); \
Next; \
} \
if (Is_promoted_hd(Hd_val(accu)) && Is_young(accu)) \
accu = caml_addrmap_lookup(&caml_remembered_set.promotion, accu); \
value v2 = *(value*)sp; \
if (Is_promoted_hd(Hd_val(v2)) && Is_young(v2)) \
v2 = caml_addrmap_lookup(&caml_remembered_set.promotion, v2); \
accu = Val_int((typ) accu tst (typ) v2); \
sp++; \
Next; \
}

Integer_comparison(intnat,EQ, ==)
Integer_comparison(intnat,NEQ, !=)
Expand Down

0 comments on commit 0d111fd

Please sign in to comment.