blob: 0c65a8644b86f8f7db3dcd610e0d70b6e13c96f0 [file] [log] [blame]
Mike Fleming3933d922018-04-02 10:53:08 -07001// Copyright 2017 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
7Debug = debug.Debug;
8var listened = false;
9
10function listener(event, exec_state, event_data, data) {
11 if (event != Debug.DebugEvent.Break) return;
12 try {
13 var foo_arguments = exec_state.frame(1).evaluate("arguments").value();
14 var bar_arguments = exec_state.frame(0).evaluate("arguments").value();
15 assertArrayEquals(foo_expected, foo_arguments);
16 assertArrayEquals(bar_expected, bar_arguments);
17 listened = true;
18 } catch (e) {
19 print(e);
20 print(e.stack);
21 }
22}
23
24Debug.setListener(listener);
25
26function foo(a) {
27 function bar(a,b,c) {
28 debugger;
29 return a + b + c;
30 }
31 return bar(1,2,a);
32}
Andrew Top63c7ad42019-11-25 16:10:13 -080033%PrepareFunctionForOptimization(foo);
Mike Fleming3933d922018-04-02 10:53:08 -070034
35listened = false;
36foo_expected = [3];
37bar_expected = [1,2,3];
38assertEquals(6, foo(3));
39assertTrue(listened);
40
41listened = false;
42foo_expected = [3];
43bar_expected = [1,2,3];
44assertEquals(6, foo(3));
45assertTrue(listened);
46
47listened = false;
48foo_expected = [3];
49bar_expected = [1,2,3];
50%OptimizeFunctionOnNextCall(foo);
51assertEquals(6, foo(3));
52assertTrue(listened);
53
54listened = false;
55foo_expected = [3,4,5];
56bar_expected = [1,2,3];
Andrew Top63c7ad42019-11-25 16:10:13 -080057%PrepareFunctionForOptimization(foo);
Mike Fleming3933d922018-04-02 10:53:08 -070058%OptimizeFunctionOnNextCall(foo);
59assertEquals(6, foo(3,4,5));
60assertTrue(listened);
61
62Debug.setListener(null);