Package com.google.gwt.dev.jjs.impl.codesplitter

Examples of com.google.gwt.dev.jjs.impl.codesplitter.FragmentPartitioningResult


  }

  private void recordFragments(JProgram jprogram) throws IOException, JSONException {
    JSONObject jsonPoints = new JSONObject();
    // adding runAsyncs, if any
    FragmentPartitioningResult partitionResult = jprogram.getFragmentPartitioningResult();
    // a FragmentPartitioningResult' instance exist if and only if there are runAyncs nodes
    if (partitionResult != null) {
      Map<Integer, Set<String>> runAsyncPerFragment = Maps.newHashMap();
      for (JRunAsync runAsync : jprogram.getRunAsyncs()) {
        int fragmentId = partitionResult.getFragmentForRunAsync(runAsync.getRunAsyncId());
        Set<String> runAsyncNames = runAsyncPerFragment.get(fragmentId);
        if (runAsyncNames == null) {
          runAsyncNames = Sets.newHashSet();
        }
        runAsyncNames.add(runAsync.getName());
        runAsyncPerFragment.put(fragmentId, runAsyncNames);
      }
      for (Integer idx : runAsyncPerFragment.keySet()) {
        sizeMetrics[idx].put(FRAGMENT_POINTS, runAsyncPerFragment.get(idx));
      }
      // initial fragment sequence points
      JSONArray initialSequence = new JSONArray();
      for (int fragId : jprogram.getInitialFragmentIdSequence()) {
        initialSequence.put(partitionResult.getFragmentForRunAsync(fragId));
      }
      jsonPoints.put(INITIAL_SEQUENCE, initialSequence);
    }

    jsonPoints.put(FRAGMENTS, this.sizeMetrics);
View Full Code Here


      htmlOut.newline();
      htmlOut.indentIn();
      htmlOut.indentIn();

      List<JRunAsync> runAsyncs = jprogram.getRunAsyncs();
      FragmentPartitioningResult partitionResult = jprogram.getFragmentPartitioningResult();
      if (runAsyncs.size() > 0) {
        curLine = "<splitpoints>";
        htmlOut.printRaw(curLine);
        htmlOut.newline();
        htmlOut.indentIn();
        htmlOut.indentIn();
        for (JRunAsync runAsync : runAsyncs) {
          int sp = runAsync.getRunAsyncId();
          if (partitionResult != null) {
            sp = partitionResult.getFragmentForRunAsync(sp);
          }
          String name = runAsync.getName();
          curLine = "<splitpoint id=\"" + sp + "\" location=\"" + name + "\"/>";
          htmlOut.printRaw(curLine);
          htmlOut.newline();
          if (logger.isLoggable(TreeLogger.TRACE)) {
            logger.log(TreeLogger.TRACE, "Assigning split point #" + sp + " for '" + name + "'");
          }
        }
        htmlOut.indentOut();
        htmlOut.indentOut();
        curLine = "</splitpoints>";
        htmlOut.printRaw(curLine);
        htmlOut.newline();
      }

      if (!jprogram.getInitialFragmentIdSequence().isEmpty()) {
        curLine = "<initialseq>";
        htmlOut.printRaw(curLine);
        htmlOut.newline();
        htmlOut.indentIn();

        for (int sp : jprogram.getInitialFragmentIdSequence()) {
          if (partitionResult != null) {
            sp = partitionResult.getFragmentForRunAsync(sp);
          }
          curLine = "<splitpointref id=\"" + sp + "\"/>";
          htmlOut.printRaw(curLine);
          htmlOut.newline();
        }
View Full Code Here

  }

  private void computeFragmentMap(JProgram jprogram, JsProgram jsProgram) {
    int fragments = jsProgram.getFragmentCount();
    List<Integer> initSeq = jprogram.getInitialFragmentIdSequence();
    FragmentPartitioningResult partitionResult = jprogram.getFragmentPartitioningResult();

    //
    // The fragments are expected in a specific order:
    // init, split-1, split-2, ...,
    // where the leftovers are dependent on the init module
    // and the split modules are dependent on the leftovers
    //
    // However, Closure Compiler modules must be in dependency order
    //

    assert closureModuleSequenceMap == null;
    closureModuleSequenceMap = new int[fragments];
    for (int i = 0; i < fragments; i++) {
      closureModuleSequenceMap[i] = -1;
    }

    int module = 0;
    // The initial fragments is always first.
    closureModuleSequenceMap[0] = module++;

    // Then come the specified load order sequence
    for (int i = 0; i < initSeq.size(); i++) {
      int initSeqNum = initSeq.get(i);
      if (partitionResult != null) {
        initSeqNum = partitionResult.getFragmentForRunAsync(initSeqNum);
      }
      closureModuleSequenceMap[initSeqNum] = module++;
    }

    // Then the leftovers fragments:
    if (fragments > 1) {
      int leftoverIndex = fragments - 1;
      if (partitionResult != null) {
        leftoverIndex = partitionResult.getLeftoverFragmentId();
      }
      closureModuleSequenceMap[leftoverIndex] = module++;
    }

    // Finally, the exclusive fragments.
View Full Code Here

  }

  private void recordFragments(JProgram jprogram) throws IOException, JSONException {
    JSONObject jsonPoints = new JSONObject();
    // adding runAsyncs, if any
    FragmentPartitioningResult partitionResult = jprogram.getFragmentPartitioningResult();
    // a FragmentPartitioningResult' instance exist if and only if there are runAyncs nodes
    if (partitionResult != null) {
      Map<Integer, Set<String>> runAsyncPerFragment = Maps.newHashMap();
      for (JRunAsync runAsync : jprogram.getRunAsyncs()) {
        int fragmentId = partitionResult.getFragmentForRunAsync(runAsync.getRunAsyncId());
        Set<String> runAsyncNames = runAsyncPerFragment.get(fragmentId);
        if (runAsyncNames == null) {
          runAsyncNames = Sets.newHashSet();
        }
        runAsyncNames.add(runAsync.getName());
        runAsyncPerFragment.put(fragmentId, runAsyncNames);
      }
      for (Integer idx : runAsyncPerFragment.keySet()) {
        sizeMetrics[idx].put(FRAGMENT_POINTS, runAsyncPerFragment.get(idx));
      }
      // initial fragment sequence points
      JSONArray initialSequence = new JSONArray();
      for (int fragId : jprogram.getInitialFragmentIdSequence()) {
        initialSequence.put(partitionResult.getFragmentForRunAsync(fragId));
      }
      jsonPoints.put(INITIAL_SEQUENCE, initialSequence);
    }

    jsonPoints.put(FRAGMENTS, this.sizeMetrics);
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.jjs.impl.codesplitter.FragmentPartitioningResult

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.