69a645d3c6
Adds typed lowering of JSStringConcat to ConsString allocation if the following conditions hold: - All concatinations will result in a ConsString of >= ConString::kMinLength - No concatinations will result in a empty string in the RHS unless there is a sequential string in the LHS. This also means JSStringConcat needs an eager checkpoint since it can deopt if throwing a RangeError when the string length protector is valid. BUG=v8:6243 Change-Id: I01ca79f884df467c10f2c032c72d51b5199c1a3c Reviewed-on: https://chromium-review.googlesource.com/526636 Commit-Queue: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> Cr-Commit-Position: refs/heads/master@{#46093}
29 lines
704 B
JavaScript
29 lines
704 B
JavaScript
// Copyright 2017 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
|
|
|
|
var a = "a".repeat(268435440);
|
|
|
|
(function() {
|
|
function foo(a) {
|
|
try {
|
|
return "longer than ConsString:kMinLength" + a + "0123456789012";
|
|
} catch (e) {
|
|
return e;
|
|
}
|
|
}
|
|
|
|
foo("a");
|
|
foo("a");
|
|
// Optimize with string length protector check.
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
foo("a");
|
|
assertInstanceof(foo(a), RangeError);
|
|
// Optimize without string length protector check.
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
foo("a");
|
|
assertInstanceof(foo(a), RangeError);
|
|
})();
|