forked from jasder/antlr
Finer locks in DFA updates
This commit is contained in:
parent
8b3062175d
commit
5c2b764670
|
@ -602,7 +602,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
|
||||
DFA dfa = decisionToDFA[mode];
|
||||
synchronized (dfa) {
|
||||
synchronized (p) {
|
||||
if ( p.edges==null ) {
|
||||
// make room for tokens 1..n and -1 masquerading as index 0
|
||||
p.edges = new DFAState[MAX_DFA_EDGE-MIN_DFA_EDGE+1];
|
||||
|
@ -641,7 +641,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
|
||||
DFA dfa = decisionToDFA[mode];
|
||||
synchronized (dfa) {
|
||||
synchronized (dfa.states) {
|
||||
DFAState existing = dfa.states.get(proposed);
|
||||
if ( existing!=null ) return existing;
|
||||
|
||||
|
@ -650,7 +650,7 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
newState.stateNumber = dfa.states.size();
|
||||
configs.setReadonly(true);
|
||||
newState.configs = configs;
|
||||
decisionToDFA[mode].states.put(newState, newState);
|
||||
dfa.states.put(newState, newState);
|
||||
return newState;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1546,7 +1546,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
if ( debug ) System.out.println("EDGE "+from+" -> "+to+" upon "+getTokenName(t));
|
||||
if ( from==null || t < -1 || to == null ) return;
|
||||
to = addDFAState(dfa, to); // used existing if possible not incoming
|
||||
synchronized (dfa) {
|
||||
synchronized (from) {
|
||||
if ( from.edges==null ) {
|
||||
from.edges = new DFAState[atn.maxTokenType+1+1]; // TODO: make adaptive
|
||||
}
|
||||
|
@ -1557,7 +1557,7 @@ public class ParserATNSimulator extends ATNSimulator {
|
|||
|
||||
/** Add D if not there and return D. Return previous if already present. */
|
||||
protected DFAState addDFAState(@NotNull DFA dfa, @NotNull DFAState D) {
|
||||
synchronized (dfa) {
|
||||
synchronized (dfa.states) {
|
||||
DFAState existing = dfa.states.get(D);
|
||||
if ( existing!=null ) return existing;
|
||||
|
||||
|
|
Loading…
Reference in New Issue