Example usage for com.google.gwt.core.client JsArrayString length

List of usage examples for com.google.gwt.core.client JsArrayString length

Introduction

In this page you can find the example usage for com.google.gwt.core.client JsArrayString length.

Prototype

public final native int length() ;

Source Link

Document

Gets the length of the array.

Usage

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Given an array of the fields in a single log line, execute the appropriate
 * action on that entry based on the first field.
 *//*from w w  w  .ja  v  a2  s .  c  o m*/
private void parseLogEntry(JsArrayString logEntries) {
    if (logEntries.length() == 0) {
        return;
    }
    String command = logEntries.get(0);
    if (command.length() == 0) {
        return;
    }
    LogAction cmdMethod = logActions.get(actionTypeMap.get(command));
    if (cmdMethod != null) {
        cmdMethod.doAction(logEntries);
    } else if (ClientConfig.isDebugMode()) {
        Logging.getLogger().logText("Unknown v8 profiler command: " + command);
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Process an 'alias' command. Simply aliases a command to a different string.
 * The format of this log entry is://from w w  w .j  a v a  2  s .  c  o  m
 * 
 * alias, aliasName, originalName
 */
private void parseV8AliasEntry(JsArrayString logEntries) {
    assert logEntries.length() == 3;

    String originalName = logEntries.get(2);
    String aliasName = logEntries.get(1);

    V8SymbolType symbol = symbolTypeMap.get(originalName);
    if (symbol != null) {
        symbolTypeMap.put(aliasName, symbol);
    } else {
        ActionType action = actionTypeMap.get(originalName);
        if (action != null) {
            actionTypeMap.put(aliasName, action);
        } else if (ClientConfig.isDebugMode()) {
            Logging.getLogger().logText(
                    "Unable to find command: '" + logEntries.get(2) + "' to match alias: " + logEntries.get(1));
        }
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * New code was added to the virtual machine. The format of this log entry is:
 * //  w  w w .j  av a 2  s . c o m
 * code-creation, symbolType, offset, length, "symbolName"
 * 
 * e.g. code-creation,lic,-5910913e,179,"parentNode"
 * 
 */
private void parseV8CodeCreationEntry(JsArrayString logEntries) {
    assert logEntries.length() == 5;
    V8SymbolType symbolType = symbolTypeMap.get(logEntries.get(1));

    String name = logEntries.get(4);

    double address = parseAddress(logEntries.get(2), ADDRESS_TAG_CODE);
    int executableSize = Integer.parseInt(logEntries.get(3));

    // Keep some debugging stats around
    V8Symbol found = symbolTable.lookup(address);

    if (found != null) {
        debugStats.addCollisions++;
    }

    V8Symbol symbol = new V8Symbol(scrubStringForXSS(name), symbolType, address, executableSize);

    // We have a heuristic for finding the resource for a Code Creation for
    // functions. The symbol name and function length. It is just a guess, seems
    // to work, and its better than not knowing 100% of the time where a symbol
    // comes from.
    if (symbolType.getValue() == SYMBOL_TYPE_LAZY_COMPILE) {
        lazyCompiledSymbols.put(symbol.getJsSymbol().getSymbolName() + symbol.getAddressSpan().addressLength,
                symbol);
    }

    if (symbolType.getValue() == SYMBOL_TYPE_FUNCTION) {
        V8Symbol lazySymbol = lazyCompiledSymbols
                .get(symbol.getJsSymbol().getSymbolName() + symbol.getAddressSpan().addressLength);
        if (lazySymbol != null) {
            symbol.getJsSymbol().merge(lazySymbol.getJsSymbol());
        }
    }

    symbolTable.add(symbol);
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Process a code-delete entry in the log.
 * //from   w w  w  .ja v a2s .co  m
 * The format of this entry is:
 * 
 * code-delete, address
 */
private void parseV8CodeDeleteEntry(JsArrayString logEntries) {
    assert logEntries.length() == 2;
    double address = parseAddress(logEntries.get(1), ADDRESS_TAG_CODE);
    V8Symbol symbol = symbolTable.lookup(address);
    if (symbol != null) {
        symbolTable.remove(symbol);
    } else {
        // update debugging stats
        debugStats.removeMisses++;
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Process a code-move entry.//w  ww .ja va  2 s  . c om
 * 
 * The format of this entry is:
 * 
 * code-move, fromAddress, toAddress
 */
private void parseV8CodeMoveEntry(JsArrayString logEntries) {
    assert logEntries.length() == 3;
    double fromAddress = parseAddress(logEntries.get(1), ADDRESS_TAG_CODE);
    double toAddress = parseAddress(logEntries.get(2), ADDRESS_TAG_CODE_MOVE);
    V8Symbol symbol = symbolTable.lookup(fromAddress);
    if (symbol != null) {
        symbolTable.remove(symbol);
        symbol.getAddressSpan().setAddress(toAddress);
        symbolTable.add(symbol);
    } else {
        // update debugging stats
        debugStats.moveMisses++;
    }
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Process a tick entry in the v8 log. The format of this log entry is:
 * /*w  w w .  ja  v a  2  s .  c  o  m*/
 * command, codeOffset, stackOffset, type, <codeOffset2, <codeOffset3, <...>>>
 * 
 * e.g.: t,-7364bb,+45c,0
 */
private void parseV8TickEntry(JsArrayString logEntries) {
    assert logEntries.length() >= 4;
    double address = parseAddress(logEntries.get(1), ADDRESS_TAG_CODE);
    // stack address is currently ignored, but it must be parsed to keep the
    // stack address tag up to date if anyone else ever wants to use it.
    // double stackAddress = parseAddress(logEntries.get(2), ADDRESS_TAG_STACK);
    int vmState = Integer.parseInt(logEntries.get(3));
    currentProfile.addStateTime(vmState, 1.0);

    List<V8Symbol> symbols = new ArrayList<V8Symbol>();
    V8Symbol found = symbolTable.lookup(address);
    if (found != null) {
        symbols.add(found);
    }
    addressTags.put(ADDRESS_TAG_SCRATCH, address);
    for (int i = 4; i < logEntries.length(); ++i) {
        address = parseAddress(logEntries.get(i), ADDRESS_TAG_SCRATCH);
        found = symbolTable.lookup(address);
        if (found != null) {
            symbols.add(found);
        }
    }

    updateFlatProfile(symbols, vmState);
    updateBottomUpProfile(symbols, vmState);
    updateTopDownProfile(symbols, vmState);
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Process a portion of the logLines array. If the workQueue is enabled, exit
 * early if the timeslice expires.//from   ww w.j av  a  2 s.  co  m
 */
private void processLogLines(final UiEvent refRecord, final JSOArray<String> logLines, int currentLine) {
    final int logLinesLength = logLines.size();

    for (; currentLine < logLinesLength; ++currentLine) {
        if (workQueue != null) {
            // Occasionally check to see if the time to run this chunk has expired.
            if ((currentLine % 10 == 0) && workQueue.isTimeSliceExpired()) {
                break;
            }
        }

        String logLine = logLines.get(currentLine);
        if (logDecompressor != null && logLine.length() > 0) {
            logLine = logDecompressor.decompressLogEntry(logLine);
        }
        JsArrayString decompressedLogLine = Csv.split(logLine);
        if (decompressedLogLine.length() > 0) {
            parseLogEntry(decompressedLogLine);
        }

        // force gc on processed log lines.
        logLines.set(currentLine, null);
    }

    if (currentLine < logLinesLength) {
        // Schedule this record to be the next thing run off the queue
        workQueue.prepend(new LogLineWorker(logLines, refRecord, currentLine));
    } else {
        // All done!
        if (currentProfile.getProfile(JavaScriptProfile.PROFILE_TYPE_BOTTOM_UP) == null) {
            if (refRecord != null) {
                refRecord.setHasJavaScriptProfile(false);
            }
        } else {
            if (refRecord != null) {
                refRecord.setHasJavaScriptProfile(true);
            }
        }
    }
}

From source file:com.google.speedtracer.client.model.V8LogDecompressor.java

License:Apache License

public String decompressLogEntry(String logLine) {
    String decompressedLogEntry = logLine;

    if (windowSize > 0) {

        /**//  w ww  . j  ava 2s.c om
         * Compression will cause some lines to have # references in them.
         * 
         * Formatting string for back references to the whole line. E.g. "#2"
         * means "the second line above".
         * 
         * Formatting string for back references. E.g. "#2:10" means
         * "the second line above, start from char 10 (0-based)".
         */

        int compressionStart = logLine.indexOf('#');

        /**
         * logLine.indexOf('#') is too simple - it is tricked by # chars inside of
         * quoted strings. This follows the example of devtools, where they use
         * the knowledge that only RegExp entries have an embedded #, and those
         * lines always end with a quote character.
         */
        if (compressionStart != -1 && !logLine.endsWith("\"")) {
            String compressionString = logLine.substring(compressionStart + 1);
            int colonStart = compressionString.indexOf(':');
            int lineOffset = 0;
            int charOffset = 0;
            if (colonStart < 0) {
                lineOffset = Integer.parseInt(compressionString);
            } else {
                lineOffset = Integer.parseInt(compressionString.substring(0, colonStart));
                charOffset = Integer.parseInt(compressionString.substring(colonStart + 1));
            }
            assert charOffset >= 0;
            decompressedLogEntry = logLine.substring(0, compressionStart)
                    + fetchLogBackref(lineOffset, charOffset);
        }
    }
    JsArrayString logEntry = Csv.split(decompressedLogEntry);
    if (logEntry.length() == 0) {

    } else {
        String command = logEntry.get(0);
        if (command.equals("profiler")) {
            // ignore
        } else if (command.equals("repeat") || command.equals("r")) {
            // skip the first 2 fields.
            int firstCommaOffset = decompressedLogEntry.indexOf(",");
            int secondCommaOffset = decompressedLogEntry.indexOf(",", firstCommaOffset + 1);
            appendLogEntry(decompressedLogEntry.substring(secondCommaOffset + 1));
        } else {
            appendLogEntry(decompressedLogEntry);
        }
    }
    return decompressedLogEntry;
}

From source file:com.googlecode.gflot.client.options.PlotOptions.java

License:Open Source License

/**
 * Set a default color theme to get colors for the data series from. You can specify as many colors as you like,
 * like this://from   www . j a v a  2 s  . c o  m
 * <p>
 * colors: ["#d18b2c", "#dba255", "#919733"]
 * </p>
 * If there are more data series than colors, Flot will try to generate extra colors by lightening and darkening
 * colors in the theme.
 */
public final PlotOptions setDefaultColorTheme(JsArrayString colors) {
    assert null != colors && colors.length() > 0 : "colors can't be null or empty";

    put(COLORS_KEY, colors);
    return this;
}

From source file:com.googlecode.gflot.client.options.TimeSeriesAxisOptions.java

License:Open Source License

/**
 * Set the label used for month.// w w  w.  ja  v  a 2 s.  co  m
 */
public final TimeSeriesAxisOptions setMonthNames(JsArrayString monthNames) {
    assert null != monthNames : "monthNames can't be null";
    assert monthNames.length() == 12 : "monthNames must have all 12 month names";

    put(MONTH_NAMES_KEY, monthNames);
    return this;
}