regress-5901-2.js 903 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

function f() {
  debugger;
  return 1;
}

function g() {
11 12
  return f();  // Break
}
13 14 15 16 17

function h() {
  return g();
}

18
%PrepareFunctionForOptimization(h);
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
h();
h();

var Debug = debug.Debug;
var step_count = 0;
var exception = null;

function listener(event, exec_state, event_data, data) {
  if (event != Debug.DebugEvent.Break) return;
  try {
    if (step_count == 0) {
      exec_state.prepareStep(Debug.StepAction.StepOut);
    } else {
      assertTrue(exec_state.frame().sourceLineText().includes('Break'));
    }
    step_count++;
  } catch (e) {
    exception = e;
    print(e);
  }
}

Debug.setListener(listener);
42
%OptimizeFunctionOnNextCall(h);
43 44 45 46
h();
Debug.setListener(null);
assertNull(exception);
assertEquals(2, step_count);