annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeStoreMacroNode.java @ 16582:0eb70f622d01

Truffle: make NeverPartOfCompilationNode a MacroStateSplitNode for better debuggability
author Andreas Woess <andreas.woess@jku.at>
date Fri, 18 Jul 2014 00:33:37 +0200
parents e6622e77e8c7
children 5d468add216f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
16256
6f02ff62c3ef new constructor (with stateAfter) for UnsafeStoreNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15018
diff changeset
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.truffle.nodes.typesystem;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 import com.oracle.graal.api.meta.*;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26 import com.oracle.graal.graph.*;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import com.oracle.graal.graph.spi.*;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import com.oracle.graal.nodes.*;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.nodes.extended.*;
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12445
diff changeset
30 import com.oracle.graal.truffle.nodes.*;
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.truffle.nodes.asserts.*;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 import com.oracle.truffle.api.*;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 /**
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 * Macro node for method {@link CompilerDirectives#unsafeCast(Object, Class, boolean)}.
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 */
16290
e6622e77e8c7 split MacroNode into MacroNode and MacroStateSplitNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16256
diff changeset
37 public class CustomizedUnsafeStoreMacroNode extends NeverPartOfCompilationNode implements Canonicalizable, StateSplit {
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 private static final int ARGUMENT_COUNT = 4;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 private static final int OBJECT_ARGUMENT_INDEX = 0;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 private static final int OFFSET_ARGUMENT_INDEX = 1;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 private static final int VALUE_ARGUMENT_INDEX = 2;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 private static final int LOCATION_ARGUMENT_INDEX = 3;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 public CustomizedUnsafeStoreMacroNode(Invoke invoke) {
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 super(invoke, "The location argument could not be resolved to a constant.");
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 assert arguments.size() == ARGUMENT_COUNT;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 }
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 @Override
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 public Node canonical(CanonicalizerTool tool) {
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 ValueNode locationArgument = arguments.get(LOCATION_ARGUMENT_INDEX);
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 if (locationArgument.isConstant()) {
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 ValueNode objectArgument = arguments.get(OBJECT_ARGUMENT_INDEX);
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 ValueNode offsetArgument = arguments.get(OFFSET_ARGUMENT_INDEX);
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 ValueNode valueArgument = arguments.get(VALUE_ARGUMENT_INDEX);
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 LocationIdentity locationIdentity;
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12445
diff changeset
57 if (locationArgument.asConstant().isNull()) {
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 locationIdentity = LocationIdentity.ANY_LOCATION;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 } else {
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12445
diff changeset
60 locationIdentity = ObjectLocationIdentity.create(locationArgument.asConstant());
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 }
11927
776e348d6c2e Propagate state after when creating unsafe store node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11926
diff changeset
62
16582
0eb70f622d01 Truffle: make NeverPartOfCompilationNode a MacroStateSplitNode for better debuggability
Andreas Woess <andreas.woess@jku.at>
parents: 16290
diff changeset
63 return new UnsafeStoreNode(objectArgument, offsetArgument, valueArgument, this.getTargetMethod().getSignature().getParameterKind(VALUE_ARGUMENT_INDEX), locationIdentity, stateAfter());
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 }
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 return this;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 }
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 }