Skip to content

Commit c68a018

Browse files
committed
[Truffle] Lazily create the require node as it's only needed for autoloading modules.
1 parent 2d0e094 commit c68a018

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

truffle/src/main/java/org/jruby/truffle/nodes/dispatch/UnresolvedDispatchNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public UnresolvedDispatchNode(
4747
this.ignoreVisibility = ignoreVisibility;
4848
this.indirect = indirect;
4949
this.missingBehavior = missingBehavior;
50-
requireNode = KernelNodesFactory.RequireNodeFactory.create(context, getSourceSection(), new RubyNode[]{});
5150
}
5251

5352
@Override
@@ -203,6 +202,11 @@ private Object doRubyBasicObject(
203202
}
204203

205204
if (constant.isAutoload()) {
205+
if (requireNode == null) {
206+
CompilerDirectives.transferToInterpreter();
207+
requireNode = insert(KernelNodesFactory.RequireNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{}));
208+
}
209+
206210
module.removeConstant(this, (String) methodName);
207211

208212
requireNode.require((RubyString) constant.getValue());

0 commit comments

Comments
 (0)