本文整理汇总了Java中com.sun.squawk.translator.Translator.TRACING_ENABLED属性的典型用法代码示例。如果您正苦于以下问题:Java Translator.TRACING_ENABLED属性的具体用法?Java Translator.TRACING_ENABLED怎么用?Java Translator.TRACING_ENABLED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.squawk.translator.Translator
的用法示例。
在下文中一共展示了Translator.TRACING_ENABLED属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: traceType
/**
* 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+"}");
}
}
}
示例2: traceStack
/**
* Traces the state of the operand stack at the current verification
* address.
*
* @param target the stack map (if any) at the current verification address
*/
private void traceStack(Target target) {
if (Translator.TRACING_ENABLED) {
Klass[] map = target == null ? Klass.NO_CLASSES : target.getStack();
int r = 0; // index into recorded stack (i.e. from stack map)
int d = 0; // index into derived stack
while (r < map.length || d < sp) {
Klass derived = (d < sp) ? getStackTypeAt(d) : null;
Klass recorded = (r < map.length) ? map[r] : null;
String prefix = " stack["+r+"]: ";
traceType(derived, prefix, true);
if (recorded != null) {
traceType(recorded, prefix, false);
}
++r;
++d;
}
}
}
示例3: traceLocals
/**
* Traces the state of the local variables at the current verification address.
*
* @param target the stack map (if any) at the current verification address
*/
private void traceLocals(Target target) {
if (Translator.TRACING_ENABLED) {
Klass[] map = (target == null) ? Klass.NO_CLASSES : target.getLocals();
int i = 0;
int l = 0;
while (i < map.length || l < localTypes.length) {
Klass derived = (l < localTypes.length) ? localTypes[l] : null;
Klass recorded = (i < map.length) ? map[i] : null;
String prefix = " local["+l+"]: ";
traceType(derived, prefix, true);
if (recorded != null) {
traceType(recorded, prefix, false);
}
i++;
l++;
}
}
}
示例4: traceFrameState
/**
* 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);
}
}
示例5: InstructionEmitter
/**
* 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());
}
}
示例6: traceTarget
/**
* 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);
}
}
示例7: doSlotClearingAnalysis
/**
* Performs an analysis for a set of non-parameter, reference typed local variables
* to find those that are uninitialized at some point at which a garbage collection
* may occur. As a result of the analysis, the local variables found to have this
* property will return true when isUninitializedAtGC() is invoked on them.
*
* @param localRefs the set of local variables to analyze
* @return the number of slots that need clearing at the start of the method
*/
private int doSlotClearingAnalysis(SquawkVector localRefs) {
final boolean trace = Translator.TRACING_ENABLED && Tracer.isTracing("slotclearingdetail", method.toString());
int cleared = 0;
if (trace) {
Tracer.traceln("");
Tracer.traceln("++++ Slot clearing analysis for " + method + " ++++");
}
/*
* If the method is going to have a CLASS_CLINIT instruction then all the
* local pointers must be cleared. (An alternate solution would be to
* clear all the local variables at runtime if the CLASS_CLINIT bytecode
* is calling into Java code, but the cost of doing it this way appears to
* be very small.)
*/
boolean requiresClassClinit = method.requiresClassClinit();
/*
* Iterate through all the pointer locals and test if they need clearing.
*/
for (Enumeration e = localRefs.elements(); e.hasMoreElements(); ) {
Local local = (Local)e.nextElement();
Assert.that(!local.isParameter() && local.getType() == Klass.REFERENCE);
/*if[FULL_SLOT_CLEARING_ANALYSIS]*/
boolean mustClear = false;
SquawkVector traversed = new SquawkVector();
if (requiresClassClinit || !traverse(local, ir.getHead(), null, traversed)) {
mustClear = true;
} else { // Traverse all the exception handlers
Enumeration handlers = ir.getExceptionHandlers();
if (handlers != null) {
while (handlers.hasMoreElements()) {
IRExceptionHandler handler = (IRExceptionHandler)handlers.nextElement();
Target target = handler.getTarget();
if (!traverse(local, handler.getCatch().getNext(), target, traversed)) {
mustClear = true;
break;
}
}
}
}
/*else[FULL_SLOT_CLEARING_ANALYSIS]*/
// boolean mustClear = true;
/*end[FULL_SLOT_CLEARING_ANALYSIS]*/
if (trace) {
Tracer.traceln(" local = " + local+ " mustClear = "+mustClear);
}
if (mustClear) {
if (local.setUninitializedAtGC()) {
cleared++;
}
}
}
if (trace) {
Tracer.traceln("---- Slot clearing analysis for " + method + " cleared = "+cleared + " not cleared = "+(localRefs.size()-cleared)+" ----");
}
return cleared;
}
示例8: loadStackMap
/**
* Loads a "StackMap" attribute and builds a table of <code>Target</code>
* instances representing the entries in the stack map.
*
* @param codeParser the "Code" attribute parser
* @param cfr the class file reader used to read the attribute
* @param constantPool the constant pool of the enclosing class
* @param codeLength the length of the bytecode array for the enclosing method
* @return a table of <code>Target</code> instances indexed by address
* representing the entries in the stack map
*/
public static IntHashtable loadStackMap(CodeParser codeParser, ClassFileReader cfr, ConstantPool constantPool, int codeLength) {
/*
* Read number_of_entries
*/
int nmaps = cfr.readUnsignedShort("map-nmaps");
if (nmaps == 0) {
return null;
} else {
IntHashtable table = new IntHashtable(nmaps + (nmaps/4) + 1);
int lastAddress = -1;
final boolean trace = Translator.TRACING_ENABLED && Tracer.isTracing("maps", codeParser.getMethod().toString());
for (int i = 0 ; i < nmaps ; i++) {
int address = cfr.readUnsignedShort("map-address");
if (address <= lastAddress) {
throw cfr.formatError("stack map ip addresses not in order");
}
lastAddress = address;
/*
* Load the list of types in the local variables array
*/
Klass[] locals = loadStackMapList(codeParser, cfr, constantPool, codeLength);
if (locals.length > codeParser.getMaxLocals()) {
throw cfr.formatError("stack map locals greater than max_locals");
}
/*
* Load the list of types on the operand stack
*/
Klass[] stack = loadStackMapList(codeParser, cfr, constantPool, codeLength);
if (stack.length > codeParser.getMaxStack()) {
throw cfr.formatError("stack map stack greater than max_stack");
}
Target target = new Target(address, stack, locals);
table.put(address, target);
/*
* Trace.
*/
if (trace) {
Tracer.traceln("Stackmap @"+ target);
}
}
return table;
}
}
示例9: doSlotClearingAnalysis
/**
* Performs an analysis for a set of non-parameter, reference typed local variables
* to find those that are uninitialized at some point at which a garbage collection
* may occur. As a result of the analysis, the local variables found to have this
* property will return true when isUninitializedAtGC() is invoked on them.
*
* @param localRefs the set of local variables to analyze
* @return the number of slots that need clearing at the start of the method
*/
private int doSlotClearingAnalysis(SquawkVector localRefs) {
final boolean trace = Translator.TRACING_ENABLED && Tracer.isTracing("slotclearingdetail", method.toString());
int cleared = 0;
if (trace) {
Tracer.traceln("");
Tracer.traceln("++++ Slot clearing analysis for " + method + " ++++");
}
/*
* If the method is going to have a CLASS_CLINIT instruction then all the
* local pointers must be cleared. (An alternate solution would be to
* clear all the local variables at runtime if the CLASS_CLINIT bytecode
* is calling into Java code, but the cost of doing it this way appears to
* be very small.)
*/
boolean requiresClassClinit = method.requiresClassClinit();
/*
* Iterate through all the pointer locals and test if they need clearing.
*/
for (Enumeration e = localRefs.elements(); e.hasMoreElements(); ) {
Local local = (Local)e.nextElement();
Assert.that(!local.isParameter() && local.getType() == Klass.REFERENCE);
// boolean mustClear = false;
// SquawkVector traversed = new SquawkVector();
// if (requiresClassClinit || !traverse(local, ir.getHead(), null, traversed)) {
// mustClear = true;
// } else { // Traverse all the exception handlers
// Enumeration handlers = ir.getExceptionHandlers();
// if (handlers != null) {
// while (handlers.hasMoreElements()) {
// IRExceptionHandler handler = (IRExceptionHandler)handlers.nextElement();
// Target target = handler.getTarget();
// if (!traverse(local, handler.getCatch().getNext(), target, traversed)) {
// mustClear = true;
// break;
// }
// }
// }
// }
boolean mustClear = true;
if (trace) {
Tracer.traceln(" local = " + local+ " mustClear = "+mustClear);
}
if (mustClear) {
if (local.setUninitializedAtGC()) {
cleared++;
}
}
}
if (trace) {
Tracer.traceln("---- Slot clearing analysis for " + method + " cleared = "+cleared + " not cleared = "+(localRefs.size()-cleared)+" ----");
}
return cleared;
}