# HG changeset patch # User Tom Rodriguez # Date 1426616586 25200 # Node ID 815a87264cbb50a573fe48943cd26db634f384a5 # Parent ea280aa54d58ff2eeb68d0732a5d812b755091b7# Parent fc1e46a702a14b0bed70fb969c8bbfd1d10eed73 Merge diff -r fc1e46a702a1 -r 815a87264cbb graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java Mon Mar 16 18:19:12 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java Tue Mar 17 11:23:06 2015 -0700 @@ -149,9 +149,9 @@ @Override public JavaType getType() { - if (!(type instanceof ResolvedJavaType)) { + if (type instanceof HotSpotUnresolvedJavaType) { // Don't allow unresolved types to hang around forever - ResolvedJavaType resolved = type.resolve(holder); + ResolvedJavaType resolved = ((HotSpotUnresolvedJavaType) type).reresolve(holder); if (resolved != null) { type = resolved; } @@ -204,7 +204,7 @@ } try { return holder.mirror().getDeclaredField(name); - } catch (NoSuchFieldException e) { + } catch (NoSuchFieldException | NoClassDefFoundError e) { return null; } } diff -r fc1e46a702a1 -r 815a87264cbb graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java Mon Mar 16 18:19:12 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java Tue Mar 17 11:23:06 2015 -0700 @@ -88,4 +88,18 @@ public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { return (ResolvedJavaType) runtime.lookupType(getName(), (HotSpotResolvedObjectType) accessingClass, true); } + + /** + * Try to find a loaded version of this class. + * + * @param accessingClass + * @return the resolved class or null. + */ + ResolvedJavaType reresolve(HotSpotResolvedObjectType accessingClass) { + JavaType type = runtime.lookupType(getName(), accessingClass, false); + if (type instanceof ResolvedJavaType) { + return (ResolvedJavaType) type; + } + return null; + } } diff -r fc1e46a702a1 -r 815a87264cbb graal/com.oracle.graal.loop/src/com/oracle/graal/loop/CountedLoopInfo.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/CountedLoopInfo.java Mon Mar 16 18:19:12 2015 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/CountedLoopInfo.java Tue Mar 17 11:23:06 2015 -0700 @@ -60,6 +60,7 @@ if (iv.direction() == Direction.Up) { range = add(graph, range, ConstantNode.forIntegerStamp(stamp, 1, graph)); } else { + assert iv.direction() == Direction.Down; range = sub(graph, range, ConstantNode.forIntegerStamp(stamp, 1, graph)); } } @@ -76,6 +77,7 @@ } public long constantMaxTripCount() { + assert iv.direction() != null; long off = oneOff ? iv.direction() == Direction.Up ? 1 : -1 : 0; long max = (((ConstantNode) end).asJavaConstant().asLong() + off - iv.constantInit()) / iv.constantStride(); return Math.max(0, max); diff -r fc1e46a702a1 -r 815a87264cbb graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java Mon Mar 16 18:19:12 2015 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java Tue Mar 17 11:23:06 2015 -0700 @@ -218,11 +218,12 @@ if (initStamp.upperBound() > limitStamp.lowerBound()) { return false; } - } else { - assert iv.direction() == Direction.Down; + } else if (iv.direction() == Direction.Down) { if (initStamp.lowerBound() < limitStamp.upperBound()) { return false; } + } else { + return false; } oneOff = true; break; @@ -265,9 +266,12 @@ if (loop().getExits().contains(b)) { exits.add((LoopExitNode) b.getBeginNode()); } else { - assert loop().getBlocks().contains(b); blocks.add(b.getBeginNode()); - work.addAll(b.getDominated()); + for (Block d : b.getDominated()) { + if (loop.getBlocks().contains(d)) { + work.add(d); + } + } } } return LoopFragment.computeNodes(branch.graph(), blocks, exits); diff -r fc1e46a702a1 -r 815a87264cbb mxtool/mx.py --- a/mxtool/mx.py Mon Mar 16 18:19:12 2015 +0100 +++ b/mxtool/mx.py Tue Mar 17 11:23:06 2015 -0700 @@ -2823,7 +2823,7 @@ else: # Using just SC_ARG_MAX without extra downwards adjustment # results in "[Errno 7] Argument list too long" on MacOS. - commandLinePrefixAllowance -= 20000 + commandLinePrefixAllowance = 20000 syslimit = os.sysconf('SC_ARG_MAX') if syslimit == -1: syslimit = 262144 # we could use sys.maxint but we prefer a more robust smaller value diff -r fc1e46a702a1 -r 815a87264cbb src/share/vm/graal/graalRuntime.cpp --- a/src/share/vm/graal/graalRuntime.cpp Mon Mar 16 18:19:12 2015 +0100 +++ b/src/share/vm/graal/graalRuntime.cpp Tue Mar 17 11:23:06 2015 -0700 @@ -626,6 +626,7 @@ // private static GraalRuntime Graal.initializeRuntime() JVM_ENTRY(jobject, JVM_GetGraalRuntime(JNIEnv *env, jclass c)) + GraalRuntime::initialize_HotSpotGraalRuntime(); return GraalRuntime::get_HotSpotGraalRuntime_jobject(); JVM_END @@ -688,21 +689,43 @@ } } -Handle GraalRuntime::get_HotSpotGraalRuntime() { +Handle GraalRuntime::callInitializer(const char* className, const char* methodName, const char* returnType) { + guarantee(!_HotSpotGraalRuntime_initialized, "cannot reinitialize HotSpotGraalRuntime"); + Thread* THREAD = Thread::current(); + check_generated_sources_sha1(CHECK_ABORT_(Handle())); + + TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_ABORT_(Handle())); + KlassHandle klass = load_required_class(name); + TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_ABORT_(Handle())); + TempNewSymbol sig = SymbolTable::new_symbol(returnType, CHECK_ABORT_(Handle())); + JavaValue result(T_OBJECT); + JavaCalls::call_static(&result, klass, runtime, sig, CHECK_ABORT_(Handle())); + return Handle((oop)result.get_jobject()); +} + +void GraalRuntime::initialize_HotSpotGraalRuntime() { if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) { - guarantee(!_HotSpotGraalRuntime_initialized, "cannot reinitialize HotSpotGraalRuntime"); +#ifdef ASSERT + // This should only be called in the context of the Graal class being initialized Thread* THREAD = Thread::current(); - check_generated_sources_sha1(CHECK_ABORT_(Handle())); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", CHECK_ABORT_(Handle())); - KlassHandle klass = load_required_class(name); - TempNewSymbol runtime = SymbolTable::new_symbol("runtime", CHECK_ABORT_(Handle())); - TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/hotspot/HotSpotGraalRuntime;", CHECK_ABORT_(Handle())); - JavaValue result(T_OBJECT); - JavaCalls::call_static(&result, klass, runtime, sig, CHECK_ABORT_(Handle())); - _HotSpotGraalRuntime_instance = JNIHandles::make_global((oop) result.get_jobject()); + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/api/runtime/Graal", CHECK_ABORT); + instanceKlassHandle klass = InstanceKlass::cast(load_required_class(name)); + assert(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD), + "HotSpotGraalRuntime initialization should only be triggered through Graal initialization"); +#endif + + Handle result = callInitializer("com/oracle/graal/hotspot/HotSpotGraalRuntime", "runtime", + "()Lcom/oracle/graal/hotspot/HotSpotGraalRuntime;"); _HotSpotGraalRuntime_initialized = true; + _HotSpotGraalRuntime_instance = JNIHandles::make_global(result()); } - return Handle(JNIHandles::resolve_non_null(_HotSpotGraalRuntime_instance)); +} + +void GraalRuntime::initialize_Graal() { + if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) { + callInitializer("com/oracle/graal/api/runtime/Graal", "getRuntime", "()Lcom/oracle/graal/api/runtime/GraalRuntime;"); + } + assert(_HotSpotGraalRuntime_initialized == true, "what?"); } // private static void CompilerToVMImpl.init() diff -r fc1e46a702a1 -r 815a87264cbb src/share/vm/graal/graalRuntime.hpp --- a/src/share/vm/graal/graalRuntime.hpp Mon Mar 16 18:19:12 2015 +0100 +++ b/src/share/vm/graal/graalRuntime.hpp Tue Mar 17 11:23:06 2015 -0700 @@ -138,13 +138,29 @@ /** * Gets the singleton HotSpotGraalRuntime instance, initializing it if necessary */ - static Handle get_HotSpotGraalRuntime(); + static Handle get_HotSpotGraalRuntime() { + initialize_Graal(); + return Handle(JNIHandles::resolve_non_null(_HotSpotGraalRuntime_instance)); + } static jobject get_HotSpotGraalRuntime_jobject() { - get_HotSpotGraalRuntime(); + initialize_Graal(); + assert(_HotSpotGraalRuntime_initialized, "must be"); return _HotSpotGraalRuntime_instance; } + static Handle callInitializer(const char* className, const char* methodName, const char* returnType); + + /** + * Trigger initialization of HotSpotGraalRuntime through Graal.runtime() + */ + static void initialize_Graal(); + + /** + * Explicitly initialize HotSpotGraalRuntime itself + */ + static void initialize_HotSpotGraalRuntime(); + static void shutdown(); static bool shutdown_called() {