acadb20271
Add a fast path for String.p.startsWith(str) when length of str is 1. Bug: v8:8400 Change-Id: I65e657549902dc3ad064a213d815dd098ce6455f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1491872 Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#60091}
22 lines
651 B
JavaScript
22 lines
651 B
JavaScript
// Copyright 2019 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 --opt
|
|
|
|
(function() {
|
|
function foo(string) { return string.startsWith('a'); }
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertEquals(false, foo(''));
|
|
assertEquals(true, foo('a'));
|
|
assertEquals(false, foo('ba'));
|
|
assertEquals(true, foo('abc'));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertEquals(false, foo(''));
|
|
assertEquals(true, foo('a'));
|
|
assertEquals(false, foo('ba'));
|
|
assertEquals(true, foo('abc'));
|
|
assertOptimized(foo);
|
|
})();
|