| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 | 1216 |
| 1217 // Flood the function with break points. | 1217 // Flood the function with break points. |
| 1218 BreakLocationIterator it(GetDebugInfo(shared), ALL_BREAK_LOCATIONS); | 1218 BreakLocationIterator it(GetDebugInfo(shared), ALL_BREAK_LOCATIONS); |
| 1219 while (!it.Done()) { | 1219 while (!it.Done()) { |
| 1220 it.SetOneShot(); | 1220 it.SetOneShot(); |
| 1221 it.Next(); | 1221 it.Next(); |
| 1222 } | 1222 } |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 | 1225 |
| 1226 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { |
| 1227 Handle<FixedArray> new_bindings(function->function_bindings()); |
| 1228 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex)); |
| 1229 |
| 1230 if (!bindee.is_null() && bindee->IsJSFunction() && |
| 1231 !JSFunction::cast(*bindee)->IsBuiltin()) { |
| 1232 Handle<SharedFunctionInfo> shared_info(JSFunction::cast(*bindee)->shared()); |
| 1233 Debug::FloodWithOneShot(shared_info); |
| 1234 } |
| 1235 } |
| 1236 |
| 1237 |
| 1226 void Debug::FloodHandlerWithOneShot() { | 1238 void Debug::FloodHandlerWithOneShot() { |
| 1227 // Iterate through the JavaScript stack looking for handlers. | 1239 // Iterate through the JavaScript stack looking for handlers. |
| 1228 StackFrame::Id id = break_frame_id(); | 1240 StackFrame::Id id = break_frame_id(); |
| 1229 if (id == StackFrame::NO_ID) { | 1241 if (id == StackFrame::NO_ID) { |
| 1230 // If there is no JavaScript stack don't do anything. | 1242 // If there is no JavaScript stack don't do anything. |
| 1231 return; | 1243 return; |
| 1232 } | 1244 } |
| 1233 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { | 1245 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { |
| 1234 JavaScriptFrame* frame = it.frame(); | 1246 JavaScriptFrame* frame = it.frame(); |
| 1235 if (frame->HasHandler()) { | 1247 if (frame->HasHandler()) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 // ... | 1447 // ... |
| 1436 // arg0 | 1448 // arg0 |
| 1437 // Receiver | 1449 // Receiver |
| 1438 // Function to call | 1450 // Function to call |
| 1439 int expressions_count = frame->ComputeExpressionsCount(); | 1451 int expressions_count = frame->ComputeExpressionsCount(); |
| 1440 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); | 1452 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); |
| 1441 Object* fun = frame->GetExpression( | 1453 Object* fun = frame->GetExpression( |
| 1442 expressions_count - 2 - call_function_arg_count); | 1454 expressions_count - 2 - call_function_arg_count); |
| 1443 if (fun->IsJSFunction()) { | 1455 if (fun->IsJSFunction()) { |
| 1444 Handle<JSFunction> js_function(JSFunction::cast(fun)); | 1456 Handle<JSFunction> js_function(JSFunction::cast(fun)); |
| 1445 // Don't step into builtins. | 1457 if (js_function->shared()->bound()) { |
| 1446 if (!js_function->IsBuiltin()) { | 1458 Debug::FloodBoundFunctionWithOneShot(js_function); |
| 1459 } else if (!js_function->IsBuiltin()) { |
| 1460 // Don't step into builtins. |
| 1447 // It will also compile target function if it's not compiled yet. | 1461 // It will also compile target function if it's not compiled yet. |
| 1448 FloodWithOneShot(Handle<SharedFunctionInfo>(js_function->shared())); | 1462 FloodWithOneShot(Handle<SharedFunctionInfo>(js_function->shared())); |
| 1449 } | 1463 } |
| 1450 } | 1464 } |
| 1451 } | 1465 } |
| 1452 | 1466 |
| 1453 // Fill the current function with one-shot break points even for step in on | 1467 // Fill the current function with one-shot break points even for step in on |
| 1454 // a call target as the function called might be a native function for | 1468 // a call target as the function called might be a native function for |
| 1455 // which step in will not stop. It also prepares for stepping in | 1469 // which step in will not stop. It also prepares for stepping in |
| 1456 // getters/setters. | 1470 // getters/setters. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 if (is_constructor) { | 1646 if (is_constructor) { |
| 1633 ASSERT(it.frame()->is_construct()); | 1647 ASSERT(it.frame()->is_construct()); |
| 1634 it.Advance(); | 1648 it.Advance(); |
| 1635 } | 1649 } |
| 1636 fp = it.frame()->fp(); | 1650 fp = it.frame()->fp(); |
| 1637 } | 1651 } |
| 1638 | 1652 |
| 1639 // Flood the function with one-shot break points if it is called from where | 1653 // Flood the function with one-shot break points if it is called from where |
| 1640 // step into was requested. | 1654 // step into was requested. |
| 1641 if (fp == step_in_fp()) { | 1655 if (fp == step_in_fp()) { |
| 1642 // Don't allow step into functions in the native context. | 1656 if (function->shared()->bound()) { |
| 1643 if (!function->IsBuiltin()) { | 1657 // Handle Function.prototype.bind |
| 1658 Debug::FloodBoundFunctionWithOneShot(function); |
| 1659 } else if (!function->IsBuiltin()) { |
| 1660 // Don't allow step into functions in the native context. |
| 1644 if (function->shared()->code() == | 1661 if (function->shared()->code() == |
| 1645 Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply) || | 1662 Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply) || |
| 1646 function->shared()->code() == | 1663 function->shared()->code() == |
| 1647 Isolate::Current()->builtins()->builtin(Builtins::kFunctionCall)) { | 1664 Isolate::Current()->builtins()->builtin(Builtins::kFunctionCall)) { |
| 1648 // Handle function.apply and function.call separately to flood the | 1665 // Handle function.apply and function.call separately to flood the |
| 1649 // function to be called and not the code for Builtins::FunctionApply or | 1666 // function to be called and not the code for Builtins::FunctionApply or |
| 1650 // Builtins::FunctionCall. The receiver of call/apply is the target | 1667 // Builtins::FunctionCall. The receiver of call/apply is the target |
| 1651 // function. | 1668 // function. |
| 1652 if (!holder.is_null() && holder->IsJSFunction() && | 1669 if (!holder.is_null() && holder->IsJSFunction() && |
| 1653 !JSFunction::cast(*holder)->IsBuiltin()) { | 1670 !JSFunction::cast(*holder)->IsBuiltin()) { |
| (...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3562 { | 3579 { |
| 3563 Locker locker; | 3580 Locker locker; |
| 3564 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3581 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
| 3565 } | 3582 } |
| 3566 } | 3583 } |
| 3567 } | 3584 } |
| 3568 | 3585 |
| 3569 #endif // ENABLE_DEBUGGER_SUPPORT | 3586 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3570 | 3587 |
| 3571 } } // namespace v8::internal | 3588 } } // namespace v8::internal |
| OLD | NEW |