Package com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger

Examples of com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event


    private final class UnitProcessorImpl implements UnitProcessor {

      @Override
      public void process(CompilationUnitBuilder builder, CompilationUnitDeclaration cud,
          List<CompiledClass> compiledClasses) {
        Event event = SpeedTracerLogger.start(DevModeEventType.CSB_PROCESS);
        try {
          Map<MethodDeclaration, JsniMethod> jsniMethods =
              JsniCollector.collectJsniMethods(cud, builder.getSourceMapPath(),
                  builder.getSource(), JsRootScope.INSTANCE, DummyCorrelationFactory.INSTANCE);

          JSORestrictionsChecker.check(jsoState, cud);

          // JSNI check + collect dependencies.
          final Set<String> jsniDeps = new HashSet<String>();
          Map<String, Binding> jsniRefs = new HashMap<String, Binding>();
          JsniChecker.check(cud, jsoState, jsniMethods, jsniRefs, new JsniChecker.TypeResolver() {
            @Override
            public ReferenceBinding resolveType(String typeName) {
              ReferenceBinding resolveType = compiler.resolveType(typeName);
              if (resolveType != null) {
                jsniDeps.add(String.valueOf(resolveType.qualifiedSourceName()));
              }
              return resolveType;
            }
          });

          Map<TypeDeclaration, Binding[]> artificialRescues =
              new HashMap<TypeDeclaration, Binding[]>();
          ArtificialRescueChecker.check(cud, builder.isGenerated(), artificialRescues);
          BinaryTypeReferenceRestrictionsChecker.check(cud);

          MethodArgNamesLookup methodArgs = MethodParamCollector.collect(cud,
              builder.getSourceMapPath());

          StringInterner interner = StringInterner.get();
          String packageName = interner.intern(Shared.getPackageName(builder.getTypeName()));
          List<String> unresolvedQualified = new ArrayList<String>();
          List<String> unresolvedSimple = new ArrayList<String>();
          for (char[] simpleRef : cud.compilationResult().simpleNameReferences) {
            unresolvedSimple.add(interner.intern(String.valueOf(simpleRef)));
          }
          for (char[][] qualifiedRef : cud.compilationResult().qualifiedReferences) {
            unresolvedQualified.add(interner.intern(CharOperation.toString(qualifiedRef)));
          }
          for (String jsniDep : jsniDeps) {
            unresolvedQualified.add(interner.intern(jsniDep));
          }
          ArrayList<String> apiRefs = compiler.collectApiRefs(cud);
          for (int i = 0; i < apiRefs.size(); ++i) {
            apiRefs.set(i, interner.intern(apiRefs.get(i)));
          }
          Dependencies dependencies =
              new Dependencies(packageName, unresolvedQualified, unresolvedSimple, apiRefs);

          List<JDeclaredType> types = Collections.emptyList();
          if (!cud.compilationResult().hasErrors()) {
            // Make a GWT AST.
            types = astBuilder.process(cud, builder.getSourceMapPath(), artificialRescues,
                jsniMethods, jsniRefs);
          }

          for (CompiledClass cc : compiledClasses) {
            allValidClasses.put(cc.getSourceName(), cc);
          }

          builder.setClasses(compiledClasses).setTypes(types).setDependencies(dependencies)
              .setJsniMethods(jsniMethods.values()).setMethodArgs(methodArgs).setProblems(
                  cud.compilationResult().getProblems());
          buildQueue.add(builder);
        } finally {
          event.end();
        }
      }
View Full Code Here


  public static void enableTracker() {
    trackerEnabled = true;
  }

  public static OptimizerStats exec(JProgram program) {
    Event optimizeEvent = SpeedTracerLogger.start(CompilerEventType.OPTIMIZE, "optimizer", NAME);

    startTracker();
    OptimizerStats stats = new EnumOrdinalizer(program).execImpl();
    optimizeEvent.end("didChange", "" + stats.didChange());
    return stats;
  }
View Full Code Here

   * @param logger logger to use
   * @param units collection of compilation units to process
   */
  public void addNewUnits(TreeLogger logger,
      Collection<CompilationUnit> units) {
    Event typeOracleMediatorEvent = SpeedTracerLogger.start(CompilerEventType.TYPE_ORACLE_MEDIATOR);
   
    // First collect all class data.
    Event visitClassFileEvent = SpeedTracerLogger.start(
        CompilerEventType.TYPE_ORACLE_MEDIATOR, "phase", "Visit Class Files");
    classMap = new HashMap<String, CollectClassData>();
    for (CompilationUnit unit : units) {
      Collection<CompiledClass> compiledClasses = unit.getCompiledClasses();
      for (CompiledClass compiledClass : compiledClasses) {
        // XXX <<< Instantiations
        if (compiledClass.getBytes().length == 0) {
          continue;
        }
        // XXX >>> Instantiations
        CollectClassData cv = processClass(compiledClass);
        // skip any classes that can't be referenced by name outside of
        // their local scope, such as anonymous classes and method-local classes
        if (!cv.hasNoExternalName()) {
          classMap.put(compiledClass.getInternalName(), cv);
        }
      }
    }
    visitClassFileEvent.end();

    Event identityEvent = SpeedTracerLogger.start(
        CompilerEventType.TYPE_ORACLE_MEDIATOR, "phase", "Establish Identity");
    // Perform a shallow pass to establish identity for new and old types.
    classMapType = new HashMap<JRealClassType, CollectClassData>();
    allMethodArgs = new MethodArgNamesLookup();
    Set<JRealClassType> unresolvedTypes = new HashSet<JRealClassType>();
    for (CompilationUnit unit : units) {
      Collection<CompiledClass> compiledClasses = unit.getCompiledClasses();
      for (CompiledClass compiledClass : compiledClasses) {
        String internalName = compiledClass.getInternalName();
        CollectClassData cv = classMap.get(internalName);
        if (cv == null) {
          // ignore classes that were skipped earlier
          continue;
        }
        JRealClassType type = createType(compiledClass, unresolvedTypes);
        if (type != null) {
          allMethodArgs.mergeFrom(unit.getMethodArgs());
          binaryMapper.put(internalName, type);
          classMapType.put(type, cv);
        }
      }
    }
    identityEvent.end();

    Event resolveEnclosingEvent = SpeedTracerLogger.start(CompilerEventType.TYPE_ORACLE_MEDIATOR, "phase", "Resolve Enclosing Classes");
    // Hook up enclosing types
    TreeLogger branch = logger.branch(TreeLogger.SPAM,
        "Resolving enclosing classes");
    for (Iterator<JRealClassType> it = unresolvedTypes.iterator(); it.hasNext();) {
      JRealClassType type = it.next();
      if (!resolveEnclosingClass(branch, type)) {
        // already logged why it failed, don't try and use it further
        it.remove();
      }
    }
    resolveEnclosingEvent.end();

    Event resolveUnresolvedEvent = SpeedTracerLogger.start(CompilerEventType.TYPE_ORACLE_MEDIATOR, "phase", "Resolve Unresolved Types");
    // Resolve unresolved types.
    for (JRealClassType type : unresolvedTypes) {
      branch = logger.branch(TreeLogger.SPAM, "Resolving "
          + type.getQualifiedSourceName());
      if (!resolveClass(branch, type)) {
        // already logged why it failed
        // TODO: should we do anything else here?
      }
    }
    resolveUnresolvedEvent.end();

    Event finishEvent = SpeedTracerLogger.start(CompilerEventType.TYPE_ORACLE_MEDIATOR, "phase", "Finish");
    super.finish();
    finishEvent.end();

    // no longer needed
    allMethodArgs = null;
    classMap = null;
    classMapType = null;
View Full Code Here

    // Load the blacklist/whitelist
    TypeFilter blacklistTypeFilter = new BlacklistTypeFilter(logger, propertyOracle);

    // Determine the set of serializable types
    Event event = SpeedTracerLogger.start(CompilerEventType.GENERATOR_RPC_STOB);
    SerializableTypeOracle typesSentFromBrowser;
    SerializableTypeOracle typesSentToBrowser;
    String rpcLog = null;
    try {
      SerializableTypeOracleBuilder typesSentFromBrowserBuilder =
          new SerializableTypeOracleBuilder(logger, context);
      typesSentFromBrowserBuilder.setTypeFilter(blacklistTypeFilter);
      SerializableTypeOracleBuilder typesSentToBrowserBuilder =
          new SerializableTypeOracleBuilder(logger, context);
      typesSentToBrowserBuilder.setTypeFilter(blacklistTypeFilter);

      addRoots(logger, typeOracle, typesSentFromBrowserBuilder, typesSentToBrowserBuilder);

      // Decide what types to send in each direction.
      {
        if (logger.isLoggable(TreeLogger.Type.DEBUG)) {
          // Log the decisions to a string that will be written later in this method
          StringWriter stringWriter = new StringWriter();
          PrintWriter writer = new PrintWriter(stringWriter);

          typesSentFromBrowserBuilder.setLogOutputWriter(writer);
          typesSentToBrowserBuilder.setLogOutputWriter(writer);

          writer.write("====================================\n");
          writer.write("Types potentially sent from browser:\n");
          writer.write("====================================\n\n");
          writer.flush();
          typesSentFromBrowser = typesSentFromBrowserBuilder.build(logger);

          writer.write("===================================\n");
          writer.write("Types potentially sent from server:\n");
          writer.write("===================================\n\n");
          writer.flush();
          typesSentToBrowser = typesSentToBrowserBuilder.build(logger);

          writer.close();
          rpcLog = stringWriter.toString();
        } else {
          typesSentFromBrowser = typesSentFromBrowserBuilder.build(logger);
          typesSentToBrowser = typesSentToBrowserBuilder.build(logger);
        }
      }

    } finally {
      event.end();
    }

    // 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());
View Full Code Here

  }

  protected void generateTypeHandlers(TreeLogger logger, GeneratorContext context,
      SerializableTypeOracle typesSentFromBrowser, SerializableTypeOracle typesSentToBrowser)
      throws UnableToCompleteException {
    Event event = SpeedTracerLogger.start(CompilerEventType.GENERATOR_RPC_TYPE_SERIALIZER);
    TypeSerializerCreator tsc =
        new TypeSerializerCreator(logger, typesSentFromBrowser, typesSentToBrowser, context,
            SerializationUtils.getTypeSerializerQualifiedName(serviceIntf), SerializationUtils
                .getTypeSerializerSimpleName(serviceIntf));
    tsc.realize(logger);
    event.end();

    typeStrings = new HashMap<JType, String>(tsc.getTypeStrings());
    typeStrings.put(serviceIntf, TypeNameObfuscator.SERVICE_INTERFACE_ID);

    customSerializersUsed = tsc.getCustomSerializersUsed();
View Full Code Here

  /*
   * Create a field serializer for a type if it does not have a custom
   * serializer.
   */
  private void createFieldSerializer(TreeLogger logger, GeneratorContext ctx, JType type) {
    Event event = SpeedTracerLogger.start(CompilerEventType.GENERATOR_RPC_FIELD_SERIALIZER);
    try {
      assert (type != null);
      assert (serializationOracle.isSerializable(type) || deserializationOracle
          .isSerializable(type));

      JParameterizedType parameterizedType = type.isParameterized();
      if (parameterizedType != null) {
        createFieldSerializer(logger, ctx, parameterizedType.getRawType());
        return;
      }

      /*
       * Only a JClassType can reach this point in the code. JPrimitives have
       * been removed because their serialization is built in, interfaces have
       * been removed because they are not an instantiable type and
       * parameterized types have been broken down into their raw types.
       */
      assert (type.isClass() != null || type.isArray() != null);

      // get custom field serializer, if available
      JClassType customFieldSerializer =
          SerializableTypeOracleBuilder.findCustomFieldSerializer(typeOracle, type);

      if (ctx.isGeneratorResultCachingEnabled()) {
        // update cached info for next iteration
        if (customFieldSerializer != null) {
          customFieldSerializersUsed.add(customFieldSerializer);
        } else {
          typesNotUsingCustomFieldSerializers.add(type);
        }

        // check the cache for a valid field serializer for the current type
        if (findReusableCachedFieldSerializerIfAvailable(logger, ctx, type,
            customFieldSerializer)) {
          // we can skip re-generation of the field serializer for the current
          // type
          return;
        }
      }

      // generate a new field serializer
      FieldSerializerCreator creator =
          new FieldSerializerCreator(logger, context, serializationOracle, deserializationOracle,
              (JClassType) type, customFieldSerializer);
      creator.realize(logger, ctx);
    } finally {
      event.end();
    }
  }
View Full Code Here

    accept(program);
    return stats;
  }

  public static OptimizerStats exec(JProgram program) {
    Event optimizeEvent = SpeedTracerLogger
        .start(CompilerEventType.OPTIMIZE, "optimizer", NAME);
    OptimizerStats stats = new RemoveSpecializations(program).execImpl();
    optimizeEvent.end("didChange", "" + stats.didChange());
    return stats;
  }
View Full Code Here

  }

  public static final String NAME = MethodCallSpecializer.class.getSimpleName();

  public static OptimizerStats exec(JProgram program) {
    Event optimizeEvent = SpeedTracerLogger.start(CompilerEventType.OPTIMIZE, "optimizer", NAME);
    OptimizerStats stats = new MethodCallSpecializer(program).execImpl();
    optimizeEvent.end("didChange", "" + stats.didChange());
    return stats;
  }
View Full Code Here

  }

  public static final String NAME = MethodCallTightener.class.getSimpleName();

  public static OptimizerStats exec(JProgram program) {
    Event optimizeEvent = SpeedTracerLogger.start(CompilerEventType.OPTIMIZE, "optimizer", NAME);
    OptimizerStats stats = new MethodCallTightener(program).execImpl();
    optimizeEvent.end("didChange", "" + stats.didChange());
    return stats;
  }
View Full Code Here

  }

  private static final String NAME = SameParameterValueOptimizer.class.getSimpleName();

  public static OptimizerStats exec(JProgram program) {
    Event optimizeEvent = SpeedTracerLogger.start(CompilerEventType.OPTIMIZE, "optimizer", NAME);
    OptimizerStats stats = new SameParameterValueOptimizer(program).execImpl(program);
    optimizeEvent.end("didChange", "" + stats.didChange());
    return stats;
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.