60fdd3ba36
Added a parameter to Object::FitsRepresentation() to disallow coercion. Normally, when we ask if a Smi can "fit" into a Double representation we'd answer yes, because the Smi can be converted to a HeapNumber. However, from the compilers perspective, the object is found in a field with a particular representation. In this case, finding a Smi in a field with representation Double means something is awry. Therefore, it's useful for the compiler to be able to ask if the object fits the field without coercion. Bug: chromium:1227324, v8:7790 Change-Id: I12033736030d904ef9c29516c07999600a5f508a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3015570 Commit-Queue: Michael Stanton <mvstanton@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#75706}
24 lines
617 B
JavaScript
24 lines
617 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 --concurrent-inlining
|
|
|
|
(function() {
|
|
var use_symbol = {
|
|
[Symbol.hasInstance] : () => true
|
|
};
|
|
var use_symbol_double = {
|
|
[Symbol.hasInstance] : 0.1
|
|
};
|
|
function bar(b) {
|
|
if (b) return {} instanceof use_symbol_double;
|
|
}
|
|
%PrepareFunctionForOptimization(bar);
|
|
function foo(b) { return bar(); }
|
|
%PrepareFunctionForOptimization(foo);
|
|
foo();
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
foo();
|
|
})();
|