Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java @ 21556:48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 May 2015 00:36:16 +0200 |
parents | b1530a6cce8c |
children | 942793d2a513 |
rev | line source |
---|---|
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
1 /* |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
4 * |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
8 * |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
14 * |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
18 * |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
22 */ |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.replacements; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
24 |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
25 import static com.oracle.graal.compiler.common.GraalOptions.*; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
26 import static com.oracle.graal.replacements.SnippetTemplate.*; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
27 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
29 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13505
diff
changeset
|
30 import com.oracle.graal.api.replacements.*; |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15259
diff
changeset
|
31 import com.oracle.graal.compiler.common.type.*; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.nodes.*; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.nodes.calc.*; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.extended.*; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.nodes.spi.*; |
10569
6b9ebfcf5fc5
make BoxNode and UnboxNode floating
Lukas Stadler <lukas.stadler@jku.at>
parents:
10074
diff
changeset
|
36 import com.oracle.graal.nodes.util.*; |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
37 import com.oracle.graal.phases.util.*; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.graal.replacements.SnippetTemplate.Arguments; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
40 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo; |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
41 import com.oracle.jvmci.code.*; |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19994
diff
changeset
|
42 import com.oracle.jvmci.debug.*; |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
43 import com.oracle.jvmci.meta.*; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
44 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
45 public class BoxingSnippets implements Snippets { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
46 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
47 @Snippet |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
18935
diff
changeset
|
48 public static Object booleanValueOf(boolean value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
49 valueOfCounter.inc(); |
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:
11732
diff
changeset
|
50 return PiNode.piCast(Boolean.valueOf(value), StampFactory.forNodeIntrinsic()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
51 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
52 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
53 @Snippet |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
18935
diff
changeset
|
54 public static Object byteValueOf(byte value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
55 valueOfCounter.inc(); |
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:
11732
diff
changeset
|
56 return PiNode.piCast(Byte.valueOf(value), StampFactory.forNodeIntrinsic()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
57 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
58 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
59 @Snippet |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
18935
diff
changeset
|
60 public static Object charValueOf(char value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
61 valueOfCounter.inc(); |
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:
11732
diff
changeset
|
62 return PiNode.piCast(Character.valueOf(value), StampFactory.forNodeIntrinsic()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
63 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
64 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
65 @Snippet |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
18935
diff
changeset
|
66 public static Object doubleValueOf(double value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
67 valueOfCounter.inc(); |
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:
11732
diff
changeset
|
68 return PiNode.piCast(Double.valueOf(value), StampFactory.forNodeIntrinsic()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
69 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
70 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
71 @Snippet |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
18935
diff
changeset
|
72 public static Object floatValueOf(float value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
73 valueOfCounter.inc(); |
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:
11732
diff
changeset
|
74 return PiNode.piCast(Float.valueOf(value), StampFactory.forNodeIntrinsic()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
75 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
76 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
77 @Snippet |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
18935
diff
changeset
|
78 public static Object intValueOf(int value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
79 valueOfCounter.inc(); |
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:
11732
diff
changeset
|
80 return PiNode.piCast(Integer.valueOf(value), StampFactory.forNodeIntrinsic()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
81 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
82 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
83 @Snippet |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
18935
diff
changeset
|
84 public static Object longValueOf(long value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
85 valueOfCounter.inc(); |
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:
11732
diff
changeset
|
86 return PiNode.piCast(Long.valueOf(value), StampFactory.forNodeIntrinsic()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
87 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
88 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
89 @Snippet |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
18935
diff
changeset
|
90 public static Object shortValueOf(short value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
91 valueOfCounter.inc(); |
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:
11732
diff
changeset
|
92 return PiNode.piCast(Short.valueOf(value), StampFactory.forNodeIntrinsic()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
93 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
94 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
95 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
96 public static boolean booleanValue(Boolean value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
97 valueOfCounter.inc(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
98 return value.booleanValue(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
99 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
100 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
101 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
102 public static byte byteValue(Byte value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
103 valueOfCounter.inc(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
104 return value.byteValue(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
105 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
106 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
107 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
108 public static char charValue(Character value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
109 valueOfCounter.inc(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
110 return value.charValue(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
111 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
112 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
113 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
114 public static double doubleValue(Double value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
115 valueOfCounter.inc(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
116 return value.doubleValue(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
117 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
118 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
119 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
120 public static float floatValue(Float value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
121 valueOfCounter.inc(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
122 return value.floatValue(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
123 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
124 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
125 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
126 public static int intValue(Integer value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
127 valueOfCounter.inc(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
128 return value.intValue(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
129 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
130 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
131 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
132 public static long longValue(Long value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
133 valueOfCounter.inc(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
134 return value.longValue(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
135 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
136 |
19994
aaf5039e56d7
made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents:
19838
diff
changeset
|
137 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
138 public static short shortValue(Short value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
139 valueOfCounter.inc(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
140 return value.shortValue(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
141 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
142 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13505
diff
changeset
|
143 public static FloatingNode canonicalizeBoxing(BoxNode box, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
144 ValueNode value = box.getValue(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
145 if (value.isConstant()) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
15311
diff
changeset
|
146 JavaConstant sourceConstant = value.asJavaConstant(); |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
147 if (sourceConstant.getKind() != box.getBoxingKind() && sourceConstant.getKind().isNumericInteger()) { |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
148 switch (box.getBoxingKind()) { |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
149 case Boolean: |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
150 sourceConstant = JavaConstant.forBoolean(sourceConstant.asLong() != 0L); |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
151 break; |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
152 case Byte: |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
153 sourceConstant = JavaConstant.forByte((byte) sourceConstant.asLong()); |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
154 break; |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
155 case Char: |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
156 sourceConstant = JavaConstant.forChar((char) sourceConstant.asLong()); |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
157 break; |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
158 case Short: |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
159 sourceConstant = JavaConstant.forShort((short) sourceConstant.asLong()); |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
160 break; |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
161 } |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18680
diff
changeset
|
162 } |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
15311
diff
changeset
|
163 JavaConstant boxedConstant = constantReflection.boxPrimitive(sourceConstant); |
18680
6707a08faa9b
fix bug that prevented constants from being boxed
Lukas Stadler <lukas.stadler@oracle.com>
parents:
18370
diff
changeset
|
164 if (boxedConstant != null && sourceConstant.getKind() == box.getBoxingKind()) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13505
diff
changeset
|
165 return ConstantNode.forConstant(boxedConstant, metaAccess, box.graph()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
166 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
167 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
168 return null; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
169 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
170 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
171 public static class Templates extends AbstractTemplates { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
172 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
173 private final EnumMap<Kind, SnippetInfo> boxSnippets = new EnumMap<>(Kind.class); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
174 private final EnumMap<Kind, SnippetInfo> unboxSnippets = new EnumMap<>(Kind.class); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
175 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13505
diff
changeset
|
176 public Templates(Providers providers, SnippetReflectionProvider snippetReflection, TargetDescription target) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13505
diff
changeset
|
177 super(providers, snippetReflection, target); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
178 for (Kind kind : new Kind[]{Kind.Boolean, Kind.Byte, Kind.Char, Kind.Double, Kind.Float, Kind.Int, Kind.Long, Kind.Short}) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
179 boxSnippets.put(kind, snippet(BoxingSnippets.class, kind.getJavaName() + "ValueOf")); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
180 unboxSnippets.put(kind, snippet(BoxingSnippets.class, kind.getJavaName() + "Value")); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
181 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
182 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
183 |
10569
6b9ebfcf5fc5
make BoxNode and UnboxNode floating
Lukas Stadler <lukas.stadler@jku.at>
parents:
10074
diff
changeset
|
184 public void lower(BoxNode box, LoweringTool tool) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13505
diff
changeset
|
185 FloatingNode canonical = canonicalizeBoxing(box, providers.getMetaAccess(), providers.getConstantReflection()); |
10074
e8fbc5fd3440
aot: add/fix some javadoc
Bernhard Urban <bernhard.urban@jku.at>
parents:
10064
diff
changeset
|
186 // if in AOT mode, we don't want to embed boxed constants. |
13378
16d99e9d77ad
Options: rename flag (AOTCompilation -> ImmutableCode)
Bernhard Urban <bernhard.urban@jku.at>
parents:
12054
diff
changeset
|
187 if (canonical != null && !ImmutableCode.getValue()) { |
10569
6b9ebfcf5fc5
make BoxNode and UnboxNode floating
Lukas Stadler <lukas.stadler@jku.at>
parents:
10074
diff
changeset
|
188 box.graph().replaceFloating(box, canonical); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
189 } else { |
13505
75a67ebd50e8
Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13378
diff
changeset
|
190 Arguments args = new Arguments(boxSnippets.get(box.getBoxingKind()), box.graph().getGuardsStage(), tool.getLoweringStage()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
191 args.add("value", box.getValue()); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
192 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
193 SnippetTemplate template = template(args); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
194 Debug.log("Lowering integerValueOf in %s: node=%s, template=%s, arguments=%s", box.graph(), box, template, args); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
195 template.instantiate(providers.getMetaAccess(), box, DEFAULT_REPLACER, tool, args); |
10569
6b9ebfcf5fc5
make BoxNode and UnboxNode floating
Lukas Stadler <lukas.stadler@jku.at>
parents:
10074
diff
changeset
|
196 GraphUtil.killWithUnusedFloatingInputs(box); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
197 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
198 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
199 |
10569
6b9ebfcf5fc5
make BoxNode and UnboxNode floating
Lukas Stadler <lukas.stadler@jku.at>
parents:
10074
diff
changeset
|
200 public void lower(UnboxNode unbox, LoweringTool tool) { |
13505
75a67ebd50e8
Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13378
diff
changeset
|
201 Arguments args = new Arguments(unboxSnippets.get(unbox.getBoxingKind()), unbox.graph().getGuardsStage(), tool.getLoweringStage()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
202 args.add("value", unbox.getValue()); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
203 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
204 SnippetTemplate template = template(args); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
205 Debug.log("Lowering integerValueOf in %s: node=%s, template=%s, arguments=%s", unbox.graph(), unbox, template, args); |
19838
8aa5bd9935b3
Turn UnboxNode into a fixed node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19775
diff
changeset
|
206 template.instantiate(providers.getMetaAccess(), unbox, DEFAULT_REPLACER, args); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
207 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
208 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
209 |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9602
diff
changeset
|
210 private static final SnippetCounter.Group integerCounters = SnippetCounters.getValue() ? new SnippetCounter.Group("Integer intrinsifications") : null; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
211 private static final SnippetCounter valueOfCounter = new SnippetCounter(integerCounters, "valueOf", "valueOf intrinsification"); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
212 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
213 } |