Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java @ 7530:5e3d1a68664e
applied mx eclipseformat to all Java files
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 23 Jan 2013 16:34:57 +0100 |
parents | fe9f252f0d05 |
children | 630ea5001e33 |
rev | line source |
---|---|
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.stubs; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.hotspot.snippets.HotSpotSnippetUtils.*; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 import static com.oracle.graal.hotspot.snippets.NewObjectSnippets.*; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.api.code.*; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.hotspot.meta.*; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.hotspot.nodes.*; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.hotspot.snippets.*; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.snippets.*; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.snippets.Snippet.ConstantParameter; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.snippets.Snippet.Parameter; |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.snippets.SnippetTemplate.Key; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
38 import com.oracle.graal.word.*; |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
41 * Stub implementing the fast path for TLAB refill during instance class allocation. This stub is |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
42 * called from the {@linkplain NewObjectSnippets inline} allocation code when TLAB allocation fails. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
43 * If this stub fails to refill the TLAB or allocate the object, it calls out to the HotSpot C++ |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
44 * runtime for to complete the allocation. |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 */ |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 public class NewArrayStub extends Stub { |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 public NewArrayStub(final HotSpotRuntime runtime, Assumptions assumptions, TargetDescription target) { |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 super(runtime, assumptions, target, NewArrayStubCall.NEW_ARRAY); |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 } |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 @Override |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 protected void populateKey(Key key) { |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 HotSpotResolvedObjectType intArrayType = (HotSpotResolvedObjectType) runtime.lookupJavaType(int[].class); |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 Constant intArrayHub = intArrayType.klass(); |
7237
509d72a1d81b
made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents:
7147
diff
changeset
|
56 key.add("intArrayHub", intArrayHub).add("log", Boolean.getBoolean("graal.logNewArrayStub")); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 } |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
60 * Re-attempts allocation after an initial TLAB allocation failed or was skipped (e.g., due to |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
61 * -XX:-UseTLAB). |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
62 * |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 * @param hub the hub of the object to be allocated |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 * @param length the length of the array |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 * @param intArrayHub the hub for {@code int[].class} |
7237
509d72a1d81b
made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents:
7147
diff
changeset
|
66 * @param log specifies if logging is enabled |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 */ |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 @Snippet |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
69 private static Object newArray(@Parameter("hub") |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
70 Word hub, @Parameter("length") |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
71 int length, @ConstantParameter("intArrayHub") |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
72 Word intArrayHub, @ConstantParameter("log") |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
73 boolean log) { |
7275
4f220c85044d
replaces node intrinsics for loadinf from a Word with methods directly in the Word class itself
Doug Simon <doug.simon@oracle.com>
parents:
7254
diff
changeset
|
74 int layoutHelper = hub.readInt(layoutHelperOffset()); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask(); |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 int headerSize = (layoutHelper >> layoutHelperHeaderSizeShift()) & layoutHelperHeaderSizeMask(); |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 int elementKind = (layoutHelper >> layoutHelperElementTypeShift()) & layoutHelperElementTypeMask(); |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 int sizeInBytes = computeArrayAllocationSize(length, wordSize(), headerSize, log2ElementSize); |
7237
509d72a1d81b
made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents:
7147
diff
changeset
|
79 log(log, "newArray: element kind %d\n", elementKind); |
509d72a1d81b
made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents:
7147
diff
changeset
|
80 log(log, "newArray: array length %d\n", length); |
509d72a1d81b
made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents:
7147
diff
changeset
|
81 log(log, "newArray: array size %d\n", sizeInBytes); |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
82 log(log, "newArray: hub=%p\n", hub); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 // check that array length is small enough for fast path. |
7254
9e155cd2bb2f
enable tlab stub for array allocation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7253
diff
changeset
|
85 if (length <= MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH) { |
7253
c66968130037
replicate c1 tlab refill behavior more closely, fixes problem with huge tlab sizes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7239
diff
changeset
|
86 Word memory = refillAllocate(intArrayHub, sizeInBytes, log); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 if (memory != Word.zero()) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
88 log(log, "newArray: allocated new array at %p\n", memory); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
89 formatArray(hub, sizeInBytes, length, headerSize, memory, Word.unsigned(arrayPrototypeMarkWord()), true); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 return verifyOop(memory.toObject()); |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 } |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 } |
7237
509d72a1d81b
made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents:
7147
diff
changeset
|
93 log(log, "newArray: calling new_array_slow", 0L); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 return verifyOop(NewArraySlowStubCall.call(hub, length)); |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 } |
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 } |