# HG changeset patch # User Paul Woegerer # Date 1422024695 -3600 # Node ID 07f2a49f0bfbc3be6e3a535aa094a92d21f882ae # Parent f7c940b59147488800e21f4060e3b3ee17f2dd65 Various adjustments to simplify future merges diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Fri Jan 23 15:51:35 2015 +0100 @@ -234,6 +234,7 @@ private static final long serialVersionUID = 9011681879878139182L; + private boolean initialized; private int offset; public DataSectionReference() { @@ -242,10 +243,15 @@ } public int getOffset() { + assert initialized; + return offset; } public void setOffset(int offset) { + assert !initialized; + initialized = true; + this.offset = offset; } diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Fri Jan 23 15:51:35 2015 +0100 @@ -105,6 +105,28 @@ } } + /** + * Checks whether the supplied constant can be used without loading it into a register for store + * operations, i.e., on the right hand side of a memory access. + * + * @param c The constant to check. + * @return True if the constant can be used directly, false if the constant needs to be in a + * register. + */ + protected boolean canStoreConstant(JavaConstant c) { + // there is no immediate move of 64-bit constants on Intel + switch (c.getKind()) { + case Long: + return Util.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c); + case Double: + return false; + case Object: + return c.isNull(); + default: + return true; + } + } + protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { if (src instanceof AMD64AddressValue) { return new LeaOp(dst, (AMD64AddressValue) src); diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Fri Jan 23 15:51:35 2015 +0100 @@ -463,6 +463,19 @@ } } + public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) { + log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } + + /** + * @see #log(int, String, Object) + */ + public static void log(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) { + if (ENABLED) { + DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } + } + public static void logv(String format, Object... args) { logv(DEFAULT_LOG_LEVEL, format, args); } @@ -700,6 +713,48 @@ return null; } + public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3, Object arg4) { + return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4); + } + + /** + * @see #logAndIndent(int, String, Object) + */ + public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4) { + if (ENABLED) { + return logvAndIndent(logLevel, format, arg1, arg2, arg3, arg4); + } + return null; + } + + public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) { + return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5); + } + + /** + * @see #logAndIndent(int, String, Object) + */ + public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) { + if (ENABLED) { + return logvAndIndent(logLevel, format, arg1, arg2, arg3, arg4, arg5); + } + return null; + } + + public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) { + return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6); + } + + /** + * @see #logAndIndent(int, String, Object) + */ + public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) { + if (ENABLED) { + return logvAndIndent(logLevel, format, arg1, arg2, arg3, arg4, arg5, arg6); + } + return null; + } + /** * A convenience function which combines {@link #logv(int, String, Object...)} and * {@link #indent()}. diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Fri Jan 23 15:51:35 2015 +0100 @@ -51,7 +51,6 @@ import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp; import com.oracle.graal.lir.amd64.AMD64Move.StoreOp; import com.oracle.graal.lir.gen.*; -import com.oracle.graal.phases.util.*; /** * LIR generator specialized for AMD64 HotSpot. @@ -463,28 +462,6 @@ return result; } - /** - * Checks whether the supplied constant can be used without loading it into a register for store - * operations, i.e., on the right hand side of a memory access. - * - * @param c The constant to check. - * @return True if the constant can be used directly, false if the constant needs to be in a - * register. - */ - protected boolean canStoreConstant(JavaConstant c) { - // there is no immediate move of 64-bit constants on Intel - switch (c.getKind()) { - case Long: - return Util.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c); - case Double: - return false; - case Object: - return c.isNull(); - default: - return true; - } - } - @Override public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) { AMD64AddressValue storeAddress = asAddressValue(address); diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Fri Jan 23 15:51:35 2015 +0100 @@ -69,7 +69,7 @@ protected final ProfilingInfo profilingInfo; protected final OptimisticOptimizations optimisticOpts; protected final ConstantPool constantPool; - private final MetaAccessProvider metaAccess; + protected final MetaAccessProvider metaAccess; /** * Meters the number of actual bytecodes parsed. diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FullInfopointOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FullInfopointOp.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FullInfopointOp.java Fri Jan 23 15:51:35 2015 +0100 @@ -42,6 +42,7 @@ @Override public void emitCode(CompilationResultBuilder crb) { + crb.asm.ensureUniquePC(); crb.recordInfopoint(crb.asm.position(), state, reason); } } diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Fri Jan 23 15:51:35 2015 +0100 @@ -282,6 +282,10 @@ * mistakes. */ byte[] codes = method.getCode(); + if (codes == null) { + /* Graph was constructed manually. */ + return true; + } byte newCode = codes[newBci]; if (oldBci == newBci) { assert oldStackSize == newStackSize || oldDuringCall != newDuringCall : "bci is unchanged, stack depth shouldn't change"; diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java Fri Jan 23 15:51:35 2015 +0100 @@ -179,6 +179,10 @@ StateSplit stateSplit = (StateSplit) node; stateSplit.setStateAfter(state); } + if (node instanceof ForeignCallNode) { + ForeignCallNode foreign = (ForeignCallNode) node; + foreign.setBci(bci()); + } if (node == null) { assert getKind() == Kind.Void && usages().isEmpty(); graph().removeSplit(this, next()); diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/UncheckedInterfaceProvider.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/UncheckedInterfaceProvider.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/UncheckedInterfaceProvider.java Fri Jan 23 15:51:35 2015 +0100 @@ -34,7 +34,7 @@ Stamp uncheckedStamp(); static Stamp uncheckedOrNull(JavaType type, Stamp originalStamp) { - if (type instanceof ResolvedJavaType) { + if (type instanceof ResolvedJavaType && type.getKind() == Kind.Object) { Stamp unchecked = StampFactory.declaredTrusted((ResolvedJavaType) type); if (!unchecked.equals(originalStamp)) { return unchecked; diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.options/src/com/oracle/graal/options/DerivedOptionValue.java --- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/DerivedOptionValue.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/DerivedOptionValue.java Fri Jan 23 15:51:35 2015 +0100 @@ -36,12 +36,12 @@ public DerivedOptionValue(Supplier supplier) { this.supplier = supplier; - assert OptionValue.overrideScopes.get() == null : "derived option value should be initialized outside any override scope"; + assert OptionValue.getOverrideScope() == null : "derived option value should be initialized outside any override scope"; this.initialValue = createValue(); } public T getValue() { - OverrideScope overrideScope = OptionValue.overrideScopes.get(); + OverrideScope overrideScope = OptionValue.getOverrideScope(); if (overrideScope != null) { return overrideScope.getDerived(this); } else { diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java --- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java Fri Jan 23 15:51:35 2015 +0100 @@ -46,7 +46,7 @@ * */ public static OverrideScope override(OptionValue option, Object value) { - OverrideScope current = overrideScopes.get(); + OverrideScope current = getOverrideScope(); if (current == null) { if (!value.equals(option.getValue())) { return new SingleOverrideScope(option, value); @@ -76,7 +76,7 @@ * */ public static OverrideScope override(Map, Object> overrides) { - OverrideScope current = overrideScopes.get(); + OverrideScope current = getOverrideScope(); if (current == null && overrides.size() == 1) { Entry, Object> single = overrides.entrySet().iterator().next(); OptionValue option = single.getKey(); @@ -106,7 +106,7 @@ * @param overrides overrides in the form {@code [option1, override1, option2, override2, ...]} */ public static OverrideScope override(Object... overrides) { - OverrideScope current = overrideScopes.get(); + OverrideScope current = getOverrideScope(); if (current == null && overrides.length == 2) { OptionValue option = (OptionValue) overrides[0]; Object overrideValue = overrides[1]; @@ -128,7 +128,15 @@ return new MultipleOverridesScope(current, map); } - static final ThreadLocal overrideScopes = new ThreadLocal<>(); + private static final ThreadLocal overrideScopeTL = new ThreadLocal<>(); + + protected static OverrideScope getOverrideScope() { + return overrideScopeTL.get(); + } + + protected static void setOverrideScope(OverrideScope overrideScope) { + overrideScopeTL.set(overrideScope); + } private T initialValue; @@ -227,7 +235,7 @@ */ public boolean hasInitialValue() { if (!(this instanceof StableOptionValue)) { - OverrideScope overrideScope = overrideScopes.get(); + OverrideScope overrideScope = getOverrideScope(); if (overrideScope != null) { T override = overrideScope.getOverride(this); if (override != null) { @@ -246,7 +254,7 @@ reads++; } if (!(this instanceof StableOptionValue)) { - OverrideScope overrideScope = overrideScopes.get(); + OverrideScope overrideScope = getOverrideScope(); if (overrideScope != null) { T override = overrideScope.getOverride(this); if (override != null) { @@ -272,7 +280,7 @@ public Collection getValues(Collection c) { Collection values = c == null ? new ArrayList<>() : c; if (!(this instanceof StableOptionValue)) { - OverrideScope overrideScope = overrideScopes.get(); + OverrideScope overrideScope = getOverrideScope(); if (overrideScope != null) { overrideScope.getOverrides(this, (Collection) values); } @@ -334,7 +342,7 @@ } this.option = option; this.value = value; - overrideScopes.set(this); + setOverrideScope(this); } @Override @@ -360,7 +368,7 @@ @Override public void close() { - overrideScopes.set(null); + setOverrideScope(null); } } @@ -381,7 +389,7 @@ this.overrides.put(option, value); } if (!overrides.isEmpty()) { - overrideScopes.set(this); + setOverrideScope(this); } } @@ -405,7 +413,7 @@ } } if (!this.overrides.isEmpty()) { - overrideScopes.set(this); + setOverrideScope(this); } } @@ -437,7 +445,7 @@ @Override public void close() { if (!overrides.isEmpty()) { - overrideScopes.set(parent); + setOverrideScope(parent); } } } diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java Fri Jan 23 15:51:35 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -176,6 +176,22 @@ ValueNode value = box.getValue(); if (value.isConstant()) { JavaConstant sourceConstant = value.asJavaConstant(); + if (sourceConstant.getKind() != box.getBoxingKind() && sourceConstant.getKind().isNumericInteger()) { + switch (box.getBoxingKind()) { + case Boolean: + sourceConstant = JavaConstant.forBoolean(sourceConstant.asLong() != 0L); + break; + case Byte: + sourceConstant = JavaConstant.forByte((byte) sourceConstant.asLong()); + break; + case Char: + sourceConstant = JavaConstant.forChar((char) sourceConstant.asLong()); + break; + case Short: + sourceConstant = JavaConstant.forShort((short) sourceConstant.asLong()); + break; + } + } JavaConstant boxedConstant = constantReflection.boxPrimitive(sourceConstant); if (boxedConstant != null && sourceConstant.getKind() == box.getBoxingKind()) { return ConstantNode.forConstant(boxedConstant, metaAccess, box.graph()); diff -r f7c940b59147 -r 07f2a49f0bfb graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java Fri Jan 23 14:32:11 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java Fri Jan 23 15:51:35 2015 +0100 @@ -119,7 +119,7 @@ ValueNode object = loadField.isStatic() ? staticFieldBase(graph, field) : loadField.object(); Stamp loadStamp = loadStamp(loadField.stamp(), field.getKind()); ConstantLocationNode location = createFieldLocation(graph, field, false); - assert location != null : "Field that is loaded must not be eliminated"; + assert location != null : "Field that is loaded must not be eliminated: " + field.getDeclaringClass().toJavaName(true) + "." + field.getName(); ReadNode memoryRead = graph.add(new ReadNode(object, location, loadStamp, fieldLoadBarrierType(field))); ValueNode readValue = implicitLoadConvert(graph, field.getKind(), memoryRead);