Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/nodes/base/FixedGuardNode.java @ 3530:da773e1b6d9f
Third round of refactoring.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 10 Aug 2011 00:47:53 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3529:d683f8a40c05 | 3530:da773e1b6d9f |
---|---|
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.oracle.max.graal.nodes.base; | |
24 | |
25 import com.oracle.max.graal.graph.*; | |
26 import com.oracle.max.graal.nodes.base.DeoptimizeNode.*; | |
27 import com.oracle.max.graal.nodes.spi.*; | |
28 import com.sun.cri.ci.*; | |
29 | |
30 public final class FixedGuardNode extends FixedWithNextNode implements Canonicalizable { | |
31 | |
32 @Input private final NodeInputList<BooleanNode> conditions = new NodeInputList<BooleanNode>(this); | |
33 | |
34 public FixedGuardNode(BooleanNode node, Graph graph) { | |
35 this(graph); | |
36 addNode(node); | |
37 } | |
38 | |
39 public FixedGuardNode(Graph graph) { | |
40 super(CiKind.Illegal, graph); | |
41 } | |
42 | |
43 @Override | |
44 public void accept(ValueVisitor v) { | |
45 v.visitFixedGuard(this); | |
46 } | |
47 | |
48 public void addNode(BooleanNode x) { | |
49 conditions.add(x); | |
50 } | |
51 | |
52 @Override | |
53 public Node canonical(NotifyReProcess reProcess) { | |
54 for (BooleanNode n : conditions.snapshot()) { | |
55 if (n instanceof ConstantNode) { | |
56 ConstantNode c = (ConstantNode) n; | |
57 if (c.asConstant().asBoolean()) { | |
58 conditions.remove(n); | |
59 } else { | |
60 return new DeoptimizeNode(DeoptAction.InvalidateRecompile, graph()); | |
61 } | |
62 } | |
63 } | |
64 | |
65 if (conditions.isEmpty()) { | |
66 return next(); | |
67 } | |
68 return this; | |
69 } | |
70 } |