Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/debug.cc

Issue 725983002: Classes: Add support for stepping through default constructors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Refactor to share code Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug.h ('k') | test/mjsunit/harmony/debug-step-into-class-extends.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 1218
1219 1219
1220 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { 1220 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) {
1221 Handle<FixedArray> new_bindings(function->function_bindings()); 1221 Handle<FixedArray> new_bindings(function->function_bindings());
1222 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), 1222 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex),
1223 isolate_); 1223 isolate_);
1224 1224
1225 if (!bindee.is_null() && bindee->IsJSFunction() && 1225 if (!bindee.is_null() && bindee->IsJSFunction() &&
1226 !JSFunction::cast(*bindee)->IsFromNativeScript()) { 1226 !JSFunction::cast(*bindee)->IsFromNativeScript()) {
1227 Handle<JSFunction> bindee_function(JSFunction::cast(*bindee)); 1227 Handle<JSFunction> bindee_function(JSFunction::cast(*bindee));
1228 FloodWithOneShot(bindee_function); 1228 FloodWithOneShotGeneric(bindee_function);
1229 } 1229 }
1230 } 1230 }
1231 1231
1232
1233 void Debug::FloodDefaultConstructorWithOneShot(Handle<JSFunction> function) {
1234 DCHECK(function->shared()->is_default_constructor());
1235 // Instead of stepping into the function we directly step into the super class
1236 // constructor.
1237 Isolate* isolate = function->GetIsolate();
1238 PrototypeIterator iter(isolate, function);
1239 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
1240 if (!proto->IsJSFunction()) return; // Object.prototype
1241 Handle<JSFunction> function_proto = Handle<JSFunction>::cast(proto);
1242 FloodWithOneShotGeneric(function_proto);
1243 }
1244
1245
1246 void Debug::FloodWithOneShotGeneric(Handle<JSFunction> function,
1247 Handle<Object> holder) {
1248 if (function->shared()->bound()) {
1249 FloodBoundFunctionWithOneShot(function);
1250 } else if (function->shared()->is_default_constructor()) {
1251 FloodDefaultConstructorWithOneShot(function);
1252 } else if (!function->IsFromNativeScript()) {
1253 Isolate* isolate = function->GetIsolate();
1254 // Don't allow step into functions in the native context.
1255 if (function->shared()->code() ==
1256 isolate->builtins()->builtin(Builtins::kFunctionApply) ||
1257 function->shared()->code() ==
1258 isolate->builtins()->builtin(Builtins::kFunctionCall)) {
1259 // Handle function.apply and function.call separately to flood the
1260 // function to be called and not the code for Builtins::FunctionApply or
1261 // Builtins::FunctionCall. The receiver of call/apply is the target
1262 // function.
1263 if (!holder.is_null() && holder->IsJSFunction()) {
1264 Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder);
1265 FloodWithOneShotGeneric(js_function);
1266 }
1267 } else {
1268 FloodWithOneShot(function);
1269 }
1270 }
1271 }
1272
1232 1273
1233 void Debug::FloodHandlerWithOneShot() { 1274 void Debug::FloodHandlerWithOneShot() {
1234 // Iterate through the JavaScript stack looking for handlers. 1275 // Iterate through the JavaScript stack looking for handlers.
1235 StackFrame::Id id = break_frame_id(); 1276 StackFrame::Id id = break_frame_id();
1236 if (id == StackFrame::NO_ID) { 1277 if (id == StackFrame::NO_ID) {
1237 // If there is no JavaScript stack don't do anything. 1278 // If there is no JavaScript stack don't do anything.
1238 return; 1279 return;
1239 } 1280 }
1240 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { 1281 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) {
1241 JavaScriptFrame* frame = it.frame(); 1282 JavaScriptFrame* frame = it.frame();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 while (fun->IsJSFunction()) { 1498 while (fun->IsJSFunction()) {
1458 Code* code = JSFunction::cast(fun)->shared()->code(); 1499 Code* code = JSFunction::cast(fun)->shared()->code();
1459 if (code != apply && code != call) break; 1500 if (code != apply && code != call) break;
1460 fun = frame->GetExpression( 1501 fun = frame->GetExpression(
1461 expressions_count - 1 - call_function_arg_count); 1502 expressions_count - 1 - call_function_arg_count);
1462 } 1503 }
1463 } 1504 }
1464 1505
1465 if (fun->IsJSFunction()) { 1506 if (fun->IsJSFunction()) {
1466 Handle<JSFunction> js_function(JSFunction::cast(fun)); 1507 Handle<JSFunction> js_function(JSFunction::cast(fun));
1467 if (js_function->shared()->bound()) { 1508 FloodWithOneShotGeneric(js_function);
1468 FloodBoundFunctionWithOneShot(js_function);
1469 } else if (!js_function->IsFromNativeScript()) {
1470 // Don't step into builtins.
1471 // It will also compile target function if it's not compiled yet.
1472 FloodWithOneShot(js_function);
1473 }
1474 } 1509 }
1475 } 1510 }
1476 1511
1477 // Fill the current function with one-shot break points even for step in on 1512 // Fill the current function with one-shot break points even for step in on
1478 // a call target as the function called might be a native function for 1513 // a call target as the function called might be a native function for
1479 // which step in will not stop. It also prepares for stepping in 1514 // which step in will not stop. It also prepares for stepping in
1480 // getters/setters. 1515 // getters/setters.
1481 // If we are stepping into another frame, only fill calls and returns. 1516 // If we are stepping into another frame, only fill calls and returns.
1482 FloodWithOneShot(function, step_action == StepFrame ? CALLS_AND_RETURNS 1517 FloodWithOneShot(function, step_action == StepFrame ? CALLS_AND_RETURNS
1483 : ALL_BREAK_LOCATIONS); 1518 : ALL_BREAK_LOCATIONS);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 if (is_constructor) { 1640 if (is_constructor) {
1606 DCHECK(it.frame()->is_construct()); 1641 DCHECK(it.frame()->is_construct());
1607 it.Advance(); 1642 it.Advance();
1608 } 1643 }
1609 fp = it.frame()->fp(); 1644 fp = it.frame()->fp();
1610 } 1645 }
1611 1646
1612 // Flood the function with one-shot break points if it is called from where 1647 // Flood the function with one-shot break points if it is called from where
1613 // step into was requested, or when stepping into a new frame. 1648 // step into was requested, or when stepping into a new frame.
1614 if (fp == thread_local_.step_into_fp_ || step_frame) { 1649 if (fp == thread_local_.step_into_fp_ || step_frame) {
1615 if (function->shared()->bound()) { 1650 FloodWithOneShotGeneric(function, holder);
1616 // Handle Function.prototype.bind
1617 FloodBoundFunctionWithOneShot(function);
1618 } else if (!function->IsFromNativeScript()) {
1619 // Don't allow step into functions in the native context.
1620 if (function->shared()->code() ==
1621 isolate->builtins()->builtin(Builtins::kFunctionApply) ||
1622 function->shared()->code() ==
1623 isolate->builtins()->builtin(Builtins::kFunctionCall)) {
1624 // Handle function.apply and function.call separately to flood the
1625 // function to be called and not the code for Builtins::FunctionApply or
1626 // Builtins::FunctionCall. The receiver of call/apply is the target
1627 // function.
1628 if (!holder.is_null() && holder->IsJSFunction()) {
1629 Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder);
1630 if (!js_function->IsFromNativeScript()) {
1631 FloodWithOneShot(js_function);
1632 } else if (js_function->shared()->bound()) {
1633 // Handle Function.prototype.bind
1634 FloodBoundFunctionWithOneShot(js_function);
1635 }
1636 }
1637 } else {
1638 FloodWithOneShot(function);
1639 }
1640 }
1641 } 1651 }
1642 } 1652 }
1643 1653
1644 1654
1645 void Debug::ClearStepping() { 1655 void Debug::ClearStepping() {
1646 // Clear the various stepping setup. 1656 // Clear the various stepping setup.
1647 ClearOneShot(); 1657 ClearOneShot();
1648 ClearStepIn(); 1658 ClearStepIn();
1649 ClearStepOut(); 1659 ClearStepOut();
1650 ClearStepNext(); 1660 ClearStepNext();
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after
3426 logger_->DebugEvent("Put", message.text()); 3436 logger_->DebugEvent("Put", message.text());
3427 } 3437 }
3428 3438
3429 3439
3430 void LockingCommandMessageQueue::Clear() { 3440 void LockingCommandMessageQueue::Clear() {
3431 base::LockGuard<base::Mutex> lock_guard(&mutex_); 3441 base::LockGuard<base::Mutex> lock_guard(&mutex_);
3432 queue_.Clear(); 3442 queue_.Clear();
3433 } 3443 }
3434 3444
3435 } } // namespace v8::internal 3445 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | test/mjsunit/harmony/debug-step-into-class-extends.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698