2d26a2688a
Some string constant optimizations in JSNativeContextSpecialization assumed an incorrect maximal string length of double values. Bug: chromium:1189077, chromium:1178718 Change-Id: Iae531f0e323679a4490e666a971b66655c25c757 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2843361 Commit-Queue: Nico Hartmann <nicohartmann@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#74101}
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
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
|
|
|
|
const string_max_length = %StringMaxLength();
|
|
const longest_double = -2.2250738585105353E-308;
|
|
const s18 = "A".repeat(string_max_length - 18);
|
|
const s23 = "A".repeat(string_max_length - 23);
|
|
const s24 = "A".repeat(string_max_length - 24);
|
|
const s25 = "A".repeat(string_max_length - 25);
|
|
|
|
(function() {
|
|
function f() {
|
|
return s18 + longest_double;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(f);
|
|
assertThrows(f, RangeError);
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertThrows(f, RangeError);
|
|
})();
|
|
|
|
(function() {
|
|
function f() {
|
|
return s23 + longest_double;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(f);
|
|
assertThrows(f, RangeError);
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertThrows(f, RangeError);
|
|
})();
|
|
|
|
(function() {
|
|
function f() {
|
|
return s24 + longest_double;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(f);
|
|
assertEquals(string_max_length, f().length);
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals(string_max_length, f().length);
|
|
})();
|
|
|
|
(function() {
|
|
function f() {
|
|
return s25 + longest_double;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(f);
|
|
assertEquals(string_max_length - 1, f().length);
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals(string_max_length - 1, f().length);
|
|
})();
|