Michaël Zasso 918fe04351
deps: update V8 to 13.6.233.8
PR-URL: https://github.com/nodejs/node/pull/58070
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2025-05-02 15:06:53 +02:00

34 lines
1.0 KiB
JavaScript

// Copyright 2024 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.
// Flags: --allow-natives-syntax --turbolev --turbofan
// Testing exceptions (multiple throwing points, using the exception value).
function h(x) {
if (x) { willThrow(); }
else { return 17; }
}
%NeverOptimizeFunction(h);
function multi_exc_f(a, b) {
let r = a;
try {
r = h(a);
return h(b) + r;
} catch (e) {
// Stringifying the exception for easier comparison.
return 'abc' + e + r;
}
}
%PrepareFunctionForOptimization(multi_exc_f);
assertEquals(34, multi_exc_f(0, 0)); // Won't cause an exception.
let err1 = multi_exc_f(0, 11); // Will cause an exception on the 2nd call to h.
let err2 = multi_exc_f(7, 0); // Will cause an exception on the 1st call to h.
%OptimizeFunctionOnNextCall(multi_exc_f);
assertEquals(34, multi_exc_f(0, 0));
assertEquals(err1, multi_exc_f(0, 11));
assertEquals(err2, multi_exc_f(7, 0));
assertOptimized(multi_exc_f);