From: <cap...@us...> - 2007-04-14 11:35:55
|
Revision: 53 http://svn.sourceforge.net/pearcolator/?rev=53&view=rev Author: captain5050 Date: 2007-04-14 04:35:53 -0700 (Sat, 14 Apr 2007) Log Message: ----------- Clear up compiler warnings running current test code Modified Paths: -------------- src/org/binarytranslator/DBT.java src/org/binarytranslator/generic/memory/CallBasedMemory.java src/org/binarytranslator/generic/memory/Memory.java src/org/binarytranslator/vmInterface/DBT_Trace.java Modified: src/org/binarytranslator/DBT.java =================================================================== --- src/org/binarytranslator/DBT.java 2007-04-14 10:17:47 UTC (rev 52) +++ src/org/binarytranslator/DBT.java 2007-04-14 11:35:53 UTC (rev 53) @@ -1,33 +1,60 @@ +/* + * This file is part of binarytranslator.org. The binarytranslator.org + * project is distributed under the Common Public License (CPL). + * A copy of the license is included in the distribution, and is also + * available at http://www.opensource.org/licenses/cpl1.0.php + * + * (C) Copyright The University of Manchester 2003-2007 + */ package org.binarytranslator; import org.jikesrvm.VM; +import org.vmmagic.pragma.Uninterruptible; +/** + * Common utility routines for the running DBT. Generally this class is dressing + * up methods from org.jikesrvm.VM. + */ public final class DBT { - public static final boolean VerifyAssertions = true; - + /** Should the following assertion be checked? */ + public static final boolean VerifyAssertions = VM.VerifyAssertions; + + /** + * Assert the following condition is true, if false then fail with stack trace + * @param cond the condition that should be true + */ public static void _assert(boolean cond) { - - if (!VerifyAssertions) - return; - - if (VM.VerifyAssertions) + if (!VerifyAssertions) { + // Checking an assertion in a production build is a bad idea + fail("Assertion checked when assertions should be disabled.\n" + + "Please guard the assertion with DBT.VerifyAssertions"); + } else { VM._assert(cond); - else - { - if (!cond) { - //assertion failed, see if we can get some info on where the assertion occurred - StackTraceElement[] trace = Thread.currentThread().getStackTrace(); - - if (trace.length > 0) { - StackTraceElement source = trace[trace.length-1]; - System.err.println("Assertion failed in: " + source.getFileName() + "(" + source.getLineNumber() + ")"); - } - else { - System.err.println("Assertion failed. No stack trace on assertion source available."); - } - - System.exit(-1); - } } } + + /** + * Exit and print stack trace + * @param message failure message + */ + @Uninterruptible + public static void fail(String message) { + VM.sysFail(message); + } + + /** + * Write the given message + */ + @Uninterruptible + public static void write(String message) { + VM.write(message); + } + + /** + * Write the given int + */ + @Uninterruptible + public static void write(int message) { + VM.write(message); + } } Modified: src/org/binarytranslator/generic/memory/CallBasedMemory.java =================================================================== --- src/org/binarytranslator/generic/memory/CallBasedMemory.java 2007-04-14 10:17:47 UTC (rev 52) +++ src/org/binarytranslator/generic/memory/CallBasedMemory.java 2007-04-14 11:35:53 UTC (rev 53) @@ -18,6 +18,7 @@ import org.jikesrvm.classloader.VM_MethodReference; import org.jikesrvm.classloader.VM_TypeReference; import org.jikesrvm.compilers.opt.ir.*; +import org.vmmagic.pragma.Uninterruptible; /** * CallBasedMemory abstraction: @@ -415,6 +416,7 @@ * @param callAddress * the address associated with this call */ + @Uninterruptible public VM_MethodReference getMethodRef(int callAddress) { switch (callAddress) { case DBT_Trace.MEMORY_STORE8: Modified: src/org/binarytranslator/generic/memory/Memory.java =================================================================== --- src/org/binarytranslator/generic/memory/Memory.java 2007-04-14 10:17:47 UTC (rev 52) +++ src/org/binarytranslator/generic/memory/Memory.java 2007-04-14 11:35:53 UTC (rev 53) @@ -12,6 +12,7 @@ import org.jikesrvm.compilers.opt.ir.OPT_RegisterOperand; import org.jikesrvm.classloader.VM_MethodReference; import org.binarytranslator.vmInterface.TranslationHelper; +import org.vmmagic.pragma.Uninterruptible; import java.io.RandomAccessFile; /** @@ -291,6 +292,7 @@ * @param callAddress * the address associated with this call */ + @Uninterruptible public VM_MethodReference getMethodRef(int callAddress) { throw new Error("Error linking method at " + callAddress + " for memory model " + this.getClass()); Modified: src/org/binarytranslator/vmInterface/DBT_Trace.java =================================================================== --- src/org/binarytranslator/vmInterface/DBT_Trace.java 2007-04-14 10:17:47 UTC (rev 52) +++ src/org/binarytranslator/vmInterface/DBT_Trace.java 2007-04-14 11:35:53 UTC (rev 53) @@ -11,6 +11,7 @@ import org.binarytranslator.generic.decoder.DecoderUtils; import org.binarytranslator.generic.os.process.ProcessSpace; import org.binarytranslator.vmInterface.DummyDynamicCodeRunner; +import org.binarytranslator.DBT; import org.jikesrvm.compilers.common.VM_CompiledMethod; import org.jikesrvm.compilers.common.VM_CompiledMethods; import org.jikesrvm.classloader.VM_NormalMethod; @@ -230,7 +231,8 @@ .asMethodReference(), JBC_invokevirtual); break; case BAD_INSTRUCTION_NEW: - throw new Error("Todo: dynamic linking for new bad instruction exception"); + DBT.fail("Todo: dynamic linking for new bad instruction exception"); + break; case BAD_INSTRUCTION_INIT: dynamicLink.set(DecoderUtils.badInstrKlassInitMethod.getMemberRef() .asMethodReference(), JBC_invokevirtual); @@ -246,9 +248,8 @@ dynamicLink.set(ps.memory.getMethodRef(bcIndex), JBC_invokevirtual); break; default: - throw new Error( - "Trying to dynamic link inside a DBT trace for an unknown dynamic link location: 0x" - + Integer.toHexString(bcIndex)); + DBT.write(bcIndex); + DBT.fail("Trying to dynamic link inside a DBT trace for an unknown dynamic link location"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |