comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java @ 18749:6fa518bf5d1b

SL: add boundaries for BigInteger add and String add.
author Christian Humer <christian.humer@gmail.com>
date Mon, 29 Dec 2014 23:37:58 +0100
parents abe7128ca473
children 301fea50e42e
comparison
equal deleted inserted replaced
18748:3d6e630a72f1 18749:6fa518bf5d1b
23 package com.oracle.truffle.sl.nodes.expression; 23 package com.oracle.truffle.sl.nodes.expression;
24 24
25 import java.math.*; 25 import java.math.*;
26 26
27 import com.oracle.truffle.api.*; 27 import com.oracle.truffle.api.*;
28 import com.oracle.truffle.api.CompilerDirectives.*;
28 import com.oracle.truffle.api.dsl.*; 29 import com.oracle.truffle.api.dsl.*;
29 import com.oracle.truffle.api.nodes.*; 30 import com.oracle.truffle.api.nodes.*;
30 import com.oracle.truffle.api.source.*; 31 import com.oracle.truffle.api.source.*;
31 import com.oracle.truffle.sl.nodes.*; 32 import com.oracle.truffle.sl.nodes.*;
32 33
78 * right operand is a {@code long} value. Because the {@link #add(long, long) long} 79 * right operand is a {@code long} value. Because the {@link #add(long, long) long}
79 * specialization} has the {@code rewriteOn} attribute, this specialization is also taken if 80 * specialization} has the {@code rewriteOn} attribute, this specialization is also taken if
80 * both input values are {@code long} values but the primitive addition overflows. 81 * both input values are {@code long} values but the primitive addition overflows.
81 */ 82 */
82 @Specialization 83 @Specialization
84 @TruffleBoundary
83 protected BigInteger add(BigInteger left, BigInteger right) { 85 protected BigInteger add(BigInteger left, BigInteger right) {
84 return left.add(right); 86 return left.add(right);
85 } 87 }
86 88
87 /** 89 /**
91 * <p> 93 * <p>
92 * To implement these semantics, we tell the Truffle DSL to use a custom guard. The guard 94 * To implement these semantics, we tell the Truffle DSL to use a custom guard. The guard
93 * function is defined in {@link #isString this class}, but could also be in any superclass. 95 * function is defined in {@link #isString this class}, but could also be in any superclass.
94 */ 96 */
95 @Specialization(guards = "isString") 97 @Specialization(guards = "isString")
98 @TruffleBoundary
96 protected String add(Object left, Object right) { 99 protected String add(Object left, Object right) {
97 return left.toString() + right.toString(); 100 return left.toString() + right.toString();
98 } 101 }
99 102
100 /** 103 /**