annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java @ 9516:cf8104ed68ba

Merge.
author Doug Simon <doug.simon@oracle.com>
date Thu, 02 May 2013 14:12:24 +0200
parents 659bb6cf930c 106f0a0acafa
children 19c5a07c7843
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 /*
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
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.*;
9513
659bb6cf930c rename: HotSpotSnippetUtils -> HotSpotReplacementsUtil
Doug Simon <doug.simon@oracle.com>
parents: 9423
diff changeset
26 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
7035
52c88c405d07 Simplify how stamp is preserved after lowering of allocation nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7034
diff changeset
27 import static com.oracle.graal.nodes.extended.UnsafeArrayCastNode.*;
52c88c405d07 Simplify how stamp is preserved after lowering of allocation nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7034
diff changeset
28 import static com.oracle.graal.nodes.extended.UnsafeCastNode.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
29 import static com.oracle.graal.replacements.SnippetTemplate.*;
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
30 import static com.oracle.graal.replacements.nodes.BranchProbabilityNode.*;
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
31 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
32
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 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
34 import com.oracle.graal.api.meta.*;
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.debug.*;
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 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
37 import com.oracle.graal.hotspot.nodes.*;
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 import com.oracle.graal.nodes.*;
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.nodes.java.*;
5720
46ad94a0574a moved everything from com.oracle.graal.nodes.cri into com.oracle.graal.nodes.spi
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
40 import com.oracle.graal.nodes.spi.*;
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6568
diff changeset
41 import com.oracle.graal.nodes.type.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6511
diff changeset
42 import com.oracle.graal.phases.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
43 import com.oracle.graal.replacements.*;
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
44 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
45 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
46 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
47 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
48 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 8413
diff changeset
49 import com.oracle.graal.replacements.nodes.*;
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
50 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
51
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 /**
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
53 * 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
54 */
8413
d9347ee39fbe rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents: 7868
diff changeset
55 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
56
5663
77069a28a983 split lowering of NEW into two separate nodes - one for doing the allocation and one for doing the object formatting. Both of these nodes are in turn lowered via snippets.
Doug Simon <doug.simon@oracle.com>
parents: 5648
diff changeset
57 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
58 public static Word allocate(int size) {
6419
b74402a7079b fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents: 6375
diff changeset
59 Word thread = thread();
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
60 Word top = readTlabTop(thread);
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
61 Word end = readTlabEnd(thread);
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
62 Word newTop = top.add(size);
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
63 /*
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
64 * this check might lead to problems if the TLAB is within 16GB of the address space end
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
65 * (checked in c++ code)
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
66 */
9316
5e1465ec46d6 Change the way branch probabilities are injected. Update all snippets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9015
diff changeset
67 if (probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
68 writeTlabTop(thread, newTop);
5666
48a2505efb54 added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents: 5663
diff changeset
69 return top;
5663
77069a28a983 split lowering of NEW into two separate nodes - one for doing the allocation and one for doing the object formatting. Both of these nodes are in turn lowered via snippets.
Doug Simon <doug.simon@oracle.com>
parents: 5648
diff changeset
70 }
5666
48a2505efb54 added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents: 5663
diff changeset
71 return Word.zero();
5663
77069a28a983 split lowering of NEW into two separate nodes - one for doing the allocation and one for doing the object formatting. Both of these nodes are in turn lowered via snippets.
Doug Simon <doug.simon@oracle.com>
parents: 5648
diff changeset
72 }
5587
bf4f499cc538 added allocation logging to NewInstanceSnippets
Doug Simon <doug.simon@oracle.com>
parents: 5576
diff changeset
73
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74 @Snippet
9504
106f0a0acafa refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents: 9423
diff changeset
75 public static Object initializeObject(Word memory, Word hub, Word prototypeMarkWord, @ConstantParameter int size, @ConstantParameter boolean fillContents) {
5602
e79b593e0632 made NewInstanceSnippets respect the UseTLAB HotSpot option
Doug Simon <doug.simon@oracle.com>
parents: 5594
diff changeset
76
7035
52c88c405d07 Simplify how stamp is preserved after lowering of allocation nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7034
diff changeset
77 Object result;
9316
5e1465ec46d6 Change the way branch probabilities are injected. Update all snippets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9015
diff changeset
78 if (probability(SLOW_PATH_PROBABILITY, memory.equal(0))) {
5772
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
79 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
80 result = NewInstanceStubCall.call(hub);
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6504
diff changeset
81 } else {
9504
106f0a0acafa refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents: 9423
diff changeset
82 formatObject(hub, size, memory, prototypeMarkWord, fillContents);
7035
52c88c405d07 Simplify how stamp is preserved after lowering of allocation nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7034
diff changeset
83 result = memory.toObject();
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6504
diff changeset
84 }
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
85 /*
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
86 * make sure that the unsafeCast is anchored after initialization, see ReadAfterCheckCast
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
87 * and CheckCastSnippets
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
88 */
8897
1a8a0375ba74 unsafeCast: anchor cast after initialization of an object
Bernhard Urban <bernhard.urban@jku.at>
parents: 8637
diff changeset
89 BeginNode anchorNode = BeginNode.anchor(StampFactory.forNodeIntrinsic());
1a8a0375ba74 unsafeCast: anchor cast after initialization of an object
Bernhard Urban <bernhard.urban@jku.at>
parents: 8637
diff changeset
90 return unsafeCast(verifyOop(result), StampFactory.forNodeIntrinsic(), anchorNode);
5624
7d25723b7699 added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents: 5616
diff changeset
91 }
7d25723b7699 added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents: 5616
diff changeset
92
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
93 @Snippet
9504
106f0a0acafa refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents: 9423
diff changeset
94 public static Object initializeArray(Word memory, Word hub, int length, int allocationSize, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter boolean fillContents) {
7035
52c88c405d07 Simplify how stamp is preserved after lowering of allocation nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7034
diff changeset
95 Object result;
9316
5e1465ec46d6 Change the way branch probabilities are injected. Update all snippets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9015
diff changeset
96 if (probability(SLOW_PATH_PROBABILITY, memory.equal(0))) {
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
97 newarray_stub.inc();
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
98 result = NewArrayStubCall.call(hub, length);
5772
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
99 } else {
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
100 newarray_loopInit.inc();
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
101 formatArray(hub, allocationSize, length, headerSize, memory, prototypeMarkWord, fillContents);
7035
52c88c405d07 Simplify how stamp is preserved after lowering of allocation nodes
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7034
diff changeset
102 result = memory.toObject();
5772
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
103 }
8898
9f56bb503db4 unsafeArrayCast: anchor cast after initialization of an array
Bernhard Urban <bernhard.urban@jku.at>
parents: 8897
diff changeset
104 BeginNode anchorNode = BeginNode.anchor(StampFactory.forNodeIntrinsic());
9f56bb503db4 unsafeArrayCast: anchor cast after initialization of an array
Bernhard Urban <bernhard.urban@jku.at>
parents: 8897
diff changeset
105 return unsafeArrayCast(verifyOop(result), length, StampFactory.forNodeIntrinsic(), anchorNode);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
106 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
107
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
108 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
109 * 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
110 */
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
111 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
112
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
113 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
114 public static Object allocateArrayAndInitialize(int length, @ConstantParameter int alignment, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize,
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
115 @ConstantParameter boolean fillContents, @ConstantParameter ResolvedJavaType type) {
5763
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5760
diff changeset
116 if (!belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) {
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
117 // This handles both negative array sizes and very large array sizes
7251
c305a0315bea use DeoptAction.None for array allocations with invalid length (very large or negative)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7147
diff changeset
118 DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
119 }
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
120 int allocationSize = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize);
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
121 Word memory = TLABAllocateNode.allocateVariableSize(allocationSize);
9504
106f0a0acafa refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents: 9423
diff changeset
122 return InitializeArrayNode.initialize(memory, length, allocationSize, type, fillContents);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
123 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
124
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
125 /**
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
126 * 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
127 * 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
128 * alignment requirements.
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
129 *
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
130 * @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
131 * @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
132 * @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
133 * @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
134 */
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
135 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
136 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
137 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
138 return size & mask;
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
139 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
140
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 /**
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
142 * Calls the runtime stub for implementing MULTIANEWARRAY.
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
143 */
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
144 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
145 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
146 Word dims = DimensionsNode.allocaDimsArray(rank);
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
147 ExplodeLoopNode.explodeLoop();
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
148 for (int i = 0; i < rank; i++) {
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
149 dims.writeInt(i * 4, dimensions[i], ANY_LOCATION);
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
150 }
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
151 return NewMultiArrayStubCall.call(hub, rank, dims);
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
152 }
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
153
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
154 /**
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
155 * Maximum size of an object whose body is initialized by a sequence of zero-stores to its
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
156 * fields. Larger 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
157 */
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
158 private static final int MAX_UNROLLED_OBJECT_ZEROING_SIZE = 10 * wordSize();
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
159
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
160 /**
5683
0ca242de9383 improved type stamp for value flowing out of a lowered NEW bytecode instruction
Doug Simon <doug.simon@oracle.com>
parents: 5679
diff changeset
161 * Formats some allocated memory with an object header zeroes out the rest.
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 */
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6568
diff changeset
163 private static void formatObject(Word hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents) {
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
164 Word prototypeMarkWord = useBiasedLocking() ? hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION) : compileTimePrototypeMarkWord;
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
165 initializeObjectHeader(memory, prototypeMarkWord, hub);
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
166 if (fillContents) {
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
167 if (size <= MAX_UNROLLED_OBJECT_ZEROING_SIZE) {
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
168 new_seqInit.inc();
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
169 explodeLoop();
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
170 for (int offset = 2 * wordSize(); offset < size; offset += wordSize()) {
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
171 memory.writeWord(offset, Word.zero(), ANY_LOCATION);
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
172 }
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
173 } else {
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
174 new_loopInit.inc();
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
175 for (int offset = 2 * wordSize(); offset < size; offset += wordSize()) {
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
176 memory.writeWord(offset, Word.zero(), ANY_LOCATION);
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
177 }
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
178 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
179 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
180 }
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 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
183 * Formats some allocated memory with an object header zeroes out the rest.
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
184 */
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
185 public static void formatArray(Word hub, int allocationSize, int length, int headerSize, Word memory, Word prototypeMarkWord, boolean fillContents) {
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
186 memory.writeInt(arrayLengthOffset(), length, ANY_LOCATION);
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
187 /*
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
188 * 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
189 * is not null
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
190 */
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
191 initializeObjectHeader(memory, prototypeMarkWord, hub);
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
192 if (fillContents) {
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
193 for (int offset = headerSize; offset < allocationSize; offset += wordSize()) {
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
194 memory.writeWord(offset, Word.zero(), ANY_LOCATION);
6355
892d3c82febe add support for fillConents to NewObjectSnippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 6328
diff changeset
195 }
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
196 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
197 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
198
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
199 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
200
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
201 private final SnippetInfo allocate = snippet(NewObjectSnippets.class, "allocate");
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
202 private final SnippetInfo initializeObject = snippet(NewObjectSnippets.class, "initializeObject");
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
203 private final SnippetInfo initializeArray = snippet(NewObjectSnippets.class, "initializeArray");
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
204 private final SnippetInfo allocateArrayAndInitialize = snippet(NewObjectSnippets.class, "allocateArrayAndInitialize");
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
205 private final SnippetInfo newmultiarray = snippet(NewObjectSnippets.class, "newmultiarray");
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
206
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
207 private final boolean useTLAB;
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
208
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8604
diff changeset
209 public Templates(CodeCacheProvider runtime, Replacements replacements, TargetDescription target, boolean useTLAB) {
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
210 super(runtime, replacements, target);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
211 this.useTLAB = useTLAB;
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
212 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
213
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
214 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
215 * 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
216 */
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
217 @SuppressWarnings("unused")
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
218 public void lower(NewInstanceNode newInstanceNode, LoweringTool tool) {
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
219 StructuredGraph graph = (StructuredGraph) newInstanceNode.graph();
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
220 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newInstanceNode.instanceClass();
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6568
diff changeset
221 ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, graph);
7544
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
222 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
223
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
224 ValueNode memory;
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
225 if (!useTLAB) {
7105
f1f32b695d1e Make constructors of Constant private to ensure proper encapuslation of the type-overloaded primitive field; reduce to one constructor that sets all fields.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7099
diff changeset
226 memory = ConstantNode.defaultForKind(target.wordKind, graph);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
227 } else {
5805
013081f7771b consolidated 2 separate size fields in TLABAllocate into 1
Doug Simon <doug.simon@oracle.com>
parents: 5772
diff changeset
228 ConstantNode sizeNode = ConstantNode.forInt(size, graph);
6954
0e20ad1ea98b removed WordStamp (and a nasty bug associated with its misusage)
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
229 TLABAllocateNode tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode));
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
230 graph.addBeforeFixed(newInstanceNode, tlabAllocateNode);
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
231 memory = tlabAllocateNode;
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
232 }
9504
106f0a0acafa refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents: 9423
diff changeset
233 InitializeObjectNode initializeNode = graph.add(new InitializeObjectNode(memory, type, newInstanceNode.fillContents()));
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
234 graph.replaceFixedWithFixed(newInstanceNode, initializeNode);
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
235 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
236
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
237 /**
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
238 * 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
239 */
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
240 @SuppressWarnings("unused")
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
241 public void lower(NewArrayNode newArrayNode, LoweringTool tool) {
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
242 StructuredGraph graph = (StructuredGraph) newArrayNode.graph();
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
243 ValueNode lengthNode = newArrayNode.length();
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
244 TLABAllocateNode tlabAllocateNode;
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
245 ResolvedJavaType elementType = newArrayNode.elementType();
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
246 ResolvedJavaType arrayType = elementType.getArrayClass();
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
247 Kind elementKind = elementType.getKind();
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
248 final int alignment = target.wordSize;
7099
3656236c7d27 Cleanup of Kind class: remove use of Unsafe class
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
249 final int headerSize = HotSpotRuntime.getArrayBaseOffset(elementKind);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
250 final Integer length = lengthNode.isConstant() ? Integer.valueOf(lengthNode.asConstant().asInt()) : null;
9423
3426008293e7 Move getSizeInBytes method to Architecture class.
Roland Schatz <roland.schatz@oracle.com>
parents: 9316
diff changeset
251 int log2ElementSize = CodeUtil.log2(target.arch.getSizeInBytes(elementKind));
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
252 if (!useTLAB) {
7105
f1f32b695d1e Make constructors of Constant private to ensure proper encapuslation of the type-overloaded primitive field; reduce to one constructor that sets all fields.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7099
diff changeset
253 ConstantNode zero = ConstantNode.defaultForKind(target.wordKind, graph);
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
254 /*
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
255 * value for 'size' doesn't matter as it isn't used since a stub call will be made
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
256 * anyway for both allocation and initialization - it just needs to be non-null
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
257 */
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
258 ConstantNode size = ConstantNode.forInt(-1, graph);
9504
106f0a0acafa refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents: 9423
diff changeset
259 InitializeArrayNode initializeNode = graph.add(new InitializeArrayNode(zero, lengthNode, size, arrayType, newArrayNode.fillContents()));
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
260 graph.replaceFixedWithFixed(newArrayNode, initializeNode);
7352
00e3c2e4e43c Re-enable fast array allocation/initialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7351
diff changeset
261 } else if (length != null && belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) {
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
262 // Calculate aligned size
7147
88d626e2c2a8 added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
263 int size = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
264 ConstantNode sizeNode = ConstantNode.forInt(size, graph);
6954
0e20ad1ea98b removed WordStamp (and a nasty bug associated with its misusage)
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
265 tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode));
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
266 graph.addBeforeFixed(newArrayNode, tlabAllocateNode);
9504
106f0a0acafa refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents: 9423
diff changeset
267 InitializeArrayNode initializeNode = graph.add(new InitializeArrayNode(tlabAllocateNode, lengthNode, sizeNode, arrayType, newArrayNode.fillContents()));
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
268 graph.replaceFixedWithFixed(newArrayNode, initializeNode);
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
269 } else {
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
270 Arguments args = new Arguments(allocateArrayAndInitialize);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
271 args.add("length", lengthNode);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
272 args.addConst("alignment", alignment);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
273 args.addConst("headerSize", headerSize);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
274 args.addConst("log2ElementSize", log2ElementSize);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
275 args.addConst("fillContents", newArrayNode.fillContents());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
276 args.addConst("type", arrayType);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
277
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
278 SnippetTemplate template = template(args);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
279 Debug.log("Lowering allocateArrayAndInitialize in %s: node=%s, template=%s, arguments=%s", graph, newArrayNode, template, args);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
280 template.instantiate(runtime, 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
281 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
282 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
283
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
284 @SuppressWarnings("unused")
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
285 public void lower(TLABAllocateNode tlabAllocateNode, LoweringTool tool) {
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
286 StructuredGraph graph = (StructuredGraph) tlabAllocateNode.graph();
5805
013081f7771b consolidated 2 separate size fields in TLABAllocate into 1
Doug Simon <doug.simon@oracle.com>
parents: 5772
diff changeset
287 ValueNode size = tlabAllocateNode.size();
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
288 Arguments args = new Arguments(allocate).add("size", size);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
289
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
290 SnippetTemplate template = template(args);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
291 Debug.log("Lowering fastAllocate in %s: node=%s, template=%s, arguments=%s", graph, tlabAllocateNode, template, args);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
292 template.instantiate(runtime, tlabAllocateNode, 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
293 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
294
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
295 @SuppressWarnings("unused")
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
296 public void lower(InitializeObjectNode initializeNode, LoweringTool tool) {
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
297 StructuredGraph graph = (StructuredGraph) initializeNode.graph();
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
298 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) initializeNode.type();
7060
06d5f450f32b rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents: 7035
diff changeset
299 assert !type.isArray();
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6568
diff changeset
300 ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, graph);
7544
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
301 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
302 ValueNode memory = initializeNode.memory();
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
303
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
304 Arguments args = new Arguments(initializeObject);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
305 args.add("memory", memory);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
306 args.add("hub", hub);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
307 args.add("prototypeMarkWord", type.prototypeMarkWord());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
308 args.addConst("size", size).addConst("fillContents", initializeNode.fillContents());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
309
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
310 SnippetTemplate template = template(args);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
311 Debug.log("Lowering initializeObject in %s: node=%s, template=%s, arguments=%s", graph, initializeNode, template, args);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
312 template.instantiate(runtime, initializeNode, 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
313 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
314
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
315 @SuppressWarnings("unused")
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
316 public void lower(InitializeArrayNode initializeNode, LoweringTool tool) {
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
317 StructuredGraph graph = (StructuredGraph) initializeNode.graph();
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
318 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) initializeNode.type();
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
319 ResolvedJavaType elementType = type.getComponentType();
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
320 assert elementType != null;
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6568
diff changeset
321 ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, graph);
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
322 Kind elementKind = elementType.getKind();
7099
3656236c7d27 Cleanup of Kind class: remove use of Unsafe class
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
323 final int headerSize = HotSpotRuntime.getArrayBaseOffset(elementKind);
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5720
diff changeset
324 ValueNode memory = initializeNode.memory();
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
325
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
326 Arguments args = new Arguments(initializeArray);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
327 args.add("memory", memory);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
328 args.add("hub", hub);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
329 args.add("length", initializeNode.length());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
330 args.add("allocationSize", initializeNode.allocationSize());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
331 args.add("prototypeMarkWord", type.prototypeMarkWord());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
332 args.addConst("headerSize", headerSize);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
333 args.addConst("fillContents", initializeNode.fillContents());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
334
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
335 SnippetTemplate template = template(args);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
336 Debug.log("Lowering initializeArray in %s: node=%s, template=%s, arguments=%s", graph, initializeNode, template, args);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
337 template.instantiate(runtime, initializeNode, DEFAULT_REPLACER, args);
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
338 }
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
339
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
340 @SuppressWarnings("unused")
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
341 public void lower(NewMultiArrayNode newmultiarrayNode, LoweringTool tool) {
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
342 StructuredGraph graph = (StructuredGraph) newmultiarrayNode.graph();
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
343 int rank = newmultiarrayNode.dimensionCount();
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
344 ValueNode[] dims = new ValueNode[rank];
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
345 for (int i = 0; i < newmultiarrayNode.dimensionCount(); i++) {
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
346 dims[i] = newmultiarrayNode.dimension(i);
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
347 }
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7081
diff changeset
348 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newmultiarrayNode.type();
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6568
diff changeset
349 ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, graph);
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
350
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
351 Arguments args = new Arguments(newmultiarray);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
352 args.add("hub", hub);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
353 args.addConst("rank", rank);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
354 args.addVarargs("dimensions", int.class, StampFactory.forKind(Kind.Int), dims);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8898
diff changeset
355 template(args).instantiate(runtime, newmultiarrayNode, DEFAULT_REPLACER, args);
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6420
diff changeset
356 }
7544
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
357
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
358 private static int instanceSize(HotSpotResolvedObjectType type) {
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
359 int size = type.instanceSize();
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
360 assert (size % wordSize()) == 0;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
361 assert size >= 0;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
362 return size;
5d9c23b8dbb8 factored out common code in NewObjectSnippets
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
363 }
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
364 }
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
365
5772
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
366 private static final SnippetCounter.Group countersNew = GraalOptions.SnippetCounters ? new SnippetCounter.Group("NewInstance") : null;
2f7a03583a32 added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents: 5770
diff changeset
367 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
368 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
369 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
370
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
371 private static final SnippetCounter.Group countersNewArray = GraalOptions.SnippetCounters ? new SnippetCounter.Group("NewArray") : null;
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
372 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
373 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
374 }