• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax
6
7var boom = { valueOf: function() { throw "boom" } };
8
9function mult_left_plain(x) {
10  try {
11    return 2 * x;
12  } catch (e) {
13    return e;
14  }
15}
16
17%OptimizeFunctionOnNextCall(mult_left_plain);
18assertEquals("boom", mult_left_plain(boom));
19assertEquals(46, mult_left_plain(23));
20
21function mult_right_plain(x) {
22  try {
23    return x * 3;
24  } catch (e) {
25    return e;
26  }
27}
28
29%OptimizeFunctionOnNextCall(mult_right_plain);
30assertEquals("boom", mult_right_plain(boom));
31assertEquals(69, mult_right_plain(23));
32
33function mult_none_plain(x,y) {
34  try {
35    return x * y;
36  } catch (e) {
37    return e;
38  }
39}
40
41%OptimizeFunctionOnNextCall(mult_none_plain);
42assertEquals("boom", mult_none_plain(boom, boom));
43assertEquals("boom", mult_none_plain(boom, 2));
44assertEquals("boom", mult_none_plain(2, boom));
45assertEquals(966, mult_none_plain(23, 42));
46