v8/test/mjsunit/maglev/call-js-runtime.js
jameslahm dc8c911ad0 [maglev] Support CallJSRuntime
Bug: v8:7700
Change-Id: Iad4b8c8187dc99e811a90f66b05d0cd9e2713ec9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3815484
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#82250}
2022-08-08 09:04:51 +00:00

22 lines
556 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: --allow-natives-syntax --maglev --no-stress-opt --no-always-turbofan
function Bar(x) {
this.bar = x
}
function foo(x) {
return new Bar(...x, 1);
}
%PrepareFunctionForOptimization(foo);
assertEquals(1, foo([1]).bar);
assertEquals(2, foo([2]).bar);
%OptimizeMaglevOnNextCall(foo);
assertEquals(1, foo([1]).bar);
assertEquals(2, foo([2]).bar);
assertTrue(isMaglevved(foo));