Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java @ 11586:9652640fae42
tightened option verifier to check all class initializers in the hierarchy of a class that declares at least one @Option
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 10 Sep 2013 21:29:31 +0200 |
parents | eae432b7c462 |
children | d9342daa5078 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
8999
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
23 package com.oracle.graal.phases; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
25 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
26 import com.oracle.graal.nodes.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 |
8999
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
28 /** |
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
29 * Base class for all compiler phases. Subclasses should be stateless. There will be one global |
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
30 * instance for each compiler phase that is shared for all compilations. VM-, target- and |
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
31 * compilation-specific data can be passed with a context object. |
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
32 */ |
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
33 public abstract class BasePhase<C> { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
35 private String name; |
11586
9652640fae42
tightened option verifier to check all class initializers in the hierarchy of a class that declares at least one @Option
Doug Simon <doug.simon@oracle.com>
parents:
8999
diff
changeset
|
36 |
5134
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
37 private static final DebugMetric metricPhaseRuns = Debug.metric("Runs"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 |
8999
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
39 protected BasePhase() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 this.name = this.getClass().getSimpleName(); |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
41 if (name.endsWith("Phase")) { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
42 name = name.substring(0, name.length() - "Phase".length()); |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
43 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 |
8999
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
46 protected BasePhase(String name) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 this.name = name; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 protected String getDetailedName() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 return getName(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 |
8999
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
54 public final void apply(final StructuredGraph graph, final C context) { |
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
55 apply(graph, context, true); |
4546
df329f268a05
Make IntegerAddNode non-final.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
56 } |
df329f268a05
Make IntegerAddNode non-final.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
57 |
8999
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
58 public final void apply(final StructuredGraph graph, final C context, final boolean dumpGraph) { |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
59 Debug.scope(name, this, new Runnable() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6526
diff
changeset
|
60 |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
61 public void run() { |
8999
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
62 BasePhase.this.run(graph, context); |
5134
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
63 metricPhaseRuns.increment(); |
4546
df329f268a05
Make IntegerAddNode non-final.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
64 if (dumpGraph) { |
df329f268a05
Make IntegerAddNode non-final.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
65 Debug.dump(graph, "After phase %s", name); |
df329f268a05
Make IntegerAddNode non-final.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
66 } |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4546
diff
changeset
|
67 assert graph.verify(); |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
68 } |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
69 }); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 public final String getName() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 return name; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 |
8999
eae432b7c462
Pass context object to compiler phases.
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
76 protected abstract void run(StructuredGraph graph, C context); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 } |