OLD | NEW |
---|---|
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 Loading... | |
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 if (bindee_function->shared()->is_default_constructor()) { |
1229 FloodDefaultConstructorWithOneShot(bindee_function); | |
1230 } else { | |
1231 FloodWithOneShot(bindee_function); | |
1232 } | |
1229 } | 1233 } |
1230 } | 1234 } |
1231 | 1235 |
1236 | |
1237 void Debug::FloodDefaultConstructorWithOneShot(Handle<JSFunction> function) { | |
1238 DCHECK(function->shared()->is_default_constructor()); | |
1239 // Instead of stepping into the function we directly step into the super class | |
1240 // constructor. | |
1241 Isolate* isolate = function->GetIsolate(); | |
1242 PrototypeIterator iter(isolate, function); | |
1243 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); | |
1244 if (!proto->IsJSFunction()) return; // Object.prototype | |
1245 Handle<JSFunction> function_proto = Handle<JSFunction>::cast(proto); | |
1246 | |
1247 if (function_proto->shared()->bound()) { | |
aandrey
2014/11/14 19:27:13
this if-else block is repeated several times below
arv (Not doing code reviews)
2014/11/14 22:02:22
Done.
| |
1248 FloodBoundFunctionWithOneShot(function_proto); | |
1249 } else if (function_proto->shared()->is_default_constructor()) { | |
1250 FloodDefaultConstructorWithOneShot(function_proto); | |
1251 } else if (!function_proto->IsFromNativeScript()) { | |
1252 FloodWithOneShot(function_proto); | |
1253 } | |
1254 } | |
1255 | |
1232 | 1256 |
1233 void Debug::FloodHandlerWithOneShot() { | 1257 void Debug::FloodHandlerWithOneShot() { |
1234 // Iterate through the JavaScript stack looking for handlers. | 1258 // Iterate through the JavaScript stack looking for handlers. |
1235 StackFrame::Id id = break_frame_id(); | 1259 StackFrame::Id id = break_frame_id(); |
1236 if (id == StackFrame::NO_ID) { | 1260 if (id == StackFrame::NO_ID) { |
1237 // If there is no JavaScript stack don't do anything. | 1261 // If there is no JavaScript stack don't do anything. |
1238 return; | 1262 return; |
1239 } | 1263 } |
1240 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { | 1264 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { |
1241 JavaScriptFrame* frame = it.frame(); | 1265 JavaScriptFrame* frame = it.frame(); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1457 while (fun->IsJSFunction()) { | 1481 while (fun->IsJSFunction()) { |
1458 Code* code = JSFunction::cast(fun)->shared()->code(); | 1482 Code* code = JSFunction::cast(fun)->shared()->code(); |
1459 if (code != apply && code != call) break; | 1483 if (code != apply && code != call) break; |
1460 fun = frame->GetExpression( | 1484 fun = frame->GetExpression( |
1461 expressions_count - 1 - call_function_arg_count); | 1485 expressions_count - 1 - call_function_arg_count); |
1462 } | 1486 } |
1463 } | 1487 } |
1464 | 1488 |
1465 if (fun->IsJSFunction()) { | 1489 if (fun->IsJSFunction()) { |
1466 Handle<JSFunction> js_function(JSFunction::cast(fun)); | 1490 Handle<JSFunction> js_function(JSFunction::cast(fun)); |
1467 if (js_function->shared()->bound()) { | 1491 if (js_function->shared()->bound()) { |
aandrey
2014/11/14 19:27:13
repeated again
arv (Not doing code reviews)
2014/11/14 22:02:22
Done.
| |
1468 FloodBoundFunctionWithOneShot(js_function); | 1492 FloodBoundFunctionWithOneShot(js_function); |
1493 } else if (js_function->shared()->is_default_constructor()) { | |
1494 FloodDefaultConstructorWithOneShot(js_function); | |
1469 } else if (!js_function->IsFromNativeScript()) { | 1495 } else if (!js_function->IsFromNativeScript()) { |
1470 // Don't step into builtins. | 1496 // Don't step into builtins. |
1471 // It will also compile target function if it's not compiled yet. | 1497 // It will also compile target function if it's not compiled yet. |
1472 FloodWithOneShot(js_function); | 1498 FloodWithOneShot(js_function); |
1473 } | 1499 } |
1474 } | 1500 } |
1475 } | 1501 } |
1476 | 1502 |
1477 // Fill the current function with one-shot break points even for step in on | 1503 // 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 | 1504 // a call target as the function called might be a native function for |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1605 if (is_constructor) { | 1631 if (is_constructor) { |
1606 DCHECK(it.frame()->is_construct()); | 1632 DCHECK(it.frame()->is_construct()); |
1607 it.Advance(); | 1633 it.Advance(); |
1608 } | 1634 } |
1609 fp = it.frame()->fp(); | 1635 fp = it.frame()->fp(); |
1610 } | 1636 } |
1611 | 1637 |
1612 // Flood the function with one-shot break points if it is called from where | 1638 // 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. | 1639 // step into was requested, or when stepping into a new frame. |
1614 if (fp == thread_local_.step_into_fp_ || step_frame) { | 1640 if (fp == thread_local_.step_into_fp_ || step_frame) { |
1615 if (function->shared()->bound()) { | 1641 if (function->shared()->bound()) { |
aandrey
2014/11/14 19:27:13
repeated once more.
arv (Not doing code reviews)
2014/11/14 22:02:22
Done.
| |
1616 // Handle Function.prototype.bind | 1642 // Handle Function.prototype.bind |
1617 FloodBoundFunctionWithOneShot(function); | 1643 FloodBoundFunctionWithOneShot(function); |
1644 } else if (function->shared()->is_default_constructor()) { | |
1645 FloodDefaultConstructorWithOneShot(function); | |
1618 } else if (!function->IsFromNativeScript()) { | 1646 } else if (!function->IsFromNativeScript()) { |
1619 // Don't allow step into functions in the native context. | 1647 // Don't allow step into functions in the native context. |
1620 if (function->shared()->code() == | 1648 if (function->shared()->code() == |
aandrey
2014/11/14 19:27:13
maybe the following apply & call checks should be
arv (Not doing code reviews)
2014/11/14 22:02:22
This is the only place where we have the holder.
| |
1621 isolate->builtins()->builtin(Builtins::kFunctionApply) || | 1649 isolate->builtins()->builtin(Builtins::kFunctionApply) || |
1622 function->shared()->code() == | 1650 function->shared()->code() == |
1623 isolate->builtins()->builtin(Builtins::kFunctionCall)) { | 1651 isolate->builtins()->builtin(Builtins::kFunctionCall)) { |
1624 // Handle function.apply and function.call separately to flood the | 1652 // Handle function.apply and function.call separately to flood the |
1625 // function to be called and not the code for Builtins::FunctionApply or | 1653 // function to be called and not the code for Builtins::FunctionApply or |
1626 // Builtins::FunctionCall. The receiver of call/apply is the target | 1654 // Builtins::FunctionCall. The receiver of call/apply is the target |
1627 // function. | 1655 // function. |
1628 if (!holder.is_null() && holder->IsJSFunction()) { | 1656 if (!holder.is_null() && holder->IsJSFunction()) { |
1629 Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder); | 1657 Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder); |
1630 if (!js_function->IsFromNativeScript()) { | 1658 if (!js_function->IsFromNativeScript()) { |
aandrey
2014/11/14 19:27:13
BTW, is this in the correct order?
arv (Not doing code reviews)
2014/11/14 19:36:57
Yeah. This looks wrong.
arv (Not doing code reviews)
2014/11/14 22:02:22
Done.
| |
1631 FloodWithOneShot(js_function); | 1659 FloodWithOneShot(js_function); |
1632 } else if (js_function->shared()->bound()) { | 1660 } else if (js_function->shared()->bound()) { |
1633 // Handle Function.prototype.bind | 1661 // Handle Function.prototype.bind |
1634 FloodBoundFunctionWithOneShot(js_function); | 1662 FloodBoundFunctionWithOneShot(js_function); |
1663 } else if (js_function->shared()->is_default_constructor()) { | |
1664 FloodDefaultConstructorWithOneShot(js_function); | |
1635 } | 1665 } |
1636 } | 1666 } |
1637 } else { | 1667 } else { |
1638 FloodWithOneShot(function); | 1668 FloodWithOneShot(function); |
1639 } | 1669 } |
1640 } | 1670 } |
1641 } | 1671 } |
1642 } | 1672 } |
1643 | 1673 |
1644 | 1674 |
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3426 logger_->DebugEvent("Put", message.text()); | 3456 logger_->DebugEvent("Put", message.text()); |
3427 } | 3457 } |
3428 | 3458 |
3429 | 3459 |
3430 void LockingCommandMessageQueue::Clear() { | 3460 void LockingCommandMessageQueue::Clear() { |
3431 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3461 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
3432 queue_.Clear(); | 3462 queue_.Clear(); |
3433 } | 3463 } |
3434 | 3464 |
3435 } } // namespace v8::internal | 3465 } } // namespace v8::internal |
OLD | NEW |