當前位置: 首頁>>代碼示例>>Java>>正文


Java Tracer類代碼示例

本文整理匯總了Java中com.sun.squawk.util.Tracer的典型用法代碼示例。如果您正苦於以下問題:Java Tracer類的具體用法?Java Tracer怎麽用?Java Tracer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Tracer類屬於com.sun.squawk.util包,在下文中一共展示了Tracer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mergeMethodsObjectTable

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
void mergeMethodsObjectTable(Translator translator, Code[] methodsCode, boolean isStatic) {
    for (int i = 0; i < methodsCode.length; i++) {
        Method method = definedClass.getMethod(i, isStatic);
        Code code = methodsCode[i];
        if (!method.isHosted() && !method.isAbstract() && !method.isNative()) {
            Assert.that(code != null);
            boolean unusedMethod = safeToDoDeadMethodElim && !translator.dme.isMarkedUsed(method);
            if (unusedMethod) {
                if (safeToDoDeadStringElim) {
                    if (Translator.TRACING_ENABLED && Tracer.isTracing("converting", method.toString())) {
                        Tracer.traceln("Ignoring objects used by unused method " + method);
                    }
                } else {
                    mergeObjectTable(code.getObjectTable(), true);
                }
            } else {
                mergeObjectTable(code.getObjectTable(), false);
            }
        }
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:22,代碼來源:ObjectTable.java

示例2: traceType

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Traces a type on the operand stack or in a local variable.
 *
 * @param type       the type to trace
 * @param prefix     the prefix to use if <code>isDerived</code> is true
 *                   otherwise a prefix of spaces the same length as
 *                   <code>prefix</code> is used instead
 * @param isDerived  specifies if this a type derived by the verifer or
 *                   is specified by a stack map entry
 */
private void traceType(Klass type, String prefix, boolean isDerived) {
    if (Translator.TRACING_ENABLED) {
        if (!isDerived) {
            char[] spaces = new char[prefix.length()];
            Arrays.fill(spaces, ' ');
            Tracer.trace(new String(spaces));
        } else {
            Tracer.trace(prefix);
        }
        String name = (type == null ? "-T-" : type.getInternalName());
        if (isDerived) {
            Tracer.traceln(" "+name);
        } else {
            Tracer.traceln("{"+name+"}");
        }
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:28,代碼來源:Frame.java

示例3: traceFrameState

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Traces the frame state at the current verification address.
 *
 * @param  opcode   the opcode of the instruction at <code>address</code>
 * @param  address  the current verification address
 */
public void traceFrameState(int opcode, int address) {
    /*
     * Trace the recorded and derived types
     */
    if (Translator.TRACING_ENABLED) {
        Target target = null;
        try {
            target = codeParser.getTarget(address);
        } catch (NoClassDefFoundError e) {
            /* Just means there is no stack map at this address */
        }
        Tracer.traceln("Frame state @ "+address+" [ "+ Opcode.mnemonics[opcode]+" ]");
        traceLocals(target);
        traceStack(target);
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:23,代碼來源:Frame.java

示例4: convert0

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Convert the code of this method from it Java bytecode form to its
 * Squawk bytecode form. This must only be called once and cannot be called
 * for an abstract or native <code>Method</code>.
 *
 * @param  translator   the translation context
 * @param  method       the method owning this code
 * @param  index        the index of this method in the symbols table of the enclosing class
 * @param  phase        the compilation phase (1 or 2)
 * @param  bodies       {@link Vector} to insert method body into
 */
private void convert0(Translator translator, Method method, int index, int phase, final Vector bodies) {
    try {
        if (phase == 1) {
            convertPhase1(translator, method, index);
        } else {
            MethodBody b = convertPhase2(translator, method, index);
            if (bodies != null)
                bodies.addElement(b);
        }
    } catch (NoClassDefFoundError e) {
        /*
         * Write trace message and re-throw exception.
         */
        if (Translator.TRACING_ENABLED && Tracer.isTracing("converting", method.toString())) {
            Tracer.traceln("[error converting method " + method + ": " + e + "]");
        }
        code = null;
        irBuilder = null;
        codeParser = null;
        throw e;
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:34,代碼來源:Code.java

示例5: setOptions

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Read translator properties and set corresponding options.
 */
static void setOptions() {
    for (int i = 0; i < translatorArgs.length; i++) {
        translatorArgs[i].setValue();
    }
            
    Arg verbose = get(VERBOSE);
    verbose.setBoolValue(verbose.getBool() | VM.isVerbose() | VM.isVeryVerbose() | Tracer.isTracing("converting"));
    
    if (get(HELP).getBool() || verbose.getBool()) {
        System.out.println("Translator properties and current values:");
        for (int i = 0; i < translatorArgs.length; i++) {
            Arg arg = translatorArgs[i];
            System.out.print("    ");
            System.out.print(arg.getPropertyName());
            System.out.print("=");
            if (arg.getType() == INT) {
                System.out.println(arg.getInt());
            } else {
                System.out.println(arg.getBool());
            }
        }
    }
}
 
開發者ID:sics-sse,項目名稱:moped,代碼行數:27,代碼來源:Arg.java

示例6: traceProgress

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Returns true if the translator should print verbose progress
 */
public void traceProgress() {
    if (verbose()) {
        progressCounter++;
        Tracer.trace(".");
        if (progressCounter % 40 == 0) {
            Tracer.trace("\n");
        }
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:13,代碼來源:Translator.java

示例7: trace

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
public static void trace(MethodBody mb) {
    if (Translator.TRACING_ENABLED ) {
        Method method = mb.getDefiningMethod();
        Tracer.traceln("++++ Method for " + method + " ++++");
        new MethodBodyTracer(mb).traceAll();
        Tracer.traceln("---- Method for " + method + " ----");
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:9,代碼來源:Translator.java

示例8: setOptions

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
     * Read translator properties and set corresponding options.
     */
    static void setOptions() {
        for (int i = 0; i < translatorArgs.length; i++) {
            translatorArgs[i].setValue();
        }
                
        Arg verbose = get(VERBOSE);
/*if[ENABLE_VERBOSE]*/	
        verbose.setBoolValue(verbose.getBool() | VM.isVerbose() | VM.isVeryVerbose() | Tracer.isTracing("converting"));
/*else[ENABLE_VERBOSE]*/	
//        verbose.setBoolValue(verbose.getBool() | Tracer.isTracing("converting"));
/*end[ENABLE_VERBOSE]*/	
        
        if (get(HELP).getBool() || verbose.getBool()) {
            System.out.println("Translator properties and current values:");
            for (int i = 0; i < translatorArgs.length; i++) {
                Arg arg = translatorArgs[i];
                System.out.print("    ");
                System.out.print(arg.getPropertyName());
                System.out.print("=");
                if (arg.getType() == INT) {
                    System.out.println(arg.getInt());
                } else {
                    System.out.println(arg.getBool());
                }
            }
        }
    }
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:31,代碼來源:Arg.java

示例9: InstructionEmitter

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Constructor.
 *
 * @param ir
 * @param classFile the class file for the method being converted
 * @param method    the method of the ir
 * @param clearedSlots the number of local variables (after the first one) that need clearing
 */
InstructionEmitter(IR ir, ClassFile classFile, Method method, int clearedSlots) {
    this.ir           = ir;
    this.classFile    = classFile;
    this.method       = method;
    this.clearedSlots = clearedSlots;
    this.trace        = Translator.TRACING_ENABLED && Tracer.isTracing("emitter", method.toString());

    if (VM.getCurrentIsolate().getLeafSuite().isBootstrap()) {
        isAppClass = !isSystemClass(classFile.getDefinedClass());
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:20,代碼來源:InstructionEmitter.java

示例10: traceTarget

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Traces the frame state at the current verification address.
 *
 * @param  opcode   the opcode of the instruction at <code>address</code>
 * @param  address  the current verification address
 */
public void traceTarget(Target target) {
    /*
     * Trace the recorded and derived types
     */
    if (Translator.TRACING_ENABLED) {
        Tracer.traceln("target "+target);
        traceLocals(target);
        traceStack(target);
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:17,代碼來源:Frame.java

示例11: parseOpcode

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Read an opcode from the bytecode stream. The returned value will be
 * one of the <code>opc_...</code> defined in {@link Opcode}.
 *
 * @return  the opcode read
 */
public int parseOpcode() {
    lastOpcodeAddress = bcin.getCurrentIndex();
    int opcode = cfr.readUnsignedByte(null);
    if (Translator.TRACING_ENABLED && trace) {
        Tracer.traceln("["+lastOpcodeAddress+"]:opcode:"+Opcode.mnemonics[opcode]);
    }
    return opcode;
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:15,代碼來源:CodeParser.java

示例12: load

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Loads the definition of a class from its class file.
 *
 * @param cf  the class file definition to load
 */
public void load(ClassFile cf) {
    this.cf = cf;
    this.klass = cf.getDefinedClass();
    this.traceClassInfo = Translator.TRACING_ENABLED && Tracer.isTracing("classinfo", klass.getName());
    
    Assert.that(klass.getState() < Klass.STATE_LOADED);

    String classFilePath = getClassFilePath(klass);
    InputStream is = null;
    try {
        ClasspathConnection classPath = translator.getClassPath();
        if (classPath == null) {
            throw new IOException("null class path");
        }
        is = classPath.openInputStream(classFilePath);
        load(classFilePath, is);
    } catch (IOException ioe) {
        if (VM.isHosted() || VM.isVeryVerbose()) {
            System.err.println("IO error while loading: " + klass);
            ioe.printStackTrace();
        }
        throw new NoClassDefFoundError(prefix(ioe.toString()));
    }  catch (RuntimeException e) {
        System.err.println("\n\nError while loading " + klass + "\n");
        throw e;
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException ex) {
                ex.printStackTrace();
                Assert.shouldNotReachHere();
            }
        }
    }
}
 
開發者ID:sics-sse,項目名稱:moped,代碼行數:42,代碼來源:ClassFileLoader.java

示例13: stripFields

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Prunes the fields based on a given suite type.
 *
 * @param klass     the enclosing class
 * @param type      specifies a closed suite type. Must be {@link Suite#LIBRARY} or {@link Suite#EXTENDABLE_LIBRARY}.
 * @param category  specifies instance or static fields
 * @param types     the collection to which the types in the signatures of the remaining fields should be added
 * @return an integer with the only the bit in position 'category' set if at least one field was not stripped otherwise 0
 */
private int stripFields(Klass klass, int type, int category, SquawkVector types) {
    Assert.that(category == INSTANCE_FIELDS || category == STATIC_FIELDS);
    int count = getMemberCount(category);
    boolean keptAtLeastOne = false;
    if (count != 0) {
        for (int i = 0; i != count; ++i) {
            select(category, i);
            Klass fieldType = getSignatureType(getSignatureAt(0));
            Field field = klass.getField(i, category == STATIC_FIELDS);
            if (keepForRuntimeStatics(klass, fieldType, category)
                    || (retainMember(type, modifiers, fieldType) && VM.isExported(field))) {
                if (!keptAtLeastOne) {
                    symbolsBuffer.addUnsignedByte(category);
                    keptAtLeastOne = true;
                }
                membersBuffer.reset();
                membersBuffer.addUnsignedShort(modifiers);
                membersBuffer.addUnsignedShort(getOffset());
                membersBuffer.addUtf8(getName());
                if (Modifier.hasPragmas(modifiers)) {
                    membersBuffer.addUnsignedShort(0);
                }
                membersBuffer.addUnsignedShort(KlassMetadata.addSignatureType(types, fieldType));
                if (Modifier.hasConstant(modifiers)) {
                    if (!fieldType.isPrimitive()) {
                        membersBuffer.addUtf8(getStringConstantValue());
                    } else {
                        long value = getPrimitiveConstantValue();
                        int dataSize = fieldType.getDataSize();
                        for (int bite = 0; bite != dataSize; ++bite) {
                            membersBuffer.addUnencodedByte((byte)value);
                            value = value >> 8;
                        }
                    }
                }
                symbolsBuffer.add(membersBuffer);
            } else if (Klass.TRACING_ENABLED && Tracer.isTracing("stripping")) {
                Tracer.trace("  discarded metadata for field: " + fieldType.getInternalName() + " " + getName());
                if (Modifier.hasConstant(modifiers)) {
                    Tracer.trace(" [constantValue=" + (fieldType.isPrimitive() ? ""+getPrimitiveConstantValue() : getStringConstantValue()) + "]");
                }
                Tracer.traceln("");
            }

        }
    }
    return keptAtLeastOne ? 1 << category : 0;
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:58,代碼來源:SymbolParser.java

示例14: stripMethods

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
 * Prunes the methods based on a given suite type.
 * 
 * @todo Now we're keeping symbols for all methods if lnt is true. But we can strip symbols for methods that have been eliminated.
 *
 * @param klass     the enclosing class
 * @param type      specifies a closed suite type. Must be {@link Suite#LIBRARY} or {@link Suite#EXTENDABLE_LIBRARY}.
 * @param category  specifies virtual or static methods
 * @param types     the collection to which the types in the signatures of the remaining methods should be added
 * @return an integer with the only the bit in position 'category' set if at least one method was not stripped otherwise 0
 */
private int stripMethods(Klass klass, int type, int category, SquawkVector types) {
    Assert.that(category == VIRTUAL_METHODS || category == STATIC_METHODS);
    int count = getMemberCount(category);
    boolean keptAtLeastOne = false;
    if (count != 0) {
        for (int i = 0; i != count; ++i) {
            select(category, i);
            String name = getName();
            if (!PragmaException.isHosted(pragmas) &&               // strip methods called only in hosted VM mode
                !PragmaException.isInterpreterInvoked(pragmas) &&   // strip methods called from the interpreter
                (MethodMetadata.lineNumberTablesKept() ||           // if we want line numbers then we want method names too...
                    (retainMember(type, modifiers, null) &&
                    VM.isExported(klass.getMethod(i, category == STATIC_METHODS)))))
            {
                // keeping this method:
                if (!keptAtLeastOne) {
                    symbolsBuffer.addUnsignedByte(category);
                    keptAtLeastOne = true;
                }
                membersBuffer.reset();
                membersBuffer.addUnsignedShort(modifiers);
                membersBuffer.addUnsignedShort(getOffset());
                membersBuffer.addUtf8(name);
                if (Modifier.hasPragmas(modifiers)) {
                    membersBuffer.addUnsignedShort(pragmas);
                }
                int sigCount = getSignatureCount();
                for (int j = 0; j != sigCount; ++j) {
                    membersBuffer.addUnsignedShort(KlassMetadata.addSignatureType(types, getSignatureType(getSignatureAt(j))));
                }
                symbolsBuffer.add(membersBuffer);
            } else {
                // Stripping this method:
                if ((Modifier.isAbstract(modifiers) || klass.isInterface())
                    && !(Modifier.isPackagePrivate(modifiers) || Modifier.isSuitePrivate(klass.getModifiers()))) {
                    // If a class with abstract methods, or an interface, is exported from a suite, but the abstract methods are not exported,
                    // then there is no way to extend or implement the exported class or interface.
                    throw new IllegalStateException("Can't strip method " + name + " because it is abstract in a class exported from a suite: " + klass);
                }
                
                if (Klass.TRACING_ENABLED && Tracer.isTracing("stripping")) {
                    String signature = name;
                    int parameterCount = getSignatureCount() - 1;
                    if (parameterCount == 0) {
                        signature += "()";
                    } else {
                        StringBuffer strbuf = new StringBuffer(15);
                        strbuf.append('(');
                        for (int j = 0 ; j < parameterCount ; j++) {
                            Klass parameterType = getSignatureType(getSignatureAt(j + 1));
                            strbuf.append(parameterType.getInternalName());
                            if (j != parameterCount - 1) {
                                strbuf.append(',');
                            }
                        }
                        strbuf.append(')');
                        signature += strbuf.toString();
                    }
                    signature = getSignatureType(getSignatureAt(0)).getInternalName() + " " + signature;
                    Tracer.traceln("  discarded metadata for method: " + signature);
                }
            }
        }
    }
    return keptAtLeastOne ? 1 << category : 0;
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:78,代碼來源:SymbolParser.java

示例15: close

import com.sun.squawk.util.Tracer; //導入依賴的package包/類
/**
     * {@inheritDoc}
     */
    public void close(int suiteType) throws NoClassDefFoundError {
        long time = 0;
        this.suiteType = suiteType;
        
        if (verbose()) {
            Tracer.trace("[Translator: computing closure...");
            time = System.currentTimeMillis();
        }
        
        computeClosure();
        
        if (translationStrategy == BY_SUITE || translationStrategy == BY_TRANSLATION) {
            if (verbose()) {
                time = System.currentTimeMillis() - time;
                Tracer.traceln(time + "ms.]");
                Tracer.trace("[Translator: whole-suite optimizing and inlining...");
                time = System.currentTimeMillis();
            }
            // bytecode optimizations and inlining go here
            
            if (Arg.get(Arg.DEAD_METHOD_ELIMINATION).getBool()) {
                dme = new DeadMethodEliminator(this);
                dme.computeMethodsUsed();
            }
            
            if (Arg.get(Arg.DEAD_CLASS_ELIMINATION).getBool()) {
                dce = new DeadClassEliminator(this);
                dce.computeClassesUsed();
            }

            if (Arg.get(Arg.DEAD_METHOD_ELIMINATION).getBool()) {
                dme = new DeadMethodEliminator(this);
                dme.computeMethodsUsed();
            }
	    
            if (verbose()) {
                time = System.currentTimeMillis() - time;
                Tracer.traceln(time + "ms.]");
                Tracer.trace("[Translator: phase2...");
                time = System.currentTimeMillis();
            }
            
            for (int cno = 0; cno < suite.getClassCount(); cno++) {
                Klass klass = suite.getKlass(cno);
                Assert.always(Arg.get(Arg.DEAD_CLASS_ELIMINATION).getBool() || (klass != null));
                if (klass != null) {
                    convertPhase2(klass);
                }
            }
        }
        classFiles.clear();
        
        if (verbose()) {
            time = System.currentTimeMillis() - time;
            Tracer.traceln(time + "ms.]");
/*if[ENABLE_VERBOSE]*/
            if (VM.isVeryVerbose()) {
                InstructionEmitter.printUncalledNativeMethods();
            }
/*end[ENABLE_VERBOSE]*/	    
        }
        Assert.always(lastClassNameStack.empty());
    }
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:67,代碼來源:Translator.java


注:本文中的com.sun.squawk.util.Tracer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。