Skip to content

Commit c2807fb

Browse files
committed
[GR-27617] Fix issues with -H:+RemoveSaturatedTypeFlows.
PullRequest: fastr/2538
2 parents 72c1ea6 + 282e025 commit c2807fb

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ public SourceSection getSourceSection() {
650650
}
651651

652652
@Override
653+
@TruffleBoundary
653654
public boolean isInternal() {
654655
return RSyntaxNode.isInternal(getBody().getLazySourceSection());
655656
}

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Quote.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
2525
import static com.oracle.truffle.r.runtime.builtins.RBehavior.PURE;
2626
import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE;
2727

28+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
2829
import com.oracle.truffle.api.dsl.Cached;
2930
import com.oracle.truffle.api.dsl.ImportStatic;
3031
import com.oracle.truffle.api.dsl.Specialization;
@@ -67,6 +68,7 @@ protected final Object cachedCreateLanguage(Closure closure) {
6768
return result;
6869
}
6970

71+
@TruffleBoundary
7072
protected static Object createLanguage(Closure closure) {
7173
return RASTUtils.createLanguageElement(closure.getExpr().asRSyntaxNode());
7274
}

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Substitute.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE;
2929

3030
import com.oracle.truffle.api.CompilerDirectives;
31+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
3132
import com.oracle.truffle.api.dsl.Cached;
3233
import com.oracle.truffle.api.dsl.Specialization;
3334
import com.oracle.truffle.api.frame.VirtualFrame;
35+
import com.oracle.truffle.api.profiles.BranchProfile;
3436
import com.oracle.truffle.r.library.methods.SubstituteDirect;
3537
import com.oracle.truffle.r.nodes.RASTUtils;
3638
import com.oracle.truffle.r.nodes.builtin.EnvironmentNodes.RList2EnvNode;
@@ -51,6 +53,7 @@
5153
public abstract class Substitute extends RBuiltinNode.Arg2 {
5254

5355
@Child private Quote quote;
56+
private final BranchProfile createLanguageBranch = BranchProfile.create();
5457

5558
static {
5659
Casts casts = new Casts(Substitute.class);
@@ -114,6 +117,12 @@ private Object doSubstituteWithEnv(RPromise expr, REnvironment env) {
114117

115118
// The "expr" promise comes from the no-evalarg aspect of the builtin,
116119
// so get the actual expression (AST) from that
120+
createLanguageBranch.enter();
121+
return createLanguage(expr, env);
122+
}
123+
124+
@TruffleBoundary(allowInlining = true)
125+
private Object createLanguage(RPromise expr, REnvironment env) {
117126
return RASTUtils.createLanguageElement(RSubstitute.substitute(env, expr.getClosure().getSyntaxElement(), getRLanguage()));
118127
}
119128

com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinNode.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@
3030
import com.oracle.truffle.api.frame.VirtualFrame;
3131
import com.oracle.truffle.api.nodes.Node;
3232
import com.oracle.truffle.r.nodes.function.RCallNode;
33-
import com.oracle.truffle.r.runtime.nodes.unary.CastNode;
34-
import com.oracle.truffle.r.runtime.RError;
3533
import com.oracle.truffle.r.runtime.RArguments.S3Args;
34+
import com.oracle.truffle.r.runtime.RError;
3635
import com.oracle.truffle.r.runtime.RError.ErrorContext;
3736
import com.oracle.truffle.r.runtime.builtins.RBuiltin;
3837
import com.oracle.truffle.r.runtime.builtins.RBuiltinDescriptor;
@@ -47,6 +46,7 @@
4746
import com.oracle.truffle.r.runtime.nodes.RSyntaxElement;
4847
import com.oracle.truffle.r.runtime.nodes.RSyntaxLookup;
4948
import com.oracle.truffle.r.runtime.nodes.builtin.RBuiltinBaseNode;
49+
import com.oracle.truffle.r.runtime.nodes.unary.CastNode;
5050

5151
@TypeSystemReference(RTypes.class)
5252
public abstract class RBuiltinNode extends RBuiltinBaseNode implements NodeWithArgumentCasts {
@@ -87,7 +87,10 @@ private static RBuiltin getRBuiltin(Class<?> klass) {
8787
* information as initially parsed. However, currently, builtins called via
8888
* {@code do.call("func", )} have a {@link RBuiltinRootNode} as a parent, which carries no
8989
* context about the original call, so we return {@code null}.
90+
*
91+
* Note: behind Truffle boundary, because it messes up with saturated type flows.
9092
*/
93+
@TruffleBoundary(allowInlining = true)
9194
public RSyntaxElement getOriginalCall() {
9295
Node p = getParent();
9396
while (p != null) {

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/RBaseNode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import com.oracle.truffle.api.CompilerDirectives;
2626
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
27+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
2728
import com.oracle.truffle.api.dsl.ImportStatic;
2829
import com.oracle.truffle.api.instrumentation.Tag;
2930
import com.oracle.truffle.api.nodes.LoopNode;
@@ -143,6 +144,7 @@ protected RSyntaxNode getRSyntaxNode() {
143144
* However, currently that is not always the case, so this method can be used by defensive code.
144145
* It returns {@code null} if the {@link RSyntaxNode} cannot be located.
145146
*/
147+
@TruffleBoundary
146148
private RSyntaxNode checkGetRSyntaxNode() {
147149
Node current = this;
148150
while (current != null) {

0 commit comments

Comments
 (0)