You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/06/13 10:23:45 UTC
[groovy] branch GROOVY-9589 updated (65414a1 -> a7c3ec7)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a change to branch GROOVY-9589
in repository https://gitbox.apache.org/repos/asf/groovy.git.
discard 65414a1 GROOVY-9589: Parse source codes in parallel
add 9038ccb GROOVY-9585 preparatory work plus fix typo
add 81b1dd8 Trigger peeking of stream
add 45f4974 Tweak test
new a7c3ec7 GROOVY-9589: Parse source codes in parallel
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (65414a1)
\
N -- N -- N refs/heads/GROOVY-9589 (a7c3ec7)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../groovy/control/CompilerConfiguration.java | 2 ++
.../groovy/tools/javac/JavaStubGenerator.java | 3 ++-
src/test/groovy/bugs/Groovy9031.groovy | 5 ++++-
.../groovy/control/CompilerConfigurationTest.java | 21 +++++++++++++--------
4 files changed, 21 insertions(+), 10 deletions(-)
[groovy] 01/01: GROOVY-9589: Parse source codes in parallel
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY-9589
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit a7c3ec7b0d0202cbf34da2fc6f808cada882d009
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jun 13 17:56:05 2020 +0800
GROOVY-9589: Parse source codes in parallel
---
.../org/codehaus/groovy/control/CompilationUnit.java | 14 ++++++++++++++
.../java/org/codehaus/groovy/control/SourceUnit.java | 19 ++++++++++++++-----
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/control/CompilationUnit.java b/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
index 24d52e1..644956e 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
@@ -73,6 +73,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Queue;
import java.util.Set;
+import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList;
import static org.codehaus.groovy.ast.tools.GeneralUtils.classX;
@@ -626,6 +627,10 @@ public class CompilationUnit extends ProcessingUnit {
if (dequeued()) continue;
}
+ if (phase == Phases.CONVERSION) {
+ convertSourceUnits();
+ }
+
processPhaseOperations(phase);
// Grab processing may have brought in new AST transforms into various phases, process them as well
processNewPhaseOperations(phase);
@@ -647,6 +652,15 @@ public class CompilationUnit extends ProcessingUnit {
getErrorCollector().failIfErrors();
}
+ private void convertSourceUnits() {
+ // no need to build AST with parallel stream when we just have one/no source unit
+ if (sources.size() < 2) {
+ return;
+ }
+
+ sources.values().parallelStream().peek(SourceUnit::buildAST).collect(Collectors.counting());
+ }
+
private void processPhaseOperations(final int phase) {
for (PhaseOperation op : phaseOperations[phase]) {
op.doPhaseOperation(this);
diff --git a/src/main/java/org/codehaus/groovy/control/SourceUnit.java b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
index b25cee0..c23653b 100644
--- a/src/main/java/org/codehaus/groovy/control/SourceUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
@@ -240,6 +240,19 @@ public class SourceUnit extends ProcessingUnit {
//
// Build the AST
+ buildAST();
+
+ String property = (String) AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty("groovy.ast"));
+
+ if ("xml".equals(property)) {
+ XStreamUtils.serialize(name, ast);
+ }
+ }
+
+ public ModuleNode buildAST() {
+ if (null != this.ast) {
+ return this.ast;
+ }
try {
this.ast = parserPlugin.buildAST(this, this.classLoader, this.cst);
@@ -252,11 +265,7 @@ public class SourceUnit extends ProcessingUnit {
getErrorCollector().addError(new SyntaxErrorMessage(e, this));
}
- String property = (String) AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty("groovy.ast"));
-
- if ("xml".equals(property)) {
- XStreamUtils.serialize(name, ast);
- }
+ return this.ast;
}
//---------------------------------------------------------------------------