v8/test/mjsunit/maglev/lda-global.js
jameslahm fc4483e740 [maglev] Support LdaGlobalInsideTypeof
Bug: v8:7700
Change-Id: I92596898718a57ea9d8fbd002306aa45a8e9a549
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3821206
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#82346}
2022-08-10 13:18:24 +00:00

24 lines
582 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
var b = 1;
function foo(x) {
return b + x
}
%PrepareFunctionForOptimization(foo);
assertEquals(2, foo(1));
assertEquals(3, foo(2));
%OptimizeMaglevOnNextCall(foo);
assertEquals(4, foo(3));
assertEquals(5, foo(4));
assertTrue(isMaglevved(foo));
// We should deopt here.
b = 2
assertEquals(7, foo(5));
assertFalse(isMaglevved(foo))