annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java @ 18699:08b17b738500

Add hooks for verifying heap from generated code
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 16 Dec 2014 13:36:16 -0800
parents ecb9d0cedbab
children e23a5de08e2a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
18362
ea0fbb571466 Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents: 18340
diff changeset
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
23 package com.oracle.graal.hotspot.replacements;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
6501
55c54c4bdcfc moved UnsignedMath to com.oracle.graal.api.code
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
25 import static com.oracle.graal.api.code.UnsignedMath.*;
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
26 import static com.oracle.graal.compiler.common.GraalOptions.*;
18699
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
27 import static com.oracle.graal.hotspot.nodes.CStringNode.*;
9513
659bb6cf930c rename: HotSpotSnippetUtils -> HotSpotReplacementsUtil
Doug Simon <doug.simon@oracle.com>
parents: 9423
diff changeset
28 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
29 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
30 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
31 import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
32 import static com.oracle.graal.replacements.SnippetTemplate.*;
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
33 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
34
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.api.code.*;
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.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
37 import com.oracle.graal.api.replacements.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15066
diff changeset
38 import com.oracle.graal.compiler.common.*;
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.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 import com.oracle.graal.hotspot.meta.*;
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.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
46 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
47 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
48 import com.oracle.graal.nodes.*;
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
49 import com.oracle.graal.nodes.debug.*;
10586
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
50 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
51 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
52 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
53 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
54 import com.oracle.graal.options.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
55 import com.oracle.graal.replacements.*;
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
56 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
57 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
58 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
59 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
60 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
61 import com.oracle.graal.replacements.nodes.*;
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
62 import com.oracle.graal.word.*;
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 /**
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
65 * 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
66 */
8413
d9347ee39fbe rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents: 7868
diff changeset
67 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
68
18307
85f5227a7a37 add mutable/immutable factory methods to NamedLocationIdentity
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18259
diff changeset
69 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
70
12732
8212479436e0 disabled type context specialization of allocation snippets unless allocation profiling is enabled
Doug Simon <doug.simon@oracle.com>
parents: 12579
diff changeset
71 static class Options {
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
72
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
73 //@formatter:off
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18541
diff changeset
74 @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
75 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
76 //@formatter:on
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
77 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
78
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
79 static enum ProfileMode {
14908
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
80 AllocatingMethods,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
81 InstanceOrArray,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
82 AllocatedTypes,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
83 AllocatedTypesInMethods,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14863
diff changeset
84 Total
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
85 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
86
17391
e890b86b397d default allocation profiling to AllocatedTypes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17204
diff changeset
87 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
88
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
89 @Fold
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
90 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
91 switch (PROFILE_MODE) {
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
92 case AllocatingMethods:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
93 return "";
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
94 case InstanceOrArray:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
95 return path;
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
96 case AllocatedTypes:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
97 case AllocatedTypesInMethods:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
98 return typeContext;
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
99 case Total:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
100 return "bytes";
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
101 default:
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
102 throw GraalInternalError.shouldNotReachHere();
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
103 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
104 }
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 @Fold
12381
20150eaa1dc7 remove unused parameters from doProfile methods
Lukas Stadler <lukas.stadler@jku.at>
parents: 12054
diff changeset
107 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
108 return ProfileAllocations.getValue();
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
109 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
110
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15018
diff changeset
111 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
112 if (doProfile()) {
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
113 String name = createName(path, typeContext);
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
114
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
115 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
116 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
117 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
118 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
119 }
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
120
17204
fcf71ef8a0e5 visibility change in NewObjectSnippets
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16478
diff changeset
121 public static void emitPrefetchAllocate(Word address, boolean isArray) {
13255
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
122 if (config().allocatePrefetchStyle > 0) {
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
123 // 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
124 // Generate several prefetch instructions.
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
125 int lines = isArray ? config().allocatePrefetchLines : config().allocateInstancePrefetchLines;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
126 int stepSize = config().allocatePrefetchStepSize;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
127 int distance = config().allocatePrefetchDistance;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
128 ExplodeLoopNode.explodeLoop();
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
129 for (int i = 0; i < lines; i++) {
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
130 PrefetchAllocateNode.prefetch(address, Word.signed(distance));
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
131 distance += stepSize;
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
132 }
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
133 }
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
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136 @Snippet
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
137 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
138 @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
139 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
140 Word thread = registerAsWord(threadRegister);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
141 Word top = readTlabTop(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
142 Word end = readTlabEnd(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
143 Word newTop = top.add(size);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
144 if (useTLAB() && probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
145 writeTlabTop(thread, newTop);
13255
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
146 emitPrefetchAllocate(newTop, false);
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
147 result = formatObject(hub, size, top, prototypeMarkWord, fillContents, constantSize, true);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
148 } else {
5772
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
149 new_stub.inc();
7035
52c88c405d07 Simplify how stamp is preserved after lowering of allocation nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7034
diff changeset
150 result = NewInstanceStubCall.call(hub);
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6504
diff changeset
151 }
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
152 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
153 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
154 }
7d25723b7699 added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents: 5616
diff changeset
155
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
156 @Snippet
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
157 public static Object allocateInstanceDynamic(Class<?> type, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister, @ConstantParameter String typeContext) {
18502
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18491
diff changeset
158 KlassPointer hub = ClassGetHubNode.readClass(type);
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18491
diff changeset
159 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
160 if (probability(FAST_PATH_PROBABILITY, isInstanceKlassFullyInitialized(hub))) {
18502
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18491
diff changeset
161 int layoutHelper = readLayoutHelper(hub);
13582
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
162 /*
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
163 * 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
164 * 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
165 * 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
166 * allocated using the fastpath.
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
167 */
13631
11c46696a655 Add probabilities to NewObjectSnippets.allocateInstanceDynamic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13582
diff changeset
168 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
169 Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
18502
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18491
diff changeset
170 return allocateInstance(layoutHelper, hub, prototypeMarkWord, fillContents, threadRegister, false, typeContext);
13582
be5006687c43 Add initialization checks to Unsafe.allocateInstance intrinsic
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13578
diff changeset
171 }
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
172 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
173 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
174 return dynamicNewInstanceStub(type);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
175 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
176
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
177 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
178 * 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
179 */
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
180 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
181
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
182 @Snippet
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
183 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
184 @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
185 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
186 }
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
187
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
188 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
189 @ConstantParameter Register threadRegister, @ConstantParameter boolean maybeUnroll, String typeContext, boolean skipNegativeCheck) {
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
190 Object result;
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
191 int alignment = wordSize();
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
192 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
193 Word thread = registerAsWord(threadRegister);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
194 Word top = readTlabTop(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
195 Word end = readTlabEnd(thread);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
196 Word newTop = top.add(allocationSize);
15634
172484b8f800 don't deopt on large array allocations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15261
diff changeset
197 if ((skipNegativeCheck || belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) && useTLAB() && probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
198 writeTlabTop(thread, newTop);
13255
785bbb619238 Basic allocation prefetching support
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13150
diff changeset
199 emitPrefetchAllocate(newTop, true);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
200 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
201 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
202 } else {
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
203 newarray_stub.inc();
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
204 result = NewArrayStubCall.call(hub, length);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
205 }
11873
8a201c64cd18 in-depth profiling of allocations and monitors
Lukas Stadler <lukas.stadler@jku.at>
parents: 11845
diff changeset
206 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
207 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
208 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
209
10586
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
210 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
211 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
212
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
213 @NodeIntrinsic(ForeignCallNode.class)
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
214 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
215
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
216 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
217 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
218 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
219
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
220 @NodeIntrinsic(ForeignCallNode.class)
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
221 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
222
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
223 @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
224 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
225 Word hub = loadWordFromObject(elementType, arrayKlassOffset(), CLASS_ARRAY_KLASS_LOCATION);
10542
554f67e4ff3f Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10456
diff changeset
226 if (hub.equal(Word.zero()) || !belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) {
10586
110434bc2913 Remove unnecessary class.
Roland Schatz <roland.schatz@oracle.com>
parents: 10542
diff changeset
227 return dynamicNewArrayStub(DYNAMIC_NEW_ARRAY, elementType, length);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
228 }
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
229
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
230 KlassPointer klass = KlassPointer.fromWord(hub);
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
231 int layoutHelper = readLayoutHelper(klass);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
232 //@formatter:off
10427
58777dad7f90 Cite source of comment in NewObjectSnippets.
Roland Schatz <roland.schatz@oracle.com>
parents: 10030
diff changeset
233 // from src/share/vm/oops/klass.hpp:
58777dad7f90 Cite source of comment in NewObjectSnippets.
Roland Schatz <roland.schatz@oracle.com>
parents: 10030
diff changeset
234 //
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
235 // For arrays, layout helper is a negative number, containing four
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
236 // distinct bytes, as follows:
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
237 // MSB:[tag, hsz, ebt, log2(esz)]:LSB
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
238 // where:
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
239 // tag is 0x80 if the elements are oops, 0xC0 if non-oops
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
240 // 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
241 // ebt is the BasicType of the elements
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
242 // esz is the element size in bytes
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
243 //@formatter:on
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
244
10456
e4dd840a39de Use values from HotSpotVMConfig instead of hardcoding shifts and bitmasks.
Roland Schatz <roland.schatz@oracle.com>
parents: 10442
diff changeset
245 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
246 int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask();
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
247 Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
248
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
249 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
250 }
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
251
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
252 /**
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
253 * Computes the size of the memory chunk allocated for an array. This size accounts for the
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
254 * array header size, boy size and any padding after the last element to satisfy object
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
255 * alignment requirements.
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14101
diff changeset
256 *
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
257 * @param length the number of elements in the array
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
258 * @param alignment the object alignment requirement
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
259 * @param headerSize the size of the array header
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
260 * @param log2ElementSize log2 of the size of an element in the array
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
261 */
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
262 public static int computeArrayAllocationSize(int length, int alignment, int headerSize, int log2ElementSize) {
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
263 int size = (length << log2ElementSize) + headerSize + (alignment - 1);
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
264 int mask = ~(alignment - 1);
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
265 return size & mask;
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
266 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
267
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
268 /**
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
269 * Calls the runtime stub for implementing MULTIANEWARRAY.
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
270 */
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
271 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
272 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
273 Word dims = DimensionsNode.allocaDimsArray(rank);
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
274 ExplodeLoopNode.explodeLoop();
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
275 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
276 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
277 }
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
278 return NewMultiArrayStubCall.call(hub, rank, dims);
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
279 }
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
280
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
281 /**
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14766
diff changeset
282 * 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
283 * 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
284 */
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
285 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
286
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
287 /**
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
288 * 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
289 * that stores are aligned.
14763
a6c1c3eb20c4 transition to JDK8
Doug Simon <doug.simon@oracle.com>
parents: 14101
diff changeset
290 *
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
291 * @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
292 * @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
293 * @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
294 * @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
295 * @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
296 */
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
297 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
298 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
299 int offset = startOffset;
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
300 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
301 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
302 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
303 }
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
304 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
305 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
306 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
307 // 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
308 // 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
309 // 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
310 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
311 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
312 }
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
313 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
314 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
315 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
316 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
317 }
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13631
diff changeset
318 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
319 }
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 } 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
321 // 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
322 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
323 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
324 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
325 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
326 }
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
327 explodeLoop();
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
328 } 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
329 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
330 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
331 }
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
332 }
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
333 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
334 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
335 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
336 }
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
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 /**
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 * 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
341 * 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
342 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
343 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
344 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
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 /**
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 * 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
349 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
350 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
351 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
352 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
353 if (fillContents) {
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
354 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
355 }
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
356 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
357 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
358
18699
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
359 @Snippet
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
360 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
361 Word thread = registerAsWord(threadRegister);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
362 Word topValue = readTlabTop(thread);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
363 if (!topValue.equal(Word.zero())) {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
364 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
365 if (topValueContents.equal(Word.zero())) {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
366 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
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 }
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
370
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
371 /**
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
372 * 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
373 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
374 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
375 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
376 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
377 /*
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
378 * 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
379 * is not null
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
380 */
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
381 initializeObjectHeader(memory, prototypeMarkWord, hub);
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
382 if (fillContents) {
16084
b37dbfdfbbfb assertion mechanism for snippets and stubs
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15889
diff changeset
383 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
384 }
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
385 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
386 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
387
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
388 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
389
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
390 private final SnippetInfo allocateInstance = snippet(NewObjectSnippets.class, "allocateInstance");
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
391 private final SnippetInfo allocateArray = snippet(NewObjectSnippets.class, "allocateArray");
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
392 private final SnippetInfo allocateArrayDynamic = snippet(NewObjectSnippets.class, "allocateArrayDynamic");
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
393 private final SnippetInfo allocateInstanceDynamic = snippet(NewObjectSnippets.class, "allocateInstanceDynamic");
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
394 private final SnippetInfo newmultiarray = snippet(NewObjectSnippets.class, "newmultiarray");
18699
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
395 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
396
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14908
diff changeset
397 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
398 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
399 }
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 * 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
403 */
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
404 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
405 StructuredGraph graph = newInstanceNode.graph();
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
406 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newInstanceNode.instanceClass();
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
407 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
408 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
409 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
410
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
411 Arguments args = new Arguments(allocateInstance, graph.getGuardsStage(), tool.getLoweringStage());
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
412 args.addConst("size", size);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
413 args.add("hub", hub);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
414 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
415 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
416 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
417 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
418 args.addConst("typeContext", ProfileAllocations.getValue() ? type.toJavaName(false) : "");
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
419
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
420 SnippetTemplate template = template(args);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
421 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
422 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
423 }
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 * 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
427 */
18515
8b87897f5b42 introduced HotSpotGraalRuntimeProvder interface
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
428 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
429 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
430 ResolvedJavaType elementType = newArrayNode.elementType();
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
431 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
432 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
433 ConstantNode hub = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), arrayType.klass(), providers.getMetaAccess(), graph);
18515
8b87897f5b42 introduced HotSpotGraalRuntimeProvder interface
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
434 final int headerSize = runtime.getArrayBaseOffset(elementKind);
12796
68ff7abbfae5 renamed HotSpotHostLoweringProvider to HotSpotLoweringProvider
Doug Simon <doug.simon@oracle.com>
parents: 12789
diff changeset
435 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
436 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
437
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
438 Arguments args = new Arguments(allocateArray, graph.getGuardsStage(), tool.getLoweringStage());
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
439 args.add("hub", hub);
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
440 ValueNode length = newArrayNode.length();
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
441 args.add("length", length.isAlive() ? length : graph.addOrUniqueWithInputs(length));
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
442 args.add("prototypeMarkWord", arrayType.prototypeMarkWord());
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
443 args.addConst("headerSize", headerSize);
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
444 args.addConst("log2ElementSize", log2ElementSize);
10760
59d2d6a30d29 Re-enable omission of array initialization for G1.
Roland Schatz <roland.schatz@oracle.com>
parents: 10745
diff changeset
445 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
446 args.addConst("threadRegister", registers.getThreadRegister());
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
447 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
448 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
449
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
450 SnippetTemplate template = template(args);
9688
0d0645267c32 simplify NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
451 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
452 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
453 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
454
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
455 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
456 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
457 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
458 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
459 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
460
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
461 SnippetTemplate template = template(args);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
462 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
463 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13505
diff changeset
464
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
465 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
466 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
467 Arguments args = new Arguments(allocateArrayDynamic, newArrayNode.graph().getGuardsStage(), tool.getLoweringStage());
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
468 args.add("elementType", newArrayNode.getElementType());
16238
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
469 ValueNode length = newArrayNode.length();
db5b41891078 let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16084
diff changeset
470 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
471 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
472 args.addConst("threadRegister", registers.getThreadRegister());
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
473
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
474 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
475 template.instantiate(providers.getMetaAccess(), newArrayNode, DEFAULT_REPLACER, args);
10027
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
476 }
e561e0a6f727 DynamicNewArrayNode
Roland Schatz <roland.schatz@oracle.com>
parents: 9896
diff changeset
477
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
478 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
479 StructuredGraph graph = newmultiarrayNode.graph();
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
480 int rank = newmultiarrayNode.dimensionCount();
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
481 ValueNode[] dims = new ValueNode[rank];
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
482 for (int i = 0; i < newmultiarrayNode.dimensionCount(); i++) {
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
483 dims[i] = newmultiarrayNode.dimension(i);
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
484 }
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
485 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
486 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
487
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
488 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
489 args.add("hub", hub);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
490 args.addConst("rank", rank);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
491 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
492 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
493 }
7544
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
494
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
495 private static int instanceSize(HotSpotResolvedObjectType type) {
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
496 int size = type.instanceSize();
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
497 assert size >= 0;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
498 return size;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
499 }
18699
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
500
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
501 static class WarnOnce {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
502 static {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
503 System.out.println("VerifyHeapNode requires a VM with asserts enabled.");
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
504 }
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
505
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
506 static void warn() {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
507 }
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
508 }
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
509
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
510 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
511 if (runtime.getConfig().cAssertions) {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
512 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
513 args.addConst("threadRegister", registers.getThreadRegister());
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
514
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
515 SnippetTemplate template = template(args);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
516 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
517 } else {
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
518 WarnOnce.warn();
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
519 GraphUtil.removeFixedWithUnusedInputs(verifyHeapNode);
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
520 }
08b17b738500 Add hooks for verifying heap from generated code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18674
diff changeset
521 }
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
522 }
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
523
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9793
diff changeset
524 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
525 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
526 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
527 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
528
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9793
diff changeset
529 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
530 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
531 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
532 }