From: <dgr...@us...> - 2008-10-31 20:54:55
|
Revision: 6590 http://x10.svn.sourceforge.net/x10/?rev=6590&view=rev Author: dgrove-oss Date: 2008-10-31 20:54:49 +0000 (Fri, 31 Oct 2008) Log Message: ----------- Rename the java package x10.runtime to x10.runtime.impl.java This clears the x10.runtime package for use by x10 classes in XRX. Modified Paths: -------------- trunk/x10.compiler.p3/data/Main.xcd trunk/x10.compiler.p3/data/await.xcd trunk/x10.compiler.p3/data/when.xcd trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.dist/.launchConfigs/x10.launch trunk/x10.dist/bin/x10.in trunk/x10.runtime.17/META-INF/MANIFEST.MF trunk/x10.runtime.17/src-java/x10/core/Ref.java trunk/x10.runtime.17/src-java/x10/runtime/abstractmetrics/AbstractMetricsFactory.java trunk/x10.runtime.17/src-java/x10/types/RuntimeType.java trunk/x10.runtime.17/src-x10/x10/lang/Activity.x10 trunk/x10.runtime.17/src-x10/x10/lang/HashMap.x10 trunk/x10.runtime.17/src-x10/x10/lang/Place.x10 trunk/x10.runtime.17/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime.17/src-x10/x10/lang/Stack.x10 Added Paths: ----------- trunk/x10.runtime.17/src-java/x10/runtime/impl/ trunk/x10.runtime.17/src-java/x10/runtime/impl/java/ trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Configuration.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/JavaRuntime.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/NativeHashMap.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/NativeStack.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/PreLoader.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Report.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Runtime.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Usage.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/VMInterface.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/X10Thread.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/X10ThreadFactory.java trunk/x10.runtime.17/src-java/x10/runtime/impl/java/X10ThreadPoolExecutor.java Removed Paths: ------------- trunk/x10.runtime.17/src-java/x10/runtime/Configuration.java trunk/x10.runtime.17/src-java/x10/runtime/JavaRuntime.java trunk/x10.runtime.17/src-java/x10/runtime/NativeHashMap.java trunk/x10.runtime.17/src-java/x10/runtime/NativeStack.java trunk/x10.runtime.17/src-java/x10/runtime/PreLoader.java trunk/x10.runtime.17/src-java/x10/runtime/Report.java trunk/x10.runtime.17/src-java/x10/runtime/Runtime.java trunk/x10.runtime.17/src-java/x10/runtime/Usage.java trunk/x10.runtime.17/src-java/x10/runtime/VMInterface.java trunk/x10.runtime.17/src-java/x10/runtime/X10Thread.java trunk/x10.runtime.17/src-java/x10/runtime/X10ThreadFactory.java trunk/x10.runtime.17/src-java/x10/runtime/X10ThreadPoolExecutor.java Modified: trunk/x10.compiler.p3/data/Main.xcd =================================================================== --- trunk/x10.compiler.p3/data/Main.xcd 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.compiler.p3/data/Main.xcd 2008-10-31 20:54:49 UTC (rev 6590) @@ -33,5 +33,5 @@ } // How to invoke? Use the following general command: -// java $(javaArgs) x10.runtime.Runtime $(x10Args) ClassName $(x10AppArgs) +// java $(javaArgs) x10.runtime.impl.java.Runtime $(x10Args) ClassName $(x10AppArgs) Modified: trunk/x10.compiler.p3/data/await.xcd =================================================================== --- trunk/x10.compiler.p3/data/await.xcd 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.compiler.p3/data/await.xcd 2008-10-31 20:54:49 UTC (rev 6590) @@ -10,7 +10,7 @@ } } catch (java.lang.Throwable tmp#1) { tmp#1.printStackTrace(); - x10.runtime.Runtime.java.log(java.util.logging.Level.SEVERE, + x10.runtime.impl.java.Runtime.java.log(java.util.logging.Level.SEVERE, "Unexpected exception during conditional atomic.", tmp#1); throw new java.lang.RuntimeException(tmp#1); } finally { Modified: trunk/x10.compiler.p3/data/when.xcd =================================================================== --- trunk/x10.compiler.p3/data/when.xcd 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.compiler.p3/data/when.xcd 2008-10-31 20:54:49 UTC (rev 6590) @@ -14,7 +14,7 @@ } } catch (java.lang.Throwable tmp#4) { tmp#4.printStackTrace(); - x10.runtime.Runtime.java.log(java.util.logging.Level.SEVERE, + x10.runtime.impl.java.Runtime.java.log(java.util.logging.Level.SEVERE, "Unexpected exception during conditional atomic.", tmp#4); throw new java.lang.RuntimeException(tmp#4); } finally { Modified: trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.compiler.p3/src/polyglot/ext/x10/visit/X10PrettyPrinterVisitor.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -174,7 +174,7 @@ public class X10PrettyPrinterVisitor extends X10DelegatingVisitor { public static final String X10_RUNTIME_TYPE_CLASS = "x10.types.Type"; public static final String X10_FUN_CLASS_PREFIX = "x10.core.fun.Fun"; - public static final String X10_RUNTIME_CLASS = "x10.runtime.Runtime"; + public static final String X10_RUNTIME_CLASS = "x10.runtime.impl.java.Runtime"; public static final boolean USE_JAVA_GENERICS = true; Modified: trunk/x10.dist/.launchConfigs/x10.launch =================================================================== --- trunk/x10.dist/.launchConfigs/x10.launch 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.dist/.launchConfigs/x10.launch 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/x10.runtime.x10/src/x10/runtime/Runtime.java"/> +<listEntry value="/x10.runtime.x10/src-java/x10/runtime/impl/java/Runtime.java"/> </listAttribute> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listEntry value="1"/> @@ -20,7 +20,7 @@ <listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="polyglot3" type="1"/> "/> </listAttribute> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="x10.runtime.Runtime"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="x10.runtime.impl.java.Runtime"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="${resource_name}"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="x10.runtime.17"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/> Modified: trunk/x10.dist/bin/x10.in =================================================================== --- trunk/x10.dist/bin/x10.in 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.dist/bin/x10.in 2008-10-31 20:54:49 UTC (rev 6590) @@ -85,7 +85,7 @@ fi java_args="${java_args} ${defs}" -command="\"$JAVA\" $java_args $config x10.runtime.Runtime $args" +command="\"$JAVA\" $java_args $config x10.runtime.impl.java.Runtime $args" [ -n "$verbose" ] && echo "$command" Modified: trunk/x10.runtime.17/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.runtime.17/META-INF/MANIFEST.MF 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/META-INF/MANIFEST.MF 2008-10-31 20:54:49 UTC (rev 6590) @@ -10,7 +10,7 @@ x10.base, x10.compilergenerated, x10.lang, - x10.runtime, + x10.runtime.impl.java x10.runtime.util Bundle-Vendor: rf...@wa... Modified: trunk/x10.runtime.17/src-java/x10/core/Ref.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/core/Ref.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/core/Ref.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -8,7 +8,7 @@ package x10.core; -import x10.runtime.X10Thread; +import x10.runtime.impl.java.X10Thread; // Base class of all X10 ref objects -- should be generated, but we need this class to get Box to compile. public class Ref { Deleted: trunk/x10.runtime.17/src-java/x10/runtime/Configuration.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/Configuration.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/Configuration.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,216 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -/* - * Created on Sep 28, 2004 - */ -package x10.runtime; - -import x10.config.ConfigurationError; -import x10.config.OptionError; -import x10.runtime.util.ShowUsageNotification; - -import java.util.StringTokenizer; - -/** - * This class provides the configuration for the X10 runtime. - * The configuration is a set of values that can be used to - * configure the runtime, for example in order to tune performance. - * - * @see x10.config.Configuration - * - * @author Christian Grothoff - * - * Extensions for JUC implementation - * @author Raj Barik, Vivek Sarkar - */ -public final class Configuration extends x10.config.Configuration { - - /** - * The error received when attempting to load the configuration from - * the specified resource, or null if successful. - */ - public static final ConfigurationError LOAD_ERROR; - - public static int NUMBER_OF_LOCAL_PLACES = 4; - private static final String NUMBER_OF_LOCAL_PLACES_desc = "The number of places"; - - public static boolean NULL_DEFAULT_VALUE = true; - private static final String NULL_DEFAULT_VALUE_desc = "Value types have a null default value"; - - public static int INIT_THREADS_PER_PLACE = 3; - private static final String INIT_THREADS_PER_PLACE_desc = "Initial number of Java threads allocated to thread pool for a single place"; - - /** - * Perform additional instrumentation in the X10 runtime to dump out - * abstract parallel execution statistics for the X10 program. - * Default is false. - */ - public static boolean ABSTRACT_EXECUTION_STATS = false; - private static final String ABSTRACT_EXECUTION_STATS_desc = "Dump out parallel execution statistics"; - - /** - * Dump out unblocked execution times in each place. The time that an - * activity spent blocked in the X10 runtime is not counted. However, - * this is still an approximate estimate because it does account for time - * that an activity is not executing because its Java thread in the thread - * pool does not have an available processor. - * - * NOTE: this option is only enabled when ABSTRACT_EXECUTION_STATS==true; - */ - public static boolean ABSTRACT_EXECUTION_TIMES = false; - private static final String ABSTRACT_EXECUTION_TIMES_desc = "If dumping out statistics, also dump out unblocked execution times"; - - public static boolean BIND_THREADS = false; - private static final String BIND_THREADS_desc = "Use platform-specific calls to bind Java threads to CPUs"; - - public static boolean BIND_THREADS_DIAGNOSTICS = false; - private static final String BIND_THREADS_DIAGNOSTICS_desc = "Print diagnostics related to platform-specific calls to bind Java threads to CPUs"; - - // Set Bad_PLACE_RUNTIME_CHECK = false as the default value in support of implicit-place syntax - public static boolean BAD_PLACE_RUNTIME_CHECK = false; - private static final String BAD_PLACE_RUNTIME_CHECK_desc = "Perform runtime place checks"; - - /** - * The name of the main class of the application. - * TODO: Move this to Runtime.main(). - */ - public static String MAIN_CLASS_NAME = null; - private static final String MAIN_CLASS_NAME_desc = "The name of the main class"; - - /** - * Enables new (experimental) ateach and foreach optimization (code by - * Christian Grothoff and Raj Barik). Default to off until that code is - * sufficiently tested... - */ - public static boolean OPTIMIZE_FOREACH = false; - private static final String OPTIMIZE_FOREACH_desc = "Experimental: Enable runtime loop optimizations"; - - /** - * Pre-load all classes recursively on startup. This is needed for JIT - * optimizations. Default to off until the initialization sequence is - * sufficiently tested... - */ - public static boolean PRELOAD_CLASSES = false; - private static final String PRELOAD_CLASSES_desc = "Pre-load all classes on recursively startup"; - - /** - * Pre-load all strings in all classes on startup. This is needed for - * JIT optimizations. This option only takes effect if PRELOAD_CLASSES - * is also on. Default to off until the JIT can actually take advantage - * of it. - */ - public static boolean PRELOAD_STRINGS = false; - private static final String PRELOAD_STRINGS_desc = "If pre-loading classes, also pre-load all strings"; - - /** - * Which shared libraries should be loaded? The format - * is libraryname[:libraryname]*. Null or "" are valid - * entries (for not loading any libraries). - */ - public static String LOAD = null; - private static final String LOAD_desc = "Load specified shared library"; - - /** - * Parses the command line. This allows the user to specify - * options also on the command line (in addition to the - * configuration file and the defaults). The name of the - * main class is the first argument that does not start with - * a "-". All arguments after the main class are returned - * and should be passed to the application. - * - * @param args arguments. Example: -BAD_PLACE_RUNTIME_CHECK=true - * @return the arguments for the application - */ - public static String[] parseCommandLine(String[] args) throws ConfigurationError { - if (args == null) - return new String[0]; - - int pos = 0; - while (pos < args.length && args[pos].length() > 0 && args[pos].charAt(0) == '-') { - if (args[pos].equals("-h") || - args[pos].equals("-help") || - args[pos].equals("--help")) - throw new ShowUsageNotification(); - // vj: added to allow the runtime to use Polyglot's report mechanism - if (args[pos].equals("-report")) { - pos++; - StringTokenizer st = new StringTokenizer(args[pos], "="); - String topic = ""; int level = 0; - if (st.hasMoreTokens()) topic = st.nextToken(); - if (st.hasMoreTokens()) { - try { - level = Integer.parseInt(st.nextToken()); - } - catch (NumberFormatException e) {} - } - - Report.addTopic(topic, level); - pos++; - continue; - } - - try { - parseArgument(Configuration.class, args[pos]); - } catch (OptionError e) { - throw new ConfigurationError("Invalid argument: '"+args[pos]+"'"); - } - pos++; - } - // TODO: Move MAIN_CLASS_NAME processing to Runtime.main() - MAIN_CLASS_NAME = args[pos++]; - // vj hack to let Eclipse x10 command run with ${resource_loc} - // get rid of prefix pathname. - MAIN_CLASS_NAME = MAIN_CLASS_NAME.substring(MAIN_CLASS_NAME.lastIndexOf("\\")+1); - if (MAIN_CLASS_NAME.endsWith(".java")) - MAIN_CLASS_NAME = MAIN_CLASS_NAME.substring(0, MAIN_CLASS_NAME.length()-5); - else if (MAIN_CLASS_NAME.endsWith(".x10")) - MAIN_CLASS_NAME = MAIN_CLASS_NAME.substring(0, MAIN_CLASS_NAME.length()-4); - - // Sanity checks for values. - if (NUMBER_OF_LOCAL_PLACES < 0) { - System.err.println("Negative value |" + NUMBER_OF_LOCAL_PLACES - + "| for NUMBER_OF_LOCAL_PLACES rejected. Set to 4." ); - NUMBER_OF_LOCAL_PLACES = 4; - } - if (INIT_THREADS_PER_PLACE < 0) { - System.err.println("Negative value |" + INIT_THREADS_PER_PLACE - + "| for INIT_THREADS_PER_PLACE rejected. Set to 3." ); - INIT_THREADS_PER_PLACE = 3; - } - - int aa = args.length-pos; - String[] appArgs = new String[aa]; - System.arraycopy(args, pos, appArgs, 0, aa); - if (Report.should_report(Report.ACTIVITY, 3)) { - Report.report(3, Thread.currentThread() + " user class is |" - + Configuration.MAIN_CLASS_NAME+ "|."); - } - return appArgs; - } - - /** - * Return an array of (option,description) pairs. - */ - public static String[][] options() { - return options(Configuration.class); - } - - static { - String cfg = getConfigurationResource(); - ConfigurationError loadError = null; - try { - readConfiguration(Configuration.class, cfg); - } catch (ConfigurationError err) { - System.err.println("Failed to read configuration file " + cfg + ": " + err); - System.err.println("Using defaults"); - loadError = err; - } - LOAD_ERROR = loadError; - } -} - Deleted: trunk/x10.runtime.17/src-java/x10/runtime/JavaRuntime.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/JavaRuntime.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/JavaRuntime.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,70 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -import java.util.logging.Level; -import java.util.logging.Logger; -import java.lang.System; - - -/** - * "Native" functions mapped through to Java. In the long run the - * idea is that this becomes the "X10 native interface" (akin to JNI, - * but of course better). For the prototype, this interface contains - * the few native functions that we just feel like we have to provide. - * - * In principle, this class can be subclassed, but since it is - * unlikely that we will have multiple implementations of any of these - * functions other than the default, we currently do without. - * - * I'm not sure that this class should live in this package -- maybe - * the code can live here (JavaRuntime_c), but the current situation - * where x10.runtime.Runtime directly refers to a class in x10.runtime - * is definitively bad. - * - * @author Christian Grothoff, Christoph von Praun - */ -public class JavaRuntime { - - private final Logger logger_ - = Logger.getAnonymousLogger(); - - public long currentTimeMillis() { - return System.currentTimeMillis(); - } - - public void log(Level l, - String message, - Object param1) { - logger_.log(l, message, param1); - } - - public void log(Level l, - String message, - Object[] params) { - logger_.log(l, message, params); - } - - public void log(Level l, - String message, - Throwable thrown) { - logger_.log(l, message, thrown); - } - - public void error(String message, Throwable thrown) { - Error tmp = new Error("Unexpected runtime error, see log for details."); - if (thrown != null) - thrown.printStackTrace(); - else - tmp.printStackTrace(); - logger_.log(Level.SEVERE, message, (Object) null); - throw tmp; - } - -} // end of Native - Deleted: trunk/x10.runtime.17/src-java/x10/runtime/NativeHashMap.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/NativeHashMap.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/NativeHashMap.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,13 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -public class NativeHashMap<K,V> extends java.util.HashMap<K,V> { - // HACK discard type parameters - public NativeHashMap(Object typeK, Object typeV) { super(); } -} Deleted: trunk/x10.runtime.17/src-java/x10/runtime/NativeStack.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/NativeStack.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/NativeStack.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,13 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -public class NativeStack<T> extends java.util.Stack<T> { - // HACK discard type parameter - public NativeStack(Object typeT) { super(); } -} Deleted: trunk/x10.runtime.17/src-java/x10/runtime/PreLoader.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/PreLoader.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/PreLoader.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,303 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -import java.io.*; -import java.util.*; - -/** - * A utility for pre-loading a given class and all non-system classes that - * it references. - * The entrypoint is a static <code>preLoad()</code> method. Calling - * <code>preLoad(c, true)</code> will also intern all strings in the - * classes' constant pool. - * - * @author Igor Peshansky - */ -public class PreLoader { - public static void main(String[] args) { -// try { -// String name = getClassFile(PreLoader.class); -// if (args.length > 0) -// name = args[0]; -// InputStream in = getClassAsStream(name, PreLoader.class); -// byte[][] cp = getConstantPool(in); -// String[] ref_classes = getReferencedClasses(name, cp); -// for (int i = 0; i < ref_classes.length; i++) -// System.err.println(i+": "+ref_classes[i]); -// } catch (IOException e) { e.printStackTrace(); } - if (args.length > 0) - preLoad(args[0], PreLoader.class); - else - preLoad(PreLoader.class); - } - private static final String TRUE = "true"; - private static final Map inited = new HashMap(); - private static final ClassLoader bootstrap = Object.class.getClassLoader(); - /** - * Recursively pre-load the given class and all the classes it statically - * references. - * @param c the class to pre-load - */ - public static void preLoad(Class c) { - preLoad(getClassFile(c), c); - } - /** - * Recursively pre-load the given class and all the classes it statically - * references, optionally interning string constants. - * @param c the class to pre-load - * @param intern whether to intern string constants - */ - public static void preLoad(Class c, boolean intern) { - if (c.getClassLoader() == bootstrap) return; - preLoad(getClassFile(c), c, intern); - } - private static void preLoad(String name, Class c) { - preLoad(name, c, true); - } - private static void preLoad(String name, Class c, boolean intern) { - if (inited.get(name) != null) return; - inited.put(name, TRUE); -// System.err.println("Pre-loading '"+name+"'"); - try { - InputStream in = getClassAsStream(name, c); - byte[][] cp = getConstantPool(name, in); -// for (int j = 1; j < cp.length; j++) -// printConstantPoolEntry(cp, j, System.err); - if (intern) internStrings(cp); - String[] ref_classes = getReferencedClasses(name, cp); - for (int i = 0; i < ref_classes.length; i++) { - String nm = toClassName(ref_classes[i]); - try { - Class u = Class.forName(nm); -// System.err.println(i+": "+nm+" -> "+u); - // Skip arrays - if (nm.charAt(0) == '[') continue; - // Skip system classes - if (u.getClassLoader() == bootstrap) continue; - preLoad(toFileName(nm), c, intern); - } catch (ClassNotFoundException e) { -// System.err.println(i+": "+nm+" not found"); - } - } - } catch (IOException e) { e.printStackTrace(System.err); assert false; } - } - private static InputStream getClassAsStream(Class c) throws IOException { - return getClassAsStream(getClassFile(c), c); - } - private static InputStream getClassAsStream(String name, Class c) throws IOException { - InputStream cin = c.getClassLoader().getResourceAsStream(name); - if (cin == null) - throw new IOException("Class file "+name+" cannot be found"); - return cin; - } - private static String toClassName(String n) { - return n.replace('/','.'); - } - private static String toFileName(String n) { - return n.replace('.','/')+".class"; - } - private static String getClassFile(Class c) { - return toFileName(c.getName()); - } - private static byte[] getClassBytes(String name, Class c) throws IOException { - InputStream cin = getClassAsStream(name, c); - byte[] classbytes = new byte[cin.available()]; - if (cin.read(classbytes) != classbytes.length) - throw new IOException("Could not read class"); - return classbytes; - } - private static void internStrings(byte[][] cp) { - for (int i = 1; i < cp.length; i++) { - if (cp[i][0] != CONSTANT_Utf8) continue; - int len = (cp[i][1] & 0xFF) << 8 | (cp[i][2] & 0xFF); - try { - String s = new String(cp[i], 3, len, "UTF-8").intern(); -// System.err.println("Interned '"+s+"'"); - } catch (UnsupportedEncodingException e) { } - } - } - private static String[] getReferencedClasses(String name, byte[][] cp) { - int num_classes = 0; - for (int i = 1; i < cp.length; i++) - if (cp[i][0] == CONSTANT_Class) - num_classes++; - String[] ref_classes = new String[num_classes]; - int j = 0; - for (int i = 1; i < cp.length; i++) { - if (cp[i][0] != CONSTANT_Class) continue; - int name_idx = (cp[i][1] & 0xFF) << 8 | (cp[i][2] & 0xFF); - if (cp[name_idx][0] != CONSTANT_Utf8) - throw new Error("Class entry "+i+" refers to non-utf ("+cp[name_idx][0]+") entry "+name_idx+" in "+name); - int name_len = (cp[name_idx][1] & 0xFF) << 8 | (cp[name_idx][2] & 0xFF); - try { - ref_classes[j++] = new String(cp[name_idx], 3, name_len, "UTF-8").intern(); - } catch (UnsupportedEncodingException e) { } - } - return ref_classes; - } - private static byte[][] getConstantPool(String name, byte[] classbytes) { - try { - return getConstantPool(name, new ByteArrayInputStream(classbytes)); - } catch (IOException e) { - throw new Error("Unable to read from an array of bytes"); - } - } - private static final int CONSTANT_Empty = 0; - private static final int CONSTANT_Class = 7; - private static final int CONSTANT_Fieldref = 9; - private static final int CONSTANT_Methodref = 10; - private static final int CONSTANT_InterfaceMethodref = 11; - private static final int CONSTANT_String = 8; - private static final int CONSTANT_Integer = 3; - private static final int CONSTANT_Float = 4; - private static final int CONSTANT_Long = 5; - private static final int CONSTANT_Double = 6; - private static final int CONSTANT_NameAndType = 12; - private static final int CONSTANT_Utf8 = 1; - private static final byte[] EMPTY = new byte[] { CONSTANT_Empty }; - private static byte[][] getConstantPool(String name, InputStream in) throws IOException { - for (int i = 0; i < 8; i++) in.read(); - int cp_size = ((in.read() & 0xFF) << 8 | (in.read() & 0xFF)); - byte[][] cp = new byte[cp_size][]; - cp[0] = EMPTY; - for (int i = 1; i < cp_size; i++) { - byte tag = (byte)in.read(); - switch (tag) { - case CONSTANT_Class: - case CONSTANT_String: - cp[i] = new byte[] { tag, (byte)in.read(), (byte)in.read() }; - break; - case CONSTANT_Fieldref: - case CONSTANT_Methodref: - case CONSTANT_InterfaceMethodref: - cp[i] = new byte[] { tag, (byte)in.read(), (byte)in.read(), - (byte)in.read(), (byte)in.read() }; - break; - case CONSTANT_Integer: - case CONSTANT_Float: - cp[i] = new byte[] { tag, (byte)in.read(), (byte)in.read(), - (byte)in.read(), (byte)in.read() }; - break; - case CONSTANT_Long: - case CONSTANT_Double: - cp[i] = new byte[] { tag, (byte)in.read(), (byte)in.read(), - (byte)in.read(), (byte)in.read(), - (byte)in.read(), (byte)in.read(), - (byte)in.read(), (byte)in.read() }; - cp[++i] = EMPTY; - break; - case CONSTANT_NameAndType: - cp[i] = new byte[] { tag, (byte)in.read(), (byte)in.read(), - (byte)in.read(), (byte)in.read() }; - break; - case CONSTANT_Utf8: - { - byte l_h = (byte)in.read(); - byte l_l = (byte)in.read(); - int len = (l_h & 0xFF) << 8 | (l_l & 0xFF); - cp[i] = new byte[len+3]; - cp[i][0] = tag; cp[i][1] = l_h; cp[i][2] = l_l; - int off = 3; - int n; - while ((n = in.read(cp[i], off, len)) != len) { - len -= n; - off += n; - } - } - break; - default: - throw new Error("Unknown constant pool tag ("+tag+") at entry "+i+" in "+name); - } -// printConstantPoolEntry(cp, i-1, System.err); -// printConstantPoolEntry(cp, i, System.err); - } - return cp; - } - private static final String[] TAGS = { "EMPTY", "UTF8", null, "INTEGER", - "FLOAT", "LONG", "DOUBLE", "CLASS", "STRING", "FIELDREF", "METHODREF", - "IMETHOD", "NAME/TYPE" }; - private static void printConstantPoolEntry(byte[][] cp, int i, PrintStream out) { - byte[] entry = cp[i]; - byte tag = entry[0]; - int tmp1, tmp2; - out.print(i+": "+TAGS[tag]); - switch (tag) { - case CONSTANT_Empty: - out.println(); - break; - case CONSTANT_Class: - case CONSTANT_String: - tmp1 = (entry[1] & 0xFF) << 8 | (entry[2] & 0xFF); - out.println("["+tmp1+"]"); -// out.print(" -> "); -// printConstantPoolEntry(cp, tmp1, out); - break; - case CONSTANT_Fieldref: - case CONSTANT_Methodref: - case CONSTANT_InterfaceMethodref: - tmp1 = (entry[1] & 0xFF) << 8 | (entry[2] & 0xFF); - tmp2 = (entry[3] & 0xFF) << 8 | (entry[4] & 0xFF); - out.println("["+tmp1+","+tmp2+"]"); -// out.print(" -> "); -// printConstantPoolEntry(cp, tmp1, out); -// out.print(" -> "); -// printConstantPoolEntry(cp, tmp2, out); - break; - case CONSTANT_Integer: - case CONSTANT_Float: - tmp1 = ((entry[1] & 0xFF) << 8 | (entry[2] & 0xFF)) << 16 | - ((entry[3] & 0xFF) << 8 | (entry[4] & 0xFF)); - if (tag == CONSTANT_Float) - out.println(" = "+toFloat(tmp1)); - else - out.println(" = "+tmp1); - break; - case CONSTANT_Long: - case CONSTANT_Double: - tmp1 = ((entry[1] & 0xFF) << 8 | (entry[2] & 0xFF)) << 16 | - ((entry[3] & 0xFF) << 8 | (entry[4] & 0xFF)); - tmp2 = ((entry[5] & 0xFF) << 8 | (entry[6] & 0xFF)) << 16 | - ((entry[7] & 0xFF) << 8 | (entry[8] & 0xFF)); - if (tag == CONSTANT_Double) - out.println(" = "+toDouble(tmp1,tmp2)); - else - out.println(" = "+toLong(tmp1,tmp2)); - break; - case CONSTANT_NameAndType: - tmp1 = (entry[1] & 0xFF) << 8 | (entry[2] & 0xFF); - tmp2 = (entry[3] & 0xFF) << 8 | (entry[4] & 0xFF); - out.println("["+tmp1+","+tmp2+"]"); -// out.print(" -> "); -// printConstantPoolEntry(cp, tmp1, out); -// out.print(" -> "); -// printConstantPoolEntry(cp, tmp2, out); - break; - case CONSTANT_Utf8: - tmp1 = (entry[1] & 0xFF) << 8 | (entry[2] & 0xFF); - try { - out.println(" = \""+new String(entry, 3, tmp1, "UTF-8")+"\""); - } catch (UnsupportedEncodingException e) { } - break; - default: - throw new Error("Unknown constant pool tag ("+tag+") at entry "+i); - } - } - private static float toFloat(int v) { - return Float.intBitsToFloat(v); - } - private static long toLong(int h, int l) { - long r = h; - return r << 32 + l; - } - private static double toDouble(int h, int l) { - long r = h; - return Double.longBitsToDouble(r << 32 + l); - } -} - Deleted: trunk/x10.runtime.17/src-java/x10/runtime/Report.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/Report.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/Report.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,132 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Stack; - -/** Class used for reporting debug messages. Adapted from polyglot.main.Report - * @author vj - * */ -public class Report { - - public static final String ACTIVITY = "activity"; - - public static final String CLOCK = "clock"; - - /** A collection of string names of topics which can be used with the - -report command-line switch */ - public static Collection topics = new HashSet(); - - /** A collection of string names of topics which we should always check - if we should report. */ - public static Stack should_report = new Stack(); - - /** - * The topics that the user has selected to report, mapped to the level - * they want to report them to. - */ - protected static Map reportTopics = new HashMap(); // Map[String, Integer] - - /** - * Indicates if there is no reporting at all. - * The normal case is that we do not report anything, so for efficiency - * reasons, since <code>should_report</code> is called so often, we'll use - * this flag to bypass a lot of the checking. When the options are processed, - * this flag should be changed. - */ - // Replaced by a VMInterface ENABLE_REPORTING - protected static boolean noReporting = true; - - /** Report topics understood by the runtime system. */ - - // This topic is the level of detail that should be in messages. - public static String debug = "debug"; - public static String verbose="verbose"; - static { - - topics.add(Report.CLOCK); - topics.add(Report.ACTIVITY); - - should_report.push(verbose); - } - - /** - * Return whether a message on <code>topic</code> of obscurity - * <code>level</code> should be reported, based on use of the - * -report command-line switches given by the user. - */ - public static boolean should_report(String topic, int level) { - if (noReporting) - return false; - return should_report(Collections.singletonList(topic), level); - } - - /** - * Return whether a message on <code>topics</code> of obscurity - * <code>level</code> should be reported, based on use of the - * -report command-line switches given by the user. - */ - public static boolean should_report(String[] topics, int level) { - if (noReporting) - return false; - return should_report(Arrays.asList(topics), level); - } - - /** - * Return whether a message on <code>topics</code> of obscurity - * <code>level</code> should be reported, based on use of the - * -report command-line switches given by the user. - */ - public static boolean should_report(Collection topics, int level) { - if (noReporting) - return false; - for (Iterator i = should_report.iterator(); i.hasNext();) { - String topic = (String) i.next(); - if (level(topic) >= level) return true; - } - if (topics != null) { - for (Iterator i = topics.iterator(); i.hasNext();) { - String topic = (String) i.next(); - if (level(topic) >= level) return true; - } - } - return false; - } - - public static void addTopic(String topic, int level) { - Integer i = (Integer)reportTopics.get(topic); - if (i == null || i.intValue() < level) { - reportTopics.put(topic, new Integer(level)); - } - } - - protected static int level(String name) { - Object i = reportTopics.get(name); - if (i == null) return 0; - return ((Integer)i).intValue(); - } - - /** This is the standard way to report debugging information in the - * RTS. It reports a message of the specified level (which - * controls the presentation of the message. To test whether such - * message should be reported, use "should_report" - * - */ - public static void report(int level, String message) { - for (int j = 1; j < level; j++) System.err.print(" "); - System.err.println(message); - } - -} Deleted: trunk/x10.runtime.17/src-java/x10/runtime/Runtime.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/Runtime.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/Runtime.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,88 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -import x10.config.ConfigurationError; -import x10.runtime.util.ShowUsageNotification; - -public class Runtime { - public static JavaRuntime java; - - /* Pre-load the VMInterface class */ - static { VMInterface foo = null; } - - public static void main(String[] args) { - if (args.length == 0) { - System.err.println("usage: java x10.runtime.Runtime MainClass [args]"); - System.exit(1); - } - try { - String[] strippedArgs = Configuration.parseCommandLine(args); - java = new JavaRuntime(); - loadAndInitLibs(); - run(strippedArgs); - } catch (ShowUsageNotification e) { - Usage.usage(System.out, null); - } catch (ConfigurationError e) { - Usage.usage(System.err, e); - } catch (Exception e) { - Runtime.java.error("Unexpected Exception in X10 runtime.", e); - } - } - - /** - * Load and init shared library - */ - private static void loadAndInitLibs() { - if (null != Configuration.LOAD) { - String[] libs = Configuration.LOAD.split(":"); - for (int i=libs.length-1;i>=0;i--) - System.loadLibrary(libs[i]); - } - } - - public static final int MAX_PLACES = Configuration.NUMBER_OF_LOCAL_PLACES; - - private static final Class[] STRING_ARRAYS = new Class[] { String[].class }; - - /** - * Instantiate and run the main activity - */ - private static void run(String[] strippedArgs) { - java.lang.Object[] args = { strippedArgs }; - try { - // instantiation using reflection - Class main = Class.forName(Configuration.MAIN_CLASS_NAME + "$Main"); - Runnable r = (Runnable) main.getDeclaredConstructor(STRING_ARRAYS).newInstance(args); - if (Configuration.PRELOAD_CLASSES) - PreLoader.preLoad(main, Configuration.PRELOAD_STRINGS); - // run the main activity - r.run(); - } catch (Exception e) { - System.err.println("Could not find default constructor of main class '" - + Configuration.MAIN_CLASS_NAME + "$Main" + "'!"); - throw new Error(e); - } - exit(); - } - - private static int exitCode = 0; - - public static void setExitCode(int code) { - exitCode = code; - } - - public static void exit() { - System.exit(exitCode); - } - - public static void exit(int code) { - setExitCode(code); - exit(); - } -} Deleted: trunk/x10.runtime.17/src-java/x10/runtime/Usage.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/Usage.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/Usage.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,122 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -import java.io.PrintStream; -import java.util.StringTokenizer; - -import x10.config.ConfigurationError; - -/** - * Code for outputting usage information for the X10 runtime. - */ -public abstract class Usage { - /** - * The name of the language this runtime represents. - */ - public static final String LANGUAGE = "x10"; - - /** - * Print usage information - */ - public static void usage(PrintStream out, ConfigurationError err) { - if (err != null) - out.println("Error: "+err.getMessage()); - out.println("Usage: " + LANGUAGE + " [options] " + - "<main-class> [arg0 arg1 ...]"); - out.println("where [options] includes:"); - String[][] options = Configuration.options(); - for (int i = 0; i < options.length; i++) { - String[] optinfo = options[i]; - String optflag = "-"+optinfo[0]+"="+optinfo[1]; - String optdesc = optinfo[2]+"(default = "+optinfo[3]+")"; - usageForFlag(out, optflag, optdesc); - } - } - - /* The following code was borrowed from Polyglot's Options.java */ - /** - * The maximum width of a line when printing usage information. Used - * by <code>usageForFlag</code> and <code>usageSubsection</code>. - */ - protected static final int USAGE_SCREEN_WIDTH = 76; - - /** - * The number of spaces from the left that the descriptions for flags will - * be displayed. Used by <code>usageForFlag</code>. - */ - private static final int USAGE_FLAG_WIDTH = 34; - - /** - * The number of spaces from the left that the flag names will be - * indented. Used by <code>usageForFlag</code>. - */ - private static final int USAGE_FLAG_INDENT = 4; - - /** - * Utility method to print a number of spaces to a PrintStream. - * @param out output PrintStream - * @param n number of spaces to print. - */ - protected static void printSpaces(PrintStream out, int n) { - while (n-- > 0) { - out.print(' '); - } - } - - /** - * Output a flag and a description of its usage in a nice format. - * - * @param out output PrintStream - * @param flag - * @param description description of the flag. - */ - protected static void usageForFlag(PrintStream out, String flag, String description) { - printSpaces(out, USAGE_FLAG_INDENT); - out.print(flag); - // cur is where the cursor is on the screen. - int cur = flag.length() + USAGE_FLAG_INDENT; - - // print space to get up to indentation level - if (cur < USAGE_FLAG_WIDTH) { - printSpaces(out, USAGE_FLAG_WIDTH - cur); - } - else { - // the flag is long. Get a new line before printing the - // description. - out.println(); - printSpaces(out, USAGE_FLAG_WIDTH); - } - cur = USAGE_FLAG_WIDTH; - - // break up the description. - StringTokenizer st = new StringTokenizer(description); - while (st.hasMoreTokens()) { - String s = st.nextToken(); - if (cur + s.length() > USAGE_SCREEN_WIDTH) { - out.println(); - printSpaces(out, USAGE_FLAG_WIDTH); - cur = USAGE_FLAG_WIDTH; - } - out.print(s); - cur += s.length(); - if (st.hasMoreTokens()) { - if (cur + 1 > USAGE_SCREEN_WIDTH) { - out.println(); - printSpaces(out, USAGE_FLAG_WIDTH); - cur = USAGE_FLAG_WIDTH; - } - else { - out.print(" "); - cur++; - } - } - } - out.println(); - } -} Deleted: trunk/x10.runtime.17/src-java/x10/runtime/VMInterface.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/VMInterface.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/VMInterface.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,121 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -/* - * Created on Sep 28, 2004 - */ -package x10.runtime; - -import java.util.concurrent.atomic.*; - -/** - * This class introduces static final fields that are initialized with values provided by other classes. - * Any references to these fields should be recognized as constants by a JIT compiler compiling code that - * references any of these fields. (It is important to ensure that classes that reference these fields - * do not introduce a cycle in class loading dependences.) - * - * @author Vivek Sarkar (based on ideas suggested by Allan Kielstra, Igor Peshansky, Chris Donawa, Raj Barik) - */ -public final class VMInterface { - - public static final int NUMBER_OF_LOCAL_PLACES = Configuration.NUMBER_OF_LOCAL_PLACES; - - public static final boolean ABSTRACT_EXECUTION_STATS = Configuration.ABSTRACT_EXECUTION_STATS; - - public static final boolean ABSTRACT_EXECUTION_TIMES = Configuration.ABSTRACT_EXECUTION_TIMES; - - // Set to true if individual PoolRunners should be pre-assigned to - // CPUs on an SMP system. - public static final boolean BIND_THREADS = Configuration.BIND_THREADS; - public static final boolean BIND_THREADS_DIAGNOSTICS = Configuration.BIND_THREADS_DIAGNOSTICS; - - // The following methods are all specially treated by the Testarossa - // JIT and may be specially treated by any JIT. - // call this method early so that Helpers will be loaded before - // we attempt to JIT compile any calls to methods below - public static final void loadMeInMain() { } - - // The Testarossa JIT (in J9) will use this to allow - // speculative loads of array elements beyond the end of - // the array without bounds check violations - public static final int speculateIndex(int index,int upperBound) { - if(index >=upperBound) return 0; - return index; - } - // The Testarossa JIT (in J9) will turn this into a direct - // call to the appropriate system routine on AIX - public static final int getCPU() { return -1; } - - // When the Testarossa JIT (in J9) sees something like: - // arr[x10JITHelpers.Helpers.noBoundsCheck(x)] - // it will treat it as: - // arr[(x)] only with no bounds check - public static final int noBoundsCheck(int i) { return i; } - - // When the JIT sees something like: - // checkLowBound(i,low) - // it can inline the following method body, and treat this method as an intrinsic that is a candidate for redundancy optimizations - public static int checkLowBound(int i, int low) { if (i < low) throw new ArrayIndexOutOfBoundsException(); return i; } - - // When the JIT sees something like: - // checkHighBound(i,high) - // it can inline the following method body, and treat this method as an intrinsic that is a candidate for redundancy optimizations - public static int checkHighBound(int i, int high) { if (i > high) throw new ArrayIndexOutOfBoundsException(); return i; } - - // NOTE: we can later evaluate if we want to also create an optimized combined call for low and high bounds, as Igor suggested - - // When the Testarossa JIT (in J9) sees something like: - // noNullCheck(x) - // it will treat it as: - // (x) only with no null reference check - public static final Object noNullCheck(Object o) { return o; } - - // When the Testarossa JIT (in J9) sees something like: - // noCastCheck(x) - // it will treat it as: - // (x) only with no type cast check - public static final Object noCastCheck(Object o) { return o; } - - // Given a j.u.c Worker Runnable, construct a Runnable that will first - // ensure that the Worker thread runs on "the right" CPU - static final Runnable mapPoolThreadToCPU(final Runnable workerRunnable, final int placeNumber, final int workerWithinPool, String threadName) { - if (BIND_THREADS && (numCPUs != 0)) { - final int CPUsPerPlace = numCPUs / Configuration.NUMBER_OF_LOCAL_PLACES; - final int firstCPUInThisPlace = CPUsPerPlace * placeNumber; - final int numCPUsInThisPlace = (placeNumber == Configuration.NUMBER_OF_LOCAL_PLACES - 1) ? (numCPUs - firstCPUInThisPlace) : CPUsPerPlace; - final int myCPU = (firstCPUInThisPlace + workerWithinPool % numCPUsInThisPlace) % numCPUs ; - if ( BIND_THREADS_DIAGNOSTICS ) System.err.println("BIND_THREADS: Mapping thread " + threadName + " to CPU " + myCPU); - return new Runnable() { - public void run() { - putMeOnCPU(myCPU); - workerRunnable.run(); - } - }; - } else { - return workerRunnable; - } - } - - private final static AtomicInteger globalThreadNumber = new AtomicInteger(0); - private final native static int getNumCPUs(); - private final static int numCPUs; - private final static String thrdSuppLib = "X10ThreadSupp"; - private final native static void putMeOnCPU(int i); - static { - int n = 0; - try { - System.loadLibrary(thrdSuppLib); - n = getNumCPUs(); - } catch (java.lang.UnsatisfiedLinkError ule) { - if ( BIND_THREADS_DIAGNOSTICS ) System.err.println("BIND_THREADS: Library " + thrdSuppLib + " not found???"); - } finally { - numCPUs = n; - } - } - -} - Deleted: trunk/x10.runtime.17/src-java/x10/runtime/X10Thread.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/X10Thread.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/X10Thread.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,46 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -/** - * Thread in the thread pool that can be used to run multiple - * activities over time. - * - * @author Christian Grothoff - * @author vj - * @author Raj Barik, Vivek Sarkar - * 3/6/2006: replaced original PoolRunner by JCU implementation - * @author tardieu - */ -public class X10Thread extends Thread { - public static X10Thread currentThread() { - Thread t = Thread.currentThread(); - if (t instanceof X10Thread) return (X10Thread) t; - return null; // happens before main activity is spawned - } - - private final int placeId; - private Runnable runnable; // the activity currently executed - - X10Thread(ThreadGroup group, Runnable r, String name, int id) { - super(group, r, name, 0); - placeId = id; - } - - public void setRunnable(Runnable r) { - runnable = r; - } - - public Runnable getRunnable() { - return runnable; - } - - public int getPlaceId() { - return placeId; - } -} Deleted: trunk/x10.runtime.17/src-java/x10/runtime/X10ThreadFactory.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/X10ThreadFactory.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/X10ThreadFactory.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,40 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -/** - * X10 thread factory for JCU implementation. - * @author Raj Barik, Vivek Sarkar -- 3/6/2006 - * @tardieu - */ -public class X10ThreadFactory implements ThreadFactory { - private final int placeId; - private final ThreadGroup group; - private final AtomicInteger threadNumber = new AtomicInteger(0); - private final String namePrefix; - - public X10ThreadFactory(int placeId) { - SecurityManager s = System.getSecurityManager(); - group = (s != null)? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); - namePrefix = "pool-" + placeId + "-thread-"; - this.placeId = placeId; - } - - public Thread newThread(final Runnable workerRunnable) { - final int x = threadNumber.getAndIncrement(); - String threadName = namePrefix + x; - Runnable r = VMInterface.mapPoolThreadToCPU(workerRunnable, placeId, x, threadName); - Thread t = new X10Thread(group, r, threadName, placeId); - if (t.isDaemon()) t.setDaemon(false); - if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY); - return t; - } -} Deleted: trunk/x10.runtime.17/src-java/x10/runtime/X10ThreadPoolExecutor.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/X10ThreadPoolExecutor.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/X10ThreadPoolExecutor.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -1,71 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008 - * - * This file is part of X10 Language. - * - */ -package x10.runtime; - -import java.util.concurrent.*; - -/** - * @author Raj Barik, Vivek Sarkar - * 3/6/2006: extension of JCU ThreadPoolExecutor to allow for adding threads to the pool based on the - * number of X10 activities that are blocked. - * @tardieu - */ - -public class X10ThreadPoolExecutor extends ThreadPoolExecutor { - - private int nbThreadBlocked = 0; - - public X10ThreadPoolExecutor ( int placeId ) { - super ( Configuration.INIT_THREADS_PER_PLACE, - Configuration.INIT_THREADS_PER_PLACE, - 1000L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue<Runnable> (), - new X10ThreadFactory (placeId)); - prestartAllCoreThreads(); - } - - /** Should it be atomic? - * Call this method when you are blocked on finish, force, next*/ - - public synchronized void increasePoolSize () { - if(++nbThreadBlocked >= getCorePoolSize()) { - setCorePoolSize ( getCorePoolSize() + 1 ); - setMaximumPoolSize ( getMaximumPoolSize () + 1); - } - } - - - /** - * Call this method when you are out of the blocked operation - */ - - public synchronized void decreasePoolSize () { - --nbThreadBlocked; - // TODO this code is likely to crash some non regression test - // setCorePoolSize ( getCorePoolSize () - 1 ); - // setMaximumPoolSize ( getMaximumPoolSize () - 1); - } - - - /** - * Call this method to check the size of the queue - */ - public int queueSize() { - return getQueue().size(); - } - - /** TODO */ - public void beforeExecute (Thread t, Runnable r) { - super.beforeExecute(t,r); - } - - /** TODO */ - public void afterExecute (Runnable r, Throwable t) { - super.afterExecute(r,t); - } -} Modified: trunk/x10.runtime.17/src-java/x10/runtime/abstractmetrics/AbstractMetricsFactory.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/abstractmetrics/AbstractMetricsFactory.java 2008-10-31 19:27:46 UTC (rev 6589) +++ trunk/x10.runtime.17/src-java/x10/runtime/abstractmetrics/AbstractMetricsFactory.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -7,7 +7,7 @@ */ package x10.runtime.abstractmetrics; -import x10.runtime.VMInterface; +import x10.runtime.impl.java.VMInterface; /** * The default implementation of the AbstractMetrics interface Property changes on: trunk/x10.runtime.17/src-java/x10/runtime/impl/java ___________________________________________________________________ Added: svn:mergeinfo + Added: trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Configuration.java =================================================================== --- trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Configuration.java (rev 0) +++ trunk/x10.runtime.17/src-java/x10/runtime/impl/java/Configuration.java 2008-10-31 20:54:49 UTC (rev 6590) @@ -0,0 +1,216 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008 + * + * This file is part of X10 Language. + * + */ +/* + * Created on Sep 28, 2004 + */ +package x10.runtime.impl.java; + +import x10.config.ConfigurationError; +import x10.config.OptionError; +import x10.runtime.util.ShowUsageNotification; + +import java.util.StringTokenizer; + +/** + * This class provides the configuration for the X10 runtime. + * The configuration is a set of values that can be used to + * configure the runtime, for example in order to tune performance. + * + * @see x10.config.Configuration + * + * @author Christian Grothoff + * + * Extensions for JUC implementation + * @author Raj Barik, Vivek Sarkar + */ +public final class Configuration extends x10.config.Configuration { + + /** + * The error received when attempting to load the configuration from + * the specified resource, or null if successful. + */ + public static final ConfigurationError LOAD_ERROR; + + public static int NUMBER_OF_LOCAL_PLACES = 4; + private static final String NUMBER_OF_LOCAL_PLACES_desc = "The number of places"; + + public static boolean NULL_DEFAULT_VALUE = true; + private static final String NULL_DEFAULT_VALUE_desc = "Value types have a null default value"; + + public static int INIT_THREADS_PER_PLACE = 3; + private static final String INIT_THREADS_PER_PLACE_desc = "Initial number of Java threads allocated to thread pool for a single place"; + + /** + * Perform additional instrumentation in the X10 runtime to dump out + * abstract parallel execution statistics for the X10 program. + * Default is false. + */ + public static boolean ABSTRACT_EXECUTION_STATS = false; + private static final String ABSTRACT_EXECUTION_STATS_desc = "Dump out parallel execution statistics"; + + /** + * Dump out unblocked execution times in each place. The time that an + * activity spent blocked in the X10 runtime is not counted. However, + * this is still an approximate estimate because it does account for time + * that an activity is not executing because its Java thread in the thread + * pool does not have an available processor. + * + * NOTE: this option is only enabled when ABSTRACT_EXECUTION_STATS==true; + */ + public static boolean ABSTRACT_EXECUTION_TIMES = false; + private static final String ABSTRACT_EXECUTION_TIMES_desc = "If dumping out statistics, also dump out unblocked execution times"; + + public static boolean BIND_THREADS = false; + private static final String BIND_THREADS_desc = "Use platform-specific calls to bind Java threads to CPUs"; + + public static boolean BIND_THREADS_DIAGNOSTICS = false; + private static final String BIND_THREADS_DIAGNOSTICS_desc = "Print diagnostics related to platform-specific calls to bind Java threads to CPUs"; + + // Set Bad_PLACE_RUNTIME_CHECK = false as the default value in support of implicit-place syntax + public static boolean BAD_PLACE_RUNTIME_CHECK = false; + private static final String BAD_PLACE_RUNTIME_CHECK_desc = "Perform runtime place checks"; + + /** + * The name of the main class of the application. + * TODO: Move this to Runtime.main(). + */ + public static String MAIN_CLASS_NAME = null; + private static final String MAIN_CLASS_NAME_desc = "The name of the main class"; + + /** + * Enables new (experimental) ateach and foreach optimization (code by + * Christian Grothoff and Raj Barik). Default to off until that code is + * sufficiently tested... + */ + public static boolean OPTIMIZE_FOREACH = false; + private static final String OPTIMIZE_FOREACH_desc = "Experimental: Enable runtime loop optimizations"; + + /** + * Pre-load all classes recursively on startup. This is needed for JIT + * optimizations. Default to off until the initialization sequence is + * sufficiently tested... + */ + public static boolean PRELOAD_CLASSES = false; + private static final String PRELOAD_CLASSES_desc = "Pre-load all classes on recursively startup"; + + /** + * Pre-load all strings in all classes on startup. This is needed for + * JIT optimizations. This option only takes effect if PRELOAD_CLASSES + * is also on. Default to off until the JIT can actually take advantage + * of it. + */ + public static boolean PRELOAD_STRINGS = false; + private static final String PRELOAD_STRINGS_desc = "If pre-loading classes, also pre-load all strings"; + + /** + * Which shared libraries should be loaded? The format + * is libraryname[:libraryname]*. Null or "" are valid + * entries (for not loading any libraries). + */ + public static String LOAD = null; + private static final String LOAD_desc = "Load specified shared library"; + + /** + * Parses the command line. This allows the user to specify + * options also on the command line (in addition to the + * configuration file and the defaults). The name of the + * main class is the first argument that does not start with + * a "-". All arguments after the main class are returned + * and should be passed to the application. + * + * @param args arguments. Example: -BAD_PLACE_RUNTIME_CHECK=true + * @return the arguments for the application + */ + public static String[] parseCommandLine(String[] args) throws ConfigurationError { + if (args == null) + return new String[0]; + + int pos = 0; + while (pos < args.length && args[pos].length() > 0 && args[pos].charAt(0) == '-') { + if (args[pos].equals("-h") || + args[pos].equals("-help") || + args[pos].equals("--help")) + throw new ShowUsageNotification(); + // vj: added to allow the runtime to use Polyglot's report mechanism + if (args[pos].equals("-report")) { + pos++; + StringTokenizer st = new StringTokenizer(args[pos], "="); + String topic = ""; int level = 0; + if (st.hasMoreTokens()) topic = st.nextToken(); + if (st.hasMoreTokens()) { + try { + level = Integer.parseInt(st.nextToken()); + } + ... [truncated message content] |