@@ -214,20 +214,22 @@ public Activation[] getActivations(Throwable truffleException) {
214
214
final RubyContext context = RubyLanguage .getCurrentContext ();
215
215
final CallStackManager callStackManager = context .getCallStack ();
216
216
217
- int i = 0 ;
217
+ int elementCount = 0 ;
218
+ int activationCount = 0 ;
218
219
for (TruffleStackTraceElement stackTraceElement : stackTrace ) {
219
- if (i < omitted ) {
220
- ++i ;
221
- continue ;
222
- }
223
-
224
- assert i != 0 || stackTraceElement .getLocation () == location ;
220
+ assert elementCount != 0 || stackTraceElement .getLocation () == location ;
225
221
final Node callNode = stackTraceElement .getLocation ();
222
+ ++elementCount ;
226
223
227
224
if (callStackManager .ignoreFrame (callNode , stackTraceElement .getTarget ())) {
228
225
continue ;
229
226
}
230
227
228
+ if (activationCount < omitted ) {
229
+ ++activationCount ;
230
+ continue ;
231
+ }
232
+
231
233
final RootNode rootNode = stackTraceElement .getTarget ().getRootNode ();
232
234
final String methodName ;
233
235
if (rootNode instanceof RubyRootNode ) {
@@ -243,17 +245,17 @@ public Activation[] getActivations(Throwable truffleException) {
243
245
activations .add (new Activation (callNode , methodName ));
244
246
}
245
247
246
- i ++;
248
+ activationCount ++;
247
249
}
248
250
249
251
// If there are activations with a InternalMethod but no caller information above in the
250
252
// stack, then all of these activations are internal as they are not called from user code.
251
253
while (!activations .isEmpty () && activations .get (activations .size () - 1 ).getCallNode () == null ) {
252
254
activations .remove (activations .size () - 1 );
253
- --i ;
255
+ --activationCount ;
254
256
}
255
257
256
- this .totalUnderlyingActivations = i ;
258
+ this .totalUnderlyingActivations = activationCount ;
257
259
return this .activations = activations .toArray (new Activation [activations .size ()]);
258
260
}
259
261
@@ -306,10 +308,10 @@ public DynamicObject getBacktraceLocations(int length, Node node) {
306
308
: ArrayHelpers .createEmptyArray (context );
307
309
}
308
310
309
- // NOTE (norswap, 18 Dec 2019 )
310
- // TruffleStackTrace#getStackTrace (hence Backtrace#getActivations too) does not
311
- // always respect TruffleException#getStackTraceElementLimit(), so we need to use Math#min.
312
- // The reason: it doesn't count frames whose RootNode is internal towards the limit .
311
+ // NOTE (norswap, 08 Jan 2020 )
312
+ // It used to be that TruffleException#getStackTraceElementLimit() wasn't respected
313
+ // due to a mishandling of internal frames. That's why we used Math.min and not just
314
+ // length. Leaving it in just in case .
313
315
final int locationsLength = length < 0
314
316
? activationsLength + 1 + length
315
317
: Math .min (activationsLength , length );
0 commit comments