f78392d53f
The serializer doesn't correctly propagate environment information from try blocks into their catch handlers, and this impedes optimizations that fire when we compile concurrently. function bar(x) { try { boom(); // throws } catch(_) { return x.a; } } function foo() { return bar({a: 42}); } When foo is optimized, we can normally return the constant 42 directly. This CL makes that work for concurrent inlining. Bug: v8:7790 Change-Id: Id1c5fd06d51ec6fe69ab10fbd65afd6fa7e76820 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1863193 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Commit-Queue: Michael Stanton <mvstanton@chromium.org> Cr-Commit-Position: refs/heads/master@{#64352}
68 lines
1.1 KiB
JavaScript
68 lines
1.1 KiB
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
|
|
|
|
const obj = { a: 42 };
|
|
|
|
function boom() {
|
|
throw "boom";
|
|
}
|
|
|
|
// Ensure that we optimize the monomorphic case.
|
|
(function() {
|
|
function bar(x) {
|
|
try {
|
|
boom();
|
|
++i;
|
|
} catch(_) {
|
|
%TurbofanStaticAssert(x.a == 42);
|
|
return x.a;
|
|
}
|
|
}
|
|
|
|
function foo() {
|
|
return bar(obj);
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
%PrepareFunctionForOptimization(bar);
|
|
|
|
foo();
|
|
foo();
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
foo();
|
|
})();
|
|
|
|
// And the megamorphic case.
|
|
(function() {
|
|
function bar(x) {
|
|
try {
|
|
boom();
|
|
++i;
|
|
} catch(_) {
|
|
%TurbofanStaticAssert(x.a == 42);
|
|
return x.a;
|
|
}
|
|
}
|
|
|
|
function foo() {
|
|
return bar(obj);
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
%PrepareFunctionForOptimization(bar);
|
|
|
|
bar({b: 42});
|
|
bar({c: 42});
|
|
bar({d: 42});
|
|
bar({e: 42});
|
|
bar({f: 42});
|
|
|
|
foo();
|
|
foo();
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
foo();
|
|
})();
|