annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/TraceCompilationFailureListener.java @ 19521:9c4168877444

Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 20 Feb 2015 13:58:56 +0100
parents 0a72a0f9ef2e
children 48c1ebd24120
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18208
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
1 /*
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
4 *
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
7 * published by the Free Software Foundation.
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
8 *
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
13 * accompanied this code).
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
14 *
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
15 * You should have received a copy of the GNU General Public License version
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
18 *
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
21 * questions.
abe9758da9d9 Truffle: add headers for new compilation listener files.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
22 */
18200
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 package com.oracle.graal.truffle.debug;
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 import java.util.*;
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27 import com.oracle.graal.api.code.*;
19521
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18216
diff changeset
28 import com.oracle.graal.compiler.common.*;
18200
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29 import com.oracle.graal.nodes.*;
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30 import com.oracle.graal.truffle.*;
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
31
18214
ed32f33e7cb6 Truffle: checkstyle fixes.
Christian Humer <christian.humer@gmail.com>
parents: 18208
diff changeset
32 public final class TraceCompilationFailureListener extends AbstractDebugCompilationListener {
18200
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
33
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34 private TraceCompilationFailureListener() {
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35 }
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 public static void install(GraalTruffleRuntime runtime) {
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 runtime.addCompilationListener(new TraceCompilationFailureListener());
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 }
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
40
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
41 @Override
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42 public void notifyCompilationFailed(OptimizedCallTarget target, StructuredGraph graph, Throwable t) {
19521
9c4168877444 Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18216
diff changeset
43 if (isPermanentBailout(t) || GraalOptions.PrintBailout.getValue()) {
18200
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 Map<String, Object> properties = new LinkedHashMap<>();
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
45 properties.put("Reason", t.toString());
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46 log(0, "opt fail", target.toString(), properties);
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47 }
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
48 }
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
49
18216
0a72a0f9ef2e Turffle: checkstyle fix.
Christian Humer <christian.humer@gmail.com>
parents: 18214
diff changeset
50 public static boolean isPermanentBailout(Throwable t) {
18200
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51 return !(t instanceof BailoutException) || ((BailoutException) t).isPermanent();
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52 }
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
53
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54 }