aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/regress/typed-array-lifetime.js
blob: db9a216531f03ee4128f14b0c9081af7e6fc529b (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
// 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 --typed-array-max-size-in-heap=1

var foo = (function () {
  var y = 0;
  return function foo(x) {
    // Needs to be an external array.
    var a = new Float64Array(32);
    a[0] = 42;
    y = x + 0.1;  // This has to allocate.
    return a[0];
  }
})();

foo(1);
foo(1);
%OptimizeFunctionOnNextCall(foo);
foo(1);
// Try to force a GC during allocation in above marked line.
for (var i = 0; i < 20; ++i) {
  %SetAllocationTimeout(i, i, false);
  assertEquals(42, foo(2));
}