regress-5901-1.js 968 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// 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() {
  throw new Error();
}

function g() {
  try {
    f();
  } catch (e) {
    return 1;  // Break
  }
}

function h() {
  return g();
}

21
%PrepareFunctionForOptimization(h);
22 23 24 25 26 27 28 29 30 31
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.Exception) {
    step_count++;
32
    exec_state.prepareStep(Debug.StepAction.StepOver);
33 34 35 36 37 38 39 40 41 42 43 44 45
  } else if (event == Debug.DebugEvent.Break) {
    step_count++;
    try {
      assertTrue(exec_state.frame().sourceLineText().includes('Break'));
    } catch (e) {
      exception = e;
      print(e);
    }
  }
}

Debug.setListener(listener);
Debug.setBreakOnException();
46
%OptimizeFunctionOnNextCall(h);
47 48 49
h();
Debug.setListener(null);
assertNull(exception);