Skip to content

Commit 4e70101

Browse files
committed
Remove check for strscan in Kernel#require
* Avoids walking the stack. * Use strscan for ERB.
1 parent ec974a9 commit 4e70101

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

src/main/java/org/truffleruby/core/kernel/KernelNodes.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
import org.truffleruby.language.WarnNode;
101101
import org.truffleruby.language.arguments.ReadCallerFrameNode;
102102
import org.truffleruby.language.arguments.RubyArguments;
103-
import org.truffleruby.language.backtrace.Activation;
104103
import org.truffleruby.language.backtrace.Backtrace;
105104
import org.truffleruby.language.control.RaiseException;
106105
import org.truffleruby.language.dispatch.CallDispatchHeadNode;
@@ -1372,32 +1371,10 @@ public RubyNode coerceFeatureToPath(RubyNode feature) {
13721371
@Specialization(guards = "isRubyString(featureString)")
13731372
public boolean require(DynamicObject featureString,
13741373
@Cached("create()") RequireNode requireNode) {
1375-
13761374
String feature = StringOperations.getString(featureString);
1377-
1378-
// TODO CS 1-Mar-15 ERB will use strscan if it's there, but strscan is not yet complete, so we need to hide it
1379-
if (feature.equals("strscan") && callerIs("mri/erb.rb")) {
1380-
throw new RaiseException(getContext(), coreExceptions().loadErrorCannotLoad(feature, this));
1381-
}
1382-
13831375
return requireNode.executeRequire(feature);
13841376
}
13851377

1386-
@TruffleBoundary
1387-
private boolean callerIs(String caller) {
1388-
final Backtrace backtrace = getContext().getCallStack().getBacktrace(this);
1389-
1390-
for (Activation activation : backtrace.getActivations()) {
1391-
final Node callNode = activation.getCallNode();
1392-
final Source source = callNode == null ? null : callNode.getEncapsulatingSourceSection().getSource();
1393-
1394-
if (source != null && source.getName().endsWith(caller)) {
1395-
return true;
1396-
}
1397-
}
1398-
1399-
return false;
1400-
}
14011378
}
14021379

14031380
@CoreMethod(names = "require_relative", isModuleFunction = true, required = 1)

0 commit comments

Comments
 (0)