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
44914f5c
Commit
44914f5c
authored
8 years ago
by
Mick Jordan
Browse files
Options
Downloads
Patches
Plain Diff
JNI_CallRFFI: use synchronized to allow nested calls
parent
1aaa4654
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.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/JNI_CallRFFI.java
+57
-45
57 additions, 45 deletions
...rc/com/oracle/truffle/r/runtime/ffi/jnr/JNI_CallRFFI.java
with
57 additions
and
45 deletions
com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/JNI_CallRFFI.java
+
57
−
45
View file @
44914f5c
...
...
@@ -23,8 +23,8 @@
package
com.oracle.truffle.r.runtime.ffi.jnr
;
import
static
com
.
oracle
.
truffle
.
r
.
runtime
.
ffi
.
RFFIUtils
.
traceDownCall
;
import
java.util.concurrent.Semaphore
;
import
static
com
.
oracle
.
truffle
.
r
.
runtime
.
ffi
.
RFFIUtils
.
traceDownCallReturn
;
import
static
com
.
oracle
.
truffle
.
r
.
runtime
.
ffi
.
RFFIUtils
.
traceEnabled
;
import
com.oracle.truffle.api.CompilerDirectives.TruffleBoundary
;
import
com.oracle.truffle.r.runtime.RInternalError
;
...
...
@@ -32,6 +32,7 @@ import com.oracle.truffle.r.runtime.ffi.CallRFFI;
import
com.oracle.truffle.r.runtime.ffi.DLL
;
import
com.oracle.truffle.r.runtime.ffi.DLL.DLLException
;
import
com.oracle.truffle.r.runtime.ffi.LibPaths
;
import
com.oracle.truffle.r.runtime.ffi.RFFIUtils
;
import
com.oracle.truffle.r.runtime.ffi.RFFIVariables
;
/**
...
...
@@ -66,37 +67,48 @@ public class JNI_CallRFFI implements CallRFFI {
throw
new
RInternalError
(
ex
,
"error while loading "
+
librffiPath
);
}
System
.
load
(
librffiPath
);
traceDownCall
(
"initialize"
);
initialize
(
RFFIVariables
.
values
());
}
RFFIUtils
.
initialize
();
if
(
traceEnabled
())
{
traceDownCall
(
"initialize"
);
}
try
{
initialize
(
RFFIVariables
.
values
());
}
finally
{
if
(
traceEnabled
())
{
traceDownCallReturn
(
"initialize"
,
null
);
}
private
static
final
Semaphore
inCritical
=
new
Semaphore
(
1
,
false
);
}
}
@Override
public
Object
invokeCall
(
long
address
,
String
name
,
Object
[]
args
)
{
traceDownCall
(
name
,
args
);
public
synchronized
Object
invokeCall
(
long
address
,
String
name
,
Object
[]
args
)
{
Object
result
=
null
;
if
(
traceEnabled
())
{
traceDownCall
(
name
,
args
);
}
try
{
inCritical
.
acquire
();
switch
(
args
.
length
)
{
// @formatter:off
case
0
:
re
turn
call0
(
address
);
case
1
:
re
turn
call1
(
address
,
args
[
0
]);
case
2
:
re
turn
call2
(
address
,
args
[
0
],
args
[
1
]);
case
3
:
re
turn
call3
(
address
,
args
[
0
],
args
[
1
],
args
[
2
]);
case
4
:
re
turn
call4
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
]);
case
5
:
re
turn
call5
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
]);
case
6
:
re
turn
call6
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
args
[
5
]);
case
7
:
re
turn
call7
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
args
[
5
],
args
[
6
]);
case
8
:
re
turn
call8
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
args
[
5
],
args
[
6
],
args
[
7
]);
case
9
:
re
turn
call9
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
args
[
5
],
args
[
6
],
args
[
7
],
args
[
8
]);
case
0
:
re
sult
=
call0
(
address
);
break
;
case
1
:
re
sult
=
call1
(
address
,
args
[
0
]);
break
;
case
2
:
re
sult
=
call2
(
address
,
args
[
0
],
args
[
1
]);
break
;
case
3
:
re
sult
=
call3
(
address
,
args
[
0
],
args
[
1
],
args
[
2
]);
break
;
case
4
:
re
sult
=
call4
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
]);
break
;
case
5
:
re
sult
=
call5
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
]);
break
;
case
6
:
re
sult
=
call6
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
args
[
5
]);
break
;
case
7
:
re
sult
=
call7
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
args
[
5
],
args
[
6
]);
break
;
case
8
:
re
sult
=
call8
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
args
[
5
],
args
[
6
],
args
[
7
]);
break
;
case
9
:
re
sult
=
call9
(
address
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
args
[
5
],
args
[
6
],
args
[
7
],
args
[
8
]);
break
;
default
:
re
turn
call
(
address
,
args
);
re
sult
=
call
(
address
,
args
);
break
;
// @formatter:on
}
}
catch
(
InterruptedException
ex
)
{
throw
RInternalError
.
shouldNotReachHere
();
return
result
;
}
finally
{
inCritical
.
release
();
if
(
traceEnabled
())
{
traceDownCallReturn
(
name
,
result
);
}
}
}
...
...
@@ -129,10 +141,11 @@ public class JNI_CallRFFI implements CallRFFI {
private
static
native
Object
call9
(
long
address
,
Object
arg1
,
Object
arg2
,
Object
arg3
,
Object
arg4
,
Object
arg5
,
Object
arg6
,
Object
arg7
,
Object
arg8
,
Object
arg9
);
@Override
public
void
invokeVoidCall
(
long
address
,
String
name
,
Object
[]
args
)
{
traceDownCall
(
name
,
args
);
public
synchronized
void
invokeVoidCall
(
long
address
,
String
name
,
Object
[]
args
)
{
if
(
traceEnabled
())
{
traceDownCall
(
name
,
args
);
}
try
{
inCritical
.
acquire
();
switch
(
args
.
length
)
{
case
0
:
callVoid0
(
address
);
...
...
@@ -143,9 +156,10 @@ public class JNI_CallRFFI implements CallRFFI {
default
:
throw
RInternalError
.
shouldNotReachHere
();
}
}
catch
(
InterruptedException
ex
)
{
}
finally
{
inCritical
.
release
();
if
(
traceEnabled
())
{
traceDownCallReturn
(
name
,
null
);
}
}
}
...
...
@@ -154,27 +168,25 @@ public class JNI_CallRFFI implements CallRFFI {
private
static
native
void
callVoid1
(
long
address
,
Object
arg1
);
@Override
public
void
setTempDir
(
String
tempDir
)
{
traceDownCall
(
"setTempDir"
,
tempDir
);
try
{
inCritical
.
acquire
();
RFFIVariables
.
setTempDir
(
tempDir
);
nativeSetTempDir
(
tempDir
);
}
catch
(
InterruptedException
ex
)
{
}
finally
{
inCritical
.
release
();
public
synchronized
void
setTempDir
(
String
tempDir
)
{
if
(
traceEnabled
())
{
traceDownCall
(
"setTempDir"
,
tempDir
);
}
RFFIVariables
.
setTempDir
(
tempDir
);
nativeSetTempDir
(
tempDir
);
if
(
traceEnabled
())
{
traceDownCallReturn
(
"setTempDir"
,
null
);
}
}
@Override
public
void
setInteractive
(
boolean
interactive
)
{
traceDownCall
(
"setInteractive"
,
interactive
);
try
{
inCritical
.
acquire
();
nativeSetInteractive
(
interactive
);
}
catch
(
InterruptedException
ex
)
{
}
finally
{
inCritical
.
release
();
public
synchronized
void
setInteractive
(
boolean
interactive
)
{
if
(
traceEnabled
())
{
traceDownCall
(
"setInteractive"
,
interactive
);
}
nativeSetInteractive
(
interactive
);
if
(
traceEnabled
())
{
traceDownCallReturn
(
"setInteractive"
,
null
);
}
}
...
...
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