Revision: 10390
Author:   gwt.mirror...@gmail.com
Date:     Fri Jun 24 10:56:54 2011
Log:      Don't attempt generator result caching for deRPC

Review at http://gwt-code-reviews.appspot.com/1462809

http://code.google.com/p/google-web-toolkit/source/detail?r=10390

Modified:
/trunk/user/src/com/google/gwt/user/rebind/rpc/CachedRpcTypeInformation.java
 /trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java

=======================================
--- /trunk/user/src/com/google/gwt/user/rebind/rpc/CachedRpcTypeInformation.java Tue Jun 21 04:31:29 2011 +++ /trunk/user/src/com/google/gwt/user/rebind/rpc/CachedRpcTypeInformation.java Fri Jun 24 10:56:54 2011
@@ -48,25 +48,16 @@
recordTypes(serializableFromBrowser, instantiableFromBrowser, typesFromBrowser); recordTypes(serializableToBrowser, instantiableToBrowser, typesToBrowser);

+    assert (customSerializersUsed != null);
     for (JType type : customSerializersUsed) {
       addCustomSerializerType(type);
     }

+    assert (typesNotUsingCustomSerializers != null);
     for (JType type : typesNotUsingCustomSerializers) {
       addTypeNotUsingCustomSerializer(type);
     }
   }
-
-  public void addCustomSerializerType(JType type) {
-    String sourceName = type.getQualifiedSourceName();
-    lastModifiedTimes.put(sourceName, getLastModifiedTime(type));
-    customSerializerTypes.add(sourceName);
-  }
-
-  public void addTypeNotUsingCustomSerializer(JType type) {
-    String sourceName = type.getQualifiedSourceName();
-    typesNotUsingCustomSerializer.add(sourceName);
-  }

   public boolean checkLastModifiedTime(JType type) {
     Long cachedTime = lastModifiedTimes.get(type.getQualifiedSourceName());
@@ -133,11 +124,36 @@
   public boolean checkTypeNotUsingCustomSerializer(JType type) {
return typesNotUsingCustomSerializer.contains(type.getQualifiedSourceName());
   }
+
+  private void addCustomSerializerType(JType type) {
+    String sourceName = type.getQualifiedSourceName();
+    lastModifiedTimes.put(sourceName, getLastModifiedTime(type));
+    customSerializerTypes.add(sourceName);
+  }
+
+  private void addTypeNotUsingCustomSerializer(JType type) {
+    String sourceName = type.getQualifiedSourceName();
+    typesNotUsingCustomSerializer.add(sourceName);
+  }
+
+ private boolean checkTypes(TreeLogger logger, Set<String> serializable, Set<String> instantiable,
+      SerializableTypeOracle sto) {
+    for (JType type : sto.getSerializableTypes()) {
+      String sourceName = type.getQualifiedSourceName();
+      if (sto.isSerializable(type) != serializable.contains(sourceName)
+ || sto.maybeInstantiated(type) != instantiable.contains(sourceName)
+          || !checkLastModifiedTime(type)) {
+ logger.log(TreeLogger.TRACE, "A change was detected in type " + sourceName);
+        return false;
+      }
+    }
+    return true;
+  }

   /*
    * Finds a last modified time for a type, for testing cacheability.
    */
-  public long getLastModifiedTime(JType type) {
+  private long getLastModifiedTime(JType type) {
     JType typeToCheck;
     if (type instanceof JArrayType) {
       typeToCheck = type.getLeafType();
@@ -157,20 +173,6 @@
       return Long.MAX_VALUE;
     }
   }
-
- private boolean checkTypes(TreeLogger logger, Set<String> serializable, Set<String> instantiable,
-      SerializableTypeOracle sto) {
-    for (JType type : sto.getSerializableTypes()) {
-      String sourceName = type.getQualifiedSourceName();
-      if (sto.isSerializable(type) != serializable.contains(sourceName)
- || sto.maybeInstantiated(type) != instantiable.contains(sourceName)
-          || !checkLastModifiedTime(type)) {
- logger.log(TreeLogger.TRACE, "A change was detected in type " + sourceName);
-        return false;
-      }
-    }
-    return true;
-  }

private void logDifferencesBetweenCurrentAndCachedTypes(TreeLogger logger, JType[] currentTypes,
       Set<String> cachedTypes) {
@@ -190,6 +192,7 @@

private void recordTypes(Set<String> serializable, Set<String> instantiable,
       SerializableTypeOracle sto) {
+    assert (sto != null);
     for (JType type : sto.getSerializableTypes()) {
       String sourceName = type.getQualifiedSourceName();
       lastModifiedTimes.put(sourceName, getLastModifiedTime(type));
=======================================
--- /trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java Tue Jun 21 04:31:29 2011 +++ /trunk/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java Fri Jun 24 07:48:08 2011
@@ -325,8 +325,8 @@
       event.end();
     }

-    // Check generator result cacheability, to see if we can return now
- if (checkGeneratorResultCacheability(logger, context, typesSentFromBrowser, typesSentToBrowser)) {
+    // Check previous cached result, to see if we can return now
+ if (checkCachedGeneratorResultValid(logger, context, typesSentFromBrowser, typesSentToBrowser)) { logger.log(TreeLogger.TRACE, "Reusing all cached artifacts for " + getProxyQualifiedName()); return new RebindResult(RebindStatus.USE_ALL_CACHED, getProxyQualifiedName());
     }
@@ -378,7 +378,7 @@
           serializationPolicyStrongName, rpcLog));
     }

-    if (context.isGeneratorResultCachingEnabled()) {
+    if (checkGeneratorResultCacheability(context)) {
// Remember the type info that we care about for cacheability testing.
       CachedClientDataMap clientData = new CachedClientDataMap();
       CachedRpcTypeInformation cti =
@@ -392,8 +392,8 @@

       /*
        * Return with RebindStatus.USE_PARTIAL_CACHED, since we are allowing
- * generator result caching for field serializers, but other generated
-       * types cannot be cached effectively.
+       * reuse of cached results for field serializers, when available, but
+       * all other types have been newly generated.
        */
return new RebindResult(RebindStatus.USE_PARTIAL_CACHED, getProxyQualifiedName(), clientData);
     } else {
@@ -832,7 +832,7 @@
     return typeOracle.findType(packageName, getProxySimpleName()) != null;
   }

- private boolean checkGeneratorResultCacheability(TreeLogger logger, GeneratorContextExt ctx, + private boolean checkCachedGeneratorResultValid(TreeLogger logger, GeneratorContextExt ctx, SerializableTypeOracle typesSentFromBrowser, SerializableTypeOracle typesSentToBrowser) {

     CachedRebindResult lastResult = ctx.getCachedGeneratorResult();
@@ -863,6 +863,18 @@

     return true;
   }
+
+ private boolean checkGeneratorResultCacheability(GeneratorContextExt context) {
+    /*
+ * Currently not supporting caching for implementations which sub-class this
+     * class, such as {@link RpcProxyCreator}, which implements deRPC.
+     */
+    if (!this.getClass().equals(ProxyCreator.class)) {
+      return false;
+    }
+
+    return context.isGeneratorResultCachingEnabled();
+  }

private void emitPolicyFileArtifact(TreeLogger logger, GeneratorContextExt context,
       String partialPath) throws UnableToCompleteException {

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

Reply via email to