# HG changeset patch # User Gilles Duboscq # Date 1433164479 -7200 # Node ID 36cf15e3219eee18fb62645fe35f2863403359fb # Parent 35da7c00e2fad717fe2e726c28f9188cbe0eaf64 Move HotSpotResolvedJavaMethod.getSpeculationLog to ResolvedJavaMethod diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Jun 01 15:14:39 2015 +0200 @@ -25,18 +25,11 @@ import com.oracle.jvmci.code.Architecture; import com.oracle.jvmci.code.CompilationResult; import com.oracle.jvmci.code.TargetDescription; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.InstalledCode; import com.oracle.jvmci.code.CallingConvention; import com.oracle.jvmci.code.CodeCacheProvider; -import com.oracle.jvmci.meta.DeoptimizationReason; -import com.oracle.jvmci.meta.ResolvedJavaMethod; -import com.oracle.jvmci.meta.Kind; -import com.oracle.jvmci.meta.ConstantReflectionProvider; -import com.oracle.jvmci.meta.JavaType; -import com.oracle.jvmci.meta.ResolvedJavaType; -import com.oracle.jvmci.meta.ProfilingInfo; -import com.oracle.jvmci.meta.MetaAccessProvider; +import com.oracle.jvmci.meta.*; + import static com.oracle.jvmci.code.CodeUtil.*; import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.compiler.common.GraalOptions.*; diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java Mon Jun 01 15:14:39 2015 +0200 @@ -25,13 +25,11 @@ import com.oracle.jvmci.code.CodeUtil; import com.oracle.jvmci.code.CompilationResult; import com.oracle.jvmci.code.TargetDescription; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.InstalledCode; import com.oracle.jvmci.code.CallingConvention; import com.oracle.jvmci.code.CodeCacheProvider; -import com.oracle.jvmci.meta.ResolvedJavaMethod; -import com.oracle.jvmci.meta.ProfilingInfo; -import com.oracle.jvmci.meta.MetaAccessProvider; +import com.oracle.jvmci.meta.*; + import java.lang.reflect.*; import java.util.concurrent.atomic.*; diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon Jun 01 15:14:39 2015 +0200 @@ -25,16 +25,9 @@ import com.oracle.jvmci.code.CompilationResult; import com.oracle.jvmci.code.TargetDescription; import com.oracle.jvmci.code.RegisterConfig; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.CallingConvention; -import com.oracle.jvmci.meta.Assumptions; -import com.oracle.jvmci.meta.Kind; -import com.oracle.jvmci.meta.JavaConstant; -import com.oracle.jvmci.meta.ProfilingInfo; -import com.oracle.jvmci.meta.TriState; -import com.oracle.jvmci.meta.ResolvedJavaMethod; -import com.oracle.jvmci.meta.DefaultProfilingInfo; -import com.oracle.jvmci.meta.VMConstant; +import com.oracle.jvmci.meta.*; + import static com.oracle.graal.compiler.GraalCompiler.Options.*; import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig.*; diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.graal.java.test/src/com/oracle/graal/java/test/TestResolvedJavaMethod.java --- a/graal/com.oracle.graal.java.test/src/com/oracle/graal/java/test/TestResolvedJavaMethod.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.graal.java.test/src/com/oracle/graal/java/test/TestResolvedJavaMethod.java Mon Jun 01 15:14:39 2015 +0200 @@ -358,6 +358,7 @@ "isInVirtualMethodTable", "toParameterTypes", "getParameterAnnotation", + "getSpeculationLog", "$jacocoInit" }; // @formatter:on diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java Mon Jun 01 15:14:39 2015 +0200 @@ -22,9 +22,8 @@ */ package com.oracle.graal.phases.tiers; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.TargetDescription; -import com.oracle.jvmci.meta.ProfilingInfo; +import com.oracle.jvmci.meta.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.util.*; diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Mon Jun 01 15:14:39 2015 +0200 @@ -23,8 +23,8 @@ package com.oracle.graal.truffle; import com.oracle.jvmci.code.InstalledCode; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.BailoutException; + import static com.oracle.graal.truffle.TruffleCompilerOptions.*; import java.io.*; @@ -36,6 +36,7 @@ import com.oracle.graal.truffle.debug.*; import com.oracle.jvmci.common.*; import com.oracle.jvmci.debug.*; +import com.oracle.jvmci.meta.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.frame.*; diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java Mon Jun 01 15:14:39 2015 +0200 @@ -25,11 +25,9 @@ import com.oracle.jvmci.code.CallingConvention; import com.oracle.jvmci.code.CodeCacheProvider; import com.oracle.jvmci.code.InstalledCode; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.CompilationResult; -import com.oracle.jvmci.meta.MetaAccessProvider; -import com.oracle.jvmci.meta.ResolvedJavaType; -import com.oracle.jvmci.meta.ConstantReflectionProvider; +import com.oracle.jvmci.meta.*; + import static com.oracle.jvmci.code.CodeUtil.*; import static com.oracle.graal.compiler.GraalCompiler.*; diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/CodeCacheProvider.java --- a/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/CodeCacheProvider.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/CodeCacheProvider.java Mon Jun 01 15:14:39 2015 +0200 @@ -22,9 +22,7 @@ */ package com.oracle.jvmci.code; -import com.oracle.jvmci.meta.Constant; -import com.oracle.jvmci.meta.ResolvedJavaMethod; -import com.oracle.jvmci.meta.JavaConstant; +import com.oracle.jvmci.meta.*; import com.oracle.jvmci.code.CompilationResult.DataPatch; import com.oracle.jvmci.code.DataSection.Data; diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/SpeculationLog.java --- a/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/SpeculationLog.java Fri May 29 13:22:29 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2012, 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.jvmci.code; - -import com.oracle.jvmci.meta.JavaConstant; -import java.util.*; -import java.util.concurrent.*; - -/** - * Manages a list of unique deoptimization reasons. - * - */ -public abstract class SpeculationLog { - private volatile Object lastFailed; - private volatile Collection speculations; - private Set failedSpeculations; - - public synchronized void collectFailedSpeculations() { - if (lastFailed != null) { - if (failedSpeculations == null) { - failedSpeculations = new HashSet<>(2); - } - failedSpeculations.add(lastFailed); - lastFailed = null; - speculations = null; - } - } - - public boolean maySpeculate(Object reason) { - if (failedSpeculations != null && failedSpeculations.contains(reason)) { - return false; - } - return true; - } - - protected void addSpeculation(Object reason) { - assert maySpeculate(reason); - if (speculations == null) { - synchronized (this) { - if (speculations == null) { - speculations = new ConcurrentLinkedQueue<>(); - } - } - } - speculations.add(reason); - } - - public abstract JavaConstant speculate(Object reason); -} diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/package-info.java --- a/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/package-info.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/package-info.java Mon Jun 01 15:14:39 2015 +0200 @@ -23,7 +23,7 @@ /** * Package that defines the interface between a Java application that wants to install code and the runtime. * The runtime provides in implementation of the {@link com.oracle.jvmci.code.CodeCacheProvider} interface. - * The method {@link com.oracle.jvmci.code.CodeCacheProvider#addMethod(com.oracle.jvmci.meta.ResolvedJavaMethod, CompilationResult, SpeculationLog, InstalledCode)} + * The method {@link com.oracle.jvmci.code.CodeCacheProvider#addMethod(com.oracle.jvmci.meta.ResolvedJavaMethod, CompilationResult, com.oracle.jvmci.meta.SpeculationLog, InstalledCode)} * can be used to install code for a given method. */ package com.oracle.jvmci.code; diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/CompilerToVMImpl.java --- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/CompilerToVMImpl.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/CompilerToVMImpl.java Mon Jun 01 15:14:39 2015 +0200 @@ -26,6 +26,7 @@ import static com.oracle.jvmci.hotspot.InitTimer.*; import com.oracle.jvmci.code.*; +import com.oracle.jvmci.meta.*; /** * Entries into the HotSpot VM from Java code. diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod.java Mon Jun 01 15:14:39 2015 +0200 @@ -24,7 +24,6 @@ import java.lang.reflect.*; -import com.oracle.jvmci.code.*; import com.oracle.jvmci.meta.*; /** @@ -116,6 +115,4 @@ int allocateCompileId(int entryBCI); boolean hasCodeAtLevel(int entryBCI, int level); - - SpeculationLog getSpeculationLog(); } diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java --- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Mon Jun 01 15:14:39 2015 +0200 @@ -30,7 +30,6 @@ import java.lang.reflect.*; import java.util.*; -import com.oracle.jvmci.code.*; import com.oracle.jvmci.common.*; import com.oracle.jvmci.debug.*; import com.oracle.jvmci.meta.*; diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotSpeculationLog.java --- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotSpeculationLog.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotSpeculationLog.java Mon Jun 01 15:14:39 2015 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.jvmci.hotspot; -import com.oracle.jvmci.code.*; import com.oracle.jvmci.meta.*; public class HotSpotSpeculationLog extends SpeculationLog { diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java --- a/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java Fri May 29 13:22:29 2015 +0200 +++ b/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java Mon Jun 01 15:14:39 2015 +0200 @@ -295,4 +295,6 @@ default boolean isJavaLangObjectInit() { return getDeclaringClass().isJavaLangObject() && getName().equals(""); } + + SpeculationLog getSpeculationLog(); } diff -r 35da7c00e2fa -r 36cf15e3219e graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/SpeculationLog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/SpeculationLog.java Mon Jun 01 15:14:39 2015 +0200 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2012, 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.jvmci.meta; + +import java.util.*; +import java.util.concurrent.*; + +/** + * Manages a list of unique deoptimization reasons. + * + */ +public abstract class SpeculationLog { + private volatile Object lastFailed; + private volatile Collection speculations; + private Set failedSpeculations; + + public synchronized void collectFailedSpeculations() { + if (lastFailed != null) { + if (failedSpeculations == null) { + failedSpeculations = new HashSet<>(2); + } + failedSpeculations.add(lastFailed); + lastFailed = null; + speculations = null; + } + } + + public boolean maySpeculate(Object reason) { + if (failedSpeculations != null && failedSpeculations.contains(reason)) { + return false; + } + return true; + } + + protected void addSpeculation(Object reason) { + assert maySpeculate(reason); + if (speculations == null) { + synchronized (this) { + if (speculations == null) { + speculations = new ConcurrentLinkedQueue<>(); + } + } + } + speculations.add(reason); + } + + public abstract JavaConstant speculate(Object reason); +} diff -r 35da7c00e2fa -r 36cf15e3219e src/share/vm/classfile/systemDictionary.hpp --- a/src/share/vm/classfile/systemDictionary.hpp Fri May 29 13:22:29 2015 +0200 +++ b/src/share/vm/classfile/systemDictionary.hpp Mon Jun 01 15:14:39 2015 +0200 @@ -239,7 +239,7 @@ JVMCI_ONLY(do_klass(StackSlot_klass, com_oracle_jvmci_code_StackSlot, Jvmci)) \ JVMCI_ONLY(do_klass(StackLockValue_klass, com_oracle_jvmci_code_StackLockValue, Jvmci)) \ JVMCI_ONLY(do_klass(VirtualObject_klass, com_oracle_jvmci_code_VirtualObject, Jvmci)) \ - JVMCI_ONLY(do_klass(SpeculationLog_klass, com_oracle_jvmci_code_SpeculationLog, Jvmci)) \ + JVMCI_ONLY(do_klass(SpeculationLog_klass, com_oracle_jvmci_meta_SpeculationLog, Jvmci)) \ JVMCI_ONLY(do_klass(JavaConstant_klass, com_oracle_jvmci_meta_JavaConstant, Jvmci)) \ JVMCI_ONLY(do_klass(PrimitiveConstant_klass, com_oracle_jvmci_meta_PrimitiveConstant, Jvmci)) \ JVMCI_ONLY(do_klass(RawConstant_klass, com_oracle_jvmci_meta_RawConstant, Jvmci)) \ diff -r 35da7c00e2fa -r 36cf15e3219e src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Fri May 29 13:22:29 2015 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Mon Jun 01 15:14:39 2015 +0200 @@ -331,6 +331,7 @@ JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_NoFinalizableSubclass, "com/oracle/jvmci/meta/Assumptions$NoFinalizableSubclass")) \ JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_ConcreteMethod, "com/oracle/jvmci/meta/Assumptions$ConcreteMethod")) \ JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_CallSiteTargetValue, "com/oracle/jvmci/meta/Assumptions$CallSiteTargetValue")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_SpeculationLog, "com/oracle/jvmci/meta/SpeculationLog")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_Call, "com/oracle/jvmci/code/CompilationResult$Call")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_ConstantReference, "com/oracle/jvmci/code/CompilationResult$ConstantReference")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_DataPatch, "com/oracle/jvmci/code/CompilationResult$DataPatch")) \ @@ -352,7 +353,6 @@ JVMCI_ONLY(template(com_oracle_jvmci_code_VirtualObject, "com/oracle/jvmci/code/VirtualObject")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_RegisterSaveLayout, "com/oracle/jvmci/code/RegisterSaveLayout")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_InvalidInstalledCodeException, "com/oracle/jvmci/code/InvalidInstalledCodeException")) \ - JVMCI_ONLY(template(com_oracle_jvmci_code_SpeculationLog, "com/oracle/jvmci/code/SpeculationLog")) \ JVMCI_ONLY(template(compileMetaspaceMethod_name, "compileMetaspaceMethod")) \ JVMCI_ONLY(template(compileMetaspaceMethod_signature, "(JIJI)V")) \ JVMCI_ONLY(template(com_oracle_jvmci_hotspot_Stable_signature, "Lcom/oracle/jvmci/hotspot/Stable;")) \ diff -r 35da7c00e2fa -r 36cf15e3219e src/share/vm/jvmci/jvmciCompilerToVM.cpp --- a/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri May 29 13:22:29 2015 +0200 +++ b/src/share/vm/jvmci/jvmciCompilerToVM.cpp Mon Jun 01 15:14:39 2015 +0200 @@ -1034,7 +1034,7 @@ #define TYPE "Lcom/oracle/jvmci/meta/JavaType;" #define METHOD "Lcom/oracle/jvmci/meta/JavaMethod;" #define FIELD "Lcom/oracle/jvmci/meta/JavaField;" -#define SPECULATION_LOG "Lcom/oracle/jvmci/code/SpeculationLog;" +#define SPECULATION_LOG "Lcom/oracle/jvmci/meta/SpeculationLog;" #define STRING "Ljava/lang/String;" #define OBJECT "Ljava/lang/Object;" #define CLASS "Ljava/lang/Class;"