Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Lopez
QueryR
Commits
1c36352f
Commit
1c36352f
authored
8 years ago
by
Lukas Stadler
Browse files
Options
Downloads
Patches
Plain Diff
remove use of RPromise in Return
parent
18d7a3a9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Return.java
+7
-32
7 additions, 32 deletions
...n/src/com/oracle/truffle/r/nodes/builtin/base/Return.java
with
7 additions
and
32 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Return.java
+
7
−
32
View file @
1c36352f
...
...
@@ -25,60 +25,35 @@ package com.oracle.truffle.r.nodes.builtin.base;
import
static
com
.
oracle
.
truffle
.
r
.
runtime
.
builtins
.
RBehavior
.
COMPLEX
;
import
static
com
.
oracle
.
truffle
.
r
.
runtime
.
builtins
.
RBuiltinKind
.
PRIMITIVE
;
import
com.oracle.truffle.api.CompilerDirectives
;
import
com.oracle.truffle.api.dsl.Specialization
;
import
com.oracle.truffle.api.frame.VirtualFrame
;
import
com.oracle.truffle.api.profiles.BranchProfile
;
import
com.oracle.truffle.r.nodes.builtin.RBuiltinNode
;
import
com.oracle.truffle.r.nodes.function.
PromiseHelper
Node
;
import
com.oracle.truffle.r.nodes.function.
FunctionDefinition
Node
;
import
com.oracle.truffle.r.runtime.RArguments
;
import
com.oracle.truffle.r.runtime.RCaller
;
import
com.oracle.truffle.r.runtime.ReturnException
;
import
com.oracle.truffle.r.runtime.builtins.RBuiltin
;
import
com.oracle.truffle.r.runtime.data.RMissing
;
import
com.oracle.truffle.r.runtime.data.RNull
;
import
com.oracle.truffle.r.runtime.data.RPromise
;
/**
*
In the normal case, we are returning
from the currently executing function,
but in the case wher
e
*
"return" was passed as an argument (promise) (e.g. in tryCatch) to a function, w
e will be
*
evaluating that in the context of a PromiseEvalFrame and the frame we need to return to
i
s
th
at
*
given by the PromiseEvalFrame
.
*
Return a value
from the currently executing function,
which is identified by th
e
*
{@link RArguments#getCall(com.oracle.truffle.api.frame.Frame) call}. The return valu
e will be
*
delivered via a {@link ReturnException}, which is subsequently caught
i
n
th
e
*
{@link FunctionDefinitionNode}
.
*/
@RBuiltin
(
name
=
"return"
,
kind
=
PRIMITIVE
,
parameterNames
=
{
"value"
},
nonEvalArgs
=
{
0
},
behavior
=
COMPLEX
)
@RBuiltin
(
name
=
"return"
,
kind
=
PRIMITIVE
,
parameterNames
=
{
"value"
},
behavior
=
COMPLEX
)
public
abstract
class
Return
extends
RBuiltinNode
{
private
final
BranchProfile
isPromiseEvalProfile
=
BranchProfile
.
create
();
@Child
private
PromiseHelperNode
promiseHelper
;
private
PromiseHelperNode
initPromiseHelper
()
{
if
(
promiseHelper
==
null
)
{
CompilerDirectives
.
transferToInterpreterAndInvalidate
();
promiseHelper
=
insert
(
new
PromiseHelperNode
());
}
return
promiseHelper
;
}
@Override
public
Object
[]
getDefaultParameterValues
()
{
return
new
Object
[]{
RNull
.
instance
};
}
@Specialization
protected
Object
returnFunction
(
VirtualFrame
frame
,
@SuppressWarnings
(
"unused"
)
RMissing
arg
)
{
throw
new
ReturnException
(
RNull
.
instance
,
RArguments
.
getCall
(
frame
));
}
@Specialization
protected
Object
returnFunction
(
VirtualFrame
frame
,
RNull
arg
)
{
throw
new
ReturnException
(
arg
,
RArguments
.
getCall
(
frame
));
}
@Specialization
protected
Object
returnFunction
(
VirtualFrame
frame
,
RPromise
expr
)
{
// Evaluate the result
Object
value
=
initPromiseHelper
().
evaluate
(
frame
,
expr
);
protected
Object
returnFunction
(
VirtualFrame
frame
,
Object
value
)
{
RCaller
call
=
RArguments
.
getCall
(
frame
);
while
(
call
.
isPromise
())
{
isPromiseEvalProfile
.
enter
();
...
...
This diff is collapsed.
Click to expand it.
Julien Lopez
@jlopez
mentioned in commit
2e5ab89a
·
8 years ago
mentioned in commit
2e5ab89a
mentioned in commit 2e5ab89a571c99aa0ca439a48eb3025116007524
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment