Commit f03bebc7 authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] add mixed-stack tests.

R=jgruber@chromium.org, mstarzinger@chromium.org
BUG=v8:5265

Review-Url: https://codereview.chromium.org/2246483002
Cr-Commit-Position: refs/heads/master@{#38621}
parent a7c63607
......@@ -140,6 +140,46 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_InterpretFunctionOnNextCall) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
if (!function_object->IsJSFunction()) {
return isolate->heap()->undefined_value();
}
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
// Do not tier down if we are already on optimized code. Replacing optimized
// code without actual deoptimization can lead to funny bugs.
if (function->code()->kind() != Code::OPTIMIZED_FUNCTION &&
function->shared()->HasBytecodeArray()) {
function->ReplaceCode(*isolate->builtins()->InterpreterEntryTrampoline());
}
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_BaselineFunctionOnNextCall) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
if (!function_object->IsJSFunction()) {
return isolate->heap()->undefined_value();
}
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
// Do not tier down if we are already on optimized code. Replacing optimized
// code without actual deoptimization can lead to funny bugs.
if (function->code()->kind() != Code::OPTIMIZED_FUNCTION &&
function->code()->kind() != Code::FUNCTION) {
if (function->shared()->HasBaselineCode()) {
function->ReplaceCode(function->shared()->code());
} else {
function->MarkForBaseline();
}
}
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
HandleScope scope(isolate);
......
......@@ -836,6 +836,8 @@ namespace internal {
F(RunningInSimulator, 0, 1) \
F(IsConcurrentRecompilationSupported, 0, 1) \
F(OptimizeFunctionOnNextCall, -1, 1) \
F(InterpretFunctionOnNextCall, 1, 1) \
F(BaselineFunctionOnNextCall, 1, 1) \
F(OptimizeOsr, -1, 1) \
F(NeverOptimizeFunction, 1, 1) \
F(GetOptimizationStatus, -1, 1) \
......
// Copyright 2016 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: --expose-debug-as debug --allow-natives-syntax
Debug = debug.Debug
var exception = null;
var frame_depth = 10;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals(frame_depth, exec_state.frameCount());
assertTrue(/\/\/ Break$/.test(exec_state.frame(0).sourceLineText()));
assertEquals(12 - frame_depth, exec_state.frame(0).evaluate("x").value());
frame_depth--;
} catch (e) {
exception = e;
print(e + e.stack);
}
}
function ChooseCode(f, x) {
if (x == 1) {
Debug.setBreakPoint(factorial, 4);
}
switch (x % 2) {
case 0:
%BaselineFunctionOnNextCall(f);
break;
case 1:
%InterpretFunctionOnNextCall(f);
break;
}
}
function factorial(x) {
ChooseCode(factorial, x);
if (x == 1) return 1;
var factor = factorial(x - 1);
return x * factor; // Break
}
Debug.setListener(listener);
assertEquals(3628800, factorial(10));
Debug.setListener(null);
assertNull(exception);
assertEquals(1, frame_depth);
// Copyright 2016 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: --expose-debug-as debug --allow-natives-syntax
Debug = debug.Debug
var exception = null;
var frame_depth = 11;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals(frame_depth, exec_state.frameCount());
assertTrue(/\/\/ Break$/.test(exec_state.frame(0).sourceLineText()));
assertEquals(12 - frame_depth, exec_state.frame(0).evaluate("x").value());
if (frame_depth > 2) exec_state.prepareStep(Debug.StepAction.StepOut);
frame_depth--;
} catch (e) {
exception = e;
print(e + e.stack);
}
}
function ChooseCode(f, x) {
switch (x % 2) {
case 0:
%BaselineFunctionOnNextCall(f);
break;
case 1:
%InterpretFunctionOnNextCall(f);
break;
}
}
function factorial(x) {
ChooseCode(factorial, x);
if (x == 1) {
debugger; // Break
return 1;
}
var factor = factorial(x - 1);
return x * factor; // Break
}
Debug.setListener(listener);
assertEquals(3628800, factorial(10));
Debug.setListener(null);
assertNull(exception);
assertEquals(1, frame_depth);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment