forked from jasder/antlr
back to core sync around creating DFA in decisionToDFA. not thread-safe for dfa update.
This commit is contained in:
parent
4fe9efeb85
commit
f5f6715a07
|
@ -162,10 +162,6 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
int mark = input.mark();
|
||||
traceBeginMatch(input, mode);
|
||||
try {
|
||||
synchronized (decisionToDFA[mode]) {
|
||||
// Synchronizing on the mode DFA causes a lot of contention
|
||||
// between shared lexers in multiple threads, but is the
|
||||
// simplest safety measure. We can start with it.
|
||||
if ( decisionToDFA[mode].s0==null ) {
|
||||
return matchATN(input);
|
||||
}
|
||||
|
@ -173,7 +169,6 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
return execDFA(input, decisionToDFA[mode].s0);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
traceEndMatch();
|
||||
input.release(mark);
|
||||
|
|
|
@ -196,18 +196,10 @@ public class ParserATNSimulator<Symbol extends Token> extends ATNSimulator {
|
|||
}
|
||||
}
|
||||
// Now we are certain to have a specific decision's DFA
|
||||
// Synchronize on the DFA so that nobody can read or write
|
||||
// to it while we updated during ATN simulation
|
||||
synchronized (decisionToDFA[decision]) {
|
||||
return predictATN(dfa, input, outerContext);
|
||||
}
|
||||
}
|
||||
|
||||
// We can start with an existing DFA
|
||||
synchronized (decisionToDFA[decision]) {
|
||||
// Only enter the DFA simulation if nobody else is playing with it.
|
||||
// This blocks multiple readonly simulations of the same DFA but that's
|
||||
// unlikely to happen a lot
|
||||
int m = input.mark();
|
||||
int index = input.index();
|
||||
try {
|
||||
|
@ -219,7 +211,6 @@ public class ParserATNSimulator<Symbol extends Token> extends ATNSimulator {
|
|||
input.release(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int predictATN(@NotNull DFA dfa, @NotNull TokenStream input,
|
||||
@Nullable ParserRuleContext<?> outerContext)
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PredictionContextCache {
|
|||
return cache.get(ctx);
|
||||
}
|
||||
|
||||
public synchronized int size() {
|
||||
public int size() {
|
||||
return cache.size();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue