Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java @ 10438:6a847d44d4ef
Delay write barrier addition for arraycopy.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 20 Jun 2013 16:59:58 +0200 |
parents | 8c8285e345cc |
children | 4109190a0da5 |
rev | line source |
---|---|
10436
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
1 /* |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
4 * |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
8 * |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
14 * |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
18 * |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
22 */ |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.replacements; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
24 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.api.meta.LocationIdentity.*; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
26 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.nodes.*; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.nodes.extended.*; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.spi.*; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.type.*; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.replacements.SnippetTemplate.Arguments; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
33 |
10438
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
34 public final class UnsafeArrayCopyNode extends ArrayRangeWriteNode implements Lowerable, MemoryCheckpoint.Single { |
10436
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
35 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
36 @Input private ValueNode src; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
37 @Input private ValueNode srcPos; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
38 @Input private ValueNode dest; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
39 @Input private ValueNode destPos; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
40 @Input private ValueNode length; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
41 @Input private ValueNode layoutHelper; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
42 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
43 private Kind elementKind; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
44 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
45 private UnsafeArrayCopyNode(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, ValueNode layoutHelper, Kind elementKind) { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
46 super(StampFactory.forVoid()); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
47 assert layoutHelper == null || elementKind == null; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
48 this.src = src; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
49 this.srcPos = srcPos; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
50 this.dest = dest; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
51 this.destPos = destPos; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
52 this.length = length; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
53 this.layoutHelper = layoutHelper; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
54 this.elementKind = elementKind; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
55 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
56 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
57 private UnsafeArrayCopyNode(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, Kind elementKind) { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
58 this(src, srcPos, dest, destPos, length, null, elementKind); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
59 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
60 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
61 private UnsafeArrayCopyNode(ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length, ValueNode layoutHelper) { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
62 this(src, srcPos, dest, destPos, length, layoutHelper, null); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 |
10438
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
65 @Override |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
66 public ValueNode getArray() { |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
67 return dest; |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
68 } |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
69 |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
70 @Override |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
71 public ValueNode getIndex() { |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
72 return destPos; |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
73 } |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
74 |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
75 @Override |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
76 public ValueNode getLength() { |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
77 return length; |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
78 } |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
79 |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
80 @Override |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
81 public boolean isObjectArray() { |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
82 return elementKind == Kind.Object; |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
83 } |
6a847d44d4ef
Delay write barrier addition for arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
10436
diff
changeset
|
84 |
10436
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
85 public Kind getElementKind() { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
86 return elementKind; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
87 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
88 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
89 @Override |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
90 public void lower(LoweringTool tool, LoweringType loweringType) { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
91 if (loweringType == LoweringType.AFTER_GUARDS) { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
92 UnsafeArrayCopySnippets.Templates templates = tool.getReplacements().getSnippetTemplateCache(UnsafeArrayCopySnippets.Templates.class); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
93 templates.lower(this); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
94 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
95 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
96 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
97 public void addSnippetArguments(Arguments args) { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
98 args.add("src", src); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
99 args.add("srcPos", srcPos); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
100 args.add("dest", dest); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
101 args.add("destPos", destPos); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
102 args.add("length", length); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
103 if (layoutHelper != null) { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
104 args.add("layoutHelper", layoutHelper); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
105 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
106 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
107 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
108 @Override |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
109 public LocationIdentity getLocationIdentity() { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
110 if (elementKind == null) { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
111 return ANY_LOCATION; |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
112 } else { |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
113 return NamedLocationIdentity.getArrayLocation(elementKind); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
114 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
115 } |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
116 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
117 @NodeIntrinsic |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
118 public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length, @ConstantNodeParameter Kind elementKind); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
119 |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
120 @NodeIntrinsic |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
121 public static native void arraycopyPrimitive(Object src, int srcPos, Object dest, int destPos, int length, int layoutHelper); |
8c8285e345cc
Later lowering of arraycopy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
122 } |