Skip to content

Commit 784a7ae

Browse files
committed
Extract error formatting in a different method for host inlining
* 1188 -> 971 for org.truffleruby.language.SpecialVariablesSendingNode.getSpecialVariablesIfRequired
1 parent a11ad3b commit 784a7ae

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,7 @@ protected SpecialVariableStorage getFromKnownFrameDescriptor(Frame frame,
240240

241241
if (storageFrame == null) {
242242
CompilerDirectives.transferToInterpreterAndInvalidate();
243-
int depth = 0;
244-
MaterializedFrame currentFrame = RubyArguments.getDeclarationFrame(frame);
245-
while (currentFrame != null) {
246-
depth += 1;
247-
currentFrame = RubyArguments.getDeclarationFrame(currentFrame);
248-
}
249-
250-
String message = String.format(
251-
"Expected %d declaration frames but only found %d frames.",
252-
declarationFrameDepth,
253-
depth);
254-
throw CompilerDirectives.shouldNotReachHere(message);
243+
noStorageFrameError(frame, declarationFrameDepth);
255244
}
256245

257246
variables = SpecialVariableStorage.get(storageFrame);
@@ -282,6 +271,21 @@ public static SpecialVariableStorage getSlow(MaterializedFrame aFrame) {
282271
return (SpecialVariableStorage) variables;
283272
}
284273

274+
private static void noStorageFrameError(Frame frame, int declarationFrameDepth) {
275+
int depth = 0;
276+
MaterializedFrame currentFrame = RubyArguments.getDeclarationFrame(frame);
277+
while (currentFrame != null) {
278+
depth += 1;
279+
currentFrame = RubyArguments.getDeclarationFrame(currentFrame);
280+
}
281+
282+
String message = String.format(
283+
"Expected %d declaration frames but only found %d frames.",
284+
declarationFrameDepth,
285+
depth);
286+
throw CompilerDirectives.shouldNotReachHere(message);
287+
}
288+
285289
}
286290

287291
@Primitive(name = "caller_special_variables")

0 commit comments

Comments
 (0)