Reviewers: Yury Semikhatsky, Yang, Søren Thygesen Gjesse,
Description:
Debugger: naive implementation of "step into Function.prototype.bind".
Please review this at https://chromiumcodereview.appspot.com/9705018/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/debug.h
M src/debug.cc
M test/mjsunit/debug-stepin-function-call.js
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index
2058d48b71e431bf9a89816dbfc47bcf755f11d5..c4a6a95dfbc8fd5cd2c2a79acbc14c272c5ccd9c
100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -1223,6 +1223,18 @@ void
Debug::FloodWithOneShot(Handle<SharedFunctionInfo> shared) {
}
+void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) {
+ Handle<FixedArray> new_bindings(function->function_bindings());
+ Handle<Object>
bindee(new_bindings->get(JSFunction::kBoundFunctionIndex));
+
+ if (!bindee.is_null() && bindee->IsJSFunction() &&
+ !JSFunction::cast(*bindee)->IsBuiltin()) {
+ Handle<SharedFunctionInfo>
shared_info(JSFunction::cast(*bindee)->shared());
+ Debug::FloodWithOneShot(shared_info);
+ }
+}
+
+
void Debug::FloodHandlerWithOneShot() {
// Iterate through the JavaScript stack looking for handlers.
StackFrame::Id id = break_frame_id();
@@ -1443,7 +1455,11 @@ void Debug::PrepareStep(StepAction step_action, int
step_count) {
if (fun->IsJSFunction()) {
Handle<JSFunction> js_function(JSFunction::cast(fun));
// Don't step into builtins.
- if (!js_function->IsBuiltin()) {
+ if (js_function->IsBuiltin()) {
+ if (js_function->shared()->bound()) {
+ Debug::FloodBoundFunctionWithOneShot(js_function);
+ }
+ } else {
// It will also compile target function if it's not compiled yet.
FloodWithOneShot(Handle<SharedFunctionInfo>(js_function->shared()));
}
@@ -1639,8 +1655,11 @@ void Debug::HandleStepIn(Handle<JSFunction> function,
// Flood the function with one-shot break points if it is called from
where
// step into was requested.
if (fp == step_in_fp()) {
- // Don't allow step into functions in the native context.
- if (!function->IsBuiltin()) {
+ if (function->shared()->bound()) {
+ // Handle Function.prototype.bind
+ Debug::FloodBoundFunctionWithOneShot(function);
+ } else if (!function->IsBuiltin()) {
+ // Don't allow step into functions in the native context.
if (function->shared()->code() ==
Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply) ||
function->shared()->code() ==
Index: src/debug.h
diff --git a/src/debug.h b/src/debug.h
index
b9384e574dd224fc8992d32dabaf12112716b7e6..474b90bd215e02cabf0210d2014b21dba9059d30
100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -239,6 +239,7 @@ class Debug {
void ClearBreakPoint(Handle<Object> break_point_object);
void ClearAllBreakPoints();
void FloodWithOneShot(Handle<SharedFunctionInfo> shared);
+ void FloodBoundFunctionWithOneShot(Handle<JSFunction> function);
void FloodHandlerWithOneShot();
void ChangeBreakOnException(ExceptionBreakType type, bool enable);
bool IsBreakOnException(ExceptionBreakType type);
Index: test/mjsunit/debug-stepin-function-call.js
diff --git a/test/mjsunit/debug-stepin-function-call.js
b/test/mjsunit/debug-stepin-function-call.js
index
385fcb2f8bedc1a19d350df542e66d5756af20cd..76da43ebdea7a1dc5f7ce5167e7cf60cbf46621e
100644
--- a/test/mjsunit/debug-stepin-function-call.js
+++ b/test/mjsunit/debug-stepin-function-call.js
@@ -135,8 +135,15 @@ function apply4() {
var yetAnotherLocal = 10;
}
+// Test step into bound function.
+function bind1() {
+ var bound = g.bind(null, 3);
+ debugger;
+ bound();
+}
+
var testFunctions =
- [call1, call2, call3, call4, apply1, apply2, apply3, apply4];
+ [call1, call2, call3, call4, apply1, apply2, apply3, apply4, bind1];
for (var i = 0; i < testFunctions.length; i++) {
state = 0;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev