Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java @ 23785:5cf445d2acf6 jvmci-0.22
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 11 Oct 2016 22:13:23 +0200 |
parents | 9e1235406b59 |
children | 7d8e0c328b64 |
rev | line source |
---|---|
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
1 /* |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
4 * |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
8 * |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
14 * |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
18 * |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
22 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
23 package jdk.vm.ci.hotspot; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
24 |
22699
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
25 import java.util.Collection; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
26 import java.util.HashSet; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
27 import java.util.Set; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
28 import java.util.concurrent.ConcurrentLinkedQueue; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
29 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
30 import jdk.vm.ci.meta.JavaConstant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
31 import jdk.vm.ci.meta.SpeculationLog; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
32 |
22699
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
33 public class HotSpotSpeculationLog implements SpeculationLog { |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
34 |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
35 /** Written by the C++ code that performs deoptimization. */ |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
36 private volatile Object lastFailed; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
37 |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23346
diff
changeset
|
38 /** All speculations that have caused a deoptimization. */ |
22699
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
39 private Set<SpeculationReason> failedSpeculations; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
40 |
23344
32d6bceb9adc
do not install an empty SpeculationLog in an nmethod (JDK-8153439)
Doug Simon <doug.simon@oracle.com>
parents:
22699
diff
changeset
|
41 /** Strong references to all reasons embedded in the current nmethod. */ |
22699
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
42 private volatile Collection<SpeculationReason> speculations; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
43 |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
44 @Override |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
45 public synchronized void collectFailedSpeculations() { |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
46 if (lastFailed != null) { |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
47 if (failedSpeculations == null) { |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
48 failedSpeculations = new HashSet<>(2); |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
49 } |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
50 failedSpeculations.add((SpeculationReason) lastFailed); |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
51 lastFailed = null; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
52 speculations = null; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
53 } |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
54 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
55 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
56 @Override |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23346
diff
changeset
|
57 public synchronized boolean maySpeculate(SpeculationReason reason) { |
22699
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
58 if (failedSpeculations != null && failedSpeculations.contains(reason)) { |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
59 return false; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
60 } |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
61 return true; |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
62 } |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
63 |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
64 @Override |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
65 public JavaConstant speculate(SpeculationReason reason) { |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
66 assert maySpeculate(reason); |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
67 |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
68 /* |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
69 * Objects referenced from nmethods are weak references. We need a strong reference to the |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
70 * reason objects that are embedded in nmethods, so we add them to the speculations |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
71 * collection. |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
72 */ |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
73 if (speculations == null) { |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
74 synchronized (this) { |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
75 if (speculations == null) { |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
76 speculations = new ConcurrentLinkedQueue<>(); |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
77 } |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
78 } |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
79 } |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
80 speculations.add(reason); |
ea58bbafd5b9
Move SpeculationLog implementation to HotSpotSpeculationLog, because it is not useful for other VMs
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
81 |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
82 return HotSpotObjectConstantImpl.forObject(reason); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
83 } |
23344
32d6bceb9adc
do not install an empty SpeculationLog in an nmethod (JDK-8153439)
Doug Simon <doug.simon@oracle.com>
parents:
22699
diff
changeset
|
84 |
23346
39f25354aeee
Sync speculation log changes with JDK9 version
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
23344
diff
changeset
|
85 @Override |
23344
32d6bceb9adc
do not install an empty SpeculationLog in an nmethod (JDK-8153439)
Doug Simon <doug.simon@oracle.com>
parents:
22699
diff
changeset
|
86 public synchronized boolean hasSpeculations() { |
32d6bceb9adc
do not install an empty SpeculationLog in an nmethod (JDK-8153439)
Doug Simon <doug.simon@oracle.com>
parents:
22699
diff
changeset
|
87 return speculations != null && !speculations.isEmpty(); |
32d6bceb9adc
do not install an empty SpeculationLog in an nmethod (JDK-8153439)
Doug Simon <doug.simon@oracle.com>
parents:
22699
diff
changeset
|
88 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
89 } |