# HG changeset patch # User Christos Kotselidis # Date 1364401019 -3600 # Node ID 1f958e7602610321c6157620dd1b21511e2ef4cf # Parent 0d91be9af2bc0ff0621a37163d4f6327c79ab303# Parent bd8643cea266f44b9c6937684c4e01a04d9c7da3 -Merge diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/ServiceProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/ServiceProvider.java Wed Mar 27 17:16:59 2013 +0100 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2013, 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.api.runtime; + +import java.lang.annotation.*; + +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.TYPE) +public @interface ServiceProvider { + + Class value(); +} diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed Mar 27 17:03:01 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed Mar 27 17:16:59 2013 +0100 @@ -88,6 +88,10 @@ return inProgress; } + public boolean isCancelled() { + return cancelled; + } + public int getEntryBCI() { return entryBCI; } @@ -106,10 +110,11 @@ } } runCompilation(); - if (method.currentTask() == this && entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI) { + } finally { + if (method.currentTask() == this) { method.setCurrentTask(null); } - } finally { + graalRuntime.getCompilerToVM().clearQueuedForCompilation(method); inProgress = false; withinEnqueue.set(Boolean.TRUE); } diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Wed Mar 27 17:03:01 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Wed Mar 27 17:16:59 2013 +0100 @@ -212,4 +212,6 @@ Local[] getLocalVariableTable(HotSpotResolvedJavaMethod method); String getFileName(HotSpotResolvedJavaType method); + + void clearQueuedForCompilation(HotSpotResolvedJavaMethod method); } diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Wed Mar 27 17:03:01 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Wed Mar 27 17:16:59 2013 +0100 @@ -152,4 +152,7 @@ @Override public native String getFileName(HotSpotResolvedJavaType method); + + @Override + public native void clearQueuedForCompilation(HotSpotResolvedJavaMethod method); } diff -r 0d91be9af2bc -r 1f958e760261 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 Wed Mar 27 17:03:01 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Wed Mar 27 17:16:59 2013 +0100 @@ -439,7 +439,7 @@ if (osrCompilation && bootstrapRunning) { // no OSR compilations during bootstrap - the compiler is just too slow at this point, // and we know that there are no endless loops - return current != null; + return current != null && (current.isInProgress() || !current.isCancelled()); } if (CompilationTask.withinEnqueue.get()) { @@ -447,7 +447,7 @@ // java.util.concurrent.BlockingQueue is used to implement the compilation worker // queues. If a compiler thread triggers a compilation, then it may be blocked trying // to add something to its own queue. - return current != null; + return current != null && (current.isInProgress() || !current.isCancelled()); } CompilationTask.withinEnqueue.set(Boolean.TRUE); @@ -464,7 +464,7 @@ // normally compilation tasks will only be re-queued when they get a // priority boost, so cancel the old task and add a new one current.cancel(); - } else { + } else if (!current.isCancelled()) { // without a prioritizing compile queue it makes no sense to re-queue the // compilation task return true; diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java Wed Mar 27 17:03:01 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java Wed Mar 27 17:16:59 2013 +0100 @@ -82,8 +82,7 @@ throw new BailoutException("No OnStackReplacementNode generated"); } if (osrNodes.count() > 1) { - // this can happen with JSR inlining - throw new BailoutException("Multiple OnStackReplacementNodes generated"); + throw new GraalInternalError("Multiple OnStackReplacementNodes generated"); } if (osr.stateAfter().locksSize() != 0) { throw new BailoutException("OSR with locks not supported"); diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Mar 27 17:03:01 2013 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Mar 27 17:16:59 2013 +0100 @@ -1688,6 +1688,9 @@ traceState(); traceInstruction(bci, opcode, bci == block.startBci); if (bci == entryBCI) { + if (block.jsrScope != JsrScope.EMPTY_SCOPE) { + throw new BailoutException("OSR into a JSR scope is not supported"); + } EntryMarkerNode x = currentGraph.add(new EntryMarkerNode()); append(x); frameState.insertProxies(x); diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.replacements/src/META-INF/services/com.oracle.graal.replacements.ReplacementsProvider --- a/graal/com.oracle.graal.replacements/src/META-INF/services/com.oracle.graal.replacements.ReplacementsProvider Wed Mar 27 17:03:01 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.oracle.graal.replacements.GraalMethodSubstitutions diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java Wed Mar 27 17:03:01 2013 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java Wed Mar 27 17:16:59 2013 +0100 @@ -22,11 +22,13 @@ */ package com.oracle.graal.replacements; +import com.oracle.graal.api.runtime.*; import com.oracle.graal.phases.*; /** * Method substitutions that are VM-independent. */ +@ServiceProvider(ReplacementsProvider.class) public class GraalMethodSubstitutions implements ReplacementsProvider { public void installReplacements(ReplacementsInstaller installer) { diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.service.processor/src/META-INF/services/javax.annotation.processing.Processor --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.service.processor/src/META-INF/services/javax.annotation.processing.Processor Wed Mar 27 17:16:59 2013 +0100 @@ -0,0 +1,1 @@ +com.oracle.graal.service.processor.ServiceProviderProcessor diff -r 0d91be9af2bc -r 1f958e760261 graal/com.oracle.graal.service.processor/src/com/oracle/graal/service/processor/ServiceProviderProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.service.processor/src/com/oracle/graal/service/processor/ServiceProviderProcessor.java Wed Mar 27 17:16:59 2013 +0100 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2013, 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.service.processor; + +import java.io.*; +import java.util.*; + +import javax.annotation.processing.*; +import javax.lang.model.*; +import javax.lang.model.element.*; +import javax.lang.model.type.*; +import javax.tools.Diagnostic.Kind; +import javax.tools.*; + +import com.oracle.graal.api.runtime.*; + +@SupportedSourceVersion(SourceVersion.RELEASE_7) +@SupportedAnnotationTypes("com.oracle.graal.api.runtime.ServiceProvider") +public class ServiceProviderProcessor extends AbstractProcessor { + + private Map> serviceMap; + + public ServiceProviderProcessor() { + serviceMap = new HashMap<>(); + } + + private void addProvider(String serviceName, TypeElement serviceProvider) { + Set providers = serviceMap.get(serviceName); + if (providers == null) { + providers = new HashSet<>(); + serviceMap.put(serviceName, providers); + } + providers.add(serviceProvider); + } + + private void generateServicesFiles() { + Filer filer = processingEnv.getFiler(); + for (Map.Entry> entry : serviceMap.entrySet()) { + String filename = "META-INF/services/" + entry.getKey(); + TypeElement[] providers = entry.getValue().toArray(new TypeElement[0]); + try { + FileObject servicesFile = filer.createResource(StandardLocation.CLASS_OUTPUT, "", filename, providers); + PrintWriter writer = new PrintWriter(new OutputStreamWriter(servicesFile.openOutputStream(), "UTF-8")); + for (TypeElement provider : providers) { + writer.println(provider.getQualifiedName()); + } + writer.close(); + } catch (IOException e) { + processingEnv.getMessager().printMessage(Kind.ERROR, e.getMessage()); + } + } + } + + private boolean verifyAnnotation(TypeMirror serviceInterface, TypeElement serviceProvider) { + if (!processingEnv.getTypeUtils().isSubtype(serviceProvider.asType(), serviceInterface)) { + String msg = String.format("Service provider class %s doesn't implement service interface %s", serviceProvider.getSimpleName(), serviceInterface); + processingEnv.getMessager().printMessage(Kind.ERROR, msg, serviceProvider); + return false; + } + + return true; + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + generateServicesFiles(); + return true; + } + + for (Element element : roundEnv.getElementsAnnotatedWith(ServiceProvider.class)) { + assert element.getKind().isClass(); + ServiceProvider annotation = element.getAnnotation(ServiceProvider.class); + try { + annotation.value(); + } catch (MirroredTypeException ex) { + TypeMirror serviceInterface = ex.getTypeMirror(); + TypeElement serviceProvider = (TypeElement) element; + if (verifyAnnotation(serviceInterface, serviceProvider)) { + String interfaceName = ex.getTypeMirror().toString(); + addProvider(interfaceName, serviceProvider); + } + } + } + return true; + } +} diff -r 0d91be9af2bc -r 1f958e760261 make/build-graal.xml --- a/make/build-graal.xml Wed Mar 27 17:03:01 2013 +0100 +++ b/make/build-graal.xml Wed Mar 27 17:16:59 2013 +0100 @@ -49,8 +49,8 @@ + - diff -r 0d91be9af2bc -r 1f958e760261 mx/projects --- a/mx/projects Wed Mar 27 17:03:01 2013 +0100 +++ b/mx/projects Wed Mar 27 17:16:59 2013 +0100 @@ -65,6 +65,13 @@ project@com.oracle.graal.api.replacements@checkstyle=com.oracle.graal.graph project@com.oracle.graal.api.replacements@javaCompliance=1.7 +# graal.service.processor +project@com.oracle.graal.service.processor@subDir=graal +project@com.oracle.graal.service.processor@sourceDirs=src +project@com.oracle.graal.service.processor@dependencies=com.oracle.graal.api.runtime +project@com.oracle.graal.service.processor@checkstyle=com.oracle.graal.graph +project@com.oracle.graal.service.processor@javaCompliance=1.7 + # graal.amd64 project@com.oracle.graal.amd64@subDir=graal project@com.oracle.graal.amd64@sourceDirs=src @@ -89,7 +96,7 @@ # graal.hotspot project@com.oracle.graal.hotspot@subDir=graal project@com.oracle.graal.hotspot@sourceDirs=src -project@com.oracle.graal.hotspot@dependencies=com.oracle.graal.replacements,com.oracle.graal.api.runtime,com.oracle.graal.printer +project@com.oracle.graal.hotspot@dependencies=com.oracle.graal.replacements,com.oracle.graal.printer project@com.oracle.graal.hotspot@checkstyle=com.oracle.graal.graph project@com.oracle.graal.hotspot@annotationProcessors=com.oracle.graal.replacements.verifier project@com.oracle.graal.hotspot@javaCompliance=1.7 @@ -193,10 +200,10 @@ # graal.replacements project@com.oracle.graal.replacements@subDir=graal project@com.oracle.graal.replacements@sourceDirs=src -project@com.oracle.graal.replacements@dependencies=com.oracle.graal.compiler,com.oracle.graal.java,com.oracle.graal.word +project@com.oracle.graal.replacements@dependencies=com.oracle.graal.compiler,com.oracle.graal.java,com.oracle.graal.word,com.oracle.graal.api.runtime project@com.oracle.graal.replacements@checkstyle=com.oracle.graal.graph project@com.oracle.graal.replacements@javaCompliance=1.7 -project@com.oracle.graal.replacements@annotationProcessors=com.oracle.graal.replacements.verifier +project@com.oracle.graal.replacements@annotationProcessors=com.oracle.graal.replacements.verifier,com.oracle.graal.service.processor # graal.replacements.amd64 project@com.oracle.graal.replacements.amd64@subDir=graal diff -r 0d91be9af2bc -r 1f958e760261 mxtool/mx.py --- a/mxtool/mx.py Wed Mar 27 17:03:01 2013 +0100 +++ b/mxtool/mx.py Wed Mar 27 17:16:59 2013 +0100 @@ -2307,7 +2307,7 @@ launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS', 'value': 'auto,full,incremental'}) launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS', 'value': mxCommand}) launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED','value': 'true'}) - launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': baseDir}) + launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': p.suite.dir}) launchOut.close('launchConfiguration') diff -r 0d91be9af2bc -r 1f958e760261 src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Wed Mar 27 17:03:01 2013 +0100 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Wed Mar 27 17:16:59 2013 +0100 @@ -345,8 +345,6 @@ result = GraalEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, true, false, leaf_graph_ids, installed_code, triggered_deoptimizations); - - method->clear_queued_for_compilation(); } // constructor used to create a stub diff -r 0d91be9af2bc -r 1f958e760261 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Wed Mar 27 17:03:01 2013 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Wed Mar 27 17:16:59 2013 +0100 @@ -814,6 +814,17 @@ GraalEnv::CodeInstallResult result; CodeInstaller installer(compResultHandle, method, result, nm, installed_code_handle, triggered_deoptimizations_handle); + if (PrintCodeCacheOnCompilation) { + stringStream s; + // Dump code cache into a buffer before locking the tty, + { + MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); + CodeCache::print_summary(&s, false); + } + ttyLocker ttyl; + tty->print_cr(s.as_string()); + } + if (result != GraalEnv::ok) { assert(nm == NULL, "should be"); } else { @@ -828,6 +839,11 @@ return result; C2V_END +C2V_VMENTRY(void, clearQueuedForCompilation, (JNIEnv *jniEnv, jobject, jobject resolvedMethod)) + methodHandle method = getMethodFromHotSpotMethod(JNIHandles::resolve(resolvedMethod)); + method->clear_queued_for_compilation(); +C2V_END + C2V_VMENTRY(jobject, getCode, (JNIEnv *jniEnv, jobject, jlong metaspace_nmethod)) ResourceMark rm; HandleMark hm; @@ -1089,6 +1105,7 @@ {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)}, {CC"getLocalVariableTable", CC"("HS_RESOLVED_METHOD")["LOCAL, FN_PTR(getLocalVariableTable)}, {CC"getFileName", CC"("HS_RESOLVED_JAVA_TYPE")"STRING, FN_PTR(getFileName)}, + {CC"clearQueuedForCompilation", CC"("HS_RESOLVED_METHOD")V", FN_PTR(clearQueuedForCompilation)}, }; int CompilerToVM_methods_count() {