本文整理匯總了Java中com.sun.squawk.util.Tracer.isTracing方法的典型用法代碼示例。如果您正苦於以下問題:Java Tracer.isTracing方法的具體用法?Java Tracer.isTracing怎麽用?Java Tracer.isTracing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.squawk.util.Tracer
的用法示例。
在下文中一共展示了Tracer.isTracing方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
}
}
}
示例2: 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;
}
}
示例3: 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());
}
}
示例4: 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();
}
}
}
}
示例5: 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;
}
示例6: 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;
}
示例7: loadStackMap
import com.sun.squawk.util.Tracer; //導入方法依賴的package包/類
/**
* 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;
}
}
示例8: 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[ENABLE_VERBOSE]*/
if (VM.isHosted() || VM.isVeryVerbose()) {
/*else[ENABLE_VERBOSE]*/
// if (VM.isHosted()) {
/*end[ENABLE_VERBOSE]*/
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();
}
}
}
}
示例9: convertPhase1
import com.sun.squawk.util.Tracer; //導入方法依賴的package包/類
/**
* Convert the code of this method from its 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
*/
private void convertPhase1(Translator translator, Method method, int index) {
try {
Assert.that(code != null, "code is null for " + method);
Klass declaringClass = method.getDefiningClass();
ClassFile cf = translator.getClassFile(declaringClass);
/*
* Write trace message.
*/
if (Translator.TRACING_ENABLED && Tracer.isTracing("converting", method.toString())) {
Tracer.traceln("[converting method " + method + "]");
}
/*
* Get or create the constant pool.
*/
ConstantPool constantPool;
if (code == SYNTHESIZED_DEFAULT_CONSTRUCTOR_CODE) {
constantPool = getConstantPoolForSynthesizedConstructor(translator, method.getDefiningClass());
code = getCodeForSynthesizedConstructor();
} else {
constantPool = cf.getConstantPool();
}
/*
* Ensure the parameter and return types are loaded.
*/
translator.load(method.getReturnType());
Klass[] parameterTypes = method.getParameterTypes();
for (int i = 0 ; i < parameterTypes.length ; i++) {
translator.load(parameterTypes[i]);
}
/*
* Get the code parser and build the IR.
*/
codeParser = new CodeParser(translator, method, code, constantPool);
irBuilder = new IRBuilder(translator, codeParser);
IR ir = irBuilder.getIR();
/*
* Add the object references into the table of constants.
*/
objectTable = new ObjectTable(declaringClass);
for (Instruction instruction = ir.getHead() ; instruction != null ; instruction = instruction.getNext()) {
Object object = instruction.getConstantObject();
if (object != null) {
if (instruction instanceof FieldAccessor) { // ignore special cases:
Klass fieldDefiningClass = ((FieldAccessor)instruction).getField().getDefiningClass();
if (fieldDefiningClass.hasGlobalStatics() || fieldDefiningClass == declaringClass) {
// getstatic/putstatic on global globals doesn't really use the class object table
// getstatic/putstatic on "this class" doesn't really use the class object table
continue;
}
}
objectTable.addConstantObject(object);
}
}
/*
* Transform the IR.
*/
IRTransformer transformer = new IRTransformer(ir, method, getFrame());
transformer.transform(translator);
} finally {
code = null; // Allow the code to be garbage collected
}
}
示例10: 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) {
if (false) 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;
}
示例11: 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) {
if (false) 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;
}