annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java @ 21526:1da7aef31a08

created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Tue, 19 May 2015 23:16:07 +0200
parents 82f65fca8da6
children 5324104ac4f3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
18362
ea0fbb571466 Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents: 18232
diff changeset
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.stubs;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import static com.oracle.graal.hotspot.nodes.DirectCompareAndSwapNode.*;
9513
659bb6cf930c rename: HotSpotSnippetUtils -> HotSpotReplacementsUtil
Doug Simon <doug.simon@oracle.com>
parents: 9418
diff changeset
26 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
9671
0b3d19e4e2a2 used static import for methods in StubUtil
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
27 import static com.oracle.graal.hotspot.stubs.StubUtil.*;
12767
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
28 import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.api.code.*;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.api.meta.*;
18370
6713fef8c859 Make the @Fold annotation a top-level interface in the api project. It is not tied to the Snippet class where it was located before.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18362
diff changeset
32 import com.oracle.graal.api.replacements.*;
9352
d4684b468e93 made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9232
diff changeset
33 import com.oracle.graal.graph.Node.ConstantNodeParameter;
d4684b468e93 made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9232
diff changeset
34 import com.oracle.graal.graph.Node.NodeIntrinsic;
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8508
diff changeset
35 import com.oracle.graal.hotspot.*;
21526
1da7aef31a08 created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19857
diff changeset
36 import com.oracle.graal.hotspot.jvmci.*;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.hotspot.meta.*;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 import com.oracle.graal.hotspot.nodes.*;
18481
f91e40c4bb47 Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 18401
diff changeset
39 import com.oracle.graal.hotspot.nodes.type.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 7868
diff changeset
40 import com.oracle.graal.hotspot.replacements.*;
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
41 import com.oracle.graal.hotspot.word.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
42 import com.oracle.graal.nodes.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 7868
diff changeset
43 import com.oracle.graal.replacements.*;
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8508
diff changeset
44 import com.oracle.graal.replacements.Snippet.ConstantParameter;
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
45 import com.oracle.graal.word.*;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7356
diff changeset
48 * Stub implementing the fast path for TLAB refill during instance class allocation. This stub is
19857
82f65fca8da6 Fix javadoc.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19791
diff changeset
49 * called from the {@linkplain NewObjectSnippets inline} allocation code when TLAB allocation fails.
82f65fca8da6 Fix javadoc.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19791
diff changeset
50 * If this stub fails to refill the TLAB or allocate the object, it calls out to the HotSpot C++
82f65fca8da6 Fix javadoc.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19791
diff changeset
51 * runtime for to complete the allocation.
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 */
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9576
diff changeset
53 public class NewInstanceStub extends SnippetStub {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
55 public NewInstanceStub(HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
56 super("newInstance", providers, linkage);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 @Override
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
60 protected Object[] makeConstArgs() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
61 HotSpotResolvedObjectType intArrayType = (HotSpotResolvedObjectType) providers.getMetaAccess().lookupJavaType(int[].class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
62 int count = method.getSignature().getParameterCount(false);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
63 Object[] args = new Object[count];
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
64 assert checkConstArg(1, "intArrayHub");
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
65 assert checkConstArg(2, "threadRegister");
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
66 args[1] = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), intArrayType.klass(), null);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 18502
diff changeset
67 args[2] = providers.getRegisters().getThreadRegister();
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8893
diff changeset
68 return args;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70
12792
be9c3426daad pass thread register into allocation stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12767
diff changeset
71 private static Word allocate(Word thread, int size) {
12767
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
72 Word top = readTlabTop(thread);
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
73 Word end = readTlabEnd(thread);
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
74 Word newTop = top.add(size);
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
75 /*
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
76 * this check might lead to problems if the TLAB is within 16GB of the address space end
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
77 * (checked in c++ code)
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
78 */
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
79 if (probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
80 writeTlabTop(thread, newTop);
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
81 return top;
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
82 }
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
83 return Word.zero();
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
84 }
5a51864f3088 moved raw memory TLAB allocation routine into NewInstanceStub and unsnippetized it
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
85
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
86 @Fold
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
87 private static boolean logging() {
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
88 return Boolean.getBoolean("graal.logNewInstanceStub");
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
89 }
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
90
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
91 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7356
diff changeset
92 * 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
93 * -XX:-UseTLAB).
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14101
diff changeset
94 *
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95 * @param hub the hub of the object to be allocated
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96 * @param intArrayHub the hub for {@code int[].class}
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97 */
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
98 @Snippet
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
99 private static Object newInstance(KlassPointer hub, @ConstantParameter KlassPointer intArrayHub, @ConstantParameter Register threadRegister) {
18232
31832ebd40cf Fine grained naming of immutable HotSpot LocationIdentities
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16386
diff changeset
100 /*
31832ebd40cf Fine grained naming of immutable HotSpot LocationIdentities
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16386
diff changeset
101 * The type is known to be an instance so Klass::_layout_helper is the instance size as a
31832ebd40cf Fine grained naming of immutable HotSpot LocationIdentities
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16386
diff changeset
102 * raw number
31832ebd40cf Fine grained naming of immutable HotSpot LocationIdentities
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16386
diff changeset
103 */
18377
ed0fce2e999a Fold klass._java_mirror._klass into klass and improve stamps from layout_helper
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18370
diff changeset
104 int sizeInBytes = loadKlassLayoutHelperIntrinsic(hub);
12793
af7fb87fc62e pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12792
diff changeset
105 Word thread = registerAsWord(threadRegister);
7238
7f55fd5f897d introduced graal.newArrayStub.forceSlowPath and graal.newInstanceStub.forceSlowPath system properties
Doug Simon <doug.simon@oracle.com>
parents: 7237
diff changeset
106 if (!forceSlowPath() && inlineContiguousAllocationSupported()) {
18502
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18481
diff changeset
107 if (isInstanceKlassFullyInitialized(hub)) {
12793
af7fb87fc62e pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12792
diff changeset
108 Word memory = refillAllocate(thread, intArrayHub, sizeInBytes, logging());
7701
47467b2c3fc5 Use equal() and notEqual() instead of == and != to compare words
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7556
diff changeset
109 if (memory.notEqual(0)) {
18502
f38677340519 Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18481
diff changeset
110 Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
14101
2ec05c3f773b fix overzeroing of new storage, refactor zeroing and unroll zeroing of small arrays
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13582
diff changeset
111 NewObjectSnippets.formatObjectForStub(hub, sizeInBytes, memory, prototypeMarkWord);
9671
0b3d19e4e2a2 used static import for methods in StubUtil
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
112 return verifyObject(memory.toObject());
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
114 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
115 }
9352
d4684b468e93 made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9232
diff changeset
116
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
117 if (logging()) {
9671
0b3d19e4e2a2 used static import for methods in StubUtil
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
118 printf("newInstance: calling new_instance_c\n");
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
119 }
9352
d4684b468e93 made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9232
diff changeset
120
12793
af7fb87fc62e pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12792
diff changeset
121 newInstanceC(NEW_INSTANCE_C, thread, hub);
af7fb87fc62e pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12792
diff changeset
122 handlePendingException(thread, true);
af7fb87fc62e pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12792
diff changeset
123 return verifyObject(getAndClearObjectResult(thread));
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 /**
7253
c66968130037 replicate c1 tlab refill behavior more closely, fixes problem with huge tlab sizes
Lukas Stadler <lukas.stadler@jku.at>
parents: 7238
diff changeset
127 * Attempts to refill the current thread's TLAB and retries the allocation.
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14101
diff changeset
128 *
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 * @param intArrayHub the hub for {@code int[].class}
7253
c66968130037 replicate c1 tlab refill behavior more closely, fixes problem with huge tlab sizes
Lukas Stadler <lukas.stadler@jku.at>
parents: 7238
diff changeset
130 * @param sizeInBytes the size of the allocation
7237
509d72a1d81b made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents: 7147
diff changeset
131 * @param log specifies if logging is enabled
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14101
diff changeset
132 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7356
diff changeset
133 * @return the newly allocated, uninitialized chunk of memory, or {@link Word#zero()} if the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7356
diff changeset
134 * operation was unsuccessful
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 */
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
136 static Word refillAllocate(Word thread, KlassPointer intArrayHub, int sizeInBytes, boolean log) {
10491
e98e021d1e7e Forbid direct eden allocation when G1 is enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9872
diff changeset
137 // If G1 is enabled, the "eden" allocation space is not the same always
e98e021d1e7e Forbid direct eden allocation when G1 is enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9872
diff changeset
138 // and therefore we have to go to slowpath to allocate a new TLAB.
10523
45788e918443 Code cleanup
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10491
diff changeset
139 if (useG1GC()) {
10491
e98e021d1e7e Forbid direct eden allocation when G1 is enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9872
diff changeset
140 return Word.zero();
e98e021d1e7e Forbid direct eden allocation when G1 is enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9872
diff changeset
141 }
8502
ff4fa8b0516e -Create push patch
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 8501
diff changeset
142 if (!useTLAB()) {
ff4fa8b0516e -Create push patch
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 8501
diff changeset
143 return edenAllocate(Word.unsigned(sizeInBytes), log);
ff4fa8b0516e -Create push patch
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 8501
diff changeset
144 }
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
145 Word intArrayMarkWord = Word.unsigned(tlabIntArrayMarkWord());
7253
c66968130037 replicate c1 tlab refill behavior more closely, fixes problem with huge tlab sizes
Lukas Stadler <lukas.stadler@jku.at>
parents: 7238
diff changeset
146 int alignmentReserveInBytes = tlabAlignmentReserveInHeapWords() * wordSize();
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
148 Word top = readTlabTop(thread);
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
149 Word end = readTlabEnd(thread);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 // calculate amount of free space
10869
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
152 long tlabFreeSpaceInBytes = end.subtract(top).rawValue();
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
154 if (log) {
9671
0b3d19e4e2a2 used static import for methods in StubUtil
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
155 printf("refillTLAB: thread=%p\n", thread.rawValue());
0b3d19e4e2a2 used static import for methods in StubUtil
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
156 printf("refillTLAB: top=%p\n", top.rawValue());
0b3d19e4e2a2 used static import for methods in StubUtil
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
157 printf("refillTLAB: end=%p\n", end.rawValue());
10869
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
158 printf("refillTLAB: tlabFreeSpaceInBytes=%ld\n", tlabFreeSpaceInBytes);
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
159 }
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160
10869
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
161 long tlabFreeSpaceInWords = tlabFreeSpaceInBytes >>> log2WordSize();
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 // Retain TLAB and allocate object in shared space if
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164 // the amount free in the TLAB is too large to discard.
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
165 Word refillWasteLimit = thread.readWord(tlabRefillWasteLimitOffset(), TLAB_REFILL_WASTE_LIMIT_LOCATION);
10869
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
166 if (tlabFreeSpaceInWords <= refillWasteLimit.rawValue()) {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
167 if (tlabStats()) {
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
168 // increment number of refills
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
169 thread.writeInt(tlabNumberOfRefillsOffset(), thread.readInt(tlabNumberOfRefillsOffset(), TLAB_NOF_REFILLS_LOCATION) + 1, TLAB_NOF_REFILLS_LOCATION);
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
170 if (log) {
9671
0b3d19e4e2a2 used static import for methods in StubUtil
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
171 printf("thread: %p -- number_of_refills %d\n", thread.rawValue(), thread.readInt(tlabNumberOfRefillsOffset(), TLAB_NOF_REFILLS_LOCATION));
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
172 }
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
173 // accumulate wastage
10869
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
174 int wastage = thread.readInt(tlabFastRefillWasteOffset(), TLAB_FAST_REFILL_WASTE_LOCATION) + (int) tlabFreeSpaceInWords;
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
175 if (log) {
10869
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
176 printf("thread: %p -- accumulated wastage %d\n", thread.rawValue(), wastage);
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
177 }
10869
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
178 thread.writeInt(tlabFastRefillWasteOffset(), wastage, TLAB_FAST_REFILL_WASTE_LOCATION);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
179 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
180
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
181 // if TLAB is currently allocated (top or end != null) then
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
182 // fill [top, end + alignment_reserve) with array object
7701
47467b2c3fc5 Use equal() and notEqual() instead of == and != to compare words
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7556
diff changeset
183 if (top.notEqual(0)) {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
184 int headerSize = arrayBaseOffset(Kind.Int);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7356
diff changeset
185 // just like the HotSpot assembler stubs, assumes that tlabFreeSpaceInInts fits in
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7356
diff changeset
186 // an int
10869
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
187 int tlabFreeSpaceInInts = (int) tlabFreeSpaceInBytes >>> 2;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
188 int length = ((alignmentReserveInBytes - headerSize) >>> 2) + tlabFreeSpaceInInts;
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14101
diff changeset
189 NewObjectSnippets.formatArray(intArrayHub, -1, length, headerSize, top, intArrayMarkWord, false, false, false);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
190
10869
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
191 long allocated = thread.readLong(threadAllocatedBytesOffset(), TLAB_THREAD_ALLOCATED_BYTES_LOCATION);
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
192 allocated = allocated + top.subtract(readTlabStart(thread)).rawValue();
3ad7c15c2623 Some Klass and InstanceKlass fields were read with a wrong size.
twisti
parents: 10745
diff changeset
193 thread.writeLong(threadAllocatedBytesOffset(), allocated, TLAB_THREAD_ALLOCATED_BYTES_LOCATION);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
196 // refill the TLAB with an eden allocation
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
197 Word tlabRefillSizeInWords = thread.readWord(threadTlabSizeOffset(), TLAB_SIZE_LOCATION);
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
198 Word tlabRefillSizeInBytes = tlabRefillSizeInWords.multiply(wordSize());
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199 // allocate new TLAB, address returned in top
7237
509d72a1d81b made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents: 7147
diff changeset
200 top = edenAllocate(tlabRefillSizeInBytes, log);
7701
47467b2c3fc5 Use equal() and notEqual() instead of == and != to compare words
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7556
diff changeset
201 if (top.notEqual(0)) {
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
202 end = top.add(tlabRefillSizeInBytes.subtract(alignmentReserveInBytes));
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
203 initializeTlab(thread, top, end);
7253
c66968130037 replicate c1 tlab refill behavior more closely, fixes problem with huge tlab sizes
Lukas Stadler <lukas.stadler@jku.at>
parents: 7238
diff changeset
204
12792
be9c3426daad pass thread register into allocation stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12767
diff changeset
205 return NewInstanceStub.allocate(thread, sizeInBytes);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
206 } else {
7253
c66968130037 replicate c1 tlab refill behavior more closely, fixes problem with huge tlab sizes
Lukas Stadler <lukas.stadler@jku.at>
parents: 7238
diff changeset
207 return Word.zero();
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
208 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
209 } else {
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210 // Retain TLAB
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
211 Word newRefillWasteLimit = refillWasteLimit.add(tlabRefillWasteIncrement());
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
212 thread.writeWord(tlabRefillWasteLimitOffset(), newRefillWasteLimit, TLAB_REFILL_WASTE_LIMIT_LOCATION);
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
213 if (log) {
9671
0b3d19e4e2a2 used static import for methods in StubUtil
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
214 printf("refillTLAB: retaining TLAB - newRefillWasteLimit=%p\n", newRefillWasteLimit.rawValue());
9567
a8b4f26d8485 removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents: 9557
diff changeset
215 }
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
216
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
217 if (tlabStats()) {
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
218 thread.writeInt(tlabSlowAllocationsOffset(), thread.readInt(tlabSlowAllocationsOffset(), TLAB_SLOW_ALLOCATIONS_LOCATION) + 1, TLAB_SLOW_ALLOCATIONS_LOCATION);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
219 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
220
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
221 return edenAllocate(Word.unsigned(sizeInBytes), log);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
222 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
223 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
224
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
225 /**
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
226 * Attempts to allocate a chunk of memory from Eden space.
14766
390d72c7cc04 SnippetCounters: HotSpot stubs are not allowed to embed oops, thus exclude them in stubs
Bernhard Urban <bernhard.urban@jku.at>
parents: 14101
diff changeset
227 *
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
228 * @param sizeInBytes the size of the chunk to allocate
7237
509d72a1d81b made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents: 7147
diff changeset
229 * @param log specifies if logging is enabled
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
230 * @return the allocated chunk or {@link Word#zero()} if allocation fails
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
231 */
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15018
diff changeset
232 public static Word edenAllocate(Word sizeInBytes, boolean log) {
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
233 Word heapTopAddress = Word.unsigned(heapTopAddress());
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
234 Word heapEndAddress = Word.unsigned(heapEndAddress());
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
235
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
236 while (true) {
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
237 Word heapTop = heapTopAddress.readWord(0, HEAP_TOP_LOCATION);
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
238 Word newHeapTop = heapTop.add(sizeInBytes);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
239 if (newHeapTop.belowOrEqual(heapTop)) {
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
240 return Word.zero();
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
241 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
242
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
243 Word heapEnd = heapEndAddress.readWord(0, HEAP_END_LOCATION);
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
244 if (newHeapTop.aboveThan(heapEnd)) {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
245 return Word.zero();
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
246 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
247
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7701
diff changeset
248 if (compareAndSwap(heapTopAddress, 0, heapTop, newHeapTop, HEAP_TOP_LOCATION).equal(heapTop)) {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
249 return heapTop;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
250 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
251 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
252 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
253
7238
7f55fd5f897d introduced graal.newArrayStub.forceSlowPath and graal.newInstanceStub.forceSlowPath system properties
Doug Simon <doug.simon@oracle.com>
parents: 7237
diff changeset
254 @Fold
7f55fd5f897d introduced graal.newArrayStub.forceSlowPath and graal.newInstanceStub.forceSlowPath system properties
Doug Simon <doug.simon@oracle.com>
parents: 7237
diff changeset
255 private static boolean forceSlowPath() {
7f55fd5f897d introduced graal.newArrayStub.forceSlowPath and graal.newInstanceStub.forceSlowPath system properties
Doug Simon <doug.simon@oracle.com>
parents: 7237
diff changeset
256 return Boolean.getBoolean("graal.newInstanceStub.forceSlowPath");
7f55fd5f897d introduced graal.newArrayStub.forceSlowPath and graal.newInstanceStub.forceSlowPath system properties
Doug Simon <doug.simon@oracle.com>
parents: 7237
diff changeset
257 }
9352
d4684b468e93 made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9232
diff changeset
258
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
259 public static final ForeignCallDescriptor NEW_INSTANCE_C = newDescriptor(NewInstanceStub.class, "newInstanceC", void.class, Word.class, KlassPointer.class);
9352
d4684b468e93 made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9232
diff changeset
260
9872
4391fd907278 use StubForeignCallNode within stubs, instead of ForeignCallNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
261 @NodeIntrinsic(StubForeignCallNode.class)
18401
e7ab82e7cc37 Move metaspace pointer handling to hotspot specific WordTypeRewriter.
Roland Schatz <roland.schatz@oracle.com>
parents: 18377
diff changeset
262 public static native void newInstanceC(@ConstantNodeParameter ForeignCallDescriptor newInstanceC, Word thread, KlassPointer hub);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
263 }