v8/test/mjsunit/compiler/inline-private-method.js
Shu-yu Guo d19a707d14 [compiler] Fix typing JSLoadNamed of private brands
Private method loads are compiled to a named load of a private brand,
which always loads a BlockContext. This BlockContext holds the private
methods common to all instances of a class. TurboFan currently considers
JSLoadNamed to be of Type::NonInternal(). Private methods break this
assumption, since BlockContext is of Type::OtherInternal().

This CL changes the typing of JSLoadNamed of private brands to be
Type::OtherInternal().

Bug: v8:12500
Change-Id: I91f39747bf9422bd419d299f44152f567d8be8db
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3351167
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78431}
2021-12-22 16:32:44 +00:00

23 lines
521 B
JavaScript

// Copyright 2021 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
class A {
a() { this.#b() }
#b() {}
}
function InlinePrivateMethod() {
for (let i = 0; i < 10; i++) {
new A().a();
}
}
%PrepareFunctionForOptimization(A);
%PrepareFunctionForOptimization(InlinePrivateMethod);
InlinePrivateMethod();
%OptimizeFunctionOnNextCall(InlinePrivateMethod);
InlinePrivateMethod();