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
b4be2347
Commit
b4be2347
authored
8 years ago
by
Adam Welc
Browse files
Options
Downloads
Patches
Plain Diff
Rewritten parameter casts for the unclass builtin.
parent
7e9da700
Branches
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/UnClass.java
+39
-29
39 additions, 29 deletions
.../src/com/oracle/truffle/r/nodes/builtin/base/UnClass.java
with
39 additions
and
29 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UnClass.java
+
39
−
29
View file @
b4be2347
...
...
@@ -17,62 +17,72 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE;
import
com.oracle.truffle.api.CompilerDirectives.TruffleBoundary
;
import
com.oracle.truffle.api.dsl.Specialization
;
import
com.oracle.truffle.api.profiles.BranchProfile
;
import
com.oracle.truffle.r.nodes.builtin.CastBuilder
;
import
com.oracle.truffle.r.nodes.builtin.RBuiltinNode
;
import
com.oracle.truffle.r.runtime.RRuntime
;
import
com.oracle.truffle.r.runtime.builtins.RBuiltin
;
import
com.oracle.truffle.r.runtime.data.RAttributable
;
import
com.oracle.truffle.r.runtime.data.RAttributeProfiles
;
import
com.oracle.truffle.r.runtime.data.R
Language
;
import
com.oracle.truffle.r.runtime.data.RS
4Object
;
import
com.oracle.truffle.r.runtime.data.R
Null
;
import
com.oracle.truffle.r.runtime.data.RS
hareable
;
import
com.oracle.truffle.r.runtime.data.RVector
;
import
com.oracle.truffle.r.runtime.data.model.RAbstractVector
;
@RBuiltin
(
name
=
"unclass"
,
kind
=
PRIMITIVE
,
parameterNames
=
{
"x"
},
behavior
=
PURE
)
public
abstract
class
UnClass
extends
RBuiltinNode
{
private
final
BranchProfile
objectProfile
=
BranchProfile
.
create
();
private
final
BranchProfile
shareableProfile
=
BranchProfile
.
create
();
private
final
RAttributeProfiles
attrProfiles
=
RAttributeProfiles
.
create
();
@Override
protected
void
createCasts
(
CastBuilder
casts
)
{
casts
.
arg
(
"x"
).
asAttributable
(
true
,
true
,
true
);
}
@Specialization
protected
RNull
unClass
(
RNull
rnull
)
{
return
rnull
;
}
@TruffleBoundary
protected
Object
unClass
(
RAbstractVector
arg
)
{
if
(
arg
.
isObject
(
attrProfiles
))
{
objectProfile
.
enter
();
RVector
resultVector
=
arg
.
materialize
();
if
(!
resultVector
.
isTemporary
())
{
resultVector
=
resultVector
.
copy
();
resultVector
.
incRefCount
();
}
return
RVector
.
setVectorClassAttr
(
resultVector
,
null
);
private
static
Object
unClassVector
(
RAbstractVector
arg
)
{
RVector
resultVector
=
arg
.
materialize
();
if
(!
resultVector
.
isTemporary
())
{
resultVector
=
resultVector
.
copy
();
resultVector
.
incRefCount
();
}
return
arg
;
return
RVector
.
setVectorClassAttr
(
resultVector
,
null
)
;
}
// TODO: this specialization could go away if connections were simple vectors (we wouldn't need
// special method for setting class attributes then)
@Specialization
protected
Object
unClass
(
R
Language
arg
)
{
if
(
arg
.
getClassAttr
(
attrProfiles
)
!=
null
)
{
protected
Object
unClass
(
R
AbstractVector
arg
)
{
if
(
arg
.
isObject
(
attrProfiles
))
{
objectProfile
.
enter
();
RLanguage
resultLang
=
arg
;
if
(!
resultLang
.
isTemporary
())
{
resultLang
=
resultLang
.
copy
();
resultLang
.
incRefCount
();
}
resultLang
.
removeAttr
(
attrProfiles
,
RRuntime
.
CLASS_ATTR_KEY
);
return
resultLang
;
return
unClassVector
(
arg
);
}
return
arg
;
}
@Specialization
protected
Object
unClass
(
R
S4Object
arg
)
{
@Specialization
(
guards
=
"notAbstractVector(arg)"
)
protected
Object
unClass
(
R
Attributable
arg
)
{
if
(
arg
.
getClassAttr
(
attrProfiles
)
!=
null
)
{
objectProfile
.
enter
();
RS4Object
resultS4
=
arg
;
if
(!
resultS4
.
isTemporary
())
{
resultS4
=
resultS4
.
copy
();
resultS4
.
incRefCount
();
if
(
arg
instanceof
RShareable
)
{
shareableProfile
.
enter
();
RShareable
shareable
=
(
RShareable
)
arg
;
if
(!
shareable
.
isTemporary
())
{
shareable
=
shareable
.
copy
();
shareable
.
incRefCount
();
}
}
resultS4
.
removeAttr
(
attrProfiles
,
RRuntime
.
CLASS_ATTR_KEY
);
return
resultS4
;
arg
.
removeAttr
(
attrProfiles
,
RRuntime
.
CLASS_ATTR_KEY
);
}
return
arg
;
}
protected
boolean
notAbstractVector
(
Object
arg
)
{
return
!(
arg
instanceof
RAbstractVector
);
}
}
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