annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java @ 15489:d0e3f6963ed7

mx: made parallel Java builds interact correctly with management of subprocesses upon abort/quit
author Doug Simon <doug.simon@oracle.com>
date Sun, 04 May 2014 01:26:50 +0200
parents 67905c049016
children 31832ebd40cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7160
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
7220
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
7160
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 7868
diff changeset
23 package com.oracle.graal.hotspot.replacements;
7160
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
9513
659bb6cf930c rename: HotSpotSnippetUtils -> HotSpotReplacementsUtil
Doug Simon <doug.simon@oracle.com>
parents: 8637
diff changeset
25 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
11752
7e7edb86fb43 Refactor the handling of unsafe casts to distinguish between word-object-conversions, PiNode-like type information, and real unsafe casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 11253
diff changeset
26 import static com.oracle.graal.nodes.PiNode.*;
7160
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27
9792
06dc2d2324d6 pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents: 9513
diff changeset
28 import com.oracle.graal.api.meta.*;
8420
5d3fa6f949fb created com.oracle.graal.api.replacements project and moved ClassSubstitution and MethodSubstitution there
Doug Simon <doug.simon@oracle.com>
parents: 8419
diff changeset
29 import com.oracle.graal.api.replacements.*;
8485
ba0458c143bb finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents: 8449
diff changeset
30 import com.oracle.graal.nodes.java.*;
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: 8629
diff changeset
31 import com.oracle.graal.nodes.spi.*;
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7275
diff changeset
32 import com.oracle.graal.word.*;
7160
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 /**
7356
fe9f252f0d05 renamings to clarify the difference between lowering/stub snippets and substitution snippets (the end goal is to remove the term 'snippet' from the latter altogether)
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
35 * Substitutions for {@link java.lang.Object} methods.
7160
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 */
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 @ClassSubstitution(java.lang.Object.class)
7356
fe9f252f0d05 renamings to clarify the difference between lowering/stub snippets and substitution snippets (the end goal is to remove the term 'snippet' from the latter altogether)
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
38 public class ObjectSubstitutions {
7368
f04a5e46cdd2 new facility to add branch probabilities for snippets, probabilities for frequently-used snippets
Lukas Stadler <lukas.stadler@jku.at>
parents: 7356
diff changeset
39
11253
252958589b2b macro node for Object.getClass
Lukas Stadler <lukas.stadler@jku.at>
parents: 10784
diff changeset
40 @MacroSubstitution(macro = ObjectGetClassNode.class, isStatic = false, forced = true)
252958589b2b macro node for Object.getClass
Lukas Stadler <lukas.stadler@jku.at>
parents: 10784
diff changeset
41 @MethodSubstitution(isStatic = false, forced = true)
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7368
diff changeset
42 public static Class<?> getClass(final Object thisObj) {
7220
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff changeset
43 Word hub = loadHub(thisObj);
13978
67905c049016 Provide piCast helpers instead of using raw booleans
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 11752
diff changeset
44 return piCastExactNonNull(hub.readObject(Word.signed(classMirrorOffset()), LocationIdentity.FINAL_LOCATION), Class.class);
7220
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff changeset
45 }
7160
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46
7229
855b2c53543f enforce that method substitution snippets are static methods
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7227
diff changeset
47 @MethodSubstitution(isStatic = false)
7220
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff changeset
48 public static int hashCode(final Object thisObj) {
7543
be0d995ef51e factored out code common to SystemSubstitutions.identityHashCode() and ObjectSubstitutions.hashCode()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
49 return computeHashCode(thisObj);
7160
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 }
7764
cff55cdeea48 implement Object.clone snippets and macro node
Lukas Stadler <lukas.stadler@jku.at>
parents: 7543
diff changeset
51
11253
252958589b2b macro node for Object.getClass
Lukas Stadler <lukas.stadler@jku.at>
parents: 10784
diff changeset
52 @MethodSubstitution(value = "<init>", isStatic = false, forced = true)
8485
ba0458c143bb finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents: 8449
diff changeset
53 public static void init(Object thisObj) {
ba0458c143bb finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents: 8449
diff changeset
54 RegisterFinalizerNode.register(thisObj);
ba0458c143bb finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents: 8449
diff changeset
55 }
ba0458c143bb finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents: 8449
diff changeset
56
10784
0a306985c262 force substitution of Object.clone
Lukas Stadler <lukas.stadler@jku.at>
parents: 9792
diff changeset
57 @MacroSubstitution(macro = ObjectCloneNode.class, isStatic = false, forced = true)
7764
cff55cdeea48 implement Object.clone snippets and macro node
Lukas Stadler <lukas.stadler@jku.at>
parents: 7543
diff changeset
58 public static native Object clone(Object obj);
7160
d526fa5640c8 replaced manual intrinsification of Object.getClass() with a snippet
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 }