Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyNode.java @ 18596:5afa718edb8b
arraycopy: move related classes to dedicated package
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Wed, 03 Dec 2014 10:35:42 +0200 |
parents | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java@58ea6b98cb09 |
children | 95ec1f6723ac |
rev | line source |
---|---|
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17450
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 */ |
18596
5afa718edb8b
arraycopy: move related classes to dedicated package
Bernhard Urban <bernhard.urban@jku.at>
parents:
18593
diff
changeset
|
23 package com.oracle.graal.hotspot.replacements.arraycopy; |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
11491
a03452edfc4d
made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents:
11419
diff
changeset
|
25 import static com.oracle.graal.compiler.GraalCompiler.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9265
diff
changeset
|
26 |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
13977
diff
changeset
|
28 import com.oracle.graal.compiler.common.*; |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.debug.*; |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
30 import com.oracle.graal.debug.Debug.Scope; |
7538
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
31 import com.oracle.graal.loop.phases.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16811
diff
changeset
|
32 import com.oracle.graal.nodeinfo.*; |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 import com.oracle.graal.nodes.*; |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.spi.*; |
11265 | 35 import com.oracle.graal.nodes.type.*; |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 import com.oracle.graal.phases.common.*; |
9052
989db61f2007
Make LoopFullUnrollPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
37 import com.oracle.graal.phases.tiers.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
7902
diff
changeset
|
38 import com.oracle.graal.replacements.nodes.*; |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16290
diff
changeset
|
40 @NodeInfo |
17130
f396d15ddce2
Factor out HotSpot-independent parts of ArrayCopy and ObjectClone nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16919
diff
changeset
|
41 public class ArrayCopyNode extends BasicArrayCopyNode implements Virtualizable, Lowerable { |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
43 public static ArrayCopyNode create(Invoke invoke) { |
17450
45b45f902bed
removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents:
17130
diff
changeset
|
44 return new ArrayCopyNode(invoke); |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
45 } |
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
46 |
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
47 protected ArrayCopyNode(Invoke invoke) { |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
48 super(invoke); |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
49 } |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
50 |
11716
bffe5758c209
Snippets processing in ArrayCopyNode and ObjectCloneNode need proper scoping
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11633
diff
changeset
|
51 private StructuredGraph selectSnippet(LoweringTool tool, final Replacements replacements) { |
15260
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15259
diff
changeset
|
52 ResolvedJavaType srcType = StampTool.typeOrNull(getSource().stamp()); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15259
diff
changeset
|
53 ResolvedJavaType destType = StampTool.typeOrNull(getDestination().stamp()); |
7538
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
54 |
7902
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
55 if (srcType == null || !srcType.isArray() || destType == null || !destType.isArray()) { |
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
56 return null; |
7538
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
57 } |
13977
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
58 if (!destType.getComponentType().isAssignableFrom(srcType.getComponentType())) { |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
59 return null; |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
60 } |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
61 if (!isExact()) { |
7902
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
62 return null; |
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
63 } |
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
64 Kind componentKind = srcType.getComponentType().getKind(); |
13977
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
65 final ResolvedJavaMethod snippetMethod = tool.getMetaAccess().lookupJavaMethod(ArrayCopySnippets.getSnippetForKind(componentKind, shouldUnroll(), isExact())); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
66 try (Scope s = Debug.scope("ArrayCopySnippet", snippetMethod)) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
67 return replacements.getSnippet(snippetMethod); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
68 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
69 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
70 } |
7538
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
71 } |
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
72 |
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
73 private static void unrollFixedLengthLoop(StructuredGraph snippetGraph, int length, LoweringTool tool) { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13197
diff
changeset
|
74 ParameterNode lengthParam = snippetGraph.getParameter(4); |
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13197
diff
changeset
|
75 if (lengthParam != null) { |
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13197
diff
changeset
|
76 snippetGraph.replaceFloating(lengthParam, ConstantNode.forInt(length, snippetGraph)); |
7540
a77f22f2759d
remove errorneous assert, fix ArrayCopyNode's "replace local" code
Lukas Stadler <lukas.stadler@jku.at>
parents:
7539
diff
changeset
|
77 } |
a77f22f2759d
remove errorneous assert, fix ArrayCopyNode's "replace local" code
Lukas Stadler <lukas.stadler@jku.at>
parents:
7539
diff
changeset
|
78 // the canonicalization before loop unrolling is needed to propagate the length into |
a77f22f2759d
remove errorneous assert, fix ArrayCopyNode's "replace local" code
Lukas Stadler <lukas.stadler@jku.at>
parents:
7539
diff
changeset
|
79 // additions, etc. |
18479
16e61bb57e90
Introduce StampProvider to support different stamps for metadata on different VMs.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
80 PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getLowerer(), tool.getReplacements(), tool.assumptions(), tool.getStampProvider()); |
9916
491cd7d69539
CanonicalizerPhase: remove it from context, add it to tiers instead and configure/pass it there (GRAAL-309)
Bernhard Urban <bernhard.urban@jku.at>
parents:
9908
diff
changeset
|
81 new CanonicalizerPhase(true).apply(snippetGraph, context); |
11572
a63b63822183
Pass canonicalizer into loop transformations.
Roland Schatz <roland.schatz@oracle.com>
parents:
11556
diff
changeset
|
82 new LoopFullUnrollPhase(new CanonicalizerPhase(true)).apply(snippetGraph, context); |
9916
491cd7d69539
CanonicalizerPhase: remove it from context, add it to tiers instead and configure/pass it there (GRAAL-309)
Bernhard Urban <bernhard.urban@jku.at>
parents:
9908
diff
changeset
|
83 new CanonicalizerPhase(true).apply(snippetGraph, context); |
7538
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
84 } |
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
85 |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
86 @Override |
11754
6e734982f89f
fixed concurrency issue in lowering of MacroNode replacement graphs
Doug Simon <doug.simon@oracle.com>
parents:
11716
diff
changeset
|
87 protected StructuredGraph getLoweredSnippetGraph(final LoweringTool tool) { |
11491
a03452edfc4d
made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents:
11419
diff
changeset
|
88 if (!shouldIntrinsify(getTargetMethod())) { |
7902
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
89 return null; |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
90 } |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
91 |
11716
bffe5758c209
Snippets processing in ArrayCopyNode and ObjectCloneNode need proper scoping
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11633
diff
changeset
|
92 final Replacements replacements = tool.getReplacements(); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8559
diff
changeset
|
93 StructuredGraph snippetGraph = selectSnippet(tool, replacements); |
7902
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
94 if (snippetGraph == null) { |
18593
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
95 ResolvedJavaType srcType = StampTool.typeOrNull(getSource().stamp()); |
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
96 ResolvedJavaType destType = StampTool.typeOrNull(getDestination().stamp()); |
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
97 ResolvedJavaType srcComponentType = srcType == null ? null : srcType.getComponentType(); |
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
98 ResolvedJavaType destComponentType = destType == null ? null : destType.getComponentType(); |
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
99 ResolvedJavaMethod snippetMethod = null; |
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
100 if (srcComponentType != null && destComponentType != null && srcComponentType.getKind().equals(Kind.Object) && destComponentType.getKind().equals(Kind.Object)) { |
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
101 snippetMethod = tool.getMetaAccess().lookupJavaMethod(ArrayCopySnippets.checkcastArraycopySnippet); |
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
102 } else { |
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
103 snippetMethod = tool.getMetaAccess().lookupJavaMethod(ArrayCopySnippets.genericArraycopySnippet); |
58ea6b98cb09
ArrayCopy: use hotspot stub for checkcastArraycopy.
Bernhard Urban <bernhard.urban@jku.at>
parents:
18479
diff
changeset
|
104 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
105 snippetGraph = null; |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
106 try (Scope s = Debug.scope("ArrayCopySnippet", snippetMethod)) { |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13197
diff
changeset
|
107 snippetGraph = replacements.getSnippet(snippetMethod, getTargetMethod()).copy(); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
108 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
109 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
110 } |
8550
53cc1dd7ee18
pull replaceSnippetInvokes into MacroNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
8545
diff
changeset
|
111 replaceSnippetInvokes(snippetGraph); |
7902
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
112 } else { |
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
113 assert snippetGraph != null : "ArrayCopySnippets should be installed"; |
11754
6e734982f89f
fixed concurrency issue in lowering of MacroNode replacement graphs
Doug Simon <doug.simon@oracle.com>
parents:
11716
diff
changeset
|
114 snippetGraph = snippetGraph.copy(); |
13977
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
115 if (shouldUnroll()) { |
11754
6e734982f89f
fixed concurrency issue in lowering of MacroNode replacement graphs
Doug Simon <doug.simon@oracle.com>
parents:
11716
diff
changeset
|
116 final StructuredGraph copy = snippetGraph; |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
117 try (Scope s = Debug.scope("ArrayCopySnippetSpecialization", snippetGraph.method())) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17450
diff
changeset
|
118 unrollFixedLengthLoop(copy, getLength().asJavaConstant().asInt(), tool); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
119 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
120 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13137
diff
changeset
|
121 } |
7902
14fedab0419e
improved arraycopy and Object.clone snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
122 } |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
123 } |
11754
6e734982f89f
fixed concurrency issue in lowering of MacroNode replacement graphs
Doug Simon <doug.simon@oracle.com>
parents:
11716
diff
changeset
|
124 return lowerReplacement(snippetGraph, tool); |
7538
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
125 } |
50793b11b74d
ArrayCopyNode: cleanup, unrolling for fixed length arraycopy
Lukas Stadler <lukas.stadler@jku.at>
parents:
7511
diff
changeset
|
126 |
13977
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
127 private boolean shouldUnroll() { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17450
diff
changeset
|
128 return getLength().isConstant() && getLength().asJavaConstant().asInt() <= GraalOptions.MaximumEscapeAnalysisArrayLength.getValue(); |
13977
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
129 } |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
130 |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
131 /* |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
132 * Returns true if this copy doesn't require store checks. Trivially true for primitive arrays. |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
133 */ |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
134 private boolean isExact() { |
15260
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15259
diff
changeset
|
135 ResolvedJavaType srcType = StampTool.typeOrNull(getSource().stamp()); |
13977
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
136 if (srcType.getComponentType().getKind().isPrimitive() || getSource() == getDestination()) { |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
137 return true; |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
138 } |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
139 |
15260
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15259
diff
changeset
|
140 ResolvedJavaType destType = StampTool.typeOrNull(getDestination().stamp()); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15259
diff
changeset
|
141 if (StampTool.isExactType(getDestination().stamp())) { |
13977
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
142 if (destType != null && destType.isAssignableFrom(srcType)) { |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
143 return true; |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
144 } |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
145 } |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
146 return false; |
39076a984c33
lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13933
diff
changeset
|
147 } |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
148 } |