Author: sco...@google.com
Date: Thu Apr  2 13:48:07 2009
New Revision: 5169

Modified:
    trunk/dev/core/src/com/google/gwt/dev/Precompile.java
    trunk/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
    trunk/dev/core/src/com/google/gwt/dev/cfg/Rule.java
    trunk/dev/core/src/com/google/gwt/dev/cfg/RuleGenerateWith.java
    trunk/dev/core/src/com/google/gwt/dev/cfg/Rules.java
    trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
    trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java

Log:
Follow-on to clearing out TypeOracle state; also free Generators instances.

Review by: jat

Modified: trunk/dev/core/src/com/google/gwt/dev/Precompile.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/Precompile.java       (original)
+++ trunk/dev/core/src/com/google/gwt/dev/Precompile.java       Thu Apr  2  
13:48:07 2009
@@ -373,7 +373,7 @@
     * @return the precompilation
     */
    public static Precompilation precompile(TreeLogger logger,
-      PrecompileOptionsImpl jjsOptions, ModuleDef module, File genDir,
+      JJSOptions jjsOptions, ModuleDef module, File genDir,
        File generatorResourcesDir, File dumpSignatureFile) {
      return precompile(logger, jjsOptions, module, 0, 0,
          module.getProperties().numPermutations(), genDir,
@@ -421,7 +421,7 @@
        FragmentLoaderCreator fragmentLoaderCreator = new  
FragmentLoaderCreator(
            compilationState, module, genDir, generatorResourcesDir,
            generatorArtifacts);
-      JavaToJavaScriptCompiler.precompile(logger, compilationState, rpo,
+      JavaToJavaScriptCompiler.precompile(logger, module, rpo,
            fragmentLoaderCreator, declEntryPts, additionalRootTypes,  
jjsOptions,
            true);
        return true;
@@ -432,7 +432,7 @@
    }

    private static Precompilation precompile(TreeLogger logger,
-      PrecompileOptionsImpl jjsOptions, ModuleDef module, int  
permutationBase,
+      JJSOptions jjsOptions, ModuleDef module, int permutationBase,
        int firstPerm, int numPerms, File genDir, File generatorResourcesDir,
        File dumpSignatureFile) {

@@ -462,8 +462,8 @@
            generatedArtifacts);
        PerfLogger.start("Precompile");
        UnifiedAst unifiedAst = JavaToJavaScriptCompiler.precompile(logger,
-          compilationState, rpo, fragmentLoaderCreator, declEntryPts, null,
-          jjsOptions, rpo.getPermuationCount() == 1);
+          module, rpo, fragmentLoaderCreator, declEntryPts, null,  
jjsOptions,
+          rpo.getPermuationCount() == 1);
        PerfLogger.end();

        // Merge all identical permutations together.

Modified: trunk/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java    (original)
+++ trunk/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java    Thu Apr  2  
13:48:07 2009
@@ -173,6 +173,21 @@
          defaultExcludes, caseSensitive, true);
    }

+  /**
+   * Free up memory no longer needed in later compile stages. After  
calling this
+   * method, the TypeOracle, ResourceOracle, and CompilationState will be  
empty
+   * and unusable. Calling {...@link #refresh(TreeLogger)} will restore them.
+   */
+  public void clear() {
+    if (lazySourceOracle != null) {
+      lazySourceOracle.clear();
+    }
+    if (lazyCompilationState != null) {
+      lazyCompilationState.clear();
+    }
+    rules.dispose();
+  }
+
    public void clearEntryPoints() {
      entryPointTypeNames.clear();
    }

Modified: trunk/dev/core/src/com/google/gwt/dev/cfg/Rule.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/cfg/Rule.java (original)
+++ trunk/dev/core/src/com/google/gwt/dev/cfg/Rule.java Thu Apr  2 13:48:07  
2009
@@ -37,4 +37,7 @@

    public abstract String realize(TreeLogger logger, GeneratorContext  
context,
        String typeName) throws UnableToCompleteException;
+
+  protected void dispose() {
+  }
  }

Modified: trunk/dev/core/src/com/google/gwt/dev/cfg/RuleGenerateWith.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/cfg/RuleGenerateWith.java      
(original)
+++ trunk/dev/core/src/com/google/gwt/dev/cfg/RuleGenerateWith.java     Thu  
Apr  2 13:48:07 2009
@@ -28,7 +28,7 @@
   */
  public class RuleGenerateWith extends Rule {

-  private final Generator generator;
+  private Generator generator;

    public RuleGenerateWith(Generator generator) {
      this.generator = generator;
@@ -69,5 +69,10 @@

    public String toString() {
      return "<generate-with class='" + generator.getClass().getName()  
+ "'/>";
+  }
+
+  @Override
+  protected void dispose() {
+    generator = null;
    }
  }

Modified: trunk/dev/core/src/com/google/gwt/dev/cfg/Rules.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/cfg/Rules.java        (original)
+++ trunk/dev/core/src/com/google/gwt/dev/cfg/Rules.java        Thu Apr  2  
13:48:07 2009
@@ -25,6 +25,12 @@

    private final LinkedList<Rule> list = new LinkedList<Rule>();

+  public void dispose() {
+    for (Rule rule : list) {
+      rule.dispose();
+    }
+  }
+
    public boolean isEmpty() {
      return list.isEmpty();
    }

Modified: trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java    
(original)
+++ trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java   Thu  
Apr  2 13:48:07 2009
@@ -146,7 +146,6 @@
      updateExposedUnits();
      jdtCompiler = null;
      mediator = new TypeOracleMediator();
-    sourceOracle.clear();
      invalidatorState = new CompilationUnitInvalidator.InvalidatorState();
    }


Modified:  
trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java     
 
(original)
+++ trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java     
 
Thu Apr  2 13:48:07 2009
@@ -27,7 +27,7 @@
  import com.google.gwt.core.ext.soyc.impl.SplitPointRecorderImpl;
  import com.google.gwt.core.ext.soyc.impl.StoryRecorderImpl;
  import com.google.gwt.dev.PermutationResult;
-import com.google.gwt.dev.javac.CompilationState;
+import com.google.gwt.dev.cfg.ModuleDef;
  import com.google.gwt.dev.jdt.RebindPermutationOracle;
  import com.google.gwt.dev.jdt.WebModeCompilerFrontEnd;
  import com.google.gwt.dev.jjs.CorrelationFactory.DummyCorrelationFactory;
@@ -319,7 +319,7 @@
     * Performs a precompilation, returning a unified AST.
     *
     * @param logger the logger to use
-   * @param compilationState the CompilationState
+   * @param module the module to compile
     * @param rpo the RebindPermutationOracle
     * @param fragmentLoaderCreator a FragmentLoaderCreator
     * @param declEntryPts the set of entry classes declared in a GWT module;
@@ -333,10 +333,9 @@
     * @throws UnableToCompleteException if an error other than
     *           {...@link OutOfMemoryError} occurs
     */
-  public static UnifiedAst precompile(TreeLogger logger,
-      CompilationState compilationState, RebindPermutationOracle rpo,
-      FragmentLoaderCreator fragmentLoaderCreator, String[] declEntryPts,
-      String[] additionalRootTypes, JJSOptions options,
+  public static UnifiedAst precompile(TreeLogger logger, ModuleDef module,
+      RebindPermutationOracle rpo, FragmentLoaderCreator  
fragmentLoaderCreator,
+      String[] declEntryPts, String[] additionalRootTypes, JJSOptions  
options,
        boolean singlePermutation) throws UnableToCompleteException {

      if (additionalRootTypes == null) {
@@ -363,12 +362,12 @@
      // Compile the source and get the compiler so we can get the parse tree
      //
      CompilationUnitDeclaration[] goldenCuds =  
WebModeCompilerFrontEnd.getCompilationUnitDeclarations(
-        logger, allRootTypes.toArray(new String[0]), compilationState, rpo,
-        fragmentLoaderCreator);
+        logger, allRootTypes.toArray(new String[0]),
+        module.getCompilationState(logger), rpo, fragmentLoaderCreator);

      // Free up memory.
      if (!options.isCompilationStateRetained()) {
-      compilationState.clear();
+      module.clear();
      }

      // Check for compilation problems. We don't log here because any  
problems

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to