annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java @ 23391:dd9f3badc978

Remove implicit stable field handling (JDK-8156552).
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 12 May 2016 14:24:15 +0200
parents a920338dd4d4
children b3a816d3b844
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
22773
9273bb6ba33e Simplify code installation interface: Use CompiledCode class instead of CompilationResult and DataSection.
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
23 package jdk.vm.ci.hotspot;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
25 import static jdk.vm.ci.inittimer.InitTimer.timer;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26
22626
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
27 import java.io.IOException;
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
28 import java.io.OutputStream;
23306
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
29 import java.io.PrintStream;
22562
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
30 import java.lang.reflect.Array;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
31 import java.lang.reflect.Field;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
32 import java.lang.reflect.Method;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
33 import java.lang.reflect.Modifier;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
34 import java.util.Collections;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
35 import java.util.HashMap;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
36 import java.util.Map;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
37 import java.util.Objects;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
38 import java.util.TreeMap;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
40 import jdk.vm.ci.code.Architecture;
22770
1fbfcc0334d3 JVMCI PrintCompilation support should reuse CompileBroker logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22767
diff changeset
41 import jdk.vm.ci.code.CompilationRequestResult;
22773
9273bb6ba33e Simplify code installation interface: Use CompiledCode class instead of CompilationResult and DataSection.
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
42 import jdk.vm.ci.code.CompiledCode;
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
43 import jdk.vm.ci.code.InstalledCode;
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
44 import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory;
23363
56479400913e jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents: 23319
diff changeset
45 import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
46 import jdk.vm.ci.inittimer.InitTimer;
23306
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
47 import jdk.vm.ci.inittimer.SuppressFBWarnings;
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
48 import jdk.vm.ci.meta.JVMCIMetaAccessContext;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
49 import jdk.vm.ci.meta.JavaKind;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
50 import jdk.vm.ci.meta.JavaType;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
51 import jdk.vm.ci.meta.ResolvedJavaType;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
52 import jdk.vm.ci.runtime.JVMCI;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22658
diff changeset
53 import jdk.vm.ci.runtime.JVMCIBackend;
22697
57646377e480 Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents: 22694
diff changeset
54 import jdk.vm.ci.runtime.JVMCICompiler;
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
55 import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
22761
f2206f5bb62e removed @ServiceProvider mechanism (GRAAL-1380)
Doug Simon <doug.simon@oracle.com>
parents: 22758
diff changeset
56 import jdk.vm.ci.services.Services;
22767
d88299d598d6 Add support for passing back bailout messages
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22761
diff changeset
57 import sun.misc.VM;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 //JaCoCo Exclude
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60
22562
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
61 /**
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
62 * HotSpot implementation of a JVMCI runtime.
22694
023981d7f257 Fix deadlock between JVMCI.initialize and HotSpotJVMCIRuntime.runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22672
diff changeset
63 *
023981d7f257 Fix deadlock between JVMCI.initialize and HotSpotJVMCIRuntime.runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22672
diff changeset
64 * The initialization of this class is very fragile since it's initialized both through
023981d7f257 Fix deadlock between JVMCI.initialize and HotSpotJVMCIRuntime.runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22672
diff changeset
65 * {@link JVMCI#initialize()} or through calling {@link HotSpotJVMCIRuntime#runtime()} and
023981d7f257 Fix deadlock between JVMCI.initialize and HotSpotJVMCIRuntime.runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22672
diff changeset
66 * {@link HotSpotJVMCIRuntime#runtime()} is also called by {@link JVMCI#initialize()}. So this class
023981d7f257 Fix deadlock between JVMCI.initialize and HotSpotJVMCIRuntime.runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22672
diff changeset
67 * can't have a static initializer and any required initialization must be done as part of
023981d7f257 Fix deadlock between JVMCI.initialize and HotSpotJVMCIRuntime.runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22672
diff changeset
68 * {@link #runtime()}. This allows the initialization to funnel back through
023981d7f257 Fix deadlock between JVMCI.initialize and HotSpotJVMCIRuntime.runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22672
diff changeset
69 * {@link JVMCI#initialize()} without deadlocking.
22562
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
70 */
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider, HotSpotProxified {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72
22509
267eecd6d92a suppressed -Xlint:try warnings
Doug Simon <doug.simon@oracle.com>
parents: 22486
diff changeset
73 @SuppressWarnings("try")
22462
7a7dd51e7e0b Ensure that calling HotSpotJVMCIRuntime.runtime() initializes JVMCI correctly
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22454
diff changeset
74 static class DelayedInit {
7a7dd51e7e0b Ensure that calling HotSpotJVMCIRuntime.runtime() initializes JVMCI correctly
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22454
diff changeset
75 private static final HotSpotJVMCIRuntime instance;
7a7dd51e7e0b Ensure that calling HotSpotJVMCIRuntime.runtime() initializes JVMCI correctly
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22454
diff changeset
76
7a7dd51e7e0b Ensure that calling HotSpotJVMCIRuntime.runtime() initializes JVMCI correctly
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22454
diff changeset
77 static {
22658
61bb5fa12458 Remove StartupEventListener interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 22657
diff changeset
78 try (InitTimer t = timer("HotSpotJVMCIRuntime.<init>")) {
61bb5fa12458 Remove StartupEventListener interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 22657
diff changeset
79 instance = new HotSpotJVMCIRuntime();
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
84 /**
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85 * Gets the singleton {@link HotSpotJVMCIRuntime} object.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 */
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
87 public static HotSpotJVMCIRuntime runtime() {
22694
023981d7f257 Fix deadlock between JVMCI.initialize and HotSpotJVMCIRuntime.runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22672
diff changeset
88 JVMCI.initialize();
22462
7a7dd51e7e0b Ensure that calling HotSpotJVMCIRuntime.runtime() initializes JVMCI correctly
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22454
diff changeset
89 return DelayedInit.instance;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
90 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
91
22758
a130b51efb07 removed @Option mechanism from JVMCI (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents: 22697
diff changeset
92 /**
23306
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
93 * A list of all supported JVMCI options.
22758
a130b51efb07 removed @Option mechanism from JVMCI (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents: 22697
diff changeset
94 */
23306
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
95 public enum Option {
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
96 Compiler(String.class, null, "Selects the system compiler."),
23306
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
97 // Note: The following one is not used (see InitTimer.ENABLED).
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
98 InitTimer(boolean.class, false, "Specifies if initialization timing is enabled."),
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
99 PrintConfig(boolean.class, false, "Prints all HotSpotVMConfig fields."),
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
100 PrintFlags(boolean.class, false, "Prints all JVMCI flags and exits."),
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
101 ShowFlags(boolean.class, false, "Prints all JVMCI flags and continues."),
23384
f102ee538647 Remove stable constant handling from ConstantReflectionProvider (JDK-8156552).
Roland Schatz <roland.schatz@oracle.com>
parents: 23383
diff changeset
102 TraceMethodDataFilter(String.class, null, "");
23306
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
103
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
104 /**
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
105 * The prefix for system properties that are JVMCI options.
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
106 */
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
107 private static final String JVMCI_OPTION_PROPERTY_PREFIX = "jvmci.";
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
108
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
109 /**
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
110 * Marker for uninitialized flags.
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
111 */
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
112 private static final String UNINITIALIZED = "UNINITIALIZED";
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
113
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
114 private final Class<?> type;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
115 private Object value;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
116 private final Object defaultValue;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
117 private boolean isDefault;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
118 private final String help;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
119
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
120 Option(Class<?> type, Object defaultValue, String help) {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
121 assert Character.isUpperCase(name().charAt(0)) : "Option name must start with upper-case letter: " + name();
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
122 this.type = type;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
123 this.value = UNINITIALIZED;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
124 this.defaultValue = defaultValue;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
125 this.help = help;
22758
a130b51efb07 removed @Option mechanism from JVMCI (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents: 22697
diff changeset
126 }
23306
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
127
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
128 @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "sentinel must be String since it's a static final in an enum")
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
129 private Object getValue() {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
130 if (value == UNINITIALIZED) {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
131 String propertyValue = VM.getSavedProperty(JVMCI_OPTION_PROPERTY_PREFIX + name());
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
132 if (propertyValue == null) {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
133 this.value = defaultValue;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
134 this.isDefault = true;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
135 } else {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
136 if (type == boolean.class) {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
137 this.value = Boolean.parseBoolean(propertyValue);
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
138 } else if (type == String.class) {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
139 this.value = propertyValue;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
140 } else {
23387
a920338dd4d4 remove JVMCIError and UnsafeUtil classes (JDK-8156759)
Doug Simon <doug.simon@oracle.com>
parents: 23384
diff changeset
141 throw new InternalError("Unexpected option type " + type);
23306
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
142 }
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
143 this.isDefault = false;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
144 }
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
145 // Saved properties should not be interned - let's be sure
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
146 assert value != UNINITIALIZED;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
147 }
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
148 return value;
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
149 }
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
150
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
151 /**
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
152 * Returns the option's value as boolean.
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
153 *
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
154 * @return option's value
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
155 */
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
156 public boolean getBoolean() {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
157 return (boolean) getValue();
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
158 }
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
159
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
160 /**
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
161 * Returns the option's value as String.
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
162 *
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
163 * @return option's value
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
164 */
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
165 public String getString() {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
166 return (String) getValue();
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
167 }
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
168
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
169 /**
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
170 * Prints all option flags to {@code out}.
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
171 *
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
172 * @param out stream to print to
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
173 */
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
174 public static void printFlags(PrintStream out) {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
175 out.println("[List of JVMCI options]");
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
176 for (Option option : values()) {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
177 Object value = option.getValue();
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
178 String assign = option.isDefault ? ":=" : " =";
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
179 out.printf("%9s %-40s %s %-14s %s%n", option.type.getSimpleName(), option, assign, value, option.help);
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
180 }
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
181 }
22758
a130b51efb07 removed @Option mechanism from JVMCI (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents: 22697
diff changeset
182 }
a130b51efb07 removed @Option mechanism from JVMCI (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents: 22697
diff changeset
183
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
184 public static HotSpotJVMCIBackendFactory findFactory(String architecture) {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
185 for (HotSpotJVMCIBackendFactory factory : Services.load(HotSpotJVMCIBackendFactory.class)) {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
186 if (factory.getArchitecture().equalsIgnoreCase(architecture)) {
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents: 22422
diff changeset
187 return factory;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
188 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
189 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
190
23387
a920338dd4d4 remove JVMCIError and UnsafeUtil classes (JDK-8156759)
Doug Simon <doug.simon@oracle.com>
parents: 23384
diff changeset
191 throw new InternalError(String.format("No JVMCI runtime available for the %s architecture", architecture));
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
192 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
193
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194 /**
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195 * Gets the kind of a word value on the {@linkplain #getHostJVMCIBackend() host} backend.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
196 */
22536
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22509
diff changeset
197 public static JavaKind getHostWordKind() {
22567
bfd5fdca1ce9 Clean separation between backend and frontend wordKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22562
diff changeset
198 return runtime().getHostJVMCIBackend().getCodeCache().getTarget().wordJavaKind;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
200
22546
f95eb4e457af made HotSpotJVMCIRuntime.compilerToVm final (GRAAL-1255)
Doug Simon <doug.simon@oracle.com>
parents: 22536
diff changeset
201 protected final CompilerToVM compilerToVm;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
202
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 protected final HotSpotVMConfig config;
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204 private final JVMCIBackend hostBackend;
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
205
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
206 private final JVMCICompilerFactory compilerFactory;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
207 private final HotSpotJVMCICompilerFactory hsCompilerFactory;
22697
57646377e480 Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents: 22694
diff changeset
208 private volatile JVMCICompiler compiler;
22422
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
209 protected final JVMCIMetaAccessContext metaAccessContext;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
211 /**
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
212 * Stores the result of {@link HotSpotJVMCICompilerFactory#getCompilationLevelAdjustment} so
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
213 * that it can be read from the VM.
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
214 */
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
215 @SuppressWarnings("unused") private final int compilationLevelAdjustment;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
216
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
217 private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>();
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
218
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21675
diff changeset
219 private final Iterable<HotSpotVMEventListener> vmEventListeners;
21616
4c146c9367b6 recast VM compilation request via JVMCI to be a HotSpot JVMCI event, removing the last direct reference to a Graal class in the VM (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
220
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
221 /**
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
222 * Stores the result of {@link HotSpotJVMCICompilerFactory#getTrivialPrefixes()} so that it can
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
223 * be read from the VM.
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
224 */
22656
d634e615b00d Lazily initialize compiler on first compilation request.
Roland Schatz <roland.schatz@oracle.com>
parents: 22634
diff changeset
225 @SuppressWarnings("unused") private final String[] trivialPrefixes;
22575
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22567
diff changeset
226
22509
267eecd6d92a suppressed -Xlint:try warnings
Doug Simon <doug.simon@oracle.com>
parents: 22486
diff changeset
227 @SuppressWarnings("try")
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
228 private HotSpotJVMCIRuntime() {
22547
10a9e989850e made CompilertoVM a final concrete class and removed CompilerToVMImpl (GRAAL-1255)
Doug Simon <doug.simon@oracle.com>
parents: 22546
diff changeset
229 compilerToVm = new CompilerToVM();
22562
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
230
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
231 try (InitTimer t = timer("HotSpotVMConfig<init>")) {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
232 config = new HotSpotVMConfig(compilerToVm);
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
233 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
234
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
235 String hostArchitecture = config.getHostArchitectureName();
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
236
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
237 HotSpotJVMCIBackendFactory factory;
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
238 try (InitTimer t = timer("find factory:", hostArchitecture)) {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
239 factory = findFactory(hostArchitecture);
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
240 }
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents: 22422
diff changeset
241
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
242 try (InitTimer t = timer("create JVMCI backend:", hostArchitecture)) {
22613
9409f7cec59a Remove dependency from HotSpotJVMCIRuntime to CompilerFactory.
Roland Schatz <roland.schatz@oracle.com>
parents: 22593
diff changeset
243 hostBackend = registerBackend(factory.createJVMCIBackend(this, null));
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
244 }
21616
4c146c9367b6 recast VM compilation request via JVMCI to be a HotSpot JVMCI event, removing the last direct reference to a Graal class in the VM (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
245
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents: 22422
diff changeset
246 vmEventListeners = Services.load(HotSpotVMEventListener.class);
22422
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
247
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
248 JVMCIMetaAccessContext context = null;
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
249 for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22429
diff changeset
250 context = vmEventListener.createMetaAccessContext(this);
22422
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
251 if (context != null) {
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
252 break;
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
253 }
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
254 }
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
255 if (context == null) {
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22429
diff changeset
256 context = new HotSpotJVMCIMetaAccessContext();
22422
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
257 }
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
258 metaAccessContext = context;
22562
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
259
23306
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
260 boolean printFlags = Option.PrintFlags.getBoolean();
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
261 boolean showFlags = Option.ShowFlags.getBoolean();
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
262 if (printFlags || showFlags) {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
263 Option.printFlags(System.out);
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
264 if (printFlags) {
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
265 System.exit(0);
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
266 }
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
267 }
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
268
7b09dede4552 JVMCI options should not use System.getProperty() directly (JDK-8146820)
Doug Simon <doug.simon@oracle.com>
parents: 22779
diff changeset
269 if (Option.PrintConfig.getBoolean()) {
22562
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
270 printConfig(config, compilerToVm);
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
271 }
22656
d634e615b00d Lazily initialize compiler on first compilation request.
Roland Schatz <roland.schatz@oracle.com>
parents: 22634
diff changeset
272
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
273 compilerFactory = HotSpotJVMCICompilerConfig.getCompilerFactory();
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
274 if (compilerFactory instanceof HotSpotJVMCICompilerFactory) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
275 hsCompilerFactory = (HotSpotJVMCICompilerFactory) compilerFactory;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
276 trivialPrefixes = hsCompilerFactory.getTrivialPrefixes();
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
277 compilationLevelAdjustment = hsCompilerFactory.getCompilationLevelAdjustment(config);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
278 } else {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
279 hsCompilerFactory = null;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
280 trivialPrefixes = null;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
281 compilationLevelAdjustment = 0;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
282 }
22422
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
283 }
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
284
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
285 private JVMCIBackend registerBackend(JVMCIBackend backend) {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
286 Class<? extends Architecture> arch = backend.getCodeCache().getTarget().arch.getClass();
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
287 JVMCIBackend oldValue = backends.put(arch, backend);
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
288 assert oldValue == null : "cannot overwrite existing backend for architecture " + arch.getSimpleName();
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
289 return backend;
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
290 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
291
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
292 public ResolvedJavaType fromClass(Class<?> javaClass) {
22422
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
293 return metaAccessContext.fromClass(javaClass);
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
294 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
295
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
296 public HotSpotVMConfig getConfig() {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
297 return config;
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
298 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
299
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
300 public CompilerToVM getCompilerToVM() {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
301 return compilerToVm;
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
302 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
303
22422
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
304 public JVMCIMetaAccessContext getMetaAccessContext() {
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
305 return metaAccessContext;
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
306 }
a98a02bad801 Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
307
22697
57646377e480 Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents: 22694
diff changeset
308 public JVMCICompiler getCompiler() {
22656
d634e615b00d Lazily initialize compiler on first compilation request.
Roland Schatz <roland.schatz@oracle.com>
parents: 22634
diff changeset
309 if (compiler == null) {
22657
9203f93ffeb0 Fix race condition in lazy compiler initialization.
Roland Schatz <roland.schatz@oracle.com>
parents: 22656
diff changeset
310 synchronized (this) {
9203f93ffeb0 Fix race condition in lazy compiler initialization.
Roland Schatz <roland.schatz@oracle.com>
parents: 22656
diff changeset
311 if (compiler == null) {
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
312 compiler = compilerFactory.createCompiler(this);
22657
9203f93ffeb0 Fix race condition in lazy compiler initialization.
Roland Schatz <roland.schatz@oracle.com>
parents: 22656
diff changeset
313 }
9203f93ffeb0 Fix race condition in lazy compiler initialization.
Roland Schatz <roland.schatz@oracle.com>
parents: 22656
diff changeset
314 }
22656
d634e615b00d Lazily initialize compiler on first compilation request.
Roland Schatz <roland.schatz@oracle.com>
parents: 22634
diff changeset
315 }
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents: 22422
diff changeset
316 return compiler;
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents: 22422
diff changeset
317 }
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents: 22422
diff changeset
318
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
319 public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve) {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
320 Objects.requireNonNull(accessingType, "cannot resolve type without an accessing class");
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
321 // If the name represents a primitive type we can short-circuit the lookup.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
322 if (name.length() == 1) {
22536
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22509
diff changeset
323 JavaKind kind = JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0));
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
324 return fromClass(kind.toJavaClass());
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
325 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
326
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
327 // Resolve non-primitive types in the VM.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
328 HotSpotResolvedObjectTypeImpl hsAccessingType = (HotSpotResolvedObjectTypeImpl) accessingType;
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22429
diff changeset
329 final HotSpotResolvedObjectTypeImpl klass = compilerToVm.lookupType(name, hsAccessingType.mirror(), resolve);
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
330
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22429
diff changeset
331 if (klass == null) {
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
332 assert resolve == false;
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
333 return HotSpotUnresolvedJavaType.create(this, name);
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
334 }
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22429
diff changeset
335 return klass;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
336 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
337
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
338 public JVMCIBackend getHostJVMCIBackend() {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
339 return hostBackend;
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
340 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
341
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
342 public <T extends Architecture> JVMCIBackend getJVMCIBackend(Class<T> arch) {
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
343 assert arch != Architecture.class;
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
344 return backends.get(arch);
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
345 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
346
22562
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
347 public Map<Class<? extends Architecture>, JVMCIBackend> getJVMCIBackends() {
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
348 return Collections.unmodifiableMap(backends);
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
349 }
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
350
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
351 /**
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
352 * Called from the VM.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
353 */
21616
4c146c9367b6 recast VM compilation request via JVMCI to be a HotSpot JVMCI event, removing the last direct reference to a Graal class in the VM (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
354 @SuppressWarnings({"unused"})
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
355 private int adjustCompilationLevel(Class<?> declaringClass, String name, String signature, boolean isOsr, int level) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
356 return hsCompilerFactory.adjustCompilationLevel(config, declaringClass, name, signature, isOsr, level);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
357 }
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
358
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
359 /**
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
360 * Called from the VM.
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
361 */
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23363
diff changeset
362 @SuppressWarnings({"unused"})
22770
1fbfcc0334d3 JVMCI PrintCompilation support should reuse CompileBroker logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22767
diff changeset
363 private CompilationRequestResult compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) {
22779
b41377216cf9 JVMCICompiler.compileMethod should always return non-null
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22773
diff changeset
364 CompilationRequestResult result = getCompiler().compileMethod(new HotSpotCompilationRequest(method, entryBCI, jvmciEnv, id));
b41377216cf9 JVMCICompiler.compileMethod should always return non-null
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22773
diff changeset
365 assert result != null : "compileMethod must always return something";
b41377216cf9 JVMCICompiler.compileMethod should always return non-null
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22773
diff changeset
366 return result;
21616
4c146c9367b6 recast VM compilation request via JVMCI to be a HotSpot JVMCI event, removing the last direct reference to a Graal class in the VM (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
367 }
4c146c9367b6 recast VM compilation request via JVMCI to be a HotSpot JVMCI event, removing the last direct reference to a Graal class in the VM (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
368
4c146c9367b6 recast VM compilation request via JVMCI to be a HotSpot JVMCI event, removing the last direct reference to a Graal class in the VM (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
369 /**
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
370 * Shuts down the runtime.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
371 *
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
372 * Called from the VM.
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
373 */
21616
4c146c9367b6 recast VM compilation request via JVMCI to be a HotSpot JVMCI event, removing the last direct reference to a Graal class in the VM (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
374 @SuppressWarnings({"unused"})
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
375 private void shutdown() throws Exception {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21675
diff changeset
376 for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21675
diff changeset
377 vmEventListener.notifyShutdown();
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21675
diff changeset
378 }
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
379 }
22299
7b4a47fcc4c0 Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22054
diff changeset
380
22593
cabc2b8bc3f1 Make HotSpotCodeCacheProvider.installMethod throw an exception if code installation fails
twisti
parents: 22581
diff changeset
381 /**
23383
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
382 * Notify on completion of a bootstrap.
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
383 *
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
384 * Called from the VM.
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
385 */
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
386 @SuppressWarnings({"unused"})
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
387 private void bootstrapFinished() throws Exception {
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
388 for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
389 vmEventListener.notifyBootstrapFinished();
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
390 }
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
391 }
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
392
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
393 /**
22593
cabc2b8bc3f1 Make HotSpotCodeCacheProvider.installMethod throw an exception if code installation fails
twisti
parents: 22581
diff changeset
394 * Notify on successful install into the CodeCache.
cabc2b8bc3f1 Make HotSpotCodeCacheProvider.installMethod throw an exception if code installation fails
twisti
parents: 22581
diff changeset
395 *
cabc2b8bc3f1 Make HotSpotCodeCacheProvider.installMethod throw an exception if code installation fails
twisti
parents: 22581
diff changeset
396 * @param hotSpotCodeCacheProvider
cabc2b8bc3f1 Make HotSpotCodeCacheProvider.installMethod throw an exception if code installation fails
twisti
parents: 22581
diff changeset
397 * @param installedCode
22773
9273bb6ba33e Simplify code installation interface: Use CompiledCode class instead of CompilationResult and DataSection.
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
398 * @param compiledCode
22593
cabc2b8bc3f1 Make HotSpotCodeCacheProvider.installMethod throw an exception if code installation fails
twisti
parents: 22581
diff changeset
399 */
22773
9273bb6ba33e Simplify code installation interface: Use CompiledCode class instead of CompilationResult and DataSection.
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
400 void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
22299
7b4a47fcc4c0 Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22054
diff changeset
401 for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
22773
9273bb6ba33e Simplify code installation interface: Use CompiledCode class instead of CompilationResult and DataSection.
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
402 vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode);
22299
7b4a47fcc4c0 Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22054
diff changeset
403 }
7b4a47fcc4c0 Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22054
diff changeset
404 }
22562
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
405
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
406 private static void printConfig(HotSpotVMConfig config, CompilerToVM vm) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
407 Field[] fields = config.getClass().getDeclaredFields();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
408 Map<String, Field> sortedFields = new TreeMap<>();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
409 for (Field f : fields) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
410 if (!f.isSynthetic() && !Modifier.isStatic(f.getModifiers())) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
411 f.setAccessible(true);
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
412 sortedFields.put(f.getName(), f);
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
413 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
414 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
415 for (Field f : sortedFields.values()) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
416 try {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
417 String line = String.format("%9s %-40s = %s%n", f.getType().getSimpleName(), f.getName(), pretty(f.get(config)));
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
418 byte[] lineBytes = line.getBytes();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
419 vm.writeDebugOutput(lineBytes, 0, lineBytes.length);
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
420 vm.flushDebugOutput();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
421 } catch (Exception e) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
422 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
423 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
424 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
425
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
426 private static String pretty(Object value) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
427 if (value == null) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
428 return "null";
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
429 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
430
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
431 Class<?> klass = value.getClass();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
432 if (value instanceof String) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
433 return "\"" + value + "\"";
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
434 } else if (value instanceof Method) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
435 return "method \"" + ((Method) value).getName() + "\"";
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
436 } else if (value instanceof Class<?>) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
437 return "class \"" + ((Class<?>) value).getSimpleName() + "\"";
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
438 } else if (value instanceof Integer) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
439 if ((Integer) value < 10) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
440 return value.toString();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
441 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
442 return value + " (0x" + Integer.toHexString((Integer) value) + ")";
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
443 } else if (value instanceof Long) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
444 if ((Long) value < 10 && (Long) value > -10) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
445 return value + "l";
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
446 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
447 return value + "l (0x" + Long.toHexString((Long) value) + "l)";
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
448 } else if (klass.isArray()) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
449 StringBuilder str = new StringBuilder();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
450 int dimensions = 0;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
451 while (klass.isArray()) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
452 dimensions++;
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
453 klass = klass.getComponentType();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
454 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
455 int length = Array.getLength(value);
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
456 str.append(klass.getSimpleName()).append('[').append(length).append(']');
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
457 for (int i = 1; i < dimensions; i++) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
458 str.append("[]");
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
459 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
460 str.append(" {");
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
461 for (int i = 0; i < length; i++) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
462 str.append(pretty(Array.get(value, i)));
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
463 if (i < length - 1) {
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
464 str.append(", ");
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
465 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
466 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
467 str.append('}');
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
468 return str.toString();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
469 }
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
470 return value.toString();
28fe5850735e removed HotSpotVMEventListener.completeInitialization; moved implementation of -Djvmci.printconfig=true to JVMCI; moved javadoc to method from static initializer
Doug Simon <doug.simon@oracle.com>
parents: 22550
diff changeset
471 }
22626
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
472
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
473 public OutputStream getLogStream() {
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
474 return new OutputStream() {
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
475
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
476 @Override
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
477 public void write(byte[] b, int off, int len) throws IOException {
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
478 if (b == null) {
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
479 throw new NullPointerException();
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
480 } else if (off < 0 || off > b.length || len < 0 || (off + len) > b.length || (off + len) < 0) {
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
481 throw new IndexOutOfBoundsException();
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
482 } else if (len == 0) {
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
483 return;
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
484 }
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
485 compilerToVm.writeDebugOutput(b, off, len);
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
486 }
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
487
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
488 @Override
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
489 public void write(int b) throws IOException {
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
490 write(new byte[]{(byte) b}, 0, 1);
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
491 }
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
492
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
493 @Override
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
494 public void flush() throws IOException {
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
495 compilerToVm.flushDebugOutput();
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
496 }
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
497 };
b6b46b741102 added HotSpotJVMCIRuntimeProvider.getLogStream() and made CompilerToVM.writeDebugOutput and CompilerToVm.flushDebugOutput package-private
Doug Simon <doug.simon@oracle.com>
parents: 22623
diff changeset
498 }
22634
02d95720c455 added HotSpotJVMCIRuntimeProvider.collectCounters and made CompilerToVM.collectCounters package-private
Doug Simon <doug.simon@oracle.com>
parents: 22626
diff changeset
499
02d95720c455 added HotSpotJVMCIRuntimeProvider.collectCounters and made CompilerToVM.collectCounters package-private
Doug Simon <doug.simon@oracle.com>
parents: 22626
diff changeset
500 /**
02d95720c455 added HotSpotJVMCIRuntimeProvider.collectCounters and made CompilerToVM.collectCounters package-private
Doug Simon <doug.simon@oracle.com>
parents: 22626
diff changeset
501 * Collects the current values of all JVMCI benchmark counters, summed up over all threads.
02d95720c455 added HotSpotJVMCIRuntimeProvider.collectCounters and made CompilerToVM.collectCounters package-private
Doug Simon <doug.simon@oracle.com>
parents: 22626
diff changeset
502 */
02d95720c455 added HotSpotJVMCIRuntimeProvider.collectCounters and made CompilerToVM.collectCounters package-private
Doug Simon <doug.simon@oracle.com>
parents: 22626
diff changeset
503 public long[] collectCounters() {
02d95720c455 added HotSpotJVMCIRuntimeProvider.collectCounters and made CompilerToVM.collectCounters package-private
Doug Simon <doug.simon@oracle.com>
parents: 22626
diff changeset
504 return compilerToVm.collectCounters();
02d95720c455 added HotSpotJVMCIRuntimeProvider.collectCounters and made CompilerToVM.collectCounters package-private
Doug Simon <doug.simon@oracle.com>
parents: 22626
diff changeset
505 }
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
506 }