annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java @ 18401:e7ab82e7cc37

Move metaspace pointer handling to hotspot specific WordTypeRewriter.
author Roland Schatz <roland.schatz@oracle.com>
date Mon, 17 Nov 2014 17:25:38 +0100
parents ed0fce2e999a
children f91e40c4bb47
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
18362
ea0fbb571466 Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents: 18340
diff changeset
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
23 package com.oracle.graal.hotspot.replacements;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
6501
55c54c4bdcfc moved UnsignedMath to com.oracle.graal.api.code
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
25 import static com.oracle.graal.api.code.UnsignedMath.*;
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
26 import static com.oracle.graal.compiler.common.GraalOptions.*;
9513
659bb6cf930c rename: HotSpotSnippetUtils -> HotSpotReplacementsUtil
Doug Simon <doug.simon@oracle.com>
parents: 9423
diff changeset
27 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
12732
8212479436e0 disabled type context specialization of allocation snippets unless allocation profiling is enabled
Doug Simon <doug.simon@oracle.com>
parents: 12579
diff changeset
28 import static com.oracle.graal.hotspot.replacements.NewObjectSnippets.Options.*;
11752
7e7edb86fb43 Refactor the handling of unsafe casts to distinguish between word-object-conversions, PiNode-like type information, and real unsafe casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 11732
diff changeset
29 import static com.oracle.graal.nodes.PiArrayNode.*;
10787
388fbd0dd4a4 moved BranchNodeProbabilities to graal.nodes project
Doug Simon <doug.simon@oracle.com>
parents: 10760
diff changeset
30 import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
31 import static com.oracle.graal.replacements.SnippetTemplate.*;
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
32 import static com.oracle.graal.replacements.nodes.ExplodeLoopNode.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.api.code.*;
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.api.meta.*;
18370
6713fef8c859 Make the @Fold annotation a top-level interface in the api project. It is not tied to the Snippet class where it was located before.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18362
diff changeset
36 import com.oracle.graal.api.replacements.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15066
diff changeset
37 import com.oracle.graal.compiler.common.*;
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15259
diff changeset
38 import com.oracle.graal.compiler.common.type.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.debug.*;
11752
7e7edb86fb43 Refactor the handling of unsafe casts to distinguish between word-object-conversions, PiNode-like type information, and real unsafe casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 11732
diff changeset
40 import com.oracle.graal.graph.Node.ConstantNodeParameter;
7e7edb86fb43 Refactor the handling of unsafe casts to distinguish between word-object-conversions, PiNode-like type information, and real unsafe casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 11732
diff changeset
41 import com.oracle.graal.graph.Node.NodeIntrinsic;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12381
diff changeset
42 import com.oracle.graal.hotspot.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 import com.oracle.graal.hotspot.meta.*;
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 import com.oracle.graal.hotspot.nodes.*;
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
45 import com.oracle.graal.hotspot.word.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 import com.oracle.graal.nodes.*;
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
47 import com.oracle.graal.nodes.debug.*;
10586
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
48 import com.oracle.graal.nodes.extended.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 import com.oracle.graal.nodes.java.*;
13505
75a67ebd50e8 Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13268
diff changeset
50 import com.oracle.graal.nodes.spi.*;
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
51 import com.oracle.graal.options.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
52 import com.oracle.graal.replacements.*;
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
53 import com.oracle.graal.replacements.Snippet.ConstantParameter;
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
54 import com.oracle.graal.replacements.Snippet.VarargsParameter;
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
55 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
56 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
57 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
58 import com.oracle.graal.replacements.nodes.*;
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
59 import com.oracle.graal.word.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 /**
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
62 * Snippets used for implementing NEW, ANEWARRAY and NEWARRAY.
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 */
8413
d9347ee39fbe rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents: 7868
diff changeset
64 public class NewObjectSnippets implements Snippets {
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65
18307
85f5227a7a37 add mutable/immutable factory methods to NamedLocationIdentity
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18259
diff changeset
66 public static final LocationIdentity INIT_LOCATION = NamedLocationIdentity.mutable("Initialization");
11770
7c4595b7ef3a NewInstanceNode: use INIT_LOCATION; NewArrayNode: use INIT_LOCATION and ARRAY_LENGTH_LOCATION
Bernhard Urban <bernhard.urban@jku.at>
parents: 11752
diff changeset
67
12732
8212479436e0 disabled type context specialization of allocation snippets unless allocation profiling is enabled
Doug Simon <doug.simon@oracle.com>
parents: 12579
diff changeset
68 static class Options {
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
69
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
70 //@formatter:off
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
71 @Option(help = "")
12732
8212479436e0 disabled type context specialization of allocation snippets unless allocation profiling is enabled
Doug Simon <doug.simon@oracle.com>
parents: 12579
diff changeset
72 static final OptionValue<Boolean> ProfileAllocations = new OptionValue<>(false);
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
73 //@formatter:on
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
74 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
75
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
76 static enum ProfileMode {
14908
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
77 AllocatingMethods,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
78 InstanceOrArray,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
79 AllocatedTypes,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
80 AllocatedTypesInMethods,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
81 Total
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
82 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
83
17391
e890b86b397d default allocation profiling to AllocatedTypes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17204
diff changeset
84 public static final ProfileMode PROFILE_MODE = ProfileMode.AllocatedTypes;
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
85
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
86 @Fold
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
87 private static String createName(String path, String typeContext) {
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
88 switch (PROFILE_MODE) {
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
89 case AllocatingMethods:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
90 return "";
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
91 case InstanceOrArray:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
92 return path;
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
93 case AllocatedTypes:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
94 case AllocatedTypesInMethods:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
95 return typeContext;
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
96 case Total:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
97 return "bytes";
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
98 default:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
99 throw GraalInternalError.shouldNotReachHere();
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
100 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
101 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
102
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
103 @Fold
12381
20150eaa1dc7 remove unused parameters from doProfile methods
Lukas Stadler <lukas.stadler@jku.at>
parents: 12054
diff changeset
104 private static boolean doProfile() {
12732
8212479436e0 disabled type context specialization of allocation snippets unless allocation profiling is enabled
Doug Simon <doug.simon@oracle.com>
parents: 12579
diff changeset
105 return ProfileAllocations.getValue();
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
106 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
107
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15018
diff changeset
108 protected static void profileAllocation(String path, long size, String typeContext) {
12381
20150eaa1dc7 remove unused parameters from doProfile methods
Lukas Stadler <lukas.stadler@jku.at>
parents: 12054
diff changeset
109 if (doProfile()) {
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
110 String name = createName(path, typeContext);
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
111
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
112 boolean context = PROFILE_MODE == ProfileMode.AllocatingMethods || PROFILE_MODE == ProfileMode.AllocatedTypesInMethods;
11893
ec267141f753 more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents: 11873
diff changeset
113 DynamicCounterNode.counter(name, "number of bytes allocated", size, context);
ec267141f753 more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents: 11873
diff changeset
114 DynamicCounterNode.counter(name, "number of allocations", 1, context);
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
115 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
116 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
117
17204
fcf71ef8a0e5 visibility change in NewObjectSnippets
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16478
diff changeset
118 public static void emitPrefetchAllocate(Word address, boolean isArray) {
13255
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
119 if (config().allocatePrefetchStyle > 0) {
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
120 // Insert a prefetch for each allocation only on the fast-path
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
121 // Generate several prefetch instructions.
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
122 int lines = isArray ? config().allocatePrefetchLines : config().allocateInstancePrefetchLines;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
123 int stepSize = config().allocatePrefetchStepSize;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
124 int distance = config().allocatePrefetchDistance;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
125 ExplodeLoopNode.explodeLoop();
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
126 for (int i = 0; i < lines; i++) {
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
127 PrefetchAllocateNode.prefetch(address, Word.signed(distance));
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
128 distance += stepSize;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
129 }
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
130 }
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
131 }
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
132
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133 @Snippet
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
134 public static Object allocateInstance(@ConstantParameter int size, KlassPointer hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister,
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
135 @ConstantParameter boolean constantSize, @ConstantParameter String typeContext) {
7035
52c88c405d07 Simplify how stamp is preserved after lowering of allocation nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7034
diff changeset
136 Object result;
12789
e3d1e4f635e9 pass thread register into allocation snippets instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12767
diff changeset
137 Word thread = registerAsWord(threadRegister);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
138 Word top = readTlabTop(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
139 Word end = readTlabEnd(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
140 Word newTop = top.add(size);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
141 if (useTLAB() && probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
142 writeTlabTop(thread, newTop);
13255
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
143 emitPrefetchAllocate(newTop, false);
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
144 result = formatObject(hub, size, top, prototypeMarkWord, fillContents, constantSize, true);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
145 } else {
5772
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
146 new_stub.inc();
7035
52c88c405d07 Simplify how stamp is preserved after lowering of allocation nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7034
diff changeset
147 result = NewInstanceStubCall.call(hub);
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6504
diff changeset
148 }
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
149 profileAllocation("instance", size, typeContext);
11752
7e7edb86fb43 Refactor the handling of unsafe casts to distinguish between word-object-conversions, PiNode-like type information, and real unsafe casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 11732
diff changeset
150 return piCast(verifyOop(result), StampFactory.forNodeIntrinsic());
5624
7d25723b7699 added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents: 5616
diff changeset
151 }
7d25723b7699 added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents: 5616
diff changeset
152
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
153 @Snippet
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
154 public static Object allocateInstanceDynamic(Class<?> type, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister, @ConstantParameter String typeContext) {
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
155 KlassPointer hubPtr = ClassGetHubNode.readClass(type);
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
156 Pointer hub = hubPtr.asWord();
13631
11c46696a655 Add probabilities to NewObjectSnippets.allocateInstanceDynamic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13582
diff changeset
157 if (probability(FAST_PATH_PROBABILITY, !hub.equal(Word.zero()))) {
16386
9ce3b1efc4e7 InstanceKlass::_init_state only exists for InstanceKlasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16238
diff changeset
158 if (probability(FAST_PATH_PROBABILITY, isInstanceKlassFullyInitialized(hub))) {
18377
ed0fce2e999a Fold klass._java_mirror._klass into klass and improve stamps from layout_helper
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18370
diff changeset
159 int layoutHelper = readLayoutHelper(hubPtr);
13582
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
160 /*
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
161 * src/share/vm/oops/klass.hpp: For instances, layout helper is a positive number,
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
162 * the instance size. This size is already passed through align_object_size and
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
163 * scaled to bytes. The low order bit is set if instances of this class cannot be
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
164 * allocated using the fastpath.
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
165 */
13631
11c46696a655 Add probabilities to NewObjectSnippets.allocateInstanceDynamic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13582
diff changeset
166 if (probability(FAST_PATH_PROBABILITY, (layoutHelper & 1) == 0)) {
13582
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
167 Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
168 return allocateInstance(layoutHelper, KlassPointer.fromWord(hub), prototypeMarkWord, fillContents, threadRegister, false, typeContext);
13582
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
169 }
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
170 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
171 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
172 return dynamicNewInstanceStub(type);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
173 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
174
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
175 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
176 * Maximum array length for which fast path allocation is used.
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
177 */
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
178 public static final int MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH = 0x00FFFFFF;
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
179
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
180 @Snippet
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
181 public static Object allocateArray(KlassPointer hub, int length, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize,
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
182 @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister, @ConstantParameter boolean maybeUnroll, @ConstantParameter String typeContext) {
15634
172484b8f800 don't deopt on large array allocations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15261
diff changeset
183 return allocateArrayImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, threadRegister, maybeUnroll, typeContext, false);
10542
554f67e4ff3f Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10456
diff changeset
184 }
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
185
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
186 private static Object allocateArrayImpl(KlassPointer hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents,
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
187 @ConstantParameter Register threadRegister, @ConstantParameter boolean maybeUnroll, String typeContext, boolean skipNegativeCheck) {
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
188 Object result;
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
189 int alignment = wordSize();
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
190 int allocationSize = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize);
12789
e3d1e4f635e9 pass thread register into allocation snippets instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12767
diff changeset
191 Word thread = registerAsWord(threadRegister);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
192 Word top = readTlabTop(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
193 Word end = readTlabEnd(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
194 Word newTop = top.add(allocationSize);
15634
172484b8f800 don't deopt on large array allocations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15261
diff changeset
195 if ((skipNegativeCheck || belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) && useTLAB() && probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
196 writeTlabTop(thread, newTop);
13255
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
197 emitPrefetchAllocate(newTop, true);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
198 newarray_loopInit.inc();
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
199 result = formatArray(hub, allocationSize, length, headerSize, top, prototypeMarkWord, fillContents, maybeUnroll, true);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
200 } else {
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
201 newarray_stub.inc();
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
202 result = NewArrayStubCall.call(hub, length);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
203 }
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
204 profileAllocation("array", allocationSize, typeContext);
11752
7e7edb86fb43 Refactor the handling of unsafe casts to distinguish between word-object-conversions, PiNode-like type information, and real unsafe casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 11732
diff changeset
205 return piArrayCast(verifyOop(result), length, StampFactory.forNodeIntrinsic());
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
206 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
207
10586
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
208 public static final ForeignCallDescriptor DYNAMIC_NEW_ARRAY = new ForeignCallDescriptor("dynamic_new_array", Object.class, Class.class, int.class);
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
209 public static final ForeignCallDescriptor DYNAMIC_NEW_INSTANCE = new ForeignCallDescriptor("dynamic_new_instance", Object.class, Class.class);
10586
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
210
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
211 @NodeIntrinsic(ForeignCallNode.class)
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
212 public static native Object dynamicNewArrayStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Class<?> elementType, int length);
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
213
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
214 public static Object dynamicNewInstanceStub(Class<?> elementType) {
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
215 return dynamicNewInstanceStubCall(DYNAMIC_NEW_INSTANCE, elementType);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
216 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
217
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
218 @NodeIntrinsic(ForeignCallNode.class)
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
219 public static native Object dynamicNewInstanceStubCall(@ConstantNodeParameter ForeignCallDescriptor descriptor, Class<?> elementType);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
220
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
221 @Snippet
12789
e3d1e4f635e9 pass thread register into allocation snippets instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12767
diff changeset
222 public static Object allocateArrayDynamic(Class<?> elementType, int length, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister) {
18340
a0381103324b More folding of constant classes and NodeClass references
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18307
diff changeset
223 Word hub = loadWordFromObject(elementType, arrayKlassOffset(), CLASS_ARRAY_KLASS_LOCATION);
10542
554f67e4ff3f Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10456
diff changeset
224 if (hub.equal(Word.zero()) || !belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) {
10586
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
225 return dynamicNewArrayStub(DYNAMIC_NEW_ARRAY, elementType, length);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
226 }
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
227
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
228 KlassPointer klass = KlassPointer.fromWord(hub);
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
229 int layoutHelper = readLayoutHelper(klass);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
230 //@formatter:off
10427
58777dad7f90 Cite source of comment in NewObjectSnippets.
Roland Schatz <roland.schatz@oracle.com>
parents: 10030
diff changeset
231 // from src/share/vm/oops/klass.hpp:
58777dad7f90 Cite source of comment in NewObjectSnippets.
Roland Schatz <roland.schatz@oracle.com>
parents: 10030
diff changeset
232 //
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
233 // For arrays, layout helper is a negative number, containing four
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
234 // distinct bytes, as follows:
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
235 // MSB:[tag, hsz, ebt, log2(esz)]:LSB
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
236 // where:
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
237 // tag is 0x80 if the elements are oops, 0xC0 if non-oops
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
238 // hsz is array header size in bytes (i.e., offset of first element)
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
239 // ebt is the BasicType of the elements
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
240 // esz is the element size in bytes
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
241 //@formatter:on
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
242
10456
e4dd840a39de Use values from HotSpotVMConfig instead of hardcoding shifts and bitmasks.
Roland Schatz <roland.schatz@oracle.com>
parents: 10442
diff changeset
243 int headerSize = (layoutHelper >> layoutHelperHeaderSizeShift()) & layoutHelperHeaderSizeMask();
e4dd840a39de Use values from HotSpotVMConfig instead of hardcoding shifts and bitmasks.
Roland Schatz <roland.schatz@oracle.com>
parents: 10442
diff changeset
244 int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask();
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
245 Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
246
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
247 return allocateArrayImpl(klass, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, threadRegister, false, "dynamic type", true);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
248 }
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
249
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
250 /**
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
251 * Computes the size of the memory chunk allocated for an array. This size accounts for the
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
252 * array header size, boy size and any padding after the last element to satisfy object
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
253 * alignment requirements.
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14101
diff changeset
254 *
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
255 * @param length the number of elements in the array
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
256 * @param alignment the object alignment requirement
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
257 * @param headerSize the size of the array header
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
258 * @param log2ElementSize log2 of the size of an element in the array
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
259 */
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
260 public static int computeArrayAllocationSize(int length, int alignment, int headerSize, int log2ElementSize) {
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
261 int size = (length << log2ElementSize) + headerSize + (alignment - 1);
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
262 int mask = ~(alignment - 1);
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
263 return size & mask;
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
264 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
265
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
266 /**
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
267 * Calls the runtime stub for implementing MULTIANEWARRAY.
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
268 */
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
269 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
270 public static Object newmultiarray(Word hub, @ConstantParameter int rank, @VarargsParameter int[] dimensions) {
6954
0e20ad1ea98b removed WordStamp (and a nasty bug associated with its misusage)
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
271 Word dims = DimensionsNode.allocaDimsArray(rank);
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
272 ExplodeLoopNode.explodeLoop();
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
273 for (int i = 0; i < rank; i++) {
11773
4e2be0ab31a9 NewMultiArrayNode: use INIT_LOCATION instead of ANY_LOCATION
Bernhard Urban <bernhard.urban@jku.at>
parents: 11770
diff changeset
274 dims.writeInt(i * 4, dimensions[i], INIT_LOCATION);
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
275 }
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
276 return NewMultiArrayStubCall.call(hub, rank, dims);
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
277 }
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
278
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
279 /**
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14766
diff changeset
280 * Maximum number of long stores to emit when zeroing an object with a constant size. Larger
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
281 * objects have their bodies initialized in a loop.
5687
5d06e32f10df limited length of zeroing instructions for object initialization to object below a certain size
Doug Simon <doug.simon@oracle.com>
parents: 5686
diff changeset
282 */
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
283 private static final int MAX_UNROLLED_OBJECT_ZEROING_STORES = 8;
5687
5d06e32f10df limited length of zeroing instructions for object initialization to object below a certain size
Doug Simon <doug.simon@oracle.com>
parents: 5686
diff changeset
284
5d06e32f10df limited length of zeroing instructions for object initialization to object below a certain size
Doug Simon <doug.simon@oracle.com>
parents: 5686
diff changeset
285 /**
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
286 * Zero uninitialized memory in a newly allocated object, unrolling as necessary and ensuring
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
287 * that stores are aligned.
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14101
diff changeset
288 *
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
289 * @param size number of bytes to zero
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
290 * @param memory beginning of object which is being zeroed
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
291 * @param constantSize is @ size} known to be constant in the snippet
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
292 * @param startOffset offset to begin zeroing. May not be word aligned.
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
293 * @param manualUnroll maximally unroll zeroing
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
294 */
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
295 private static void zeroMemory(int size, Word memory, boolean constantSize, int startOffset, boolean manualUnroll, boolean useSnippetCounters) {
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
296 ReplacementsUtil.runtimeAssert((size & 0x7) == 0, "unaligned object size");
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
297 int offset = startOffset;
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
298 if ((offset & 0x7) != 0) {
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
299 memory.writeInt(offset, 0, INIT_LOCATION);
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
300 offset += 4;
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
301 }
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
302 ReplacementsUtil.runtimeAssert((offset & 0x7) == 0, "unaligned offset");
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
303 if (manualUnroll && ((size - offset) / 8) <= MAX_UNROLLED_OBJECT_ZEROING_STORES) {
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
304 ReplacementsUtil.staticAssert(!constantSize, "size shouldn't be constant at instantiation time");
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
305 // This case handles arrays of constant length. Instead of having a snippet variant for
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
306 // each length, generate a chain of stores of maximum length. Once it's inlined the
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
307 // break statement will trim excess stores.
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
308 if (useSnippetCounters) {
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
309 new_seqInit.inc();
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
310 }
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
311 explodeLoop();
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
312 for (int i = 0; i < MAX_UNROLLED_OBJECT_ZEROING_STORES; i++, offset += 8) {
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
313 if (offset == size) {
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
314 break;
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
315 }
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
316 memory.initializeLong(offset, 0, INIT_LOCATION);
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
317 }
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
318 } else {
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
319 // Use Word instead of int to avoid extension to long in generated code
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
320 Word off = Word.signed(offset);
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
321 if (constantSize && ((size - offset) / 8) <= MAX_UNROLLED_OBJECT_ZEROING_STORES) {
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
322 if (useSnippetCounters) {
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
323 new_seqInit.inc();
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
324 }
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
325 explodeLoop();
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
326 } else {
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
327 if (useSnippetCounters) {
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
328 new_loopInit.inc();
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
329 }
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
330 }
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
331 for (; off.rawValue() < size; off = off.add(8)) {
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
332 memory.initializeLong(off, 0, INIT_LOCATION);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
333 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
334 }
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
335 }
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
336
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
337 /**
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
338 * Formats some allocated memory with an object header and zeroes out the rest. Disables asserts
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
339 * since they can't be compiled in stubs.
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
340 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
341 public static Object formatObjectForStub(KlassPointer hub, int size, Word memory, Word compileTimePrototypeMarkWord) {
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
342 return formatObject(hub, size, memory, compileTimePrototypeMarkWord, true, false, false);
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
343 }
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
344
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
345 /**
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
346 * Formats some allocated memory with an object header and zeroes out the rest.
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
347 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
348 protected static Object formatObject(KlassPointer hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents, boolean constantSize, boolean useSnippetCounters) {
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
349 Word prototypeMarkWord = useBiasedLocking() ? hub.asWord().readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION) : compileTimePrototypeMarkWord;
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
350 initializeObjectHeader(memory, prototypeMarkWord, hub);
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
351 if (fillContents) {
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
352 zeroMemory(size, memory, constantSize, instanceHeaderSize(), false, useSnippetCounters);
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
353 }
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
354 return memory.toObject();
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
355 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
356
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
357 /**
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
358 * Formats some allocated memory with an object header and zeroes out the rest.
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
359 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
360 public static Object formatArray(KlassPointer hub, int allocationSize, int length, int headerSize, Word memory, Word prototypeMarkWord, boolean fillContents, boolean maybeUnroll,
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14763
diff changeset
361 boolean useSnippetCounters) {
11845
7b51e43b05cd NewObjectSnippets: don't use a seperate location for initializing the array length field
Bernhard Urban <bernhard.urban@jku.at>
parents: 11773
diff changeset
362 memory.writeInt(arrayLengthOffset(), length, INIT_LOCATION);
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
363 /*
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
364 * store hub last as the concurrent garbage collectors assume length is valid if hub field
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
365 * is not null
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
366 */
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
367 initializeObjectHeader(memory, prototypeMarkWord, hub);
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
368 if (fillContents) {
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
369 zeroMemory(allocationSize, memory, false, headerSize, maybeUnroll, useSnippetCounters);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
370 }
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
371 return memory.toObject();
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
372 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
373
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
374 public static class Templates extends AbstractTemplates {
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
375
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
376 private final SnippetInfo allocateInstance = snippet(NewObjectSnippets.class, "allocateInstance");
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
377 private final SnippetInfo allocateArray = snippet(NewObjectSnippets.class, "allocateArray");
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
378 private final SnippetInfo allocateArrayDynamic = snippet(NewObjectSnippets.class, "allocateArrayDynamic");
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
379 private final SnippetInfo allocateInstanceDynamic = snippet(NewObjectSnippets.class, "allocateInstanceDynamic");
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
380 private final SnippetInfo newmultiarray = snippet(NewObjectSnippets.class, "newmultiarray");
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
381
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14908
diff changeset
382 public Templates(HotSpotProviders providers, TargetDescription target) {
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14908
diff changeset
383 super(providers, providers.getSnippetReflection(), target);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
384 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
385
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
386 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
387 * Lowers a {@link NewInstanceNode}.
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
388 */
13505
75a67ebd50e8 Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13268
diff changeset
389 public void lower(NewInstanceNode newInstanceNode, HotSpotRegistersProvider registers, LoweringTool tool) {
9602
19c5a07c7843 Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9516
diff changeset
390 StructuredGraph graph = newInstanceNode.graph();
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
391 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newInstanceNode.instanceClass();
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
392 assert !type.isArray();
18362
ea0fbb571466 Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents: 18340
diff changeset
393 ConstantNode hub = ConstantNode.forConstant(StampFactory.forPointer(PointerType.Type), type.klass(), providers.getMetaAccess(), graph);
7544
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
394 int size = instanceSize(type);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
395
13505
75a67ebd50e8 Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13268
diff changeset
396 Arguments args = new Arguments(allocateInstance, graph.getGuardsStage(), tool.getLoweringStage());
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
397 args.addConst("size", size);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
398 args.add("hub", hub);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
399 args.add("prototypeMarkWord", type.prototypeMarkWord());
10760
59d2d6a30d29 Re-enable omission of array initialization for G1.
Roland Schatz <roland.schatz@oracle.com>
parents: 10745
diff changeset
400 args.addConst("fillContents", newInstanceNode.fillContents());
12789
e3d1e4f635e9 pass thread register into allocation snippets instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12767
diff changeset
401 args.addConst("threadRegister", registers.getThreadRegister());
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
402 args.addConst("constantSize", true);
16478
1f1ac8857d92 moved toJavaName(JavaType type, boolean qualified) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents: 16386
diff changeset
403 args.addConst("typeContext", ProfileAllocations.getValue() ? type.toJavaName(false) : "");
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
404
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
405 SnippetTemplate template = template(args);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
406 Debug.log("Lowering allocateInstance in %s: node=%s, template=%s, arguments=%s", graph, newInstanceNode, template, args);
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
407 template.instantiate(providers.getMetaAccess(), newInstanceNode, DEFAULT_REPLACER, args);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
408 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
409
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
410 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
411 * Lowers a {@link NewArrayNode}.
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
412 */
13505
75a67ebd50e8 Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13268
diff changeset
413 public void lower(NewArrayNode newArrayNode, HotSpotRegistersProvider registers, LoweringTool tool) {
9602
19c5a07c7843 Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9516
diff changeset
414 StructuredGraph graph = newArrayNode.graph();
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
415 ResolvedJavaType elementType = newArrayNode.elementType();
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
416 HotSpotResolvedObjectType arrayType = (HotSpotResolvedObjectType) elementType.getArrayClass();
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
417 Kind elementKind = elementType.getKind();
18362
ea0fbb571466 Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents: 18340
diff changeset
418 ConstantNode hub = ConstantNode.forConstant(StampFactory.forPointer(PointerType.Type), arrayType.klass(), providers.getMetaAccess(), graph);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12381
diff changeset
419 final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind);
12796
68ff7abbfae5 renamed HotSpotHostLoweringProvider to HotSpotLoweringProvider
Doug Simon <doug.simon@oracle.com>
parents: 12789
diff changeset
420 HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
15889
8184c00fefd2 Factor out VM-independent part of DefaultHotSpotLoweringProvider into DefaultJavaLoweringProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15634
diff changeset
421 int log2ElementSize = CodeUtil.log2(lowerer.arrayScalingFactor(elementKind));
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
422
13505
75a67ebd50e8 Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13268
diff changeset
423 Arguments args = new Arguments(allocateArray, graph.getGuardsStage(), tool.getLoweringStage());
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
424 args.add("hub", hub);
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
425 ValueNode length = newArrayNode.length();
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
426 args.add("length", length.isAlive() ? length : graph.addOrUniqueWithInputs(length));
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
427 args.add("prototypeMarkWord", arrayType.prototypeMarkWord());
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
428 args.addConst("headerSize", headerSize);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
429 args.addConst("log2ElementSize", log2ElementSize);
10760
59d2d6a30d29 Re-enable omission of array initialization for G1.
Roland Schatz <roland.schatz@oracle.com>
parents: 10745
diff changeset
430 args.addConst("fillContents", newArrayNode.fillContents());
12789
e3d1e4f635e9 pass thread register into allocation snippets instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12767
diff changeset
431 args.addConst("threadRegister", registers.getThreadRegister());
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
432 args.addConst("maybeUnroll", length.isConstant());
16478
1f1ac8857d92 moved toJavaName(JavaType type, boolean qualified) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents: 16386
diff changeset
433 args.addConst("typeContext", ProfileAllocations.getValue() ? arrayType.toJavaName(false) : "");
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
434
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
435 SnippetTemplate template = template(args);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
436 Debug.log("Lowering allocateArray in %s: node=%s, template=%s, arguments=%s", graph, newArrayNode, template, args);
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
437 template.instantiate(providers.getMetaAccess(), newArrayNode, DEFAULT_REPLACER, args);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
438 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
439
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
440 public void lower(DynamicNewInstanceNode newInstanceNode, HotSpotRegistersProvider registers, LoweringTool tool) {
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
441 Arguments args = new Arguments(allocateInstanceDynamic, newInstanceNode.graph().getGuardsStage(), tool.getLoweringStage());
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
442 args.add("type", newInstanceNode.getInstanceType());
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
443 args.addConst("fillContents", newInstanceNode.fillContents());
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
444 args.addConst("threadRegister", registers.getThreadRegister());
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
445
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
446 SnippetTemplate template = template(args);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
447 template.instantiate(providers.getMetaAccess(), newInstanceNode, DEFAULT_REPLACER, args);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
448 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
449
13505
75a67ebd50e8 Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13268
diff changeset
450 public void lower(DynamicNewArrayNode newArrayNode, HotSpotRegistersProvider registers, LoweringTool tool) {
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
451 StructuredGraph graph = newArrayNode.graph();
13505
75a67ebd50e8 Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13268
diff changeset
452 Arguments args = new Arguments(allocateArrayDynamic, newArrayNode.graph().getGuardsStage(), tool.getLoweringStage());
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
453 args.add("elementType", newArrayNode.getElementType());
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
454 ValueNode length = newArrayNode.length();
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
455 args.add("length", length.isAlive() ? length : graph.addOrUniqueWithInputs(length));
10760
59d2d6a30d29 Re-enable omission of array initialization for G1.
Roland Schatz <roland.schatz@oracle.com>
parents: 10745
diff changeset
456 args.addConst("fillContents", newArrayNode.fillContents());
12789
e3d1e4f635e9 pass thread register into allocation snippets instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12767
diff changeset
457 args.addConst("threadRegister", registers.getThreadRegister());
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
458
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
459 SnippetTemplate template = template(args);
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
460 template.instantiate(providers.getMetaAccess(), newArrayNode, DEFAULT_REPLACER, args);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
461 }
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
462
13505
75a67ebd50e8 Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13268
diff changeset
463 public void lower(NewMultiArrayNode newmultiarrayNode, LoweringTool tool) {
9602
19c5a07c7843 Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9516
diff changeset
464 StructuredGraph graph = newmultiarrayNode.graph();
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
465 int rank = newmultiarrayNode.dimensionCount();
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
466 ValueNode[] dims = new ValueNode[rank];
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
467 for (int i = 0; i < newmultiarrayNode.dimensionCount(); i++) {
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
468 dims[i] = newmultiarrayNode.dimension(i);
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
469 }
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
470 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newmultiarrayNode.type();
18362
ea0fbb571466 Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents: 18340
diff changeset
471 ConstantNode hub = ConstantNode.forConstant(StampFactory.forPointer(PointerType.Type), type.klass(), providers.getMetaAccess(), graph);
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
472
13505
75a67ebd50e8 Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13268
diff changeset
473 Arguments args = new Arguments(newmultiarray, graph.getGuardsStage(), tool.getLoweringStage());
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
474 args.add("hub", hub);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
475 args.addConst("rank", rank);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
476 args.addVarargs("dimensions", int.class, StampFactory.forKind(Kind.Int), dims);
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
477 template(args).instantiate(providers.getMetaAccess(), newmultiarrayNode, DEFAULT_REPLACER, args);
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
478 }
7544
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
479
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
480 private static int instanceSize(HotSpotResolvedObjectType type) {
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
481 int size = type.instanceSize();
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
482 assert (size % wordSize()) == 0;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
483 assert size >= 0;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
484 return size;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
485 }
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
486 }
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
487
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9793
diff changeset
488 private static final SnippetCounter.Group countersNew = SnippetCounters.getValue() ? new SnippetCounter.Group("NewInstance") : null;
5772
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
489 private static final SnippetCounter new_seqInit = new SnippetCounter(countersNew, "tlabSeqInit", "TLAB alloc with unrolled zeroing");
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
490 private static final SnippetCounter new_loopInit = new SnippetCounter(countersNew, "tlabLoopInit", "TLAB alloc with zeroing in a loop");
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
491 private static final SnippetCounter new_stub = new SnippetCounter(countersNew, "stub", "alloc and zeroing via stub");
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
492
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9793
diff changeset
493 private static final SnippetCounter.Group countersNewArray = SnippetCounters.getValue() ? new SnippetCounter.Group("NewArray") : null;
7145
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
494 private static final SnippetCounter newarray_loopInit = new SnippetCounter(countersNewArray, "tlabLoopInit", "TLAB alloc with zeroing in a loop");
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
495 private static final SnippetCounter newarray_stub = new SnippetCounter(countersNewArray, "stub", "alloc and zeroing via stub");
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
496 }