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
e9c70cd6
Commit
e9c70cd6
authored
7 years ago
by
stepan
Browse files
Options
Downloads
Patches
Plain Diff
Synchronize accesses to the call targets map in Closure class
parent
ccf9068d
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/src/com/oracle/truffle/r/runtime/data/Closure.java
+19
-16
19 additions, 16 deletions
...untime/src/com/oracle/truffle/r/runtime/data/Closure.java
with
19 additions
and
16 deletions
com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/Closure.java
+
19
−
16
View file @
e9c70cd6
/*
* Copyright (c) 201
7
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 201
8
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -87,13 +87,24 @@ public final class Closure {
return
new
Closure
(
name
,
expr
);
}
private
RootCallTarget
getCallTarget
(
FrameDescriptor
desc
)
{
private
synchronized
RootCallTarget
getCallTarget
(
FrameDescriptor
desc
,
boolean
canReuseExpr
)
{
// This whole method is synchronized, not only the hash-map, so that we can lazily
// initialize the call targets hash-map, and reuse 'expr' in case we're the first thread
// executing this method
// Create lazily, as it is not needed at all for INLINED promises!
RootCallTarget
result
;
if
(
callTargets
==
null
)
{
callTargets
=
new
WeakHashMap
<>();
result
=
generateCallTarget
((
RNode
)
(
canReuseExpr
?
expr
:
RContext
.
getASTBuilder
().
process
(
expr
.
asRSyntaxNode
())));
callTargets
.
put
(
desc
,
result
);
}
else
{
result
=
callTargets
.
get
(
desc
);
if
(
result
==
null
)
{
result
=
generateCallTarget
((
RNode
)
RContext
.
getASTBuilder
().
process
(
expr
.
asRSyntaxNode
()));
callTargets
.
put
(
desc
,
result
);
}
}
return
callTargets
.
get
(
desc
)
;
return
result
;
}
/**
...
...
@@ -103,12 +114,7 @@ public final class Closure {
CompilerAsserts
.
neverPartOfCompilation
();
FrameDescriptor
desc
=
frame
.
getFrameDescriptor
();
RootCallTarget
callTarget
=
getCallTarget
(
desc
);
if
(
callTarget
==
null
)
{
// clone for additional call targets
callTarget
=
generateCallTarget
((
RNode
)
(
callTargets
.
isEmpty
()
?
expr
:
RContext
.
getASTBuilder
().
process
(
expr
.
asRSyntaxNode
())));
callTargets
.
put
(
desc
,
callTarget
);
}
RootCallTarget
callTarget
=
getCallTarget
(
desc
,
true
);
return
callTarget
.
call
(
frame
);
}
...
...
@@ -119,12 +125,9 @@ public final class Closure {
CompilerAsserts
.
neverPartOfCompilation
();
FrameDescriptor
desc
=
envir
.
getFrame
().
getFrameDescriptor
();
RootCallTarget
callTarget
=
getCallTarget
(
desc
);
if
(
callTarget
==
null
)
{
// clone for additional call targets
callTarget
=
generateCallTarget
((
RNode
)
RContext
.
getASTBuilder
().
process
(
expr
.
asRSyntaxNode
()));
callTargets
.
put
(
desc
,
callTarget
);
}
RootCallTarget
callTarget
=
getCallTarget
(
desc
,
false
);
// Note: because we're creating new frame, we must not reuse expr, which may have cached
// some frame slots
MaterializedFrame
vFrame
=
VirtualEvalFrame
.
create
(
envir
.
getFrame
(),
(
RFunction
)
null
,
caller
);
return
callTarget
.
call
(
vFrame
);
}
...
...
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