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

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


   * CompilationState.
   * If the compiler aborts, logs the error and throws UnableToCompleteException.
   */
  public void addGeneratedCompilationUnits(TreeLogger logger,
      Collection<GeneratedUnit> generatedUnits) throws UnableToCompleteException {
    Event generatedUnitsAddEvent = SpeedTracerLogger.start(
        DevModeEventType.COMP_STATE_ADD_GENERATED_UNITS);
    try {
      logger = logger.branch(TreeLogger.DEBUG, "Adding '"
          + generatedUnits.size() + "' new generated units");
      generatedUnitsAddEvent.addData("# new generated units", "" + generatedUnits.size());
      Collection<CompilationUnit> newUnits = compileMoreLater.addGeneratedTypes(
          logger, generatedUnits, this);
      assimilateUnits(logger, newUnits, true);
    } finally {
      generatedUnitsAddEvent.end();
    }
  }
View Full Code Here


  /**
   * Indexes referenced external compilation units but does not save them in a library.
   */
  public void addReferencedCompilationUnits(TreeLogger logger,
      List<CompilationUnit> referencedUnits) {
    Event referencedUnitsAddEvent =
        SpeedTracerLogger.start(DevModeEventType.COMP_STATE_ADD_REFERENCED_UNITS);
    try {
      logger = logger.branch(TreeLogger.DEBUG,
          "Adding '" + referencedUnits.size() + "' new referenced units");
      referencedUnitsAddEvent.addData("# new referenced units", "" + referencedUnits.size());
      assimilateUnits(logger, referencedUnits, false);
    } finally {
      referencedUnitsAddEvent.end();
    }
  }
View Full Code Here

      return false;
    }

    public String rebind(TreeLogger logger, String typeName, ArtifactAcceptor artifactAcceptor)
        throws UnableToCompleteException {
      Event rebindEvent = SpeedTracerLogger.start(DevModeEventType.REBIND, "Type Name", typeName);
      try {
        genCtx.setPropertyOracle(propOracle);
        genCtx.setRebindRuleResolver(this);
        Rule rule = getRebindRule(logger, typeName);

        if (rule == null) {
          return typeName;
        }

        CachedGeneratorResult cachedResult = rebindCacheGet(rule, typeName);
        if (cachedResult != null) {
          genCtx.setCachedGeneratorResult(cachedResult);
        }

        // realize the rule (call a generator, or do type replacement, etc.)
        RebindResult result = rule.realize(logger, genCtx, typeName);

        // handle rebind result caching (if enabled)
        String resultTypeName =
            processCacheableResult(logger, rule, typeName, cachedResult, result);

        /*
         * Finalize new artifacts from the generator context
         */
        if (artifactAcceptor != null) {
          // Go ahead and call finish() to accept new artifacts.
          ArtifactSet newlyGeneratedArtifacts = genCtx.finish(logger);
          if (!newlyGeneratedArtifacts.isEmpty()) {
            artifactAcceptor.accept(logger, newlyGeneratedArtifacts);
          }
        }

        assert (resultTypeName != null);
        return resultTypeName;
      } finally {
        rebindEvent.end();
      }
    }
View Full Code Here

    this.sourceRoot = sourceRoot;
  }

  private List<SyntheticArtifact> createArtifacts()
      throws IOException, SourceMapParseException {
    Event event = SpeedTracerLogger.start(CompilerEventType.SOURCE_MAP_RECORDER);
    List<SyntheticArtifact> toReturn = Lists.newArrayList();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SourceMapGeneratorV3 generator = new SourceMapGeneratorV3();
    int fragment = 0;
    for (JsSourceMap sourceMap : fragmentMaps) {
      generator.reset();

      if (sourceRoot != null) {
        generator.setSourceRoot(sourceRoot);
      }
      addExtensions(generator, fragment);
      addMappings(new SourceMappingWriter(generator), sourceMap);

      baos.reset();
      OutputStreamWriter out = new OutputStreamWriter(baos);
      generator.appendTo(out, "sourceMap" + fragment);
      out.flush();
      toReturn.add(new SymbolMapsLinker.SourceMapArtifact(permutationId, fragment,
          baos.toByteArray(), sourceRoot));
      fragment++;
    }
    event.end();
    return toReturn;
  }
View Full Code Here

  @Override
  protected JsValue doInvoke(String name, Object jthis, Class<?>[] types,
      Object[] args) throws Throwable {
    TreeLogger branch = host.getLogger().branch(TreeLogger.SPAM,
        "Invoke native method " + name, null);
    Event javaToJsCallEvent =
        SpeedTracerLogger.start(DevModeEventType.JAVA_TO_JS_CALL);
    if (SpeedTracerLogger.jsniCallLoggingEnabled()) {
      javaToJsCallEvent.addData("name", name);
    }

    CompilingClassLoader isolatedClassLoader = getIsolatedClassLoader();
    JsValueOOPHM jsthis = new JsValueOOPHM();
    Class<?> jthisType = (jthis == null) ? Object.class : jthis.getClass();
    JsValueGlue.set(jsthis, isolatedClassLoader, jthisType, jthis);
    if (branch.isLoggable(TreeLogger.SPAM)) {
      branch.log(TreeLogger.SPAM, "  this=" + jsthis);
    }

    int argc = args.length;
    JsValueOOPHM argv[] = new JsValueOOPHM[argc];
    for (int i = 0; i < argc; ++i) {
      argv[i] = new JsValueOOPHM();
      JsValueGlue.set(argv[i], isolatedClassLoader, types[i], args[i]);
      if (branch.isLoggable(TreeLogger.SPAM)) {
        branch.log(TreeLogger.SPAM, "  arg[" + i + "]=" + argv[i]);
      }
    }
    JsValueOOPHM returnVal = new JsValueOOPHM();
    try {
      channel.invokeJavascript(isolatedClassLoader, jsthis, name, argv,
          returnVal);
      if (branch.isLoggable(TreeLogger.SPAM)) {
        branch.log(TreeLogger.SPAM, "  returned " + returnVal);
      }
      return returnVal;
    } catch (Throwable t) {
      branch.log(TreeLogger.SPAM, "exception thrown", t);
      throw t;
    } finally {
      javaToJsCallEvent.end();
    }
  }
View Full Code Here

      super(permutation);
    }

    @Override
    protected TypeMapper<?> normalizeSemantics() {
      Event event = SpeedTracerLogger.start(CompilerEventType.JAVA_NORMALIZERS);
      try {
        Devirtualizer.exec(jprogram);
        CatchBlockNormalizer.exec(jprogram);
        PostOptimizationCompoundAssignmentNormalizer.exec(jprogram);
        LongCastNormalizer.exec(jprogram);
        LongEmulationNormalizer.exec(jprogram);
        TypeCoercionNormalizer.exec(jprogram);

        if (options.isIncrementalCompileEnabled()) {
          // Per file compilation reuses type JS even as references (like casts) in other files
          // change, which means all legal casts need to be allowed now before they are actually
          // used later.
          ComputeExhaustiveCastabilityInformation.exec(jprogram, options.isCastCheckingDisabled());
        } else {
          // If trivial casts are pruned then one can use smaller runtime castmaps.
          ComputeCastabilityInformation.exec(jprogram, options.isCastCheckingDisabled(),
              !shouldOptimize() /* recordTrivialCasts */);
        }

        ComputeInstantiatedJsoInterfaces.exec(jprogram);
        ImplementCastsAndTypeChecks.exec(jprogram, options.isCastCheckingDisabled(),
            shouldOptimize() /* pruneTrivialCasts */);
        ArrayNormalizer.exec(jprogram, options.isCastCheckingDisabled());
        EqualityNormalizer.exec(jprogram);

        TypeMapper<?> typeMapper = getTypeMapper();
        ResolveRuntimeTypeReferences.exec(jprogram, typeMapper, getTypeOrder());
        return typeMapper;
      } finally {
        event.end();
      }
    }
View Full Code Here

      }
    }

    @Override
    protected void postNormalizationOptimizeJava() {
      Event event = SpeedTracerLogger.start(CompilerEventType.JAVA_POST_NORMALIZER_OPTIMIZERS);
      try {
        if (shouldOptimize()) {
          RemoveSpecializations.exec(jprogram);
          Pruner.exec(jprogram, false);
        }
        ReplaceGetClassOverrides.exec(jprogram);
      } finally {
        event.end();
      }
    }
View Full Code Here

      ctx.replaceMe(cond);
    }
  }

  public static void exec(JProgram program) {
    Event assertionNormalizerEvent =
        SpeedTracerLogger.start(CompilerEventType.ASSERTION_NORMALIZER);
    new AssertionNormalizer(program).execImpl();
    assertionNormalizerEvent.end();
  }
View Full Code Here

  /**
   * Runs the module's user startup code.
   */
  public final void onLoad(TreeLogger logger) throws UnableToCompleteException {
    Event moduleSpaceLoadEvent = SpeedTracerLogger.start(DevModeEventType.MODULE_SPACE_LOAD);

    // Tell the host we're ready for business.
    //
    host.onModuleReady(this);

    // Make sure we can resolve JSNI references to static Java names.
    //
    try {
      createStaticDispatcher(logger);
      Object staticDispatch = getStaticDispatcher();
      invokeNativeVoid("__defineStatic", null, new Class[] {Object.class},
          new Object[] {staticDispatch});
    } catch (Throwable e) {
      logger.log(TreeLogger.ERROR, "Unable to initialize static dispatcher", e);
      throw new UnableToCompleteException();
    }

    // Actually run user code.
    //
    String entryPointTypeName = null;
    try {
      // Set up GWT-entry code
      Class<?> implClass = loadClassFromSourceName("com.google.gwt.core.client.impl.Impl");
      Method registerEntry = implClass.getDeclaredMethod("registerEntry");
      registerEntry.setAccessible(true);
      registerEntry.invoke(null);

      Method enter = implClass.getDeclaredMethod("enter");
      enter.setAccessible(true);
      enter.invoke(null);

      String[] entryPoints = host.getEntryPointTypeNames();
      if (entryPoints.length > 0) {
        try {
          for (int i = 0; i < entryPoints.length; i++) {
            entryPointTypeName = entryPoints[i];
            Method onModuleLoad = null;
            Object module;

            // Try to initialize EntryPoint, else throw up glass panel
            try {
              Class<?> clazz = loadClassFromSourceName(entryPointTypeName);
              try {
                onModuleLoad = clazz.getMethod("onModuleLoad");
                if (!Modifier.isStatic(onModuleLoad.getModifiers())) {
                  // it's non-static, so we need to rebind the class
                  onModuleLoad = null;
                }
              } catch (NoSuchMethodException e) {
                // okay, try rebinding it; maybe the rebind result will have one
              }
              module = null;
              if (onModuleLoad == null) {
                module = rebindAndCreate(entryPointTypeName);
                onModuleLoad = module.getClass().getMethod("onModuleLoad");
                // Record the rebound name of the class for stats (below).
                entryPointTypeName = module.getClass().getName().replace(
                    '$', '.');
              }
            } catch (Throwable e) {
              displayErrorGlassPanel(
                  "EntryPoint initialization exception", entryPointTypeName, e);
              throw e;
            }

            // Try to invoke onModuleLoad, else throw up glass panel
            try {
              onModuleLoad.setAccessible(true);
              invokeNativeVoid("fireOnModuleLoadStart", null,
                  new Class[]{String.class}, new Object[]{entryPointTypeName});

              Event onModuleLoadEvent = SpeedTracerLogger.start(
                  DevModeEventType.ON_MODULE_LOAD);
              try {
                onModuleLoad.invoke(module);
              } finally {
                onModuleLoadEvent.end();
              }
            } catch (Throwable e) {
              displayErrorGlassPanel(
                  "onModuleLoad() threw an exception", entryPointTypeName, e);
              throw e;
View Full Code Here

    Throwable caught = null;
    String msg = null;
    String resultName = null;
    Class<?> resolvedClass = null;

    Event moduleSpaceRebindAndCreate =
        SpeedTracerLogger.start(DevModeEventType.MODULE_SPACE_REBIND_AND_CREATE);
    try {
      // Rebind operates on source-level names.
      //
      String sourceName = BinaryName.toSourceName(requestedClassName);
      resultName = rebind(sourceName);
      moduleSpaceRebindAndCreate.addData(
          "Requested Class", requestedClassName, "Result Name", resultName);
      resolvedClass = loadClassFromSourceName(resultName);
      if (Modifier.isAbstract(resolvedClass.getModifiers())) {
        msg = "Deferred binding result type '" + resultName
            + "' should not be abstract";
      } else {
        Constructor<?> ctor = resolvedClass.getDeclaredConstructor();
        ctor.setAccessible(true);
        return (T) ctor.newInstance();
      }
    } catch (ClassNotFoundException e) {
      msg = "Could not load deferred binding result type '" + resultName + "'";
      caught = e;
    } catch (InstantiationException e) {
      caught = e;
    } catch (IllegalAccessException e) {
      caught = e;
    } catch (ExceptionInInitializerError e) {
      caught = e.getException();
    } catch (NoSuchMethodException e) {
      // If it is a nested class and not declared as static,
      // then it's not accessible from outside.
      //
      if (resolvedClass.getEnclosingClass() != null
          && !Modifier.isStatic(resolvedClass.getModifiers())) {
        msg = "Rebind result '" + resultName
        + " is a non-static inner class";
      } else {
        msg = "Rebind result '" + resultName
        + "' has no default (zero argument) constructors.";
      }
      caught = e;
    } catch (InvocationTargetException e) {
      caught = e.getTargetException();
    } finally {
      moduleSpaceRebindAndCreate.end();
    }

    // Always log here because sometimes this method gets called from static
    // initializers and other unusual places, which can obscure the problem.
    //
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.