summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/compiler/number-constructor-deopt.js
blob: 33a13bd5bc1251a205dd5f67a8343c7e49ad017f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2018 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

// This test writes {} to x to trigger lazy deopt
// from inside the number constructor.
var x = "5";
var b = false;

check = function() {
  if (b) x = {};
  return 0;
}

var obj = {};
obj.valueOf = check;

function f() {
  try {
    return x + Number(obj);
  } catch(e) {
    console.log(e.stack);
  }
}

%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
b = true;
f();