node/deps/v8/test/mjsunit/compiler/fast-api-calls-nested.js
Michaël Zasso 7772a2df9d
deps: update V8 to 14.1.146.11
PR-URL: https://github.com/nodejs/node/pull/59805
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2025-10-04 18:47:18 +02:00

28 lines
780 B
JavaScript

// Copyright 2025 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: --expose-gc --expose-fast-api --allow-natives-syntax --turbofan --deopt-every-n-times=0 --stress-compaction
const my_object = {
toString: function() {
gc();
return 2;
}
};
function foo(fast_c_api) {
// Fast API call that calls back to JS because of ToNumber() on my_object:
return fast_c_api.call_to_number(my_object);
}
const fast_c_api = new d8.test.FastCAPI();
%PrepareFunctionForOptimization(foo);
foo(fast_c_api);
%OptimizeFunctionOnNextCall(foo);
foo(fast_c_api);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(1, fast_c_api.slow_call_count());