Skip to content

Commit

Permalink
made non-lock-protected reads from SymbolicRegexBuilder._delta volatile
Browse files Browse the repository at this point in the history
  • Loading branch information
veanes committed Nov 3, 2021
1 parent d5cb37c commit a5ca169
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,8 @@ public DfaMatchingState<TSetType> TakeTransition(
Debug.Assert(builder._delta is not null);

int offset = (currentState.Id << builder._mintermsCount) | mintermId;
return
builder._delta[offset] ??
matcher.CreateNewTransition(currentState, minterm, offset);
DfaMatchingState<TSetType>? p = Volatile.Read(ref builder._delta[offset]);
return p ?? matcher.CreateNewTransition(currentState, minterm, offset);
}
}

Expand Down Expand Up @@ -391,7 +390,8 @@ public DfaMatchingState<TSetType> TakeTransition(
DfaMatchingState<TSetType> nextStates = builder.MkState(oneState, currentStates.PrevCharKind);

int offset = (nextStates.Id << builder._mintermsCount) | mintermId;
DfaMatchingState<TSetType> p = builder._delta[offset] ?? matcher.CreateNewTransition(nextStates, minterm, offset);
DfaMatchingState<TSetType>? p_ = Volatile.Read(ref builder._delta[offset]);
DfaMatchingState<TSetType> p = p_ ?? matcher.CreateNewTransition(nextStates, minterm, offset);

// Observe that if p.Node is an Or it will be flattened.
union = builder.MkOr2(union, p.Node);
Expand Down

0 comments on commit a5ca169

Please sign in to comment.