7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package jdk.vm.ci.hotspot;
24
25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
26 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
27 import static jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod.Options.UseProfilingInformation;
28 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
29 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
30
31 import java.lang.annotation.Annotation;
32 import java.lang.reflect.Executable;
33 import java.lang.reflect.InvocationTargetException;
34 import java.lang.reflect.Method;
35 import java.lang.reflect.Modifier;
36 import java.lang.reflect.Type;
37 import java.util.HashMap;
38 import java.util.Map;
39
40 import jdk.vm.ci.common.JVMCIError;
41 import jdk.vm.ci.meta.Constant;
42 import jdk.vm.ci.meta.ConstantPool;
43 import jdk.vm.ci.meta.DefaultProfilingInfo;
44 import jdk.vm.ci.meta.ExceptionHandler;
45 import jdk.vm.ci.meta.JavaConstant;
46 import jdk.vm.ci.meta.JavaMethod;
47 import jdk.vm.ci.meta.JavaType;
407 }
408
409 /**
410 * @param level
411 * @return true if the currently installed code was generated at {@code level}.
412 */
413 public boolean hasCompiledCodeAtLevel(int level) {
414 long compiledCode = getCompiledCode();
415 if (compiledCode != 0) {
416 return UNSAFE.getInt(compiledCode + config().nmethodCompLevelOffset) == level;
417 }
418 return false;
419 }
420
421 private static final String TraceMethodDataFilter = System.getProperty("jvmci.traceMethodDataFilter");
422
423 @Override
424 public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) {
425 ProfilingInfo info;
426
427 if (UseProfilingInformation.getValue() && methodData == null) {
428 long metaspaceMethodData = UNSAFE.getAddress(metaspaceMethod + config().methodDataOffset);
429 if (metaspaceMethodData != 0) {
430 methodData = new HotSpotMethodData(metaspaceMethodData, this);
431 if (TraceMethodDataFilter != null && this.format("%H.%n").contains(TraceMethodDataFilter)) {
432 System.out.println("Raw method data for " + this.format("%H.%n(%p)") + ":");
433 System.out.println(methodData.toString());
434 }
435 }
436 }
437
438 if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) {
439 // Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in
440 // case of a deoptimization.
441 info = DefaultProfilingInfo.get(TriState.FALSE);
442 } else {
443 info = new HotSpotProfilingInfo(methodData, this, includeNormal, includeOSR);
444 }
445 return info;
446 }
447
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package jdk.vm.ci.hotspot;
24
25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
26 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
27 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
28 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
29
30 import java.lang.annotation.Annotation;
31 import java.lang.reflect.Executable;
32 import java.lang.reflect.InvocationTargetException;
33 import java.lang.reflect.Method;
34 import java.lang.reflect.Modifier;
35 import java.lang.reflect.Type;
36 import java.util.HashMap;
37 import java.util.Map;
38
39 import jdk.vm.ci.common.JVMCIError;
40 import jdk.vm.ci.meta.Constant;
41 import jdk.vm.ci.meta.ConstantPool;
42 import jdk.vm.ci.meta.DefaultProfilingInfo;
43 import jdk.vm.ci.meta.ExceptionHandler;
44 import jdk.vm.ci.meta.JavaConstant;
45 import jdk.vm.ci.meta.JavaMethod;
46 import jdk.vm.ci.meta.JavaType;
406 }
407
408 /**
409 * @param level
410 * @return true if the currently installed code was generated at {@code level}.
411 */
412 public boolean hasCompiledCodeAtLevel(int level) {
413 long compiledCode = getCompiledCode();
414 if (compiledCode != 0) {
415 return UNSAFE.getInt(compiledCode + config().nmethodCompLevelOffset) == level;
416 }
417 return false;
418 }
419
420 private static final String TraceMethodDataFilter = System.getProperty("jvmci.traceMethodDataFilter");
421
422 @Override
423 public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) {
424 ProfilingInfo info;
425
426 if (methodData == null) {
427 long metaspaceMethodData = UNSAFE.getAddress(metaspaceMethod + config().methodDataOffset);
428 if (metaspaceMethodData != 0) {
429 methodData = new HotSpotMethodData(metaspaceMethodData, this);
430 if (TraceMethodDataFilter != null && this.format("%H.%n").contains(TraceMethodDataFilter)) {
431 System.out.println("Raw method data for " + this.format("%H.%n(%p)") + ":");
432 System.out.println(methodData.toString());
433 }
434 }
435 }
436
437 if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) {
438 // Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in
439 // case of a deoptimization.
440 info = DefaultProfilingInfo.get(TriState.FALSE);
441 } else {
442 info = new HotSpotProfilingInfo(methodData, this, includeNormal, includeOSR);
443 }
444 return info;
445 }
446
|