annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerifcationPhase.java @ 10074:e8fbc5fd3440

aot: add/fix some javadoc
author Bernhard Urban <bernhard.urban@jku.at>
date Mon, 17 Jun 2013 17:50:09 +0200
parents 56fc40ca4ae0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10015
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
1 /*
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
4 *
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
8 *
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
13 * accompanied this code).
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
14 *
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
18 *
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
21 * questions.
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
22 */
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
23 package com.oracle.graal.hotspot.phases;
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
24
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
25 import com.oracle.graal.api.meta.*;
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
26 import com.oracle.graal.nodes.*;
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
27 import com.oracle.graal.phases.*;
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
28
10074
e8fbc5fd3440 aot: add/fix some javadoc
Bernhard Urban <bernhard.urban@jku.at>
parents: 10062
diff changeset
29 /**
e8fbc5fd3440 aot: add/fix some javadoc
Bernhard Urban <bernhard.urban@jku.at>
parents: 10062
diff changeset
30 * Checking for embedded oops in the graph. (Interned) Strings are an exception as they live in CDS
e8fbc5fd3440 aot: add/fix some javadoc
Bernhard Urban <bernhard.urban@jku.at>
parents: 10062
diff changeset
31 * space.
e8fbc5fd3440 aot: add/fix some javadoc
Bernhard Urban <bernhard.urban@jku.at>
parents: 10062
diff changeset
32 *
e8fbc5fd3440 aot: add/fix some javadoc
Bernhard Urban <bernhard.urban@jku.at>
parents: 10062
diff changeset
33 * @see LoadJavaMirrorWithKlassPhase
e8fbc5fd3440 aot: add/fix some javadoc
Bernhard Urban <bernhard.urban@jku.at>
parents: 10062
diff changeset
34 */
10015
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
35 public class AheadOfTimeVerifcationPhase extends VerifyPhase {
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
36
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
37 @Override
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
38 protected boolean verify(StructuredGraph graph) {
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
39 for (ConstantNode node : graph.getNodes().filter(ConstantNode.class)) {
10074
e8fbc5fd3440 aot: add/fix some javadoc
Bernhard Urban <bernhard.urban@jku.at>
parents: 10062
diff changeset
40 assert !isOop(node) || isNullReference(node) || isString(node) : "embedded oop: " + node;
10015
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
41 }
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
42 return true;
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
43 }
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
44
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
45 private static boolean isOop(ConstantNode node) {
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
46 return node.kind() == Kind.Object;
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
47 }
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
48
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
49 private static boolean isNullReference(ConstantNode node) {
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
50 return isOop(node) && node.asConstant().asObject() == null;
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
51 }
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
52
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
53 private static boolean isString(ConstantNode node) {
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
54 return isOop(node) && node.asConstant().asObject() instanceof String;
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
55 }
deb5bd841422 aot: add verification phase
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
56 }