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
476aeb45
Commit
476aeb45
authored
8 years ago
by
Lukas Stadler
Browse files
Options
Downloads
Patches
Plain Diff
optimized ShareObjectNode
parent
2374a7ea
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/src/com/oracle/truffle/r/nodes/function/opt/ShareObjectNode.java
+19
-20
19 additions, 20 deletions
.../oracle/truffle/r/nodes/function/opt/ShareObjectNode.java
with
19 additions
and
20 deletions
com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/opt/ShareObjectNode.java
+
19
−
20
View file @
476aeb45
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016,
2017,
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
...
...
@@ -30,7 +30,6 @@ import com.oracle.truffle.api.dsl.TypeSystemReference;
import
com.oracle.truffle.api.nodes.Node
;
import
com.oracle.truffle.api.nodes.NodeInfo
;
import
com.oracle.truffle.api.profiles.ConditionProfile
;
import
com.oracle.truffle.api.profiles.ValueProfile
;
import
com.oracle.truffle.r.nodes.EmptyTypeSystemFlatLayout
;
import
com.oracle.truffle.r.runtime.data.RShareable
;
import
com.oracle.truffle.r.runtime.data.RSharingAttributeStorage
;
...
...
@@ -39,6 +38,9 @@ import com.oracle.truffle.r.runtime.data.RSharingAttributeStorage;
* Internal node that should be used whenever you need to increment reference count of some object.
* If the object is not instance of {@link RShareable} or if it is shared permanent, then does
* nothing.
*
* This class relies (and asserts) that all RShareable objects are subclasses of
* RSharingAttributeStorage.
*/
@TypeSystemReference
(
EmptyTypeSystemFlatLayout
.
class
)
@NodeInfo
(
cost
=
NONE
)
...
...
@@ -58,29 +60,20 @@ public abstract class ShareObjectNode extends Node {
return
obj
;
}
@Specialization
protected
Object
doShareable
(
RShareable
obj
,
@Cached
(
"createBinaryProfile()"
)
ConditionProfile
sharedPermanent
,
@Cached
(
"createClassProfile()"
)
ValueProfile
typeProfile
)
{
RShareable
objProfiled
=
typeProfile
.
profile
(
obj
);
if
(
sharedPermanent
.
profile
(!
objProfiled
.
isSharedPermanent
()))
{
objProfiled
.
incRefCount
();
}
return
obj
;
}
@Specialization
(
guards
=
"!isRShareable(obj)"
)
protected
Object
doNonShareable
(
Object
obj
)
{
return
obj
;
}
protected
static
boolean
isRShareable
(
Object
value
)
{
return
value
instanceof
RShareable
;
verify
(
value
);
return
value
instanceof
RSharingAttributeStorage
;
}
public
static
<
T
>
T
share
(
T
value
)
{
if
(
value
instanceof
RShareable
)
{
RShareable
shareable
=
(
RShareable
)
value
;
verify
(
value
);
if
(
value
instanceof
RSharingAttributeStorage
)
{
RSharingAttributeStorage
shareable
=
(
RSharingAttributeStorage
)
value
;
if
(!
shareable
.
isSharedPermanent
())
{
shareable
.
incRefCount
();
}
...
...
@@ -89,18 +82,24 @@ public abstract class ShareObjectNode extends Node {
}
public
static
<
T
>
T
sharePermanent
(
T
value
)
{
if
(
value
instanceof
RShareable
)
{
((
RShareable
)
value
).
makeSharedPermanent
();
verify
(
value
);
if
(
value
instanceof
RSharingAttributeStorage
)
{
((
RSharingAttributeStorage
)
value
).
makeSharedPermanent
();
}
return
value
;
}
public
static
void
unshare
(
Object
value
)
{
if
(
value
instanceof
RShareable
)
{
RShareable
shareable
=
(
RShareable
)
value
;
verify
(
value
);
if
(
value
instanceof
RSharingAttributeStorage
)
{
RSharingAttributeStorage
shareable
=
(
RSharingAttributeStorage
)
value
;
if
(!
shareable
.
isSharedPermanent
())
{
shareable
.
decRefCount
();
}
}
}
private
static
void
verify
(
Object
value
)
{
assert
(
value
instanceof
RShareable
)
==
(
value
instanceof
RSharingAttributeStorage
)
:
"unexpected RShareable that is not RSharingAttributeStorage: "
+
value
;
}
}
This diff is collapsed.
Click to expand it.
Julien Lopez
@jlopez
mentioned in commit
c89830d4
·
8 years ago
mentioned in commit
c89830d4
mentioned in commit c89830d4f5ced0e74da08727fa4eeed7a082436d
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