Commit a3991ed4 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

[debug] correctly get arg count for optimized builtin frames.

R=jgruber@chromium.org

Bug: v8:178
Change-Id: Ie2279c8a1bb50d01186dbd9dd29145bca9aeaf6f
Reviewed-on: https://chromium-review.googlesource.com/972983
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52106}
parent b8ae2249
......@@ -1014,10 +1014,18 @@ Code* JavaScriptFrame::unchecked_code() const {
int JavaScriptFrame::GetNumberOfIncomingArguments() const {
DCHECK(can_access_heap_objects() &&
isolate()->heap()->gc_state() == Heap::NOT_IN_GC);
return function()->shared()->internal_formal_parameter_count();
}
int OptimizedFrame::GetNumberOfIncomingArguments() const {
Code* code = LookupCode();
if (code->kind() == Code::BUILTIN) {
return static_cast<int>(
Memory::intptr_at(fp() + OptimizedBuiltinFrameConstants::kArgCOffset));
} else {
return JavaScriptFrame::GetNumberOfIncomingArguments();
}
}
Address JavaScriptFrame::GetCallerStackPointer() const {
return fp() + StandardFrameConstants::kCallerSPOffset;
......
......@@ -848,6 +848,8 @@ class OptimizedFrame : public JavaScriptFrame {
protected:
inline explicit OptimizedFrame(StackFrameIteratorBase* iterator);
int GetNumberOfIncomingArguments() const override;
private:
friend class StackFrameIteratorBase;
......
......@@ -1569,6 +1569,42 @@ TEST(BreakPointConditionBuiltin) {
ExpectString("f(10)", "aaaaaaaaaaaaaaaaaaaa");
CHECK_EQ(1, break_point_hit_count);
// === Test var-arg builtins ===
break_point_hit_count = 0;
builtin = CompileRun("String.fromCharCode").As<v8::Function>();
CompileRun("function f() { return String.fromCharCode(1, 2, 3); }");
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint.
bp = SetBreakPoint(builtin, 0, "arguments.length == 3 && arguments[1] == 2");
CompileRun("f(1, 2, 3)");
CHECK_EQ(1, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
CompileRun("f(1, 2, 3)");
CHECK_EQ(1, break_point_hit_count);
// === Test rest arguments ===
break_point_hit_count = 0;
builtin = CompileRun("String.fromCharCode").As<v8::Function>();
CompileRun("function f(...args) { return String.fromCharCode(...args); }");
CHECK_EQ(0, break_point_hit_count);
// Run with breakpoint.
bp = SetBreakPoint(builtin, 0, "arguments.length == 3 && arguments[1] == 2");
CompileRun("f(1, 2, 3)");
CHECK_EQ(1, break_point_hit_count);
ClearBreakPoint(bp);
CompileRun("f(1, 3, 3)");
CHECK_EQ(1, break_point_hit_count);
// Run without breakpoints.
ClearBreakPoint(bp);
CompileRun("f(1, 2, 3)");
CHECK_EQ(1, break_point_hit_count);
// === Test receiver ===
break_point_hit_count = 0;
builtin = CompileRun("String.prototype.repeat").As<v8::Function>();
......
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