Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/SpeculationLog.java @ 21610:f555efead2f2
Fix options in makefile
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Fri, 29 May 2015 20:43:55 -0700 |
parents | f5b549811bac |
children |
rev | line source |
---|---|
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19507
diff
changeset
|
23 package com.oracle.jvmci.code; |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19507
diff
changeset
|
25 import com.oracle.jvmci.meta.JavaConstant; |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 import java.util.*; |
13643
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
27 import java.util.concurrent.*; |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 /** |
13641
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11833
diff
changeset
|
30 * Manages a list of unique deoptimization reasons. |
19507
1cde96b96673
Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
31 * |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 */ |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13673
diff
changeset
|
33 public abstract class SpeculationLog { |
13643
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
34 private volatile Object lastFailed; |
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
35 private volatile Collection<Object> speculations; |
13641
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11833
diff
changeset
|
36 private Set<Object> failedSpeculations; |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 |
13641
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11833
diff
changeset
|
38 public synchronized void collectFailedSpeculations() { |
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11833
diff
changeset
|
39 if (lastFailed != null) { |
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11833
diff
changeset
|
40 if (failedSpeculations == null) { |
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11833
diff
changeset
|
41 failedSpeculations = new HashSet<>(2); |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 } |
13641
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11833
diff
changeset
|
43 failedSpeculations.add(lastFailed); |
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11833
diff
changeset
|
44 lastFailed = null; |
13643
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
45 speculations = null; |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 } |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 } |
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 |
13673
bd94d77af2c1
SpeculationLog: split maySpeculate into maySpeculate (check only) and speculate (register)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13643
diff
changeset
|
49 public boolean maySpeculate(Object reason) { |
13641
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11833
diff
changeset
|
50 if (failedSpeculations != null && failedSpeculations.contains(reason)) { |
13673
bd94d77af2c1
SpeculationLog: split maySpeculate into maySpeculate (check only) and speculate (register)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13643
diff
changeset
|
51 return false; |
11833
b71a1d889db2
SpeculationLog gives back the necessary Constant when calling maySpeculate. Remove the deoptimizationReasonfrom the DebugInfo
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
52 } |
13673
bd94d77af2c1
SpeculationLog: split maySpeculate into maySpeculate (check only) and speculate (register)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13643
diff
changeset
|
53 return true; |
bd94d77af2c1
SpeculationLog: split maySpeculate into maySpeculate (check only) and speculate (register)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13643
diff
changeset
|
54 } |
bd94d77af2c1
SpeculationLog: split maySpeculate into maySpeculate (check only) and speculate (register)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13643
diff
changeset
|
55 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13673
diff
changeset
|
56 protected void addSpeculation(Object reason) { |
13673
bd94d77af2c1
SpeculationLog: split maySpeculate into maySpeculate (check only) and speculate (register)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13643
diff
changeset
|
57 assert maySpeculate(reason); |
13643
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
58 if (speculations == null) { |
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
59 synchronized (this) { |
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
60 if (speculations == null) { |
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
61 speculations = new ConcurrentLinkedQueue<>(); |
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
62 } |
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
63 } |
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
64 } |
4463c520f475
Keep speculations alive in the speculation log
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
65 speculations.add(reason); |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13673
diff
changeset
|
67 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
68 public abstract JavaConstant speculate(Object reason); |
8217
dce9cefed571
Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 } |