Skip to content

Commit

Permalink
MoarVM's struct MVMCollectable's flags is now flags1 and flags2
Browse files Browse the repository at this point in the history
As part of the fix for the data race described in MoarVM/MoarVM#1336
the flags member of struct MVMCollectable needs to be changed from a
single MVMuint16 to two MVMuint8 values. As `p6setfirstflag` and
`p6takefirstflag` directly manipulate this struct, they need to be
updated to reflect the changes.

Implemented with conditional compilation so that it will work with MoarVM
before and after these changes. Once MoarVM is updated, the conditional
compilation can be removed.
  • Loading branch information
nwc10 committed Aug 11, 2020
1 parent a84952f commit 9d6d8dd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/vm/moar/ops/perl6_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ static void p6stateinit(MVMThreadContext *tc, MVMuint8 *cur_op) {
}

/* First FIRST, use a flag in the object header. */
#ifdef MVM_COLLECTABLE_FLAGS1
#define RAKUDO_FIRST_FLAG 128
#else
#define RAKUDO_FIRST_FLAG 16384
#endif

static MVMuint8 s_p6setfirstflag[] = {
MVM_operand_obj | MVM_operand_write_reg,
Expand All @@ -181,7 +185,11 @@ static MVMuint8 s_p6setfirstflag[] = {
static void p6setfirstflag(MVMThreadContext *tc, MVMuint8 *cur_op) {
MVMObject *code_obj = GET_REG(tc, 2).o;
MVMObject *vm_code = MVM_frame_find_invokee(tc, code_obj, NULL);
#ifdef MVM_COLLECTABLE_FLAGS1
vm_code->header.flags1 |= RAKUDO_FIRST_FLAG;
#else
vm_code->header.flags |= RAKUDO_FIRST_FLAG;
#endif
GET_REG(tc, 0).o = code_obj;
}

Expand All @@ -190,8 +198,13 @@ static MVMuint8 s_p6takefirstflag[] = {
};
static void p6takefirstflag(MVMThreadContext *tc, MVMuint8 *cur_op) {
MVMObject *vm_code = tc->cur_frame->code_ref;
#ifdef MVM_COLLECTABLE_FLAGS1
if (vm_code->header.flags1 & RAKUDO_FIRST_FLAG) {
vm_code->header.flags1 ^= RAKUDO_FIRST_FLAG;
#else
if (vm_code->header.flags & RAKUDO_FIRST_FLAG) {
vm_code->header.flags ^= RAKUDO_FIRST_FLAG;
#endif
GET_REG(tc, 0).i64 = 1;
}
else {
Expand Down

0 comments on commit 9d6d8dd

Please sign in to comment.