annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java @ 8519:c91917e43c98

-Merge
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Tue, 26 Mar 2013 10:51:42 +0100
parents c36e8ded27d4 68b04162180e
children b648515abd0a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 7759
diff changeset
23 package com.oracle.graal.hotspot.replacements;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 7759
diff changeset
25 import static com.oracle.graal.hotspot.replacements.HotSpotSnippetUtils.*;
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 7759
diff changeset
26 import static com.oracle.graal.replacements.nodes.BranchProbabilityNode.*;
7220
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6534
diff changeset
27
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7221
diff changeset
28 import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor;
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.*;
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 5579
diff changeset
30 import com.oracle.graal.graph.Node.ConstantNodeParameter;
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 5579
diff changeset
31 import com.oracle.graal.graph.Node.NodeIntrinsic;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
32 import com.oracle.graal.nodes.extended.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 7759
diff changeset
33 import com.oracle.graal.replacements.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 /**
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: 7355
diff changeset
36 * Substitutions for {@link java.lang.System} methods.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 @ClassSubstitution(java.lang.System.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: 7355
diff changeset
39 public class SystemSubstitutions {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7221
diff changeset
41 public static final Descriptor JAVA_TIME_MILLIS = new Descriptor("javaTimeMillis", false, long.class);
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7221
diff changeset
42 public static final Descriptor JAVA_TIME_NANOS = new Descriptor("javaTimeNanos", false, long.class);
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 5579
diff changeset
43
7759
9e68bd67b745 cleanups, javadoc, assertions
Lukas Stadler <lukas.stadler@jku.at>
parents: 7556
diff changeset
44 @MacroSubstitution(macro = ArrayCopyNode.class)
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7368
diff changeset
45 public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7368
diff changeset
46
7355
8c163cfda1e5 only @MethodSubstitution annotated methods are now considered to be method substitutions which allows for helper methods to be in the same class
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
47 @MethodSubstitution
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 public static long currentTimeMillis() {
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 5579
diff changeset
49 return callLong(JAVA_TIME_MILLIS);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
7355
8c163cfda1e5 only @MethodSubstitution annotated methods are now considered to be method substitutions which allows for helper methods to be in the same class
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
52 @MethodSubstitution
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 public static long nanoTime() {
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 5579
diff changeset
54 return callLong(JAVA_TIME_NANOS);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56
7355
8c163cfda1e5 only @MethodSubstitution annotated methods are now considered to be method substitutions which allows for helper methods to be in the same class
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
57 @MethodSubstitution
7220
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6534
diff changeset
58 public static int identityHashCode(Object x) {
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6534
diff changeset
59 if (x == null) {
7554
9472211c812b named constants for snippet probabilities (likely, frequent, fast_path, deopt), see CR-7
Lukas Stadler <lukas.stadler@jku.at>
parents: 7543
diff changeset
60 probability(NOT_FREQUENT_PROBABILITY);
7220
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6534
diff changeset
61 return 0;
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6534
diff changeset
62 }
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6534
diff changeset
63
7543
be0d995ef51e factored out code common to SystemSubstitutions.identityHashCode() and ObjectSubstitutions.hashCode()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
64 return computeHashCode(x);
7220
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6534
diff changeset
65 }
fcae6d960acd added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6534
diff changeset
66
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 5579
diff changeset
67 @NodeIntrinsic(value = RuntimeCallNode.class, setStampFromReturnType = true)
8464
68b04162180e made node intrinsic interpretable: SystemSubstitutions.callLong()
Doug Simon <doug.simon@oracle.com>
parents: 8451
diff changeset
68 public static long callLong(@ConstantNodeParameter Descriptor descriptor) {
68b04162180e made node intrinsic interpretable: SystemSubstitutions.callLong()
Doug Simon <doug.simon@oracle.com>
parents: 8451
diff changeset
69 if (descriptor == JAVA_TIME_MILLIS) {
68b04162180e made node intrinsic interpretable: SystemSubstitutions.callLong()
Doug Simon <doug.simon@oracle.com>
parents: 8451
diff changeset
70 return System.currentTimeMillis();
68b04162180e made node intrinsic interpretable: SystemSubstitutions.callLong()
Doug Simon <doug.simon@oracle.com>
parents: 8451
diff changeset
71 }
68b04162180e made node intrinsic interpretable: SystemSubstitutions.callLong()
Doug Simon <doug.simon@oracle.com>
parents: 8451
diff changeset
72 assert descriptor == JAVA_TIME_NANOS;
68b04162180e made node intrinsic interpretable: SystemSubstitutions.callLong()
Doug Simon <doug.simon@oracle.com>
parents: 8451
diff changeset
73 return System.nanoTime();
68b04162180e made node intrinsic interpretable: SystemSubstitutions.callLong()
Doug Simon <doug.simon@oracle.com>
parents: 8451
diff changeset
74 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 }