Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLPrintlnBuiltin.java @ 18130:b4e38f4ca414
Truffle: rename @SlowPath to @TruffleBoundary.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 21 Oct 2014 00:22:51 +0200 |
parents | abe7128ca473 |
children | 286aef83a9a7 |
comparison
equal
deleted
inserted
replaced
18129:b3adab5f01a2 | 18130:b4e38f4ca414 |
---|---|
22 */ | 22 */ |
23 package com.oracle.truffle.sl.builtins; | 23 package com.oracle.truffle.sl.builtins; |
24 | 24 |
25 import java.io.*; | 25 import java.io.*; |
26 | 26 |
27 import com.oracle.truffle.api.CompilerDirectives.SlowPath; | 27 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
28 import com.oracle.truffle.api.dsl.*; | 28 import com.oracle.truffle.api.dsl.*; |
29 import com.oracle.truffle.api.nodes.*; | 29 import com.oracle.truffle.api.nodes.*; |
30 import com.oracle.truffle.api.source.*; | 30 import com.oracle.truffle.api.source.*; |
31 import com.oracle.truffle.sl.runtime.*; | 31 import com.oracle.truffle.sl.runtime.*; |
32 | 32 |
35 * different specialization leverage the typed {@code println} methods available in Java, i.e., | 35 * different specialization leverage the typed {@code println} methods available in Java, i.e., |
36 * primitive values are printed without converting them to a {@link String} first. | 36 * primitive values are printed without converting them to a {@link String} first. |
37 * <p> | 37 * <p> |
38 * Printing involves a lot of Java code, so we need to tell the optimizing system that it should not | 38 * Printing involves a lot of Java code, so we need to tell the optimizing system that it should not |
39 * unconditionally inline everything reachable from the println() method. This is done via the | 39 * unconditionally inline everything reachable from the println() method. This is done via the |
40 * {@link SlowPath} annotations. | 40 * {@link TruffleBoundary} annotations. |
41 */ | 41 */ |
42 @NodeInfo(shortName = "println") | 42 @NodeInfo(shortName = "println") |
43 public abstract class SLPrintlnBuiltin extends SLBuiltinNode { | 43 public abstract class SLPrintlnBuiltin extends SLBuiltinNode { |
44 | 44 |
45 public SLPrintlnBuiltin() { | 45 public SLPrintlnBuiltin() { |
50 public long println(long value) { | 50 public long println(long value) { |
51 doPrint(getContext().getOutput(), value); | 51 doPrint(getContext().getOutput(), value); |
52 return value; | 52 return value; |
53 } | 53 } |
54 | 54 |
55 @SlowPath | 55 @TruffleBoundary |
56 private static void doPrint(PrintStream out, long value) { | 56 private static void doPrint(PrintStream out, long value) { |
57 out.println(value); | 57 out.println(value); |
58 } | 58 } |
59 | 59 |
60 @Specialization | 60 @Specialization |
61 public boolean println(boolean value) { | 61 public boolean println(boolean value) { |
62 doPrint(getContext().getOutput(), value); | 62 doPrint(getContext().getOutput(), value); |
63 return value; | 63 return value; |
64 } | 64 } |
65 | 65 |
66 @SlowPath | 66 @TruffleBoundary |
67 private static void doPrint(PrintStream out, boolean value) { | 67 private static void doPrint(PrintStream out, boolean value) { |
68 out.println(value); | 68 out.println(value); |
69 } | 69 } |
70 | 70 |
71 @Specialization | 71 @Specialization |
72 public String println(String value) { | 72 public String println(String value) { |
73 doPrint(getContext().getOutput(), value); | 73 doPrint(getContext().getOutput(), value); |
74 return value; | 74 return value; |
75 } | 75 } |
76 | 76 |
77 @SlowPath | 77 @TruffleBoundary |
78 private static void doPrint(PrintStream out, String value) { | 78 private static void doPrint(PrintStream out, String value) { |
79 out.println(value); | 79 out.println(value); |
80 } | 80 } |
81 | 81 |
82 @Specialization | 82 @Specialization |
83 public Object println(Object value) { | 83 public Object println(Object value) { |
84 doPrint(getContext().getOutput(), value); | 84 doPrint(getContext().getOutput(), value); |
85 return value; | 85 return value; |
86 } | 86 } |
87 | 87 |
88 @SlowPath | 88 @TruffleBoundary |
89 private static void doPrint(PrintStream out, Object value) { | 89 private static void doPrint(PrintStream out, Object value) { |
90 out.println(value); | 90 out.println(value); |
91 } | 91 } |
92 } | 92 } |