Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java @ 6328:6e66d97a16ae
Clean up Kind class.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 07 Sep 2012 12:12:47 +0200 |
parents | 5d7d9a6953bd |
children | 892d3c82febe |
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 */ |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.snippets; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
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
|
25 import static com.oracle.graal.hotspot.nodes.CastFromHub.*; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 import static com.oracle.graal.hotspot.nodes.RegisterNode.*; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import static com.oracle.graal.nodes.extended.UnsafeLoadNode.*; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import static com.oracle.graal.snippets.SnippetTemplate.Arguments.*; |
5770
25e37b01b92a
moved SnippetCounter and DirectObjectStoreNode into graal.snippets project as they are not HotSpot specific
Doug Simon <doug.simon@oracle.com>
parents:
5763
diff
changeset
|
29 import static com.oracle.graal.snippets.nodes.DirectObjectStoreNode.*; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import static com.oracle.graal.snippets.nodes.ExplodeLoopNode.*; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import static com.oracle.max.asm.target.amd64.AMD64.*; |
5763
a3d71693e0ce
removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
32 import static com.oracle.max.criutils.UnsignedMath.*; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.api.code.*; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.api.meta.*; |
5772
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
36 import com.oracle.graal.compiler.*; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.debug.*; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.hotspot.*; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 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
|
40 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
|
41 import com.oracle.graal.nodes.*; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 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
|
43 import com.oracle.graal.nodes.spi.*; |
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.snippets.*; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 import com.oracle.graal.snippets.Snippet.ConstantParameter; |
5576
a4d0ded32ddd
moved @Fold from Node.java to Snippet.java
Doug Simon <doug.simon@oracle.com>
parents:
5563
diff
changeset
|
46 import com.oracle.graal.snippets.Snippet.Fold; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 import com.oracle.graal.snippets.Snippet.Parameter; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
48 import com.oracle.graal.snippets.SnippetTemplate.AbstractTemplates; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 import com.oracle.graal.snippets.SnippetTemplate.Arguments; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 import com.oracle.graal.snippets.SnippetTemplate.Key; |
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 */ |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
55 public class NewObjectSnippets implements SnippetsInterface { |
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 |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
58 public static Word allocate(@Parameter("size") int size) { |
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
|
59 Word thread = asWord(register(r15, wordKind())); |
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
|
60 Word top = loadWord(thread, threadTlabTopOffset()); |
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
|
61 Word end = loadWord(thread, threadTlabEndOffset()); |
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
|
62 Word newTop = top.plus(size); |
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
|
63 if (newTop.belowOrEqual(end)) { |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
64 storeObject(thread, 0, threadTlabTopOffset(), 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
|
65 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
|
66 } |
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
|
67 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
|
68 } |
5587
bf4f499cc538
added allocation logging to NewInstanceSnippets
Doug Simon <doug.simon@oracle.com>
parents:
5576
diff
changeset
|
69 |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 @Snippet |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
71 public static Object initializeObject( |
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
|
72 @Parameter("memory") Word memory, |
5602
e79b593e0632
made NewInstanceSnippets respect the UseTLAB HotSpot option
Doug Simon <doug.simon@oracle.com>
parents:
5594
diff
changeset
|
73 @Parameter("hub") Object hub, |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
74 @Parameter("initialMarkWord") Word initialMarkWord, |
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
|
75 @ConstantParameter("size") int size) { |
5602
e79b593e0632
made NewInstanceSnippets respect the UseTLAB HotSpot option
Doug Simon <doug.simon@oracle.com>
parents:
5594
diff
changeset
|
76 |
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
|
77 if (memory == Word.zero()) { |
5772
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
78 new_stub.inc(); |
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
|
79 return NewInstanceStubCall.call(hub); |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 } |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
81 formatObject(hub, size, memory, initialMarkWord); |
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
|
82 Object instance = memory.toObject(); |
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
|
83 return castFromHub(verifyOop(instance), hub); |
5624
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
84 } |
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
85 |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
86 @Snippet |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
87 public static Object initializeObjectArray( |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
88 @Parameter("memory") Word memory, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
89 @Parameter("hub") Object hub, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
90 @Parameter("length") int length, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
91 @Parameter("size") int size, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
92 @Parameter("initialMarkWord") Word initialMarkWord, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
93 @ConstantParameter("headerSize") int headerSize) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
94 return initializeArray(memory, hub, length, size, initialMarkWord, headerSize, true); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
95 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
96 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
97 @Snippet |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
98 public static Object initializePrimitiveArray( |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
99 @Parameter("memory") Word memory, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
100 @Parameter("hub") Object hub, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
101 @Parameter("length") int length, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
102 @Parameter("size") int size, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
103 @Parameter("initialMarkWord") Word initialMarkWord, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
104 @ConstantParameter("headerSize") int headerSize) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
105 return initializeArray(memory, hub, length, size, initialMarkWord, headerSize, false); |
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 private static Object initializeArray(Word memory, Object hub, int length, int size, Word initialMarkWord, int headerSize, boolean isObjectArray) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
109 if (memory == Word.zero()) { |
5772
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
110 if (isObjectArray) { |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
111 anewarray_stub.inc(); |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
112 } else { |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
113 newarray_stub.inc(); |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
114 } |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
115 return NewArrayStubCall.call(isObjectArray, hub, length); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
116 } |
5772
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
117 if (isObjectArray) { |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
118 anewarray_loopInit.inc(); |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
119 } else { |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
120 newarray_loopInit.inc(); |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
121 } |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
122 formatArray(hub, size, length, headerSize, memory, initialMarkWord); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
123 Object instance = memory.toObject(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
124 return castFromHub(verifyOop(instance), hub); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
125 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
126 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
127 /** |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
128 * 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
|
129 */ |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
130 private static final int MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH = 0x00FFFFFF; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
131 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
132 @Snippet |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
133 public static Object allocateArrayAndInitialize( |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
134 @Parameter("length") int length, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
135 @ConstantParameter("alignment") int alignment, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
136 @ConstantParameter("headerSize") int headerSize, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
137 @ConstantParameter("log2ElementSize") int log2ElementSize, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
138 @ConstantParameter("type") ResolvedJavaType type, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
139 @ConstantParameter("wordKind") Kind wordKind) { |
5763
a3d71693e0ce
removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
140 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
|
141 // This handles both negative array sizes and very large array sizes |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
142 DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.RuntimeConstraint); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
143 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
144 int size = getArraySize(length, alignment, headerSize, log2ElementSize); |
5805
013081f7771b
consolidated 2 separate size fields in TLABAllocate into 1
Doug Simon <doug.simon@oracle.com>
parents:
5772
diff
changeset
|
145 Word memory = TLABAllocateNode.allocateVariableSize(size, wordKind); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
146 return InitializeArrayNode.initialize(memory, length, size, type); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
147 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
148 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
149 public static int getArraySize(int length, int alignment, int headerSize, int log2ElementSize) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
150 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
|
151 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
|
152 return size & mask; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
153 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
154 |
5624
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
155 private static Object verifyOop(Object object) { |
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
156 if (verifyOops()) { |
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
157 VerifyOopStubCall.call(object); |
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
158 } |
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
159 return object; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 private static Word asWord(Object object) { |
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
|
163 return Word.fromObject(object); |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 |
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
|
166 private static Word loadWord(Word address, int offset) { |
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
|
167 Object value = loadObject(address, 0, offset, true); |
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
|
168 return asWord(value); |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 /** |
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
|
172 * Maximum size of an object whose body is initialized by a sequence of |
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
|
173 * zero-stores to its fields. Larger objects have their bodies initialized |
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
|
174 * in a loop. |
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
|
175 */ |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
176 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
|
177 |
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
|
178 /** |
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
|
179 * 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
|
180 */ |
5686
6cb39a47da14
replaced loading of instance prototype header word with a constant obtained from HotSpotResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
5683
diff
changeset
|
181 private static void formatObject(Object hub, int size, Word memory, Word headerPrototype) { |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
182 storeObject(memory, 0, markOffset(), headerPrototype); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
183 storeObject(memory, 0, hubOffset(), hub); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
184 if (size <= MAX_UNROLLED_OBJECT_ZEROING_SIZE) { |
5772
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
185 new_seqInit.inc(); |
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
|
186 explodeLoop(); |
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
|
187 for (int offset = 2 * wordSize(); offset < size; offset += wordSize()) { |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
188 storeWord(memory, 0, offset, Word.zero()); |
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
|
189 } |
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
|
190 } else { |
5772
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
191 new_loopInit.inc(); |
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
|
192 for (int offset = 2 * wordSize(); offset < size; offset += wordSize()) { |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
193 storeWord(memory, 0, offset, Word.zero()); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
194 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
195 } |
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 /** |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
199 * 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
|
200 */ |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
201 private static void formatArray(Object hub, int size, int length, int headerSize, Word memory, Word headerPrototype) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
202 storeObject(memory, 0, markOffset(), headerPrototype); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
203 storeObject(memory, 0, hubOffset(), hub); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
204 storeInt(memory, 0, arrayLengthOffset(), length); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
205 for (int offset = headerSize; offset < size; offset += wordSize()) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
206 storeWord(memory, 0, offset, Word.zero()); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
207 } |
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 |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
210 public static class Templates extends AbstractTemplates<NewObjectSnippets> { |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
211 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
212 private final ResolvedJavaMethod allocate; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
213 private final ResolvedJavaMethod initializeObject; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
214 private final ResolvedJavaMethod initializeObjectArray; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
215 private final ResolvedJavaMethod initializePrimitiveArray; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
216 private final ResolvedJavaMethod allocateArrayAndInitialize; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
217 private final TargetDescription target; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
218 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
|
219 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
220 public Templates(CodeCacheProvider runtime, TargetDescription target, boolean useTLAB) { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
221 super(runtime, NewObjectSnippets.class); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
222 this.target = target; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
223 this.useTLAB = useTLAB; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
224 allocate = snippet("allocate", int.class); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
225 initializeObject = snippet("initializeObject", Word.class, Object.class, Word.class, int.class); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
226 initializeObjectArray = snippet("initializeObjectArray", Word.class, Object.class, int.class, int.class, Word.class, int.class); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
227 initializePrimitiveArray = snippet("initializePrimitiveArray", Word.class, Object.class, int.class, int.class, Word.class, int.class); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
228 allocateArrayAndInitialize = snippet("allocateArrayAndInitialize", int.class, int.class, int.class, int.class, ResolvedJavaType.class, Kind.class); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
229 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
230 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
231 /** |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
232 * 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
|
233 */ |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
234 @SuppressWarnings("unused") |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
235 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
|
236 StructuredGraph graph = (StructuredGraph) newInstanceNode.graph(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
237 HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) newInstanceNode.instanceClass(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
238 HotSpotKlassOop hub = type.klassOop(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
239 int size = type.instanceSize(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
240 assert (size % wordSize()) == 0; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
241 assert size >= 0; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
242 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
243 ValueNode memory; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
244 if (!useTLAB) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
245 memory = ConstantNode.forConstant(new Constant(target.wordKind, 0L), runtime, graph); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
246 } else { |
5805
013081f7771b
consolidated 2 separate size fields in TLABAllocate into 1
Doug Simon <doug.simon@oracle.com>
parents:
5772
diff
changeset
|
247 ConstantNode sizeNode = ConstantNode.forInt(size, graph); |
013081f7771b
consolidated 2 separate size fields in TLABAllocate into 1
Doug Simon <doug.simon@oracle.com>
parents:
5772
diff
changeset
|
248 TLABAllocateNode tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode, wordKind())); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
249 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
|
250 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
|
251 } |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
252 InitializeObjectNode initializeNode = graph.add(new InitializeObjectNode(memory, type)); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
253 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
|
254 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
255 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
256 /** |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
257 * 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
|
258 */ |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
259 @SuppressWarnings("unused") |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
260 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
|
261 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
|
262 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
|
263 TLABAllocateNode tlabAllocateNode; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
264 ResolvedJavaType elementType = newArrayNode.elementType(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
265 ResolvedJavaType arrayType = elementType.arrayOf(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
266 Kind elementKind = elementType.kind(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
267 final int alignment = target.wordSize; |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6302
diff
changeset
|
268 final int headerSize = elementKind.getArrayBaseOffset(); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
269 final Integer length = lengthNode.isConstant() ? Integer.valueOf(lengthNode.asConstant().asInt()) : null; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
270 int log2ElementSize = CodeUtil.log2(target.sizeInBytes(elementKind)); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
271 if (!useTLAB) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
272 ConstantNode zero = ConstantNode.forConstant(new Constant(target.wordKind, 0L), runtime, graph); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
273 // value for 'size' doesn't matter as it isn't used since a stub call will be made anyway |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
274 // for both allocation and initialization - it just needs to be non-null |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
275 ConstantNode size = ConstantNode.forInt(-1, graph); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
276 InitializeArrayNode initializeNode = graph.add(new InitializeArrayNode(zero, lengthNode, size, arrayType)); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
277 graph.replaceFixedWithFixed(newArrayNode, initializeNode); |
5763
a3d71693e0ce
removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
278 } 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
|
279 // Calculate aligned size |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
280 int size = getArraySize(length, alignment, headerSize, log2ElementSize); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
281 ConstantNode sizeNode = ConstantNode.forInt(size, graph); |
5805
013081f7771b
consolidated 2 separate size fields in TLABAllocate into 1
Doug Simon <doug.simon@oracle.com>
parents:
5772
diff
changeset
|
282 tlabAllocateNode = graph.add(new TLABAllocateNode(sizeNode, target.wordKind)); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
283 graph.addBeforeFixed(newArrayNode, tlabAllocateNode); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
284 InitializeArrayNode initializeNode = graph.add(new InitializeArrayNode(tlabAllocateNode, lengthNode, sizeNode, arrayType)); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
285 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
|
286 } else { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
287 Key key = new Key(allocateArrayAndInitialize). |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
288 add("alignment", alignment). |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
289 add("headerSize", headerSize). |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
290 add("log2ElementSize", log2ElementSize). |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
291 add("wordKind", target.wordKind). |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
292 add("type", arrayType); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
293 Arguments arguments = new Arguments().add("length", lengthNode); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
294 SnippetTemplate template = cache.get(key); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
295 Debug.log("Lowering allocateArrayAndInitialize in %s: node=%s, template=%s, arguments=%s", graph, newArrayNode, template, arguments); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
296 template.instantiate(runtime, newArrayNode, arguments); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
297 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
298 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
299 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
300 @SuppressWarnings("unused") |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
301 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
|
302 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
|
303 ValueNode size = tlabAllocateNode.size(); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
304 Key key = new Key(allocate); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
305 Arguments arguments = arguments("size", size); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
306 SnippetTemplate template = cache.get(key); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
307 Debug.log("Lowering fastAllocate in %s: node=%s, template=%s, arguments=%s", graph, tlabAllocateNode, template, arguments); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
308 template.instantiate(runtime, tlabAllocateNode, arguments); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
309 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
310 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
311 @SuppressWarnings("unused") |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
312 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
|
313 StructuredGraph graph = (StructuredGraph) initializeNode.graph(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
314 HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) initializeNode.type(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
315 assert !type.isArrayClass(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
316 HotSpotKlassOop hub = type.klassOop(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
317 int size = type.instanceSize(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
318 assert (size % wordSize()) == 0; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
319 assert size >= 0; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
320 Key key = new Key(initializeObject).add("size", size); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
321 ValueNode memory = initializeNode.memory(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
322 Arguments arguments = arguments("memory", memory).add("hub", hub).add("initialMarkWord", type.initialMarkWord()); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
323 SnippetTemplate template = cache.get(key); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
324 Debug.log("Lowering initializeObject in %s: node=%s, template=%s, arguments=%s", graph, initializeNode, template, arguments); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
325 template.instantiate(runtime, initializeNode, arguments); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
326 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
327 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
328 @SuppressWarnings("unused") |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
329 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
|
330 StructuredGraph graph = (StructuredGraph) initializeNode.graph(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
331 HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) initializeNode.type(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
332 ResolvedJavaType elementType = type.componentType(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
333 assert elementType != null; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
334 HotSpotKlassOop hub = type.klassOop(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
335 Kind elementKind = elementType.kind(); |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6302
diff
changeset
|
336 final int headerSize = elementKind.getArrayBaseOffset(); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
337 Key key = new Key(elementKind.isObject() ? initializeObjectArray : initializePrimitiveArray).add("headerSize", headerSize); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
338 ValueNode memory = initializeNode.memory(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
339 Arguments arguments = arguments("memory", memory).add("hub", hub).add("initialMarkWord", type.initialMarkWord()).add("size", initializeNode.size()).add("length", initializeNode.length()); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
340 SnippetTemplate template = cache.get(key); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
341 Debug.log("Lowering initializeObjectArray in %s: node=%s, template=%s, arguments=%s", graph, initializeNode, template, arguments); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5805
diff
changeset
|
342 template.instantiate(runtime, initializeNode, arguments); |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
343 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
344 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
345 |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
346 @Fold |
5624
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
347 private static boolean verifyOops() { |
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
348 return HotSpotGraalRuntime.getInstance().getConfig().verifyOops; |
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
349 } |
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
350 |
7d25723b7699
added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
Doug Simon <doug.simon@oracle.com>
parents:
5616
diff
changeset
|
351 @Fold |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
352 private static int threadTlabTopOffset() { |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
353 return HotSpotGraalRuntime.getInstance().getConfig().threadTlabTopOffset; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
354 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
355 |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
356 @Fold |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
357 private static int threadTlabEndOffset() { |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
358 return HotSpotGraalRuntime.getInstance().getConfig().threadTlabEndOffset; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
359 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
360 |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
361 @Fold |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
362 private static Kind wordKind() { |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
363 return HotSpotGraalRuntime.getInstance().getTarget().wordKind; |
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 |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
366 @Fold |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
367 private static int wordSize() { |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
368 return HotSpotGraalRuntime.getInstance().getTarget().wordSize; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
369 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
370 |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
371 @Fold |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
372 private static int markOffset() { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
373 return HotSpotGraalRuntime.getInstance().getConfig().markOffset; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
374 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
375 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
376 @Fold |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
377 private static int hubOffset() { |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
378 return HotSpotGraalRuntime.getInstance().getConfig().hubOffset; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
379 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
380 |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
381 @Fold |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
382 private static int arrayLengthOffset() { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
383 return HotSpotGraalRuntime.getInstance().getConfig().arrayLengthOffset; |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
384 } |
5772
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
385 |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
386 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
|
387 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
|
388 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
|
389 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
|
390 |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
391 private static final SnippetCounter.Group countersNewPrimitiveArray = GraalOptions.SnippetCounters ? new SnippetCounter.Group("NewPrimitiveArray") : null; |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
392 private static final SnippetCounter newarray_loopInit = new SnippetCounter(countersNewPrimitiveArray, "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
|
393 private static final SnippetCounter newarray_stub = new SnippetCounter(countersNewPrimitiveArray, "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
|
394 |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
395 private static final SnippetCounter.Group countersNewObjectArray = GraalOptions.SnippetCounters ? new SnippetCounter.Group("NewObjectArray") : null; |
2f7a03583a32
added counters for code paths through the new object snippets
Doug Simon <doug.simon@oracle.com>
parents:
5770
diff
changeset
|
396 private static final SnippetCounter anewarray_loopInit = new SnippetCounter(countersNewObjectArray, "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
|
397 private static final SnippetCounter anewarray_stub = new SnippetCounter(countersNewObjectArray, "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
|
398 } |