|
50 | 50 | import com.oracle.truffle.api.TruffleSafepoint.Interrupter;
|
51 | 51 | import com.oracle.truffle.api.dsl.Bind;
|
52 | 52 | import com.oracle.truffle.api.TruffleStackTraceElement;
|
53 |
| -import com.oracle.truffle.api.frame.FrameInstance; |
54 | 53 | import com.oracle.truffle.api.frame.VirtualFrame;
|
55 | 54 | import com.oracle.truffle.api.profiles.InlinedBranchProfile;
|
56 | 55 | import com.oracle.truffle.api.profiles.InlinedConditionProfile;
|
@@ -1048,44 +1047,38 @@ protected Object runBlockingSystemCall(Object executable, RubyArray argsArray,
|
1048 | 1047 | @CoreMethod(names = "each_caller_location", needsBlock = true, onSingleton = true)
|
1049 | 1048 | public abstract static class EachCallerLocationNode extends CoreMethodArrayArgumentsNode {
|
1050 | 1049 |
|
1051 |
| - private static final Object STOP_ITERATE = new Object(); |
1052 |
| - |
1053 | 1050 | // Skip the block of `Thread#each_caller_location` + its internal iteration.
|
1054 | 1051 | private static final int SKIP = 2;
|
1055 | 1052 |
|
1056 | 1053 | @Child private CallBlockNode yieldNode = CallBlockNode.create();
|
1057 | 1054 |
|
1058 | 1055 | @Specialization
|
1059 | 1056 | protected Object eachCallerLocation(VirtualFrame frame, RubyProc block) {
|
1060 |
| - final List<TruffleStackTraceElement> stackTraceElements = new ArrayList<>(); |
| 1057 | + final List<TruffleStackTraceElement> elements = new ArrayList<>(); |
1061 | 1058 |
|
1062 | 1059 | getContext().getCallStack().iterateFrameBindings(SKIP, frameInstance -> {
|
1063 | 1060 | final Node location = frameInstance.getCallNode();
|
1064 | 1061 |
|
1065 |
| - final RootCallTarget rootCallTarget = (RootCallTarget) frameInstance.getCallTarget(); |
1066 |
| - final TruffleStackTraceElement stackTraceElement = TruffleStackTraceElement.create( |
1067 |
| - location, |
1068 |
| - rootCallTarget, |
1069 |
| - frameInstance.getFrame(FrameInstance.FrameAccess.READ_ONLY)); |
1070 |
| - stackTraceElements.add(stackTraceElement); |
| 1062 | + final var rootCallTarget = (RootCallTarget) frameInstance.getCallTarget(); |
| 1063 | + final var element = TruffleStackTraceElement.create(location, rootCallTarget, null); |
| 1064 | + elements.add(element); |
1071 | 1065 |
|
1072 |
| - final TruffleStackTraceElement[] finalStackTraceElements = stackTraceElements |
1073 |
| - .toArray(TruffleStackTraceElement[]::new); |
1074 |
| - final boolean readyToYield = BacktraceFormatter.nextAvailableSourceSection(finalStackTraceElements, |
| 1066 | + final var elementsArray = elements.toArray(Backtrace.EMPTY_STACK_TRACE_ELEMENTS_ARRAY); |
| 1067 | + final boolean readyToYield = BacktraceFormatter.nextAvailableSourceSection(elementsArray, |
1075 | 1068 | 0) != null;
|
1076 | 1069 |
|
1077 | 1070 | if (readyToYield) {
|
1078 |
| - for (int i = 0; i < finalStackTraceElements.length; i++) { |
1079 |
| - final Backtrace backtrace = new Backtrace(location, 0, finalStackTraceElements); |
1080 |
| - RubyBacktraceLocation rubyBacktraceLocation = new RubyBacktraceLocation( |
| 1071 | + for (int i = 0; i < elementsArray.length; i++) { |
| 1072 | + final var backtrace = new Backtrace(location, 0, elementsArray); |
| 1073 | + final var rubyBacktraceLocation = new RubyBacktraceLocation( |
1081 | 1074 | getContext().getCoreLibrary().threadBacktraceLocationClass,
|
1082 | 1075 | getLanguage().threadBacktraceLocationShape,
|
1083 | 1076 | backtrace,
|
1084 | 1077 | i);
|
1085 | 1078 |
|
1086 | 1079 | yieldNode.yield(block, rubyBacktraceLocation);
|
1087 | 1080 | }
|
1088 |
| - stackTraceElements.clear(); |
| 1081 | + elements.clear(); |
1089 | 1082 | }
|
1090 | 1083 |
|
1091 | 1084 | return null;
|
|
0 commit comments