Skip to content

Commit

Permalink
[Truffle] Module#deprecate_constant move profiles to uncached nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Fish committed Sep 29, 2016
1 parent 6ab74ed commit dc20ea8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Expand Up @@ -73,13 +73,11 @@ protected RubyConstant lookupConstant(
@Cached("name") String cachedName,
@Cached("doLookup(cachedModule, cachedName)") RubyConstant constant,
@Cached("isVisible(cachedModule, constant)") boolean isVisible,
@Cached("createBinaryProfile()") ConditionProfile sameNameProfile,
@Cached("createBinaryProfile()") ConditionProfile isVisibleProfile,
@Cached("createBinaryProfile()") ConditionProfile isDeprecatedProfile) {
if (isVisibleProfile.profile(!isVisible)) {
@Cached("createBinaryProfile()") ConditionProfile sameNameProfile) {
if (!isVisible) {
throw new RaiseException(coreExceptions().nameErrorPrivateConstant(module, name, this));
}
if (isDeprecatedProfile.profile(constant != null && constant.isDeprecated())) {
if (constant != null && constant.isDeprecated()) {
warnDeprecatedConstant(frame, name);
}
return constant;
Expand All @@ -98,14 +96,16 @@ public Assumption getUnmodifiedAssumption(DynamicObject module) {
}

@Specialization(guards = "isRubyModule(module)")
protected RubyConstant lookupConstantUncached(VirtualFrame frame, DynamicObject module, String name) {
protected RubyConstant lookupConstantUncached(VirtualFrame frame, DynamicObject module, String name,
@Cached("createBinaryProfile()") ConditionProfile isVisibleProfile,
@Cached("createBinaryProfile()") ConditionProfile isDeprecatedProfile) {
RubyConstant constant = doLookup(module, name);
boolean isVisible = isVisible(module, constant);

if (!isVisible) {
if (isVisibleProfile.profile(!isVisible)) {
throw new RaiseException(coreExceptions().nameErrorPrivateConstant(module, name, this));
}
if (constant != null && constant.isDeprecated()) {
if (isDeprecatedProfile.profile(constant != null && constant.isDeprecated())) {
warnDeprecatedConstant(frame, name);
}
return constant;
Expand Down
Expand Up @@ -51,25 +51,25 @@ public RubyConstant lookupConstant(VirtualFrame frame, Object module, String nam
@Specialization(assumptions = "getUnmodifiedAssumption(getModule())")
protected RubyConstant lookupConstant(VirtualFrame frame,
@Cached("doLookup()") RubyConstant constant,
@Cached("isVisible(constant)") boolean isVisible,
@Cached("createBinaryProfile()") ConditionProfile isVisibleProfile,
@Cached("createBinaryProfile()") ConditionProfile isDeprecatedProfile) {
if (isVisibleProfile.profile(!isVisible)) {
@Cached("isVisible(constant)") boolean isVisible) {
if (!isVisible) {
throw new RaiseException(coreExceptions().nameErrorPrivateConstant(getModule(), name, this));
}
if (isDeprecatedProfile.profile(constant != null && constant.isDeprecated())) {
if (constant != null && constant.isDeprecated()) {
warnDeprecatedConstant(frame, name);
}
return constant;
}

@Specialization(assumptions = "getUnmodifiedAssumption(getModule())")
protected RubyConstant lookupConstantUncached(VirtualFrame frame) {
protected RubyConstant lookupConstantUncached(VirtualFrame frame,
@Cached("createBinaryProfile()") ConditionProfile isVisibleProfile,
@Cached("createBinaryProfile()") ConditionProfile isDeprecatedProfile) {
RubyConstant constant = doLookup();
if (!isVisible(constant)) {
if (isVisibleProfile.profile(!isVisible(constant))) {
throw new RaiseException(coreExceptions().nameErrorPrivateConstant(getModule(), name, this));
}
if (constant != null && constant.isDeprecated()) {
if (isDeprecatedProfile.profile(constant != null && constant.isDeprecated())) {
warnDeprecatedConstant(frame, name);
}
return constant;
Expand Down

0 comments on commit dc20ea8

Please sign in to comment.