Skip to content

Commit 4e6de55

Browse files
committed
[GR-17457] Use a faster frozen check for uncached cases
PullRequest: truffleruby/3292
2 parents 9e904e7 + 7f7e9eb commit 4e6de55

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/java/org/truffleruby/core/module/ModuleFields.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import org.truffleruby.language.constants.ConstantEntry;
5050
import org.truffleruby.language.constants.GetConstantNode;
5151
import org.truffleruby.language.control.RaiseException;
52-
import org.truffleruby.language.library.RubyLibrary;
5352
import org.truffleruby.language.library.RubyStringLibrary;
5453
import org.truffleruby.language.loader.ReentrantLockFreeingMap;
5554
import org.truffleruby.language.methods.InternalMethod;
@@ -245,7 +244,7 @@ public void initCopy(RubyModule from) {
245244
}
246245

247246
public void checkFrozen(RubyContext context, Node currentNode) {
248-
if (context.getCoreLibrary() != null && RubyLibrary.getUncached().isFrozen(rubyModule)) {
247+
if (context.getCoreLibrary() != null && rubyModule.isFrozenUncached()) {
249248
String name;
250249
Object receiver = rubyModule;
251250
if (rubyModule instanceof RubyClass) {

src/main/java/org/truffleruby/language/RubyDynamicObject.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package org.truffleruby.language;
1111

12+
import com.oracle.truffle.api.CompilerAsserts;
1213
import com.oracle.truffle.api.interop.StopIterationException;
1314
import com.oracle.truffle.api.interop.UnknownKeyException;
1415
import org.truffleruby.RubyContext;
@@ -20,6 +21,8 @@
2021
import org.truffleruby.core.cast.ToLongNode;
2122
import org.truffleruby.core.kernel.KernelNodes;
2223
import org.truffleruby.core.klass.RubyClass;
24+
import org.truffleruby.core.range.RubyRange;
25+
import org.truffleruby.core.string.RubyString;
2326
import org.truffleruby.core.string.StringUtils;
2427
import org.truffleruby.interop.ForeignToRubyArgumentsNode;
2528
import org.truffleruby.interop.ForeignToRubyNode;
@@ -114,6 +117,12 @@ public boolean isFrozen(
114117
@CachedLibrary("this") DynamicObjectLibrary objLib) {
115118
return (objLib.getShapeFlags(this) & FROZEN) != 0;
116119
}
120+
121+
public boolean isFrozenUncached() {
122+
CompilerAsserts.neverPartOfCompilation("Use RubyLibrary instead in PE code");
123+
assert !(this instanceof RubyString) && !(this instanceof RubyRange);
124+
return (getShape().getFlags() & FROZEN) != 0;
125+
}
117126
// endregion
118127

119128
// region InteropLibrary messages

0 commit comments

Comments
 (0)