Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java @ 9618:bd4a7d657dcc
moved static methods out of Stub into StubUtil
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 08 May 2013 21:05:39 +0200 |
parents | c1ef2bf6848e |
children | 0b3d19e4e2a2 |
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 /* |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
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 |
9352
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
25 import static com.oracle.graal.api.code.DeoptimizationAction.*; |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
26 import static com.oracle.graal.api.meta.DeoptimizationReason.*; |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
27 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
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
|
28 import static com.oracle.graal.hotspot.nodes.DirectCompareAndSwapNode.*; |
9513
659bb6cf930c
rename: HotSpotSnippetUtils -> HotSpotReplacementsUtil
Doug Simon <doug.simon@oracle.com>
parents:
9418
diff
changeset
|
29 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
7868
diff
changeset
|
30 import static com.oracle.graal.hotspot.replacements.NewObjectSnippets.*; |
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
|
31 |
9352
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
32 import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; |
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
|
33 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
|
34 import com.oracle.graal.api.meta.*; |
9352
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
35 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
|
36 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
|
37 import com.oracle.graal.hotspot.*; |
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
|
38 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
|
39 import com.oracle.graal.hotspot.nodes.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
7868
diff
changeset
|
40 import com.oracle.graal.hotspot.replacements.*; |
8637
ce5750014c3d
moved Replacements and MacroSubstitution from the graal.api.replacements project to graal.nodes project and reversed the dependency between these two projects (the latter now/again depends on the former)
Doug Simon <doug.simon@oracle.com>
parents:
8627
diff
changeset
|
41 import com.oracle.graal.nodes.spi.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
7868
diff
changeset
|
42 import com.oracle.graal.replacements.*; |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8508
diff
changeset
|
43 import com.oracle.graal.replacements.Snippet.ConstantParameter; |
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.Fold; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8893
diff
changeset
|
45 import com.oracle.graal.replacements.SnippetTemplate.Arguments; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8893
diff
changeset
|
46 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
47 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
|
48 |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
50 * Stub implementing the fast path for TLAB refill during instance class allocation. This stub is |
9418
8d3a7fb9eb5f
moved binding of parameter locations to runtime call descriptors from platform specific code to shared code for stubs that are now compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9417
diff
changeset
|
51 * called via {@link NewInstanceStubCall} from the {@linkplain NewObjectSnippets inline} allocation |
8d3a7fb9eb5f
moved binding of parameter locations to runtime call descriptors from platform specific code to shared code for stubs that are now compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9417
diff
changeset
|
52 * code when TLAB allocation fails. If this stub fails to refill the TLAB or allocate the object, it |
8d3a7fb9eb5f
moved binding of parameter locations to runtime call descriptors from platform specific code to shared code for stubs that are now compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9417
diff
changeset
|
53 * calls out to the HotSpot C++ 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
|
54 */ |
9617
c1ef2bf6848e
removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents:
9576
diff
changeset
|
55 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
|
56 |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8508
diff
changeset
|
57 public NewInstanceStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) { |
9417
ffa27c3058e9
minor simplifications for writing compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9352
diff
changeset
|
58 super(runtime, replacements, target, 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
|
59 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 @Override |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8893
diff
changeset
|
62 protected Arguments makeArguments(SnippetInfo stub) { |
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
|
63 HotSpotResolvedObjectType intArrayType = (HotSpotResolvedObjectType) runtime.lookupJavaType(int[].class); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8893
diff
changeset
|
64 |
9352
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
65 // RuntimeStub cannot (currently) support oops or metadata embedded in the code so we |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
66 // convert the hub (i.e., Klass*) for int[] to be a naked word. This should be safe since |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
67 // the int[] class will never be unloaded. |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
68 Constant intArrayHub = intArrayType.klass(); |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
69 intArrayHub = Constant.forIntegerKind(graalRuntime().getTarget().wordKind, intArrayHub.asLong(), null); |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
70 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8893
diff
changeset
|
71 Arguments args = new Arguments(stub); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8893
diff
changeset
|
72 args.add("hub", null); |
9352
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
73 args.addConst("intArrayHub", intArrayHub); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8893
diff
changeset
|
74 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
|
75 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
77 @Fold |
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
78 private static boolean logging() { |
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
79 return Boolean.getBoolean("graal.logNewInstanceStub"); |
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
80 } |
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
81 |
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
|
82 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
83 * 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
|
84 * -XX:-UseTLAB). |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
85 * |
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
|
86 * @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
|
87 * @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
|
88 */ |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 @Snippet |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
90 private static Object newInstance(Word hub, @ConstantParameter Word intArrayHub) { |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
91 int sizeInBytes = hub.readInt(klassInstanceSizeOffset(), FINAL_LOCATION); |
7238
7f55fd5f897d
introduced graal.newArrayStub.forceSlowPath and graal.newInstanceStub.forceSlowPath system properties
Doug Simon <doug.simon@oracle.com>
parents:
7237
diff
changeset
|
92 if (!forceSlowPath() && inlineContiguousAllocationSupported()) { |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
93 if (hub.readInt(klassStateOffset(), CLASS_STATE_LOCATION) == klassStateFullyInitialized()) { |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
94 Word memory = refillAllocate(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
|
95 if (memory.notEqual(0)) { |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
96 Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION); |
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
97 initializeObjectHeader(memory, prototypeMarkWord, 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
|
98 for (int offset = 2 * wordSize(); offset < sizeInBytes; offset += wordSize()) { |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
99 memory.writeWord(offset, Word.zero(), ANY_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
|
100 } |
9618
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
101 return StubUtil.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
|
102 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 } |
9352
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
105 |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
106 if (logging()) { |
9618
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
107 StubUtil.printf("newInstance: calling new_instance_c\n"); |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
108 } |
9352
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
109 |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
110 newInstanceC(NEW_INSTANCE_C, thread(), hub); |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
111 |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
112 if (clearPendingException(thread())) { |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
113 if (logging()) { |
9618
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
114 StubUtil.printf("newInstance: deoptimizing to caller\n"); |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
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 getAndClearObjectResult(thread()); |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
117 DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint); |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
118 } |
9618
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
119 return StubUtil.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
|
120 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 /** |
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
|
123 * Attempts to refill the current thread's TLAB and retries the allocation. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
124 * |
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
|
125 * @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
|
126 * @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
|
127 * @param log specifies if logging is enabled |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
128 * @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
|
129 * 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
|
130 */ |
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
|
131 static Word refillAllocate(Word intArrayHub, int sizeInBytes, boolean log) { |
8502
ff4fa8b0516e
-Create push patch
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
8501
diff
changeset
|
132 if (!useTLAB()) { |
ff4fa8b0516e
-Create push patch
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
8501
diff
changeset
|
133 return edenAllocate(Word.unsigned(sizeInBytes), log); |
ff4fa8b0516e
-Create push patch
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
8501
diff
changeset
|
134 } |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
135 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
|
136 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
|
137 |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 Word thread = thread(); |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
139 Word top = readTlabTop(thread); |
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
140 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
|
141 |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 // calculate amount of free space |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
143 Word tlabFreeSpaceInBytes = end.subtract(top); |
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
|
144 |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
145 if (log) { |
9618
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
146 StubUtil.printf("refillTLAB: thread=%p\n", thread.rawValue()); |
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
147 StubUtil.printf("refillTLAB: top=%p\n", top.rawValue()); |
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
148 StubUtil.printf("refillTLAB: end=%p\n", end.rawValue()); |
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
149 StubUtil.printf("refillTLAB: tlabFreeSpaceInBytes=%d\n", tlabFreeSpaceInBytes.rawValue()); |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
150 } |
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
|
151 |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
152 Word tlabFreeSpaceInWords = tlabFreeSpaceInBytes.unsignedShiftRight(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
|
153 |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 // 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
|
155 // 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
|
156 Word refillWasteLimit = thread.readWord(tlabRefillWasteLimitOffset(), TLAB_REFILL_WASTE_LIMIT_LOCATION); |
7237
509d72a1d81b
made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents:
7147
diff
changeset
|
157 if (tlabFreeSpaceInWords.belowOrEqual(refillWasteLimit)) { |
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
|
158 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
|
159 // 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
|
160 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
|
161 if (log) { |
9618
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
162 StubUtil.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
|
163 } |
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
|
164 // accumulate wastage |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
165 Word wastage = thread.readWord(tlabFastRefillWasteOffset(), TLAB_FAST_REFILL_WASTE_LOCATION).add(tlabFreeSpaceInWords); |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
166 if (log) { |
9618
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
167 StubUtil.printf("thread: %p -- accumulated wastage %d\n", thread.rawValue(), wastage.rawValue()); |
9567
a8b4f26d8485
removed Stub.log(...) methods
Doug Simon <doug.simon@oracle.com>
parents:
9557
diff
changeset
|
168 } |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
169 thread.writeWord(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
|
170 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
172 // 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
|
173 // 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
|
174 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
|
175 int headerSize = arrayBaseOffset(Kind.Int); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
176 // 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
|
177 // an int |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
178 int tlabFreeSpaceInInts = (int) tlabFreeSpaceInBytes.rawValue() >>> 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
|
179 int length = ((alignmentReserveInBytes - headerSize) >>> 2) + tlabFreeSpaceInInts; |
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 NewObjectSnippets.formatArray(intArrayHub, -1, length, headerSize, top, intArrayMarkWord, false); |
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 |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
182 Word allocated = thread.readWord(threadAllocatedBytesOffset(), TLAB_THREAD_ALLOCATED_BYTES_LOCATION); |
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
183 allocated = allocated.add(top.subtract(readTlabStart(thread))); |
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
184 thread.writeWord(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
|
185 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
186 |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
187 // 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
|
188 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
|
189 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
|
190 // 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
|
191 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
|
192 if (top.notEqual(0)) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
193 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
|
194 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
|
195 |
c66968130037
replicate c1 tlab refill behavior more closely, fixes problem with huge tlab sizes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7238
diff
changeset
|
196 return allocate(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
|
197 } 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
|
198 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
|
199 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
200 } 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
|
201 // Retain TLAB |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
202 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
|
203 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
|
204 if (log) { |
9618
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
205 StubUtil.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
|
206 } |
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
|
207 |
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 if (tlabStats()) { |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
209 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
|
210 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
212 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
|
213 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
214 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
215 |
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 * Attempts to allocate a chunk of memory from Eden space. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
218 * |
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 * @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
|
220 * @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
|
221 * @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
|
222 */ |
7237
509d72a1d81b
made the effect of graal.logNewArrayStub independent from graal.logNewInstanceStub
Doug Simon <doug.simon@oracle.com>
parents:
7147
diff
changeset
|
223 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
|
224 Word heapTopAddress = Word.unsigned(heapTopAddress()); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7275
diff
changeset
|
225 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
|
226 |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
227 while (true) { |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 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
|
232 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
233 |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
234 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
|
235 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
|
236 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
|
237 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
238 |
7868
7a5bbcc36bb2
add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents:
7701
diff
changeset
|
239 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
|
240 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
|
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 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 } |
445193cc2a7d
added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 |
7238
7f55fd5f897d
introduced graal.newArrayStub.forceSlowPath and graal.newInstanceStub.forceSlowPath system properties
Doug Simon <doug.simon@oracle.com>
parents:
7237
diff
changeset
|
245 @Fold |
7f55fd5f897d
introduced graal.newArrayStub.forceSlowPath and graal.newInstanceStub.forceSlowPath system properties
Doug Simon <doug.simon@oracle.com>
parents:
7237
diff
changeset
|
246 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
|
247 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
|
248 } |
9352
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
249 |
9618
bd4a7d657dcc
moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
9617
diff
changeset
|
250 public static final Descriptor NEW_INSTANCE_C = StubUtil.descriptorFor(NewInstanceStub.class, "newInstanceC", false); |
9352
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
251 |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
252 @NodeIntrinsic(CRuntimeCall.class) |
d4684b468e93
made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
253 public static native void newInstanceC(@ConstantNodeParameter Descriptor newInstanceC, Word thread, Word 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
|
254 } |