annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java @ 21543:93c50cefb9e8

moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Mon, 25 May 2015 23:30:34 +0200
parents de0cf192779c
children 5324104ac4f3
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 /*
20178
7ba8fb19d56d Check that snippets only access locations that are either accessed by the replacee, or are private to the snippet.
Roland Schatz <roland.schatz@oracle.com>
parents: 19904
diff changeset
2 * Copyright (c) 2012, 2015, 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.*;
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21528
diff changeset
27 import static com.oracle.graal.hotspot.jvmci.HotSpotMetaAccessProvider.*;
18699
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
28 import static com.oracle.graal.hotspot.nodes.CStringNode.*;
9513
659bb6cf930c rename: HotSpotSnippetUtils -> HotSpotReplacementsUtil
Doug Simon <doug.simon@oracle.com>
parents: 9423
diff changeset
29 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
30 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
31 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
32 import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
33 import static com.oracle.graal.replacements.SnippetTemplate.*;
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
34 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
35
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 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
37 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
38 import com.oracle.graal.api.replacements.*;
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15259
diff changeset
39 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
40 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
41 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
42 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
43 import com.oracle.graal.hotspot.*;
21526
1da7aef31a08 created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21489
diff changeset
44 import com.oracle.graal.hotspot.jvmci.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 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
46 import com.oracle.graal.hotspot.nodes.*;
18481
f91e40c4bb47 Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 18401
diff changeset
47 import com.oracle.graal.hotspot.nodes.type.*;
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
48 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
49 import com.oracle.graal.nodes.*;
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
50 import com.oracle.graal.nodes.debug.*;
10586
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
51 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
52 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
53 import com.oracle.graal.nodes.spi.*;
18699
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
54 import com.oracle.graal.nodes.util.*;
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
55 import com.oracle.graal.options.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
56 import com.oracle.graal.replacements.*;
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
57 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
58 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
59 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
60 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
61 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
62 import com.oracle.graal.replacements.nodes.*;
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
63 import com.oracle.graal.word.*;
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
64 import com.oracle.jvmci.common.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 /**
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
67 * 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
68 */
8413
d9347ee39fbe rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents: 7868
diff changeset
69 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
70
18307
85f5227a7a37 add mutable/immutable factory methods to NamedLocationIdentity
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18259
diff changeset
71 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
72
12732
8212479436e0 disabled type context specialization of allocation snippets unless allocation profiling is enabled
Doug Simon <doug.simon@oracle.com>
parents: 12579
diff changeset
73 static class Options {
11873
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 //@formatter:off
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18541
diff changeset
76 @Option(help = "", type = OptionType.Debug)
12732
8212479436e0 disabled type context specialization of allocation snippets unless allocation profiling is enabled
Doug Simon <doug.simon@oracle.com>
parents: 12579
diff changeset
77 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
78 //@formatter:on
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
79 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
80
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
81 static enum ProfileMode {
14908
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
82 AllocatingMethods,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
83 InstanceOrArray,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
84 AllocatedTypes,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
85 AllocatedTypesInMethods,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
86 Total
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
87 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
88
17391
e890b86b397d default allocation profiling to AllocatedTypes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17204
diff changeset
89 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
90
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
91 @Fold
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
92 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
93 switch (PROFILE_MODE) {
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
94 case AllocatingMethods:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
95 return "";
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
96 case InstanceOrArray:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
97 return path;
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
98 case AllocatedTypes:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
99 case AllocatedTypesInMethods:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
100 return typeContext;
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
101 case Total:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
102 return "bytes";
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
103 default:
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
104 throw JVMCIError.shouldNotReachHere();
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
105 }
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
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
108 @Fold
12381
20150eaa1dc7 remove unused parameters from doProfile methods
Lukas Stadler <lukas.stadler@jku.at>
parents: 12054
diff changeset
109 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
110 return ProfileAllocations.getValue();
11873
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
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15018
diff changeset
113 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
114 if (doProfile()) {
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
115 String name = createName(path, typeContext);
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 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
118 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
119 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
120 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
121 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
122
17204
fcf71ef8a0e5 visibility change in NewObjectSnippets
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16478
diff changeset
123 public static void emitPrefetchAllocate(Word address, boolean isArray) {
13255
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
124 if (config().allocatePrefetchStyle > 0) {
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
125 // 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
126 // Generate several prefetch instructions.
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
127 int lines = isArray ? config().allocatePrefetchLines : config().allocateInstancePrefetchLines;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
128 int stepSize = config().allocatePrefetchStepSize;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
129 int distance = config().allocatePrefetchDistance;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
130 ExplodeLoopNode.explodeLoop();
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
131 for (int i = 0; i < lines; i++) {
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
132 PrefetchAllocateNode.prefetch(address, Word.signed(distance));
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
133 distance += stepSize;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
134 }
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
135 }
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
136 }
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
137
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 @Snippet
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
139 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
140 @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
141 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
142 Word thread = registerAsWord(threadRegister);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
143 Word top = readTlabTop(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
144 Word end = readTlabEnd(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
145 Word newTop = top.add(size);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
146 if (useTLAB() && probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
147 writeTlabTop(thread, newTop);
13255
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
148 emitPrefetchAllocate(newTop, false);
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
149 result = formatObject(hub, size, top, prototypeMarkWord, fillContents, constantSize, true);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
150 } else {
5772
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
151 new_stub.inc();
19856
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
152 result = newInstance(HotSpotBackend.NEW_INSTANCE, hub);
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6504
diff changeset
153 }
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
154 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
155 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
156 }
7d25723b7699 added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents: 5616
diff changeset
157
19856
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
158 @NodeIntrinsic(ForeignCallNode.class)
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
159 public static native Object newInstance(@ConstantNodeParameter ForeignCallDescriptor descriptor, KlassPointer hub);
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
160
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
161 @Snippet
21456
90fc2256ed37 Remove unused argument from snippet
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20836
diff changeset
162 public static Object allocateInstanceDynamic(Class<?> type, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister) {
18502
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18491
diff changeset
163 KlassPointer hub = ClassGetHubNode.readClass(type);
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18491
diff changeset
164 if (probability(FAST_PATH_PROBABILITY, !hub.isNull())) {
16386
9ce3b1efc4e7 InstanceKlass::_init_state only exists for InstanceKlasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16238
diff changeset
165 if (probability(FAST_PATH_PROBABILITY, isInstanceKlassFullyInitialized(hub))) {
18502
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18491
diff changeset
166 int layoutHelper = readLayoutHelper(hub);
13582
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
167 /*
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
168 * 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
169 * 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
170 * 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
171 * allocated using the fastpath.
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
172 */
13631
11c46696a655 Add probabilities to NewObjectSnippets.allocateInstanceDynamic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13582
diff changeset
173 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
174 Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
19904
15ef790fec92 NewObjectSnippets: work around problems with late binding of snippet parameters in GraphBuilderPlugins.
Josef Eisl <josef.eisl@jku.at>
parents: 19856
diff changeset
175 /*
15ef790fec92 NewObjectSnippets: work around problems with late binding of snippet parameters in GraphBuilderPlugins.
Josef Eisl <josef.eisl@jku.at>
parents: 19856
diff changeset
176 * FIXME(je,ds): we should actually pass typeContext instead of "" but late
15ef790fec92 NewObjectSnippets: work around problems with late binding of snippet parameters in GraphBuilderPlugins.
Josef Eisl <josef.eisl@jku.at>
parents: 19856
diff changeset
177 * binding of parameters is not yet supported by the GraphBuilderPlugin system.
15ef790fec92 NewObjectSnippets: work around problems with late binding of snippet parameters in GraphBuilderPlugins.
Josef Eisl <josef.eisl@jku.at>
parents: 19856
diff changeset
178 */
15ef790fec92 NewObjectSnippets: work around problems with late binding of snippet parameters in GraphBuilderPlugins.
Josef Eisl <josef.eisl@jku.at>
parents: 19856
diff changeset
179 return allocateInstance(layoutHelper, hub, prototypeMarkWord, fillContents, threadRegister, false, "");
13582
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
180 }
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
181 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
182 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
183 return dynamicNewInstanceStub(type);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
184 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
185
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
186 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
187 * 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
188 */
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
189 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
190
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
191 @Snippet
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
192 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
193 @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
194 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
195 }
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
196
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
197 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
198 @ConstantParameter Register threadRegister, @ConstantParameter boolean maybeUnroll, String typeContext, boolean skipNegativeCheck) {
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
199 Object result;
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
200 int alignment = wordSize();
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
201 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
202 Word thread = registerAsWord(threadRegister);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
203 Word top = readTlabTop(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
204 Word end = readTlabEnd(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
205 Word newTop = top.add(allocationSize);
21489
b3f1d8b23037 Fix probabilities for new array instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21456
diff changeset
206 if (probability(FREQUENT_PROBABILITY, skipNegativeCheck || belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) && useTLAB() &&
b3f1d8b23037 Fix probabilities for new array instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21456
diff changeset
207 probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
208 writeTlabTop(thread, newTop);
13255
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
209 emitPrefetchAllocate(newTop, true);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
210 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
211 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
212 } else {
19856
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
213 result = newArray(HotSpotBackend.NEW_ARRAY, hub, length);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
214 }
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
215 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
216 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
217 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
218
19856
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
219 @NodeIntrinsic(ForeignCallNode.class)
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
220 public static native Object newArray(@ConstantNodeParameter ForeignCallDescriptor descriptor, KlassPointer hub, int length);
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
221
10586
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
222 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
223 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
224
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
225 @NodeIntrinsic(ForeignCallNode.class)
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
226 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
227
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
228 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
229 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
230 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
231
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
232 @NodeIntrinsic(ForeignCallNode.class)
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
233 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
234
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
235 @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
236 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
237 Word hub = loadWordFromObject(elementType, arrayKlassOffset(), CLASS_ARRAY_KLASS_LOCATION);
21489
b3f1d8b23037 Fix probabilities for new array instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21456
diff changeset
238 if (probability(BranchProbabilityNode.NOT_FREQUENT_PROBABILITY, 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
239 return dynamicNewArrayStub(DYNAMIC_NEW_ARRAY, elementType, length);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
240 }
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
241
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
242 KlassPointer klass = KlassPointer.fromWord(hub);
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
243 int layoutHelper = readLayoutHelper(klass);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
244 //@formatter:off
10427
58777dad7f90 Cite source of comment in NewObjectSnippets.
Roland Schatz <roland.schatz@oracle.com>
parents: 10030
diff changeset
245 // from src/share/vm/oops/klass.hpp:
58777dad7f90 Cite source of comment in NewObjectSnippets.
Roland Schatz <roland.schatz@oracle.com>
parents: 10030
diff changeset
246 //
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
247 // For arrays, layout helper is a negative number, containing four
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
248 // distinct bytes, as follows:
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
249 // MSB:[tag, hsz, ebt, log2(esz)]:LSB
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
250 // where:
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
251 // tag is 0x80 if the elements are oops, 0xC0 if non-oops
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
252 // 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
253 // ebt is the BasicType of the elements
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
254 // esz is the element size in bytes
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
255 //@formatter:on
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
256
10456
e4dd840a39de Use values from HotSpotVMConfig instead of hardcoding shifts and bitmasks.
Roland Schatz <roland.schatz@oracle.com>
parents: 10442
diff changeset
257 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
258 int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask();
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
259 Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
260
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
261 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
262 }
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
263
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
264 /**
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
265 * Calls the runtime stub for implementing MULTIANEWARRAY.
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
266 */
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
267 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
268 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
269 Word dims = DimensionsNode.allocaDimsArray(rank);
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
270 ExplodeLoopNode.explodeLoop();
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
271 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
272 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
273 }
19856
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
274 return newArrayCall(HotSpotBackend.NEW_MULTI_ARRAY, hub, rank, dims);
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
19856
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
277 @NodeIntrinsic(ForeignCallNode.class)
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
278 public static native Object newArrayCall(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word hub, int rank, Word dims);
63b6ad88b08f Consolidation of new allocation stubs to use the standard ForeignCallNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19613
diff changeset
279
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
280 /**
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14766
diff changeset
281 * 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
282 * 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
283 */
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
284 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
285
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
286 /**
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
287 * 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
288 * that stores are aligned.
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14101
diff changeset
289 *
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
290 * @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
291 * @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
292 * @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
293 * @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
294 * @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
295 */
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
296 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
297 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
298 int offset = startOffset;
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
299 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
300 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
301 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
302 }
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
303 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
304 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
305 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
306 // 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
307 // 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
308 // 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
309 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
310 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
311 }
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
312 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
313 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
314 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
315 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
316 }
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 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
318 }
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 } 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
320 // 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
321 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
322 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
323 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
324 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
325 }
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
326 explodeLoop();
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
327 } 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
328 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
329 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
330 }
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
331 }
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
332 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
333 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
334 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
335 }
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
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 /**
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 * 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
340 * 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
341 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
342 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
343 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
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 /**
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 * 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
348 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
349 protected static Object formatObject(KlassPointer hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents, boolean constantSize, boolean useSnippetCounters) {
18502
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18491
diff changeset
350 Word prototypeMarkWord = useBiasedLocking() ? hub.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
351 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
352 if (fillContents) {
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
353 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
354 }
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
355 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
356 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
357
18699
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
358 @Snippet
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
359 protected static void verifyHeap(@ConstantParameter Register threadRegister) {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
360 Word thread = registerAsWord(threadRegister);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
361 Word topValue = readTlabTop(thread);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
362 if (!topValue.equal(Word.zero())) {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
363 Word topValueContents = topValue.readWord(0, MARK_WORD_LOCATION);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
364 if (topValueContents.equal(Word.zero())) {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
365 AssertionSnippets.vmMessageC(AssertionSnippets.ASSERTION_VM_MESSAGE_C, true, cstring("overzeroing of TLAB detected"), 0L, 0L, 0L);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
366 }
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
367 }
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
368 }
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
369
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 * 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
372 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
373 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
374 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
375 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
376 /*
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
377 * 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
378 * is not null
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
379 */
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
380 initializeObjectHeader(memory, prototypeMarkWord, hub);
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
381 if (fillContents) {
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
382 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
383 }
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
384 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
385 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
386
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
387 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
388
20178
7ba8fb19d56d Check that snippets only access locations that are either accessed by the replacee, or are private to the snippet.
Roland Schatz <roland.schatz@oracle.com>
parents: 19904
diff changeset
389 private final SnippetInfo allocateInstance = snippet(NewObjectSnippets.class, "allocateInstance", INIT_LOCATION, MARK_WORD_LOCATION, HUB_WRITE_LOCATION, TLAB_TOP_LOCATION, TLAB_END_LOCATION);
7ba8fb19d56d Check that snippets only access locations that are either accessed by the replacee, or are private to the snippet.
Roland Schatz <roland.schatz@oracle.com>
parents: 19904
diff changeset
390 private final SnippetInfo allocateArray = snippet(NewObjectSnippets.class, "allocateArray", INIT_LOCATION, MARK_WORD_LOCATION, HUB_WRITE_LOCATION, TLAB_TOP_LOCATION, TLAB_END_LOCATION);
7ba8fb19d56d Check that snippets only access locations that are either accessed by the replacee, or are private to the snippet.
Roland Schatz <roland.schatz@oracle.com>
parents: 19904
diff changeset
391 private final SnippetInfo allocateArrayDynamic = snippet(NewObjectSnippets.class, "allocateArrayDynamic", INIT_LOCATION, MARK_WORD_LOCATION, HUB_WRITE_LOCATION, TLAB_TOP_LOCATION,
7ba8fb19d56d Check that snippets only access locations that are either accessed by the replacee, or are private to the snippet.
Roland Schatz <roland.schatz@oracle.com>
parents: 19904
diff changeset
392 TLAB_END_LOCATION);
7ba8fb19d56d Check that snippets only access locations that are either accessed by the replacee, or are private to the snippet.
Roland Schatz <roland.schatz@oracle.com>
parents: 19904
diff changeset
393 private final SnippetInfo allocateInstanceDynamic = snippet(NewObjectSnippets.class, "allocateInstanceDynamic", INIT_LOCATION, MARK_WORD_LOCATION, HUB_WRITE_LOCATION, TLAB_TOP_LOCATION,
7ba8fb19d56d Check that snippets only access locations that are either accessed by the replacee, or are private to the snippet.
Roland Schatz <roland.schatz@oracle.com>
parents: 19904
diff changeset
394 TLAB_END_LOCATION);
20836
aff67777d2ea Better verification in assertSnippetKills.
Roland Schatz <roland.schatz@oracle.com>
parents: 20178
diff changeset
395 private final SnippetInfo newmultiarray = snippet(NewObjectSnippets.class, "newmultiarray", INIT_LOCATION, TLAB_TOP_LOCATION, TLAB_END_LOCATION);
18699
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
396 private final SnippetInfo verifyHeap = snippet(NewObjectSnippets.class, "verifyHeap");
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
397
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14908
diff changeset
398 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
399 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
400 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
401
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
402 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
403 * 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
404 */
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
405 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
406 StructuredGraph graph = newInstanceNode.graph();
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
407 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newInstanceNode.instanceClass();
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
408 assert !type.isArray();
18481
f91e40c4bb47 Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 18401
diff changeset
409 ConstantNode hub = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), type.klass(), providers.getMetaAccess(), graph);
7544
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
410 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
411
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
412 Arguments args = new Arguments(allocateInstance, graph.getGuardsStage(), tool.getLoweringStage());
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
413 args.addConst("size", size);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
414 args.add("hub", hub);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
415 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
416 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
417 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
418 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
419 args.addConst("typeContext", ProfileAllocations.getValue() ? type.toJavaName(false) : "");
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
420
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
421 SnippetTemplate template = template(args);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
422 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
423 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
424 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
425
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
426 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
427 * 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
428 */
18515
8b87897f5b42 introduced HotSpotGraalRuntimeProvder interface
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
429 public void lower(NewArrayNode newArrayNode, HotSpotRegistersProvider registers, HotSpotGraalRuntimeProvider runtime, 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
430 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
431 ResolvedJavaType elementType = newArrayNode.elementType();
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
432 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
433 Kind elementKind = elementType.getKind();
18481
f91e40c4bb47 Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 18401
diff changeset
434 ConstantNode hub = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), arrayType.klass(), providers.getMetaAccess(), graph);
21528
513f8d0ae27d merge fixes
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
435 final int headerSize = runtime.getJVMCIRuntime().getArrayBaseOffset(elementKind);
12796
68ff7abbfae5 renamed HotSpotHostLoweringProvider to HotSpotLoweringProvider
Doug Simon <doug.simon@oracle.com>
parents: 12789
diff changeset
436 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
437 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
438
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
439 Arguments args = new Arguments(allocateArray, graph.getGuardsStage(), tool.getLoweringStage());
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
440 args.add("hub", hub);
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
441 ValueNode length = newArrayNode.length();
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
442 args.add("length", length.isAlive() ? length : graph.addOrUniqueWithInputs(length));
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
443 args.add("prototypeMarkWord", arrayType.prototypeMarkWord());
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
444 args.addConst("headerSize", headerSize);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
445 args.addConst("log2ElementSize", log2ElementSize);
10760
59d2d6a30d29 Re-enable omission of array initialization for G1.
Roland Schatz <roland.schatz@oracle.com>
parents: 10745
diff changeset
446 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
447 args.addConst("threadRegister", registers.getThreadRegister());
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
448 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
449 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
450
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
451 SnippetTemplate template = template(args);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
452 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
453 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
454 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
455
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
456 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
457 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
458 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
459 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
460 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
461
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
462 SnippetTemplate template = template(args);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
463 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
464 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
465
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
466 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
467 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
468 Arguments args = new Arguments(allocateArrayDynamic, newArrayNode.graph().getGuardsStage(), tool.getLoweringStage());
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
469 args.add("elementType", newArrayNode.getElementType());
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
470 ValueNode length = newArrayNode.length();
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
471 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
472 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
473 args.addConst("threadRegister", registers.getThreadRegister());
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
474
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
475 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
476 template.instantiate(providers.getMetaAccess(), newArrayNode, DEFAULT_REPLACER, args);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
477 }
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
478
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
479 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
480 StructuredGraph graph = newmultiarrayNode.graph();
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
481 int rank = newmultiarrayNode.dimensionCount();
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
482 ValueNode[] dims = new ValueNode[rank];
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
483 for (int i = 0; i < newmultiarrayNode.dimensionCount(); i++) {
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
484 dims[i] = newmultiarrayNode.dimension(i);
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
485 }
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
486 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newmultiarrayNode.type();
18481
f91e40c4bb47 Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 18401
diff changeset
487 ConstantNode hub = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), type.klass(), providers.getMetaAccess(), graph);
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
488
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
489 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
490 args.add("hub", hub);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
491 args.addConst("rank", rank);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
492 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
493 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
494 }
7544
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
495
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
496 private static int instanceSize(HotSpotResolvedObjectType type) {
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
497 int size = type.instanceSize();
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
498 assert size >= 0;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
499 return size;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
500 }
18699
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
501
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
502 public void lower(VerifyHeapNode verifyHeapNode, HotSpotRegistersProvider registers, HotSpotGraalRuntimeProvider runtime, LoweringTool tool) {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
503 if (runtime.getConfig().cAssertions) {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
504 Arguments args = new Arguments(verifyHeap, verifyHeapNode.graph().getGuardsStage(), tool.getLoweringStage());
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
505 args.addConst("threadRegister", registers.getThreadRegister());
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
506
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
507 SnippetTemplate template = template(args);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
508 template.instantiate(providers.getMetaAccess(), verifyHeapNode, DEFAULT_REPLACER, args);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
509 } else {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
510 GraphUtil.removeFixedWithUnusedInputs(verifyHeapNode);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
511 }
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
512 }
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
513 }
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
514
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9793
diff changeset
515 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
516 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
517 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
518 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
519
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9793
diff changeset
520 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
521 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
522 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
523 }