v8/test/mjsunit/harmony/regress/regress-4755.js
mstarzinger 38915ed71c [fullcodegen] Implement operand stack depth tracking.
This implements a mechanism to track the exact depth of the operand
stack in full-codegen for every sub-expression visitation. So far we
only tracked the depth at statement level, but not at expression level.
With the introduction of do-expressions it will be possible to construct
local control flow (i.e. break, continue and friends) that target labels
at an arbitrary operand stack depth, making this tracking a prerequisite
for full do-expression support.

R=rossberg@chromium.org,jarin@chromium.org
BUG=v8:4755,v8:4488
LOG=n

Review URL: https://codereview.chromium.org/1706283002

Cr-Commit-Position: refs/heads/master@{#34211}
2016-02-23 13:41:44 +00:00

46 lines
1.2 KiB
JavaScript

// Copyright 2016 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 --harmony-do-expressions
(function DoTryCatchInsideBinop() {
function f(a, b) {
return a + do { try { throw "boom" } catch(e) { b } }
}
assertEquals(3, f(1, 2));
assertEquals(3, f(1, 2));
%OptimizeFunctionOnNextCall(f);
assertEquals(3, f(1, 2));
})();
(function DoTryCatchInsideCall() {
function f(a, b) {
return Math.max(a, do { try { throw a } catch(e) { e + b } })
}
assertEquals(3, f(1, 2));
assertEquals(3, f(1, 2));
%OptimizeFunctionOnNextCall(f);
assertEquals(3, f(1, 2));
})();
(function DoTryCatchInsideTry() {
function f(a, b) {
try { return do { try { throw a } catch(e) { e + b } } } catch(e) {}
}
assertEquals(3, f(1, 2));
assertEquals(3, f(1, 2));
%OptimizeFunctionOnNextCall(f);
assertEquals(3, f(1, 2));
})();
(function DoTryCatchInsideFinally() {
function f(a, b) {
try {} finally { return do { try { throw a } catch(e) { e + b } } }
}
assertEquals(3, f(1, 2));
assertEquals(3, f(1, 2));
%OptimizeFunctionOnNextCall(f);
assertEquals(3, f(1, 2));
})();