2015-03-24 13:20:10 +00:00
|
|
|
// Copyright 2015 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 shouldThrow = false;
|
|
|
|
|
|
|
|
function h() {
|
|
|
|
try { // Prevent inlining in Crankshaft.
|
2019-06-12 14:00:50 +00:00
|
|
|
} catch (e) {
|
|
|
|
}
|
2015-03-24 13:20:10 +00:00
|
|
|
var res = g.arguments[0].x;
|
|
|
|
if (shouldThrow) {
|
|
|
|
throw res;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
function g(o) {
|
|
|
|
h();
|
|
|
|
}
|
2015-03-24 13:20:10 +00:00
|
|
|
|
|
|
|
function f1() {
|
2019-06-12 14:00:50 +00:00
|
|
|
var o = {x: 1};
|
2015-03-24 13:20:10 +00:00
|
|
|
g(o);
|
|
|
|
return o.x;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(f1);
|
2015-03-24 13:20:10 +00:00
|
|
|
function f2() {
|
2019-06-12 14:00:50 +00:00
|
|
|
var o = {x: 2};
|
2015-03-24 13:20:10 +00:00
|
|
|
g(o);
|
|
|
|
return o.x;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(f2);
|
2015-03-24 13:20:10 +00:00
|
|
|
f1();
|
|
|
|
f2();
|
|
|
|
f1();
|
|
|
|
f2();
|
|
|
|
%OptimizeFunctionOnNextCall(f1);
|
|
|
|
%OptimizeFunctionOnNextCall(f2);
|
|
|
|
shouldThrow = true;
|
2019-06-12 14:00:50 +00:00
|
|
|
try {
|
|
|
|
f1();
|
|
|
|
} catch (e) {
|
2015-03-24 13:20:10 +00:00
|
|
|
assertEquals(e, 1);
|
|
|
|
}
|
2019-06-12 14:00:50 +00:00
|
|
|
try {
|
|
|
|
f2();
|
|
|
|
} catch (e) {
|
2015-03-24 13:20:10 +00:00
|
|
|
assertEquals(e, 2);
|
|
|
|
}
|