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
e36ea522
Commit
e36ea522
authored
7 years ago
by
stepan
Browse files
Options
Downloads
Patches
Plain Diff
TryRfEvalNode: support errorFlag also with NFI
parent
b2a94f39
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.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/TryRfEvalNode.java
+42
-10
42 additions, 10 deletions
...rc/com/oracle/truffle/r/ffi/impl/nodes/TryRfEvalNode.java
with
42 additions
and
10 deletions
com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/TryRfEvalNode.java
+
42
−
10
View file @
e36ea522
...
...
@@ -22,35 +22,67 @@
*/
package
com.oracle.truffle.r.ffi.impl.nodes
;
import
com.oracle.truffle.api.CompilerDirectives
;
import
com.oracle.truffle.api.interop.ForeignAccess
;
import
com.oracle.truffle.api.interop.InteropException
;
import
com.oracle.truffle.api.interop.Message
;
import
com.oracle.truffle.api.interop.TruffleObject
;
import
com.oracle.truffle.api.interop.UnsupportedMessageException
;
import
com.oracle.truffle.api.nodes.Node
;
import
com.oracle.truffle.r.ffi.impl.interop.UnsafeAdapter
;
import
com.oracle.truffle.r.runtime.RErrorHandling
;
import
com.oracle.truffle.r.runtime.RInternalError
;
import
com.oracle.truffle.r.runtime.data.RNull
;
public
final
class
TryRfEvalNode
extends
FFIUpCallNode
.
Arg4
{
@Child
RfEvalNode
rfEvalNode
=
RfEvalNode
.
create
();
@Child
Node
writeErrorFlagNode
=
Message
.
WRITE
.
createNode
();
@Child
private
RfEvalNode
rfEvalNode
=
RfEvalNode
.
create
();
@Child
private
Node
isNullNode
=
Message
.
IS_NULL
.
createNode
();
@Child
private
Node
writeErrorFlagNode
;
@Child
private
Node
isPointerNode
;
@Child
private
Node
asPointerNode
;
@Override
public
Object
executeObject
(
Object
expr
,
Object
env
,
Object
errorFlag
,
Object
silent
)
{
Object
handlerStack
=
RErrorHandling
.
getHandlerStack
();
Object
restartStack
=
RErrorHandling
.
getRestartStack
();
boolean
ok
=
true
;
Object
result
=
RNull
.
instance
;
try
{
// TODO handle silent
RErrorHandling
.
resetStacks
();
re
turn
rfEvalNode
.
executeObject
(
expr
,
env
);
re
sult
=
rfEvalNode
.
executeObject
(
expr
,
env
);
}
catch
(
Throwable
t
)
{
try
{
ForeignAccess
.
sendWrite
(
writeErrorFlagNode
,
(
TruffleObject
)
errorFlag
,
0
,
1
);
}
catch
(
InteropException
e
)
{
// Ignore it, when using NFI, e.g., the errorFlag TO does not support the WRITE
// message
}
return
null
;
ok
=
false
;
result
=
RNull
.
instance
;
}
finally
{
RErrorHandling
.
restoreStacks
(
handlerStack
,
restartStack
);
}
TruffleObject
errorFlagTO
=
(
TruffleObject
)
errorFlag
;
if
(!
ForeignAccess
.
sendIsNull
(
isNullNode
,
errorFlagTO
))
{
if
(
isPointerNode
==
null
)
{
CompilerDirectives
.
transferToInterpreterAndInvalidate
();
isPointerNode
=
insert
(
Message
.
IS_POINTER
.
createNode
());
}
if
(
ForeignAccess
.
sendIsPointer
(
isPointerNode
,
errorFlagTO
))
{
if
(
asPointerNode
==
null
)
{
CompilerDirectives
.
transferToInterpreterAndInvalidate
();
asPointerNode
=
insert
(
Message
.
AS_POINTER
.
createNode
());
}
long
errorFlagPtr
;
try
{
errorFlagPtr
=
ForeignAccess
.
sendAsPointer
(
asPointerNode
,
errorFlagTO
);
}
catch
(
UnsupportedMessageException
e
)
{
throw
RInternalError
.
shouldNotReachHere
(
"IS_POINTER message returned true, AS_POINTER should not fail"
);
}
UnsafeAdapter
.
UNSAFE
.
putInt
(
errorFlagPtr
,
ok
?
0
:
1
);
}
else
{
try
{
ForeignAccess
.
sendWrite
(
writeErrorFlagNode
,
errorFlagTO
,
0
,
1
);
}
catch
(
InteropException
e
)
{
throw
RInternalError
.
shouldNotReachHere
(
"Rf_tryEval errorFlag should be either pointer or support WRITE message"
);
}
}
}
return
result
;
}
}
This diff is collapsed.
Click to expand it.
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