v8/test/mjsunit/maglev/argument-over-under-application.js
Leszek Swirski 4fd61de7c1 [maglev] Fix over application return stack cleanup
Under over-application (passing more arguments into a function than its
formal parameter count), we need to use the passed argc to clean up the
stack, rather than the formal parameter count. Fix Maglev's Return node
code to do the appropriate check and dynamic sized return.

Bug: v8:7700
Change-Id: I36037d29e14323b336974d4b75b75f5702ce8a28
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3555767
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79649}
2022-03-29 10:39:28 +00:00

22 lines
651 B
JavaScript

// Copyright 2022 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: --maglev --allow-natives-syntax
function f(x) {
return x;
}
%PrepareFunctionForOptimization(f);
// f(x) takes one argument but we are under-applying here
assertEquals(undefined, f());
// f(x) takes one argument but we are over-applying here
assertEquals(1, f(1, 2));
%OptimizeMaglevOnNextCall(f);
// f(x) takes one argument but we are under-applying here
assertEquals(undefined, f());
// f(x) takes one argument but we are over-applying here
assertEquals(1, f(1, 2));