# HG changeset patch # User Michael Van De Vanter # Date 1387365199 28800 # Node ID f45452c87b52ab490b3f7c932191f6abe73406f3 # Parent d3f662f9b7d6edff45003ea28a22a888d2e19327# Parent 40530019af024ad7ac77c392a161a6ad91ed50cb Merge with 40530019af024ad7ac77c392a161a6ad91ed50cb diff -r d3f662f9b7d6 -r f45452c87b52 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Tue Dec 17 22:26:33 2013 -0800 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Wed Dec 18 03:13:19 2013 -0800 @@ -1655,11 +1655,25 @@ } if (isIllegal(interval.location()) && interval.canMaterialize()) { + assert mode != OperandMode.DEF; return interval.getMaterializedValue(); } return interval.location(); } + private boolean isMaterialized(AllocatableValue operand, int opId, OperandMode mode) { + Interval interval = intervalFor(operand); + assert interval != null : "interval must exist"; + + if (opId != -1) { + // operands are not changed when an interval is split during allocation, + // so search the right interval here + interval = splitChildAtOpId(interval, opId, mode); + } + + return isIllegal(interval.location()) && interval.canMaterialize(); + } + protected IntervalWalker initIntervalWalker(IntervalPredicate predicate) { // setup lists of potential oops for walking Interval oopIntervals; @@ -1776,6 +1790,23 @@ continue; } + // remove useless moves + MoveOp move = null; + if (op instanceof MoveOp) { + move = (MoveOp) op; + AllocatableValue result = move.getResult(); + if (isVariable(result) && isMaterialized(result, op.id(), OperandMode.DEF)) { + /* + * This happens if a materializable interval is originally not spilled but then + * kicked out in LinearScanWalker.splitForSpilling(). When kicking out such an + * interval this move operation was already generated. + */ + instructions.set(j, null); + hasDead = true; + continue; + } + } + ValueProcedure assignProc = new ValueProcedure() { @Override @@ -1802,8 +1833,7 @@ }); // remove useless moves - if (op instanceof MoveOp) { - MoveOp move = (MoveOp) op; + if (move != null) { if (move.getInput().equals(move.getResult())) { instructions.set(j, null); hasDead = true; @@ -1878,14 +1908,7 @@ printLir("After register number assignment", true); EdgeMoveOptimizer.optimize(ir); ControlFlowOptimizer.optimize(ir); - - /* - * Temporarily disabled because of problem in specjvm2008. TODO: fix the problem and - * re-enable it. - * - * RedundantMoveElimination.optimize(ir, frameMap, gen.getGraph().method()); - */ - + RedundantMoveElimination.optimize(ir, frameMap, gen.getGraph().method()); NullCheckOptimizer.optimize(ir, target.implicitNullCheckLimit); printLir("After control flow optimization", false); } catch (Throwable e) { diff -r d3f662f9b7d6 -r f45452c87b52 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Tue Dec 17 22:26:33 2013 -0800 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Wed Dec 18 03:13:19 2013 -0800 @@ -197,6 +197,12 @@ * can only be a {@link Constant}. */ public Constant getMaterializedValue(LIRInstruction op, Value operand) { + if (op instanceof MoveOp) { + MoveOp move = (MoveOp) op; + if (move.getInput() instanceof Constant) { + return (Constant) move.getInput(); + } + } return null; } diff -r d3f662f9b7d6 -r f45452c87b52 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.java Tue Dec 17 22:26:33 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.java Wed Dec 18 03:13:19 2013 -0800 @@ -61,13 +61,10 @@ /** * Creates a resolved Java type. * - * @param metaspaceKlass the metaspace Klass object for the type - * @param name the {@linkplain JavaType#getName() name} of the type - * @param simpleName a simple, unqualified name for the type * @param javaMirror the {@link Class} mirror * @return the resolved type associated with {@code javaMirror} which may not be the type * instantiated by this call in the case of another thread racing to create the same * type */ - ResolvedJavaType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, int sizeOrSpecies); + ResolvedJavaType createResolvedJavaType(Class javaMirror); } diff -r d3f662f9b7d6 -r f45452c87b52 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Tue Dec 17 22:26:33 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Wed Dec 18 03:13:19 2013 -0800 @@ -679,15 +679,8 @@ } @Override - public HotSpotResolvedObjectType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, int sizeOrSpecies) { - HotSpotResolvedObjectType type = new HotSpotResolvedObjectType(metaspaceKlass, name, simpleName, javaMirror, sizeOrSpecies); - - long offset = runtime().getConfig().graalMirrorInClassOffset; - if (!unsafe.compareAndSwapObject(javaMirror, offset, null, type)) { - // lost the race - return the existing value instead - type = (HotSpotResolvedObjectType) unsafe.getObject(javaMirror, offset); - } - return type; + public ResolvedJavaType createResolvedJavaType(Class javaMirror) { + return HotSpotResolvedObjectType.fromClass(javaMirror); } public PhasePlan createPhasePlan(HotSpotProviders providers, OptimisticOptimizations optimisticOpts, boolean onStackReplacement) { diff -r d3f662f9b7d6 -r f45452c87b52 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Tue Dec 17 22:26:33 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Wed Dec 18 03:13:19 2013 -0800 @@ -109,13 +109,6 @@ return type; } - public HotSpotResolvedObjectType(long metaspaceKlass, String name, String simpleName, Class javaMirror, int sizeOrSpecies) { - super(name); - assert HotSpotGraalRuntime.unsafeReadWord(javaMirror, runtime().getConfig().klassOffset) == metaspaceKlass; - this.javaClass = javaMirror; - assert name.charAt(0) != '[' || isArray() : name + " " + simpleName + " " + Long.toHexString(sizeOrSpecies); - } - /** * Creates the Graal mirror for a {@link Class} object. * diff -r d3f662f9b7d6 -r f45452c87b52 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Tue Dec 17 22:26:33 2013 -0800 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Wed Dec 18 03:13:19 2013 -0800 @@ -297,6 +297,7 @@ int sourceIdx = getStateIdx(moveOp.getInput()); int destIdx = getStateIdx(moveOp.getResult()); if (sourceIdx >= 0 && destIdx >= 0) { + assert isObjectValue(state[sourceIdx]) || (moveOp.getInput().getKind() != Kind.Object) : "move op moves object but input is not defined as object"; state[destIdx] = state[sourceIdx]; indent.log("move value %d from %d to %d", state[sourceIdx], sourceIdx, destIdx); return initValueNum; @@ -342,8 +343,13 @@ } OutputValueProc outputValueProc = new OutputValueProc(valueNum); + + op.forEachTemp(outputValueProc); + /* + * Semantically the output values are written _after_ the temp values + */ op.forEachOutput(outputValueProc); - op.forEachTemp(outputValueProc); + valueNum = outputValueProc.opValueNum; if (op.hasState()) { @@ -351,6 +357,9 @@ * All instructions with framestates (mostly method calls), may do garbage * collection. GC will rewrite all object references which are live at this point. * So we can't rely on their values. + * + * It would be sufficient to just kill all values which are referenced in the state + * (or all values which are not), but for simplicity we kill all values. */ indent.log("kill all object values"); clearValuesOfKindObject(state, valueNum); diff -r d3f662f9b7d6 -r f45452c87b52 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Tue Dec 17 22:26:33 2013 -0800 +++ b/src/share/vm/classfile/vmSymbols.hpp Wed Dec 18 03:13:19 2013 -0800 @@ -369,7 +369,7 @@ template(createUnresolvedJavaType_name, "createUnresolvedJavaType") \ template(createUnresolvedJavaType_signature, "(Ljava/lang/String;)Lcom/oracle/graal/api/meta/JavaType;") \ template(createResolvedJavaType_name, "createResolvedJavaType") \ - template(createResolvedJavaType_signature, "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/Class;I)Lcom/oracle/graal/api/meta/ResolvedJavaType;") \ + template(createResolvedJavaType_signature, "(Ljava/lang/Class;)Lcom/oracle/graal/api/meta/ResolvedJavaType;") \ template(createPrimitiveJavaType_name, "createPrimitiveJavaType") \ template(createPrimitiveJavaType_signature, "(I)Lcom/oracle/graal/api/meta/JavaType;") \ template(getVMToCompiler_name, "getVMToCompiler") \ diff -r d3f662f9b7d6 -r f45452c87b52 src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Tue Dec 17 22:26:33 2013 -0800 +++ b/src/share/vm/graal/graalCompiler.cpp Wed Dec 18 03:13:19 2013 -0800 @@ -219,21 +219,17 @@ TRACE_graal_1("GraalCompiler::print_timers"); } -Handle GraalCompiler::get_JavaType(Symbol* klass_name, TRAPS) { - return VMToCompiler::createUnresolvedJavaType(java_lang_String::create_from_symbol(klass_name, THREAD), THREAD); -} - Handle GraalCompiler::get_JavaTypeFromSignature(Symbol* signature, KlassHandle loading_klass, TRAPS) { - BasicType field_type = FieldType::basic_type(signature); // If the field is a pointer type, get the klass of the // field. if (field_type == T_OBJECT || field_type == T_ARRAY) { - KlassHandle handle = GraalEnv::get_klass_by_name(loading_klass, signature, false); - if (handle.is_null()) { - return get_JavaType(signature, CHECK_NH); + KlassHandle klass = GraalEnv::get_klass_by_name(loading_klass, signature, false); + if (klass.is_null()) { + Handle signature_string = java_lang_String::create_from_symbol(signature, CHECK_NH); + return VMToCompiler::createUnresolvedJavaType(signature_string, CHECK_NH); } else { - return get_JavaType(handle, CHECK_NH); + return createHotSpotResolvedObjectType(klass, CHECK_NH); } } else { return VMToCompiler::createPrimitiveJavaType(field_type, CHECK_NH); @@ -256,7 +252,7 @@ if (tag.is_klass()) { // The klass has been inserted into the constant pool // very recently. - return GraalCompiler::get_JavaType(cp->resolved_klass_at(index), CHECK_NH); + return GraalCompiler::createHotSpotResolvedObjectType(cp->resolved_klass_at(index), CHECK_NH); } else if (tag.is_symbol()) { klass_name = cp->symbol_at(index); } else { @@ -264,50 +260,26 @@ klass_name = cp->unresolved_klass_at(index); } } - return GraalCompiler::get_JavaType(klass_name, CHECK_NH); + Handle klass_name_string = java_lang_String::create_from_symbol(klass_name, CHECK_NH); + return VMToCompiler::createUnresolvedJavaType(klass_name_string, CHECK_NH); } else { - return GraalCompiler::get_JavaType(klass, CHECK_NH); + return GraalCompiler::createHotSpotResolvedObjectType(klass, CHECK_NH); } } -Handle GraalCompiler::get_JavaType(KlassHandle klass, TRAPS) { - Handle name = java_lang_String::create_from_symbol(klass->name(), THREAD); - return createHotSpotResolvedObjectType(klass, name, CHECK_NH); -} - Handle GraalCompiler::get_JavaField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, TRAPS) { Handle name = java_lang_String::create_from_symbol(field_name, CHECK_NH); return VMToCompiler::createJavaField(field_holder, name, field_type, offset, flags, false, CHECK_NH); } -Handle GraalCompiler::createHotSpotResolvedObjectType(KlassHandle klass, Handle name, TRAPS) { +Handle GraalCompiler::createHotSpotResolvedObjectType(KlassHandle klass, TRAPS) { oop java_class = klass->java_mirror(); oop graal_mirror = java_lang_Class::graal_mirror(java_class); if (graal_mirror != NULL) { assert(graal_mirror->is_a(HotSpotResolvedObjectType::klass()), "unexpected class..."); return graal_mirror; } - - Handle simpleName = name; - if (klass->oop_is_instance()) { - ResourceMark rm; - InstanceKlass* ik = (InstanceKlass*) klass(); - name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NH); - } - - int sizeOrSpecies; - if (klass->is_interface()) { - sizeOrSpecies = (int) 0x80000000; // see HotSpotResolvedObjectType.INTERFACE_SPECIES_VALUE - } else if (klass->oop_is_array()) { - sizeOrSpecies = (int) 0x7fffffff; // see HotSpotResolvedObjectType.ARRAY_SPECIES_VALUE - } else { - sizeOrSpecies = InstanceKlass::cast(klass())->size_helper() * HeapWordSize; - if (!InstanceKlass::cast(klass())->can_be_fastpath_allocated()) { - sizeOrSpecies = -sizeOrSpecies; - } - } - - return VMToCompiler::createResolvedJavaType(klass(), name, simpleName, java_class, sizeOrSpecies, CHECK_NH); + return VMToCompiler::createResolvedJavaType(java_class, CHECK_NH); } BasicType GraalCompiler::kindToBasicType(jchar ch) { diff -r d3f662f9b7d6 -r f45452c87b52 src/share/vm/graal/graalCompiler.hpp --- a/src/share/vm/graal/graalCompiler.hpp Tue Dec 17 22:26:33 2013 -0800 +++ b/src/share/vm/graal/graalCompiler.hpp Wed Dec 18 03:13:19 2013 -0800 @@ -73,11 +73,9 @@ static Handle get_JavaTypeFromSignature(Symbol* signature, KlassHandle accessor, TRAPS); static Handle get_JavaType(constantPoolHandle cp, int index, KlassHandle accessor, TRAPS); - static Handle get_JavaType(Symbol* klass_name, TRAPS); - static Handle get_JavaType(KlassHandle klass, TRAPS); static Handle get_JavaField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, TRAPS); - static Handle createHotSpotResolvedObjectType(KlassHandle klass, Handle name, TRAPS); + static Handle createHotSpotResolvedObjectType(KlassHandle klass, TRAPS); void exit(); diff -r d3f662f9b7d6 -r f45452c87b52 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Tue Dec 17 22:26:33 2013 -0800 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Wed Dec 18 03:13:19 2013 -0800 @@ -187,7 +187,7 @@ if (klass->nof_implementors() == 1) { InstanceKlass* implementor = (InstanceKlass*) klass->implementor(); if (!implementor->is_abstract() && !implementor->is_interface() && implementor->is_leaf_class()) { - Handle type = GraalCompiler::get_JavaType(implementor, CHECK_NULL); + Handle type = GraalCompiler::createHotSpotResolvedObjectType(implementor, CHECK_NULL); return JNIHandles::make_local(THREAD, type()); } } @@ -243,7 +243,7 @@ Handle type = VMToCompiler::createUnresolvedJavaType(name, THREAD); result = type(); } else { - Handle type = GraalCompiler::createHotSpotResolvedObjectType(resolved_type, name, CHECK_NULL); + Handle type = GraalCompiler::createHotSpotResolvedObjectType(resolved_type, CHECK_NULL); result = type(); } } @@ -288,7 +288,7 @@ methodHandle method = GraalEnv::get_method_by_index(cp, cp_index, bc, pool_holder); if (!method.is_null()) { - Handle holder = GraalCompiler::get_JavaType(method->method_holder(), CHECK_NULL); + Handle holder = GraalCompiler::createHotSpotResolvedObjectType(method->method_holder(), CHECK_NULL); return JNIHandles::make_local(THREAD, VMToCompiler::createResolvedJavaMethod(holder, method(), THREAD)); } else { // Get the method's name and signature. @@ -363,7 +363,7 @@ flags = result.access_flags(); holder_klass = result.field_holder(); basic_type = result.field_type(); - holder = GraalCompiler::get_JavaType(holder_klass, CHECK_NULL); + holder = GraalCompiler::createHotSpotResolvedObjectType(holder_klass, CHECK_NULL); } } diff -r d3f662f9b7d6 -r f45452c87b52 src/share/vm/graal/graalVMToCompiler.cpp --- a/src/share/vm/graal/graalVMToCompiler.cpp Tue Dec 17 22:26:33 2013 -0800 +++ b/src/share/vm/graal/graalVMToCompiler.cpp Wed Dec 18 03:13:19 2013 -0800 @@ -239,17 +239,11 @@ return (oop) result.get_jobject(); } -oop VMToCompiler::createResolvedJavaType(Klass* klass, Handle name, Handle simpleName, Handle java_mirror, jint sizeOrSpecies, TRAPS) { - assert(!name.is_null(), "just checking"); - assert(!simpleName.is_null(), "just checking"); +oop VMToCompiler::createResolvedJavaType(Handle java_mirror, TRAPS) { JavaValue result(T_OBJECT); JavaCallArguments args; args.push_oop(instance()); - args.push_long((jlong) (address) klass); - args.push_oop(name); - args.push_oop(simpleName); args.push_oop(java_mirror); - args.push_int(sizeOrSpecies); JavaCalls::call_interface(&result, vmToCompilerKlass(), vmSymbols::createResolvedJavaType_name(), vmSymbols::createResolvedJavaType_signature(), &args, THREAD); check_pending_exception("Error while calling createResolvedJavaType"); return (oop) result.get_jobject(); diff -r d3f662f9b7d6 -r f45452c87b52 src/share/vm/graal/graalVMToCompiler.hpp --- a/src/share/vm/graal/graalVMToCompiler.hpp Tue Dec 17 22:26:33 2013 -0800 +++ b/src/share/vm/graal/graalVMToCompiler.hpp Wed Dec 18 03:13:19 2013 -0800 @@ -87,8 +87,8 @@ // public abstract JavaType createUnresolvedJavaType(String name); static oop createUnresolvedJavaType(Handle name, TRAPS); - // public abstract ResolvedJavaType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, int sizeOrSpecies); - static oop createResolvedJavaType(Klass* klass, Handle name, Handle simpleName, Handle java_mirror, jint sizeOrSpecies, TRAPS); + // public abstract ResolvedJavaType createResolvedJavaType(Class javaMirror); + static oop createResolvedJavaType(Handle java_mirror, TRAPS); // public abstract JavaType createPrimitiveJavaType(int basicType); static oop createPrimitiveJavaType(int basicType, TRAPS);