mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 17:51:35 +00:00

PR-URL: https://github.com/nodejs/node/pull/28016 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
63 lines
1.4 KiB
JavaScript
63 lines
1.4 KiB
JavaScript
// Copyright 2017 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
|
|
|
|
Debug = debug.Debug;
|
|
var listened = false;
|
|
|
|
function listener(event, exec_state, event_data, data) {
|
|
if (event != Debug.DebugEvent.Break) return;
|
|
try {
|
|
var foo_arguments = exec_state.frame(1).evaluate("arguments").value();
|
|
var bar_arguments = exec_state.frame(0).evaluate("arguments").value();
|
|
assertArrayEquals(foo_expected, foo_arguments);
|
|
assertArrayEquals(bar_expected, bar_arguments);
|
|
listened = true;
|
|
} catch (e) {
|
|
print(e);
|
|
print(e.stack);
|
|
}
|
|
}
|
|
|
|
Debug.setListener(listener);
|
|
|
|
function foo(a) {
|
|
function bar(a,b,c) {
|
|
debugger;
|
|
return a + b + c;
|
|
}
|
|
return bar(1,2,a);
|
|
}
|
|
%PrepareFunctionForOptimization(foo);
|
|
|
|
listened = false;
|
|
foo_expected = [3];
|
|
bar_expected = [1,2,3];
|
|
assertEquals(6, foo(3));
|
|
assertTrue(listened);
|
|
|
|
listened = false;
|
|
foo_expected = [3];
|
|
bar_expected = [1,2,3];
|
|
assertEquals(6, foo(3));
|
|
assertTrue(listened);
|
|
|
|
listened = false;
|
|
foo_expected = [3];
|
|
bar_expected = [1,2,3];
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertEquals(6, foo(3));
|
|
assertTrue(listened);
|
|
|
|
listened = false;
|
|
foo_expected = [3,4,5];
|
|
bar_expected = [1,2,3];
|
|
%PrepareFunctionForOptimization(foo);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertEquals(6, foo(3,4,5));
|
|
assertTrue(listened);
|
|
|
|
Debug.setListener(null);
|