comparison graal/com.oracle.max.graal.compiler/src/com/sun/c1x/observer/CompilationEvent.java @ 2872:0341b6424579

Project renaming.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 08 Jun 2011 08:42:25 +0200
parents graal/GraalCompiler/src/com/sun/c1x/observer/CompilationEvent.java@b003ea36fa12
children
comparison
equal deleted inserted replaced
2871:d704eb526603 2872:0341b6424579
1 /*
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package com.sun.c1x.observer;
24
25 import java.util.*;
26
27 import com.oracle.graal.graph.*;
28 import com.sun.c1x.*;
29 import com.sun.c1x.alloc.*;
30 import com.sun.c1x.graph.*;
31 import com.sun.cri.ci.*;
32 import com.sun.cri.ri.*;
33
34 /**
35 * An event that occurred during compilation. Instances of this class provide information about the event and the state
36 * of the compilation when the event was raised. {@link #getCompilation()} and {@link #getMethod()} are guaranteed to
37 * always return a non-{@code null} value. Other objects provided by getter methods may be {@code null},
38 * depending on the available information when and where the event was triggered.
39 *
40 * @author Peter Hofer
41 */
42 public class CompilationEvent {
43
44 private final C1XCompilation compilation;
45 private final String label;
46 private Graph graph;
47
48 private BlockMap blockMap;
49 private int codeSize = -1;
50
51 private LinearScan allocator;
52 private CiTargetMethod targetMethod;
53 private boolean hirValid = false;
54 private boolean lirValid = false;
55
56 private Interval[] intervals;
57 private int intervalsSize;
58 private Interval[] intervalsCopy = null;
59
60 public CompilationEvent(C1XCompilation compilation) {
61 this(compilation, null);
62 }
63
64 private CompilationEvent(C1XCompilation compilation, String label) {
65 assert compilation != null;
66 this.label = label;
67 this.compilation = compilation;
68 }
69
70 public CompilationEvent(C1XCompilation compilation, String label, Graph graph, boolean hirValid, boolean lirValid) {
71 this(compilation, label);
72 this.graph = graph;
73 this.hirValid = hirValid;
74 this.lirValid = lirValid;
75 }
76
77 public CompilationEvent(C1XCompilation compilation, String label, Graph graph, boolean hirValid, boolean lirValid, CiTargetMethod targetMethod) {
78 this(compilation, label, graph, hirValid, lirValid);
79 this.targetMethod = targetMethod;
80 }
81
82 public CompilationEvent(C1XCompilation compilation, String label, BlockMap blockMap, int codeSize) {
83 this(compilation, label);
84 this.blockMap = blockMap;
85 this.codeSize = codeSize;
86 }
87
88 public CompilationEvent(C1XCompilation compilation, String label, LinearScan allocator, Interval[] intervals, int intervalsSize) {
89 this(compilation, label);
90 this.allocator = allocator;
91 this.intervals = intervals;
92 this.intervalsSize = intervalsSize;
93 }
94
95 public C1XCompilation getCompilation() {
96 return compilation;
97 }
98
99 public String getLabel() {
100 return label;
101 }
102
103 public RiMethod getMethod() {
104 return compilation.method;
105 }
106
107 public BlockMap getBlockMap() {
108 return blockMap;
109 }
110
111 public Graph getGraph() {
112 return graph;
113 }
114
115 public LinearScan getAllocator() {
116 return allocator;
117 }
118
119 public CiTargetMethod getTargetMethod() {
120 return targetMethod;
121 }
122
123 public boolean isHIRValid() {
124 return hirValid;
125 }
126
127 public boolean isLIRValid() {
128 return lirValid;
129 }
130
131 public Interval[] getIntervals() {
132 if (intervalsCopy == null && intervals != null) {
133 // deferred copy of the valid range of the intervals array
134 intervalsCopy = Arrays.copyOf(intervals, intervalsSize);
135 }
136 return intervalsCopy;
137 }
138
139 public int getCodeSize() {
140 return codeSize;
141 }
142 }