Mercurial > hg > truffle
changeset 16881:f0e3b50c29c8
Merge to latest. Fixed conflicts in LineLocationToProbeCollection.
author | David Piorkowski <david.piorkowski@oracle.com> |
---|---|
date | Thu, 21 Aug 2014 13:32:11 -0700 |
parents | 7661cc464239 (current diff) b4e088bea501 (diff) |
children | 54696f15ac93 |
files | graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/LineLocationToProbeCollectionMap.java |
diffstat | 22 files changed, 400 insertions(+), 190 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java Thu Aug 21 13:32:11 2014 -0700 @@ -88,12 +88,30 @@ */ public abstract void mov(Register a, Constant src); + private static String getBitTypeFromKind(Kind kind) { + switch (kind) { + case Boolean: + case Byte: + case Short: + case Char: + case Int: + case Float: + return "b32"; + case Long: + case Double: + case Object: + return "b64"; + default: + throw GraalInternalError.shouldNotReachHere(); + } + } + public final void emitMov(Kind kind, Value dst, Value src) { if (isRegister(dst) && isConstant(src) && kind.getStackKind() == Kind.Object) { mov(asRegister(dst), asConstant(src)); } else { - String argtype = getArgTypeFromKind(kind).substring(1); - emitString("mov_b" + argtype + " " + mapRegOrConstToString(dst) + ", " + mapRegOrConstToString(src) + ";"); + String argtype = getBitTypeFromKind(kind); + emitString("mov_" + argtype + " " + mapRegOrConstToString(dst) + ", " + mapRegOrConstToString(src) + ";"); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MoreThanEightArgsTest.java Thu Aug 21 13:32:11 2014 -0700 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.compiler.hsail.test.lambda; + +import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester; + +import org.junit.*; + +public class MoreThanEightArgsTest extends GraalKernelTester { + + int[] makeIntArray(int size) { + int[] out = new int[size]; + + for (int i = 0; i < size; i++) { + out[i] = 1; + } + return out; + } + + final int rows = 4096; + final int cols = 4096; + final int loops = 2; + + @Result int[] result; + + void innerTest(int[] res, int[] a, int[] b, int[] c, int[] d, int base, int stride) { + final int resCols = a.length; + final int resRows = res.length; + final int limit = resCols - stride; + + dispatchLambdaKernel(resRows, (row) -> { + res[row] = 0; + if (a != null) { + for (int col = base; col < limit; col += 4) { + int p0 = 0; + int p1 = 0; + int p2 = 0; + int p3 = 0; + p0 = a[col] + b[col] + c[col] + d[col] + stride; + p1 = a[col + 1] + b[col + 1] + c[col + 1] + d[col + 1]; + p2 = a[col + 2] + b[col + 2] + c[col + 2] + d[col + 2]; + p3 = a[col + 3] + b[col + 3] + c[col + 3] + d[col + 3]; + res[row] += p0 + p1 + p2 + p3; + } + } + }); + } + + @Override + public void runTest() { + int[] a; + int[] b; + int[] c; + int[] d; + + result = makeIntArray(rows); + a = makeIntArray(cols); + b = makeIntArray(cols); + c = makeIntArray(cols); + d = makeIntArray(cols); + for (int i = 0; i < loops; i++) { + innerTest(result, a, b, c, d, 0, 4); + } + } + + @Test + public void test() { + testGeneratedHsail(); + } + + @Test + public void testUsingLambdaMethod() { + testGeneratedHsailUsingLambdaMethod(); + } +}
--- a/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java Thu Aug 21 13:32:11 2014 -0700 @@ -146,7 +146,8 @@ } /** - * Generates code for {@code GraalRuntime::set_option()}. + * Generates code for {@code GraalRuntime::set_option()} and + * {@code GraalRuntime::set_option_bool()}. */ private static void genSetOption(PrintStream out) throws Exception { SortedMap<String, OptionDescriptor> options = getOptions(); @@ -157,21 +158,20 @@ } lengths.add("PrintFlags".length()); - out.println("bool GraalRuntime::set_option(KlassHandle hotSpotOptionsClass, char* name, int name_len, const char* value, TRAPS) {"); + out.println("bool GraalRuntime::set_option_bool(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, char value, TRAPS) {"); out.println(" bool check_only = hotSpotOptionsClass.is_null();"); - out.println(" if (value != NULL && (value[0] == '+' || value[0] == '-')) {"); - out.println(" // boolean options"); genMatchers(out, lengths, options, true); - out.println(" } else {"); - out.println(" // non-boolean options"); + out.println(" return false;"); + out.println("}"); + out.println("bool GraalRuntime::set_option(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, const char* value, TRAPS) {"); + out.println(" bool check_only = hotSpotOptionsClass.is_null();"); genMatchers(out, lengths, options, false); - out.println(" }"); out.println(" return false;"); out.println("}"); } protected static void genMatchers(PrintStream out, Set<Integer> lengths, SortedMap<String, OptionDescriptor> options, boolean isBoolean) throws Exception { - out.println(" switch (name_len) {"); + out.println(" switch (name_len) {"); for (int len : lengths) { boolean printedCase = false; @@ -179,56 +179,56 @@ // null terminated for <name>=<value> style options. if (len == "PrintFlags".length() && isBoolean) { printedCase = true; - out.println(" case " + len + ":"); - out.printf(" if (strncmp(name, \"PrintFlags\", %d) == 0) {%n", len); - out.println(" if (value[0] == '+') {"); - out.println(" if (check_only) {"); - out.println(" TempNewSymbol name = SymbolTable::new_symbol(\"Lcom/oracle/graal/hotspot/HotSpotOptions;\", CHECK_(true));"); - out.println(" hotSpotOptionsClass = SystemDictionary::resolve_or_fail(name, true, CHECK_(true));"); - out.println(" }"); - out.println(" set_option_helper(hotSpotOptionsClass, name, name_len, Handle(), '?', Handle(), 0L);"); + out.println(" case " + len + ":"); + out.printf(" if (strncmp(name, \"PrintFlags\", %d) == 0) {%n", len); + out.println(" if (value == '+') {"); + out.println(" if (check_only) {"); + out.println(" TempNewSymbol name = SymbolTable::new_symbol(\"Lcom/oracle/graal/hotspot/HotSpotOptions;\", CHECK_(true));"); + out.println(" hotSpotOptionsClass = SystemDictionary::resolve_or_fail(name, true, CHECK_(true));"); out.println(" }"); - out.println(" return true;"); + out.println(" set_option_helper(hotSpotOptionsClass, name, name_len, Handle(), '?', Handle(), 0L);"); out.println(" }"); + out.println(" return true;"); + out.println(" }"); } for (Map.Entry<String, OptionDescriptor> e : options.entrySet()) { OptionDescriptor desc = e.getValue(); if (e.getKey().length() == len && ((desc.getType() == Boolean.class) == isBoolean)) { if (!printedCase) { printedCase = true; - out.println(" case " + len + ":"); + out.println(" case " + len + ":"); } - out.printf(" if (strncmp(name, \"%s\", %d) == 0) {%n", e.getKey(), len); + out.printf(" if (strncmp(name, \"%s\", %d) == 0) {%n", e.getKey(), len); Class<?> declaringClass = desc.getDeclaringClass(); if (isBoolean) { - out.printf(" Handle option = get_OptionValue(\"L%s;\", \"%s\", \"L%s;\", CHECK_(true));%n", toInternalName(declaringClass), desc.getFieldName(), + out.printf(" Handle option = get_OptionValue(\"L%s;\", \"%s\", \"L%s;\", CHECK_(true));%n", toInternalName(declaringClass), desc.getFieldName(), + toInternalName(getFieldType(desc))); + out.println(" if (!check_only) {"); + out.println(" set_option_helper(hotSpotOptionsClass, name, name_len, option, value, Handle(), 0L);"); + out.println(" }"); + } else if (desc.getType() == String.class) { + out.println(" check_required_value(name, name_len, value, CHECK_(true));"); + out.printf(" Handle option = get_OptionValue(\"L%s;\", \"%s\", \"L%s;\", CHECK_(true));%n", toInternalName(declaringClass), desc.getFieldName(), toInternalName(getFieldType(desc))); - out.println(" if (!check_only) {"); - out.println(" set_option_helper(hotSpotOptionsClass, name, name_len, option, value[0], Handle(), 0L);"); - out.println(" }"); - } else if (desc.getType() == String.class) { - out.println(" check_required_value(name, name_len, value, CHECK_(true));"); + out.println(" if (!check_only) {"); + out.println(" Handle stringValue = java_lang_String::create_from_str(value, CHECK_(true));"); + out.println(" set_option_helper(hotSpotOptionsClass, name, name_len, option, 's', stringValue, 0L);"); + out.println(" }"); + } else { + char spec = getPrimitiveSpecChar(desc); + out.println(" jlong primitiveValue = parse_primitive_option_value('" + spec + "', name, name_len, value, CHECK_(true));"); + out.println(" if (!check_only) {"); out.printf(" Handle option = get_OptionValue(\"L%s;\", \"%s\", \"L%s;\", CHECK_(true));%n", toInternalName(declaringClass), desc.getFieldName(), toInternalName(getFieldType(desc))); - out.println(" if (!check_only) {"); - out.println(" Handle stringValue = java_lang_String::create_from_str(value, CHECK_(true));"); - out.println(" set_option_helper(hotSpotOptionsClass, name, name_len, option, 's', stringValue, 0L);"); - out.println(" }"); - } else { - char spec = getPrimitiveSpecChar(desc); - out.println(" jlong primitiveValue = parse_primitive_option_value('" + spec + "', name, name_len, value, CHECK_(true));"); - out.println(" if (!check_only) {"); - out.printf(" Handle option = get_OptionValue(\"L%s;\", \"%s\", \"L%s;\", CHECK_(true));%n", toInternalName(declaringClass), desc.getFieldName(), - toInternalName(getFieldType(desc))); - out.println(" set_option_helper(hotSpotOptionsClass, name, name_len, option, '" + spec + "', Handle(), primitiveValue);"); - out.println(" }"); + out.println(" set_option_helper(hotSpotOptionsClass, name, name_len, option, '" + spec + "', Handle(), primitiveValue);"); + out.println(" }"); } - out.println(" return true;"); - out.println(" }"); + out.println(" return true;"); + out.println(" }"); } } } - out.println(" }"); + out.println(" }"); } @SuppressWarnings("unchecked")
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Thu Aug 21 13:32:11 2014 -0700 @@ -42,7 +42,6 @@ import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.options.*; import com.oracle.graal.options.OptionValue.OverrideScope; -import com.oracle.graal.phases.tiers.*; import com.oracle.graal.replacements.*; /** @@ -237,79 +236,81 @@ private void compile(String fileList) throws Throwable { final String[] entries = fileList.split(File.pathSeparator); - for (int i = 0; i < entries.length; i++) { - final String entry = entries[i]; - - // For now we only compile all methods in all classes in zip/jar files. - if (!entry.endsWith(".zip") && !entry.endsWith(".jar")) { - println("CompileTheWorld : Skipped classes in " + entry); - println(); - continue; - } + try (AutoCloseable s = config.apply()) { + for (int i = 0; i < entries.length; i++) { + final String entry = entries[i]; - println("CompileTheWorld : Compiling all classes in " + entry); - println(); - - URL url = new URL("jar", "", "file:" + entry + "!/"); - ClassLoader loader = new URLClassLoader(new URL[]{url}); - - JarFile jarFile = new JarFile(entry); - Enumeration<JarEntry> e = jarFile.entries(); - - while (e.hasMoreElements()) { - JarEntry je = e.nextElement(); - if (je.isDirectory() || !je.getName().endsWith(".class")) { + // For now we only compile all methods in all classes in zip/jar files. + if (!entry.endsWith(".zip") && !entry.endsWith(".jar")) { + println("CompileTheWorld : Skipped classes in " + entry); + println(); continue; } - // Are we done? - if (classFileCounter >= stopAt) { - break; - } + println("CompileTheWorld : Compiling all classes in " + entry); + println(); - String className = je.getName().substring(0, je.getName().length() - ".class".length()); - classFileCounter++; + URL url = new URL("jar", "", "file:" + entry + "!/"); + ClassLoader loader = new URLClassLoader(new URL[]{url}); + + JarFile jarFile = new JarFile(entry); + Enumeration<JarEntry> e = jarFile.entries(); - try (AutoCloseable s = config.apply()) { - // Load and initialize class - Class<?> javaClass = Class.forName(className.replace('/', '.'), true, loader); + while (e.hasMoreElements()) { + JarEntry je = e.nextElement(); + if (je.isDirectory() || !je.getName().endsWith(".class")) { + continue; + } - // Pre-load all classes in the constant pool. - try { - HotSpotResolvedObjectType objectType = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(javaClass); - ConstantPool constantPool = objectType.constantPool(); - for (int cpi = 1; cpi < constantPool.length(); cpi++) { - constantPool.loadReferencedType(cpi, Bytecodes.LDC); - } - } catch (Throwable t) { - // If something went wrong during pre-loading we just ignore it. - println("Preloading failed for (%d) %s", classFileCounter, className); + // Are we done? + if (classFileCounter >= stopAt) { + break; } - // Are we compiling this class? - HotSpotMetaAccessProvider metaAccess = runtime.getHostProviders().getMetaAccess(); - if (classFileCounter >= startAt) { - println("CompileTheWorld (%d) : %s", classFileCounter, className); + String className = je.getName().substring(0, je.getName().length() - ".class".length()); + classFileCounter++; + + try { + // Load and initialize class + Class<?> javaClass = Class.forName(className.replace('/', '.'), true, loader); - // Compile each constructor/method in the class. - for (Constructor<?> constructor : javaClass.getDeclaredConstructors()) { - HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaConstructor(constructor); - if (canBeCompiled(javaMethod, constructor.getModifiers())) { - compileMethod(javaMethod); + // Pre-load all classes in the constant pool. + try { + HotSpotResolvedObjectType objectType = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(javaClass); + ConstantPool constantPool = objectType.constantPool(); + for (int cpi = 1; cpi < constantPool.length(); cpi++) { + constantPool.loadReferencedType(cpi, Bytecodes.LDC); + } + } catch (Throwable t) { + // If something went wrong during pre-loading we just ignore it. + println("Preloading failed for (%d) %s", classFileCounter, className); + } + + // Are we compiling this class? + HotSpotMetaAccessProvider metaAccess = runtime.getHostProviders().getMetaAccess(); + if (classFileCounter >= startAt) { + println("CompileTheWorld (%d) : %s", classFileCounter, className); + + // Compile each constructor/method in the class. + for (Constructor<?> constructor : javaClass.getDeclaredConstructors()) { + HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaConstructor(constructor); + if (canBeCompiled(javaMethod, constructor.getModifiers())) { + compileMethod(javaMethod); + } + } + for (Method method : javaClass.getDeclaredMethods()) { + HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method); + if (canBeCompiled(javaMethod, method.getModifiers())) { + compileMethod(javaMethod); + } } } - for (Method method : javaClass.getDeclaredMethods()) { - HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method); - if (canBeCompiled(javaMethod, method.getModifiers())) { - compileMethod(javaMethod); - } - } + } catch (Throwable t) { + println("CompileTheWorld (%d) : Skipping %s", classFileCounter, className); } - } catch (Throwable t) { - println("CompileTheWorld (%d) : Skipping %s", classFileCounter, className); } + jarFile.close(); } - jarFile.close(); } println(); @@ -323,16 +324,6 @@ } /** - * Returns a fresh compilation suite for its compilation so that the CTW option value - * overriding configuration has effect. - */ - @Override - protected Suites getSuites(HotSpotProviders providers) { - assert config.scope != null : "not inside a CTW option value overriding scope"; - return providers.getSuites().createSuites(); - } - - /** * Returns empty profiling info to be as close to the CTW behavior of C1 and C2 as possible. */ @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Thu Aug 21 13:32:11 2014 -0700 @@ -27,6 +27,7 @@ import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.java.*; +import com.oracle.graal.options.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.tiers.*; @@ -35,18 +36,18 @@ */ public class HotSpotSuitesProvider implements SuitesProvider { - protected final Suites defaultSuites; + protected final DerivedOptionValue<Suites> defaultSuites; protected final PhaseSuite<HighTierContext> defaultGraphBuilderSuite; protected final HotSpotGraalRuntime runtime; public HotSpotSuitesProvider(HotSpotGraalRuntime runtime) { this.runtime = runtime; this.defaultGraphBuilderSuite = createGraphBuilderSuite(); - defaultSuites = createSuites(); + this.defaultSuites = new DerivedOptionValue<>(this::createSuites); } public Suites getDefaultSuites() { - return defaultSuites; + return defaultSuites.getValue(); } public PhaseSuite<HighTierContext> getDefaultGraphBuilderSuite() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Thu Aug 21 13:32:11 2014 -0700 @@ -88,7 +88,7 @@ @Override public HotSpotNativeFunctionHandle getFunctionHandle(NativeLibraryHandle library, String name, Class<?> returnType, Class<?>... argumentTypes) { - HotSpotNativeFunctionPointer functionPointer = lookupFunctionPointer(name, library, true); + HotSpotNativeFunctionPointer functionPointer = lookupFunctionPointer(name, library, false); return createHandle(functionPointer, returnType, argumentTypes); } @@ -179,7 +179,7 @@ if (rtldDefault == null) { throw new UnsatisfiedLinkError(name); } - return lookupFunctionPointer(name, rtldDefault, true); + return lookupFunctionPointer(name, rtldDefault, false); } public boolean isDefaultLibrarySearchSupported() {
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Thu Aug 21 13:32:11 2014 -0700 @@ -22,21 +22,22 @@ */ package com.oracle.graal.java; +import com.oracle.graal.options.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.tiers.*; public class DefaultSuitesProvider implements SuitesProvider { - private final Suites defaultSuites; + private final DerivedOptionValue<Suites> defaultSuites; private final PhaseSuite<HighTierContext> defaultGraphBuilderSuite; public DefaultSuitesProvider() { this.defaultGraphBuilderSuite = createGraphBuilderSuite(); - this.defaultSuites = createSuites(); + this.defaultSuites = new DerivedOptionValue<>(this::createSuites); } public Suites getDefaultSuites() { - return defaultSuites; + return defaultSuites.getValue(); } public Suites createSuites() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/DerivedOptionValue.java Thu Aug 21 13:32:11 2014 -0700 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.options; + +import java.util.function.*; + +import com.oracle.graal.options.OptionValue.OverrideScope; + +/** + * A cached value that needs to be recomputed when an option changes. + */ +public class DerivedOptionValue<T> { + + private final T initialValue; + private final Supplier<T> supplier; + + public DerivedOptionValue(Supplier<T> supplier) { + this.supplier = supplier; + assert OptionValue.overrideScopes.get() == null : "derived option value should be initialized outside any override scope"; + this.initialValue = createValue(); + } + + public T getValue() { + OverrideScope overrideScope = OptionValue.overrideScopes.get(); + if (overrideScope != null) { + return overrideScope.getDerived(this); + } else { + return initialValue; + } + } + + T createValue() { + return supplier.get(); + } +}
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java Thu Aug 21 13:32:11 2014 -0700 @@ -128,7 +128,7 @@ return new MultipleOverridesScope(current, map); } - private static final ThreadLocal<OverrideScope> overrideScopes = new ThreadLocal<>(); + static final ThreadLocal<OverrideScope> overrideScopes = new ThreadLocal<>(); /** * The raw option value. @@ -252,6 +252,22 @@ * {@link OptionValue#override(OptionValue, Object)} or {@link OptionValue#override(Map)}. */ public abstract static class OverrideScope implements AutoCloseable { + + private Map<DerivedOptionValue<?>, Object> derivedCache = null; + + public <T> T getDerived(DerivedOptionValue<T> key) { + if (derivedCache == null) { + derivedCache = new HashMap<>(); + } + @SuppressWarnings("unchecked") + T ret = (T) derivedCache.get(key); + if (ret == null) { + ret = key.createValue(); + derivedCache.put(key, ret); + } + return ret; + } + abstract void addToInherited(Map<OptionValue<?>, Object> inherited); abstract <T> T getOverride(OptionValue<T> option);
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java Thu Aug 21 13:32:11 2014 -0700 @@ -83,26 +83,19 @@ } } - if (CompilerConfiguration.getValue().equals("")) { - if (nonBasicCount == 1) { - /* - * There is exactly one non-basic configuration. We use this one as default. - */ - defaultConfiguration = nonBasic; - } else { - /* - * There is either no extended configuration available, or more than one. In that - * case, default to "basic". - */ - defaultConfiguration = basic; - if (defaultConfiguration == null) { - throw new GraalInternalError("unable to find basic compiler configuration"); - } - } + if (nonBasicCount == 1) { + /* + * There is exactly one non-basic configuration. We use this one as default. + */ + defaultConfiguration = nonBasic; } else { - defaultConfiguration = configurations.get(CompilerConfiguration.getValue()); + /* + * There is either no extended configuration available, or more than one. In that case, + * default to "basic". + */ + defaultConfiguration = basic; if (defaultConfiguration == null) { - throw new GraalInternalError("unknown compiler configuration: " + CompilerConfiguration.getValue()); + throw new GraalInternalError("unable to find basic compiler configuration"); } } } @@ -120,7 +113,12 @@ } public static Suites createDefaultSuites() { - return new Suites(defaultConfiguration); + String selected = CompilerConfiguration.getValue(); + if (selected.equals("")) { + return new Suites(defaultConfiguration); + } else { + return createSuites(selected); + } } public static Suites createSuites(String name) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java Thu Aug 21 13:32:11 2014 -0700 @@ -117,7 +117,7 @@ } public static ValueNode getMaterializedRepresentationHelper(VirtualObjectNode virtualNode, FixedNode fixed) { - if (fixed instanceof MaterializeFrameNode || fixed instanceof AbstractEndNode) { + if (fixed instanceof MaterializeFrameNode || fixed instanceof AbstractEndNode || fixed instanceof ForceMaterializeNode) { // We need to conservatively assume that a materialization of a virtual frame can also // happen at a merge point. return new AllocatedObjectNode(virtualNode);
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Assumption.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Assumption.java Thu Aug 21 13:32:11 2014 -0700 @@ -34,6 +34,9 @@ * method. The Truffle compiler has special knowledge of this class in order to produce efficient * machine code for checking an assumption in case the assumption object is a compile time constant. * Therefore, assumptions should be stored in final fields in Truffle nodes. + * + * All instances of classes implementing {@code Assumption} must be held in {@code final} fields for + * compiler optimizations to take effect. */ public interface Assumption { @@ -42,14 +45,14 @@ * longer the case. This method is preferred over the {@link #isValid()} method when writing * guest language interpreter code. The catch block should perform a node rewrite (see * {@link Node#replace(Node)}) with a node that no longer relies on the assumption. - * + * * @throws InvalidAssumptionException If the assumption is no longer valid. */ void check() throws InvalidAssumptionException; /** * Checks whether the assumption is still valid. - * + * * @return a boolean value indicating the validity of the assumption */ boolean isValid(); @@ -61,7 +64,7 @@ /** * A name for the assumption that is used for debug output. - * + * * @return the name of the assumption */ String getName();
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/LineLocationToProbeCollectionMap.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/LineLocationToProbeCollectionMap.java Thu Aug 21 13:32:11 2014 -0700 @@ -34,6 +34,7 @@ * a collection of {@link Probe}s whose associated {@link SourceSection} starts on that line. */ public class LineLocationToProbeCollectionMap implements ProbeListener { + /** * Map: Source line ==> probes associated with source sections starting on the line. */ @@ -69,7 +70,7 @@ } /** - * Adds a probe to the given line. + * Records creation of a probe whose associated source starts on the given line. * <p> * If the line already exists in the internal {@link #lineToProbesMap}, this probe will be added * to the existing collection. If no line already exists in the internal map, then a new key is @@ -97,11 +98,12 @@ } /** - * Returns a collection of {@link Probe}s at the given {@link LineLocation}. If there are no - * probes at that line, a new empty list of size 1 is returned. + * + * Returns a collection of {@link Probe}s whose associated source begins at the given + * {@link LineLocation}. If there are no probes at that line, an empty list is returned. * * @param line The line to check. - * @return A iterable collection of probes at the given line. + * @return A collection of probes at the given line. */ public Collection<Probe> getProbesAtLine(LineLocation line) { Collection<Probe> probeList = lineToProbesMap.get(line);
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/ProbeManager.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/ProbeManager.java Thu Aug 21 13:32:11 2014 -0700 @@ -43,10 +43,6 @@ /** * Called when a {@link #tagTrap} is activated in a Probe. */ - /** - * The callback to be triggered by the {@link #tagTrap}. - * - */ private final ProbeCallback probeCallback; /** @@ -72,9 +68,7 @@ } /** - * Add a {@link ProbeListener} to receive events. - * - * @param listener The listener to be added. + * Adds a {@link ProbeListener} to receive events. */ public void addProbeListener(ProbeListener listener) { assert listener != null; @@ -82,9 +76,7 @@ } /** - * Remove a {@link ProbeListener}. If no matching probe listener is found, nothing happens. - * - * @param removeListener + * Removes a {@link ProbeListener}. Ignored if listener not found. */ public void removeProbeListener(ProbeListener removeListener) { final List<ProbeListener> listeners = new ArrayList<>(probeListeners); @@ -97,10 +89,7 @@ /** * Creates a new {@link Probe} associated with a {@link SourceSection} of code corresponding to - * a Trufle AST node. - * - * @param source The source section to associate with this probe. - * @return The probe that was created. + * a Truffle AST node. */ public Probe createProbe(SourceSection source) { assert source != null; @@ -119,7 +108,7 @@ * Returns the subset of all {@link Probe}s holding a particular {@link SyntaxTag}, or the whole * collection if the specified tag is {@code null}. * - * @return An iterable collection of probes containing the given tag. + * @return A collection of probes containing the given tag. */ public Collection<Probe> findProbesTaggedAs(SyntaxTag tag) { final List<Probe> probes = new ArrayList<>(); @@ -132,8 +121,10 @@ } /** - * Calls {@link ProbeImpl#setTrap(SyntaxTagTrap)} for all probes with the given - * {@link SyntaxTag} . There can only be one tag trap set at a time. + * Sets the current "tag trap", which will cause a callback to be triggered whenever execution + * reaches a Probe (existing or subsequently created) with the specified tag. There can only be + * one tag trap set at a time. + * <p> * * @param tagTrap The {@link SyntaxTagTrap} to set. * @throws IllegalStateException if a trap is currently set.
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java Thu Aug 21 13:32:11 2014 -0700 @@ -32,6 +32,9 @@ * invoked first the optimized code is invalidated and the branch where {@link #enter()} is invoked * is enabled for compilation. Otherwise if the {@link #enter()} method was never invoked the branch * will not get compiled. + * + * All {@code BranchProfile} instances must be held in {@code final} fields for compiler + * optimizations to take effect. */ public final class BranchProfile {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ConditionProfile.java Thu Aug 21 13:28:22 2014 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ConditionProfile.java Thu Aug 21 13:32:11 2014 -0700 @@ -34,7 +34,7 @@ * * <pre> * private final ConditionProfile zero = ConditionProfile.createBinaryProfile(); - * + * * int value = ...; * if (zero.profile(value == 0)) { * return 0; @@ -44,6 +44,9 @@ * * </pre> * + * All instances of {@code ConditionProfile} (and subclasses) must be held in {@code final} fields + * for compiler optimizations to take effect. + * * @see #createCountingProfile() * @see #createBinaryProfile() */
--- a/mx/mx_graal.py Thu Aug 21 13:28:22 2014 -0700 +++ b/mx/mx_graal.py Thu Aug 21 13:32:11 2014 -0700 @@ -459,10 +459,14 @@ _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') if installJars: - _installDistInJdks(mx.distribution('GRAAL')) - _installDistInJdks(mx.distribution('GRAAL_LOADER')) - _installDistInJdks(mx.distribution('TRUFFLE')) - _installDistInJdks(mx.distribution('GRAAL_TRUFFLE')) + def _installDistInJdksIfExists(dist): + if exists(dist.path): + _installDistInJdks(dist) + + _installDistInJdksIfExists(mx.distribution('GRAAL')) + _installDistInJdksIfExists(mx.distribution('GRAAL_LOADER')) + _installDistInJdksIfExists(mx.distribution('TRUFFLE')) + _installDistInJdksIfExists(mx.distribution('GRAAL_TRUFFLE')) if vmToCheck is not None: jvmCfg = _vmCfgInJdk(jdk) @@ -770,7 +774,7 @@ if build is None or len(build) == 0: continue - jdk = _jdk(build, create=True, installJars=not opts2.java) + jdk = _jdk(build, create=True, installJars=vm != 'original' and not opts2.java) if vm == 'original': if build != 'product': @@ -986,6 +990,10 @@ if len(ignoredArgs) > 0: mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) + if vm == 'original': + truffle_jar = mx.archive(['@TRUFFLE'])[0] + args = ['-Xbootclasspath/p:' + truffle_jar] + args + args = mx.java().processArgs(args) return (pfx, exe, vm, args, cwd)
--- a/mxtool/mx.py Thu Aug 21 13:28:22 2014 -0700 +++ b/mxtool/mx.py Thu Aug 21 13:32:11 2014 -0700 @@ -2516,9 +2516,10 @@ log('Compiling {} failed'.format(t.proj.name)) abort('{} Java compilation tasks failed'.format(len(failed))) - for dist in sorted_dists(): - if dist not in updatedAnnotationProcessorDists: - archive(['@' + dist.name]) + if args.java: + for dist in sorted_dists(): + if dist not in updatedAnnotationProcessorDists: + archive(['@' + dist.name]) if suppliedParser: return args
--- a/src/gpu/hsail/vm/gpu_hsail.cpp Thu Aug 21 13:28:22 2014 -0700 +++ b/src/gpu/hsail/vm/gpu_hsail.cpp Thu Aug 21 13:32:11 2014 -0700 @@ -140,6 +140,8 @@ jint num_tlabs, int allocBytesPerWorkitem, jobject oop_map_array, TRAPS) { ResourceMark rm(THREAD); objArrayOop argsArray = (objArrayOop) JNIHandles::resolve(args); + // Note this length does not include the iteration variable since it is replaced by the HSA workitemid + int argsArrayLength = argsArray->length(); assert(THREAD->is_Java_thread(), "must be a JavaThread"); // We avoid HSAILAllocationInfo logic if kernel does not allocate @@ -296,7 +298,8 @@ KlassHandle methKlass = mh->method_holder(); Thread* THREAD = Thread::current(); JavaValue result(T_VOID); - JavaCallArguments javaArgs; + // Add the iteration variable to the HSA args length + JavaCallArguments javaArgs(argsArrayLength + 1); // re-resolve the args_handle here objArrayOop resolvedArgsArray = (objArrayOop) JNIHandles::resolve(args); @@ -344,8 +347,11 @@ // The kernel entrypoint is always run for the time being const char* entryPointName = "&run"; jlong okra_kernel; - jint okra_status = _okra_create_kernel(_device_context, code, entryPointName, (void**)&okra_kernel); - guarantee(okra_status==0, "_okra_create_kernel failed"); + { + TraceTime t("generate kernel ", TraceGPUInteraction); + jint okra_status = _okra_create_kernel(_device_context, code, entryPointName, (void**)&okra_kernel); + guarantee(okra_status==0, "_okra_create_kernel failed"); + } return (jlong) okra_kernel; GPU_END
--- a/src/share/vm/graal/graalRuntime.cpp Thu Aug 21 13:28:22 2014 -0700 +++ b/src/share/vm/graal/graalRuntime.cpp Thu Aug 21 13:32:11 2014 -0700 @@ -728,7 +728,8 @@ JVM_ENTRY(jboolean, JVM_ParseGraalOptions(JNIEnv *env, jclass c)) HandleMark hm; KlassHandle hotSpotOptionsClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(c))); - return GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_false); + bool result = GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_false); + return result; JVM_END jint GraalRuntime::check_arguments(TRAPS) { @@ -774,7 +775,7 @@ return CITime || CITimeEach; } -void GraalRuntime::check_required_value(const char* name, int name_len, const char* value, TRAPS) { +void GraalRuntime::check_required_value(const char* name, size_t name_len, const char* value, TRAPS) { if (value == NULL) { char buf[200]; jio_snprintf(buf, sizeof(buf), "Must use '-G:%.*s=<value>' format for %.*s option", name_len, name, name_len, name); @@ -790,7 +791,7 @@ if (first == '+' || first == '-') { name = arg + 1; name_len = strlen(name); - recognized = set_option(hotSpotOptionsClass, name, (int)name_len, arg, CHECK); + recognized = set_option_bool(hotSpotOptionsClass, name, name_len, first, CHECK); } else { char* sep = strchr(arg, '='); name = arg; @@ -801,13 +802,13 @@ } else { name_len = strlen(name); } - recognized = set_option(hotSpotOptionsClass, name, (int)name_len, value, CHECK); + recognized = set_option(hotSpotOptionsClass, name, name_len, value, CHECK); } if (!recognized) { bool throw_err = hotSpotOptionsClass.is_null(); if (!hotSpotOptionsClass.is_null()) { - set_option_helper(hotSpotOptionsClass, name, (int)name_len, Handle(), ' ', Handle(), 0L); + set_option_helper(hotSpotOptionsClass, name, name_len, Handle(), ' ', Handle(), 0L); if (!HAS_PENDING_EXCEPTION) { throw_err = true; } @@ -823,7 +824,7 @@ void GraalRuntime::parse_graal_options_file(KlassHandle hotSpotOptionsClass, TRAPS) { const char* home = Arguments::get_java_home(); - int path_len = (int)strlen(home) + (int)strlen("/lib/graal.options") + 1; + size_t path_len = strlen(home) + strlen("/lib/graal.options") + 1; char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); char sep = os::file_separator()[0]; sprintf(path, "%s%clib%cgraal.options", home, sep, sep); @@ -868,7 +869,7 @@ } } -jlong GraalRuntime::parse_primitive_option_value(char spec, const char* name, int name_len, const char* value, TRAPS) { +jlong GraalRuntime::parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS) { check_required_value(name, name_len, value, CHECK_(0L)); union { jint i; @@ -905,11 +906,11 @@ THROW_MSG_(vmSymbols::java_lang_InternalError(), buf, 0L); } -void GraalRuntime::set_option_helper(KlassHandle hotSpotOptionsClass, char* name, int name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) { +void GraalRuntime::set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) { Thread* THREAD = Thread::current(); Handle name_handle; if (name != NULL) { - if ((int) strlen(name) > name_len) { + if (strlen(name) > name_len) { // Temporarily replace '=' with NULL to create the Java string for the option name char save = name[name_len]; name[name_len] = '\0'; @@ -919,7 +920,7 @@ return; } } else { - assert((int) strlen(name) == name_len, "must be"); + assert(strlen(name) == name_len, "must be"); name_handle = java_lang_String::create_from_str(name, CHECK); } }
--- a/src/share/vm/graal/graalRuntime.hpp Thu Aug 21 13:28:22 2014 -0700 +++ b/src/share/vm/graal/graalRuntime.hpp Thu Aug 21 13:32:11 2014 -0700 @@ -52,7 +52,7 @@ * @param value string value to parse * @throws InternalError if value could not be parsed according to spec */ - static jlong parse_primitive_option_value(char spec, const char* name, int name_len, const char* value, TRAPS); + static jlong parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS); /** * Loads default option value overrides from a <jre_home>/lib/graal.options if it exists. Each @@ -70,6 +70,21 @@ static void parse_argument(KlassHandle hotSpotOptionsClass, char* arg, TRAPS); /** + * Searches for a Boolean Graal option denoted by a given name and sets it value. + * + * The definition of this method is in graalRuntime.inline.hpp + * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp. + * + * @param hotSpotOptionsClass the HotSpotOptions klass or NULL if only checking for valid option + * @param name option name + * @param name_len length of option name + * @param value '+' to set the option, '-' to reset the option + * @returns true if the option was found + * @throws InternalError if there was a problem setting the option's value + */ + static bool set_option_bool(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, char value, TRAPS); + + /** * Searches for a Graal option denoted by a given name and sets it value. * * The definition of this method is in graalRuntime.inline.hpp @@ -81,12 +96,12 @@ * @returns true if the option was found * @throws InternalError if there was a problem setting the option's value */ - static bool set_option(KlassHandle hotSpotOptionsClass, char* name, int name_len, const char* value, TRAPS); + static bool set_option(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, const char* value, TRAPS); /** * Raises an InternalError for an option that expects a value but was specified without a "=<value>" prefix. */ - static void check_required_value(const char* name, int name_len, const char* value, TRAPS); + static void check_required_value(const char* name, size_t name_len, const char* value, TRAPS); /** * Java call to HotSpotOptions.setOption(String name, OptionValue<?> option, char spec, String stringValue, long primitiveValue) @@ -94,7 +109,7 @@ * @param name option name * @param name_len length of option name */ - static void set_option_helper(KlassHandle hotSpotOptionsClass, char* name, int name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue); + static void set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue); /** * Instantiates a service object, calls its default constructor and returns it.