Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: compiler/java/com/google/dart/compiler/parser/AbstractParser.java

Issue 11189149: Issue 5530. Make DartParser thread safe. Remove compiler lock. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Wait for warm up before allowing other thread for use DartCompilerUtilities Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/parser/AbstractParser.java
diff --git a/compiler/java/com/google/dart/compiler/parser/AbstractParser.java b/compiler/java/com/google/dart/compiler/parser/AbstractParser.java
index a5c13b05c88b24c844674aa3d17559285eaab676..273313b4698cd23d88ccf04ad432b8812c1a417d 100644
--- a/compiler/java/com/google/dart/compiler/parser/AbstractParser.java
+++ b/compiler/java/com/google/dart/compiler/parser/AbstractParser.java
@@ -21,6 +21,7 @@ import java.util.Set;
*/
abstract class AbstractParser {
+ private final TerminalAnnotationsCache terminalAnnotationsCache = new TerminalAnnotationsCache();
protected final ParserContext ctx;
private int lastErrorPosition = Integer.MIN_VALUE;
@@ -33,10 +34,10 @@ abstract class AbstractParser {
}
private static class TerminalAnnotationsCache {
- private static Map<String, Class<?>> classes;
- private static Map<String, List<Token>> methods;
+ private Map<String, Class<?>> classes;
+ private Map<String, List<Token>> methods;
- private static void init(StackTraceElement[] stackTrace) {
+ private void init(StackTraceElement[] stackTrace) {
if (classes == null) {
classes = Maps.newHashMap();
methods = Maps.newHashMap();
@@ -72,7 +73,7 @@ abstract class AbstractParser {
}
}
- public static Set<Token> terminalsForStack(StackTraceElement[] stackTrace) {
+ public Set<Token> terminalsForStack(StackTraceElement[] stackTrace) {
Set<Token> results = Sets.newHashSet();
for (StackTraceElement frame: stackTrace) {
List<Token> found = methods.get(frame.getClassName() + "." + frame.getMethodName());
@@ -94,9 +95,9 @@ abstract class AbstractParser {
protected Set<Token> collectTerminalAnnotations() {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
// Get methods for every class and associated Terminals annotations & stick them in a hash
- TerminalAnnotationsCache.init(stackTrace);
+ terminalAnnotationsCache.init(stackTrace);
// Create the set of terminals to return
- return TerminalAnnotationsCache.terminalsForStack(stackTrace);
+ return terminalAnnotationsCache.terminalsForStack(stackTrace);
}
/**
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/compiler/DartCompilerUtilities.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698