Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ArithmeticNode.java @ 11760:ce0b00597980
made safepoint-on-return use specialized HotSpot runtime support for such safepoints (which have no debug info attached)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 24 Sep 2013 08:51:02 +0200 |
parents | 79041ab43660 |
children | 5a0c694ef735 |
rev | line source |
---|---|
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.sl.nodes; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import java.math.*; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
9275
76afb8f4c930
Fix imports.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
27 import com.oracle.truffle.api.*; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
9275
diff
changeset
|
28 import com.oracle.truffle.api.dsl.*; |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 public abstract class ArithmeticNode extends BinaryNode { |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 public abstract static class AddNode extends ArithmeticNode { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7503
diff
changeset
|
33 |
8243
d81ff782fa1a
Removed @SpecializationThrows from codegen API. Replaced it by a simplier version in @Specialization.
Christian Humer <christian.humer@gmail.com>
parents:
8240
diff
changeset
|
34 @Specialization(rewriteOn = ArithmeticException.class) |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
35 int doInt(int left, int right) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 return ExactMath.addExact(left, right); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 @Specialization |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 BigInteger doBigInteger(BigInteger left, BigInteger right) { |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 return left.add(right); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 @Specialization |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
45 String doString(String left, String right) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 return left + right; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 |
8240
33e08aca06ff
Codegen API change. Simplified definition of guards.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
49 @Specialization(guards = "isString") |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
50 String add(Object left, Object right) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 return left.toString() + right.toString(); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 public abstract static class SubNode extends ArithmeticNode { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7503
diff
changeset
|
56 |
8243
d81ff782fa1a
Removed @SpecializationThrows from codegen API. Replaced it by a simplier version in @Specialization.
Christian Humer <christian.humer@gmail.com>
parents:
8240
diff
changeset
|
57 @Specialization(rewriteOn = ArithmeticException.class) |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
58 int sub(int left, int right) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 return ExactMath.subtractExact(left, right); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 @Specialization |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
63 BigInteger sub(BigInteger left, BigInteger right) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 return left.subtract(right); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 } |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
66 |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 public abstract static class DivNode extends ArithmeticNode { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7503
diff
changeset
|
70 |
8243
d81ff782fa1a
Removed @SpecializationThrows from codegen API. Replaced it by a simplier version in @Specialization.
Christian Humer <christian.humer@gmail.com>
parents:
8240
diff
changeset
|
71 @Specialization(rewriteOn = ArithmeticException.class) |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
72 int div(int left, int right) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 return left / right; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 @Specialization |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
77 BigInteger div(BigInteger left, BigInteger right) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 return left.divide(right); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 public abstract static class MulNode extends ArithmeticNode { |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 |
8243
d81ff782fa1a
Removed @SpecializationThrows from codegen API. Replaced it by a simplier version in @Specialization.
Christian Humer <christian.humer@gmail.com>
parents:
8240
diff
changeset
|
84 @Specialization(rewriteOn = ArithmeticException.class) |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
85 int mul(int left, int right) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 return ExactMath.multiplyExact(left, right); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 @Specialization |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
90 BigInteger mul(BigInteger left, BigInteger right) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 return left.multiply(right); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 } |
8247
5b08b0f4d338
Updated some Truffle-SL classes to new naming convention.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
93 |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 } |