| 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 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1219   } | 1219   } | 
| 1220 } | 1220 } | 
| 1221 | 1221 | 
| 1222 | 1222 | 
| 1223 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { | 1223 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { | 
| 1224   Handle<FixedArray> new_bindings(function->function_bindings()); | 1224   Handle<FixedArray> new_bindings(function->function_bindings()); | 
| 1225   Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), | 1225   Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), | 
| 1226                         isolate_); | 1226                         isolate_); | 
| 1227 | 1227 | 
| 1228   if (!bindee.is_null() && bindee->IsJSFunction() && | 1228   if (!bindee.is_null() && bindee->IsJSFunction() && | 
| 1229       !JSFunction::cast(*bindee)->IsNative()) { | 1229       !JSFunction::cast(*bindee)->IsFromNativeScript()) { | 
| 1230     Handle<JSFunction> bindee_function(JSFunction::cast(*bindee)); | 1230     Handle<JSFunction> bindee_function(JSFunction::cast(*bindee)); | 
| 1231     Debug::FloodWithOneShot(bindee_function); | 1231     Debug::FloodWithOneShot(bindee_function); | 
| 1232   } | 1232   } | 
| 1233 } | 1233 } | 
| 1234 | 1234 | 
| 1235 | 1235 | 
| 1236 void Debug::FloodHandlerWithOneShot() { | 1236 void Debug::FloodHandlerWithOneShot() { | 
| 1237   // Iterate through the JavaScript stack looking for handlers. | 1237   // Iterate through the JavaScript stack looking for handlers. | 
| 1238   StackFrame::Id id = break_frame_id(); | 1238   StackFrame::Id id = break_frame_id(); | 
| 1239   if (id == StackFrame::NO_ID) { | 1239   if (id == StackFrame::NO_ID) { | 
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1440     if (step_action == StepOut) { | 1440     if (step_action == StepOut) { | 
| 1441       // Skip step_count frames starting with the current one. | 1441       // Skip step_count frames starting with the current one. | 
| 1442       while (step_count-- > 0 && !frames_it.done()) { | 1442       while (step_count-- > 0 && !frames_it.done()) { | 
| 1443         frames_it.Advance(); | 1443         frames_it.Advance(); | 
| 1444       } | 1444       } | 
| 1445     } else { | 1445     } else { | 
| 1446       ASSERT(it.IsExit()); | 1446       ASSERT(it.IsExit()); | 
| 1447       frames_it.Advance(); | 1447       frames_it.Advance(); | 
| 1448     } | 1448     } | 
| 1449     // Skip builtin functions on the stack. | 1449     // Skip builtin functions on the stack. | 
| 1450     while (!frames_it.done() && frames_it.frame()->function()->IsNative()) { | 1450     while (!frames_it.done() && | 
|  | 1451            frames_it.frame()->function()->IsFromNativeScript()) { | 
| 1451       frames_it.Advance(); | 1452       frames_it.Advance(); | 
| 1452     } | 1453     } | 
| 1453     // Step out: If there is a JavaScript caller frame, we need to | 1454     // Step out: If there is a JavaScript caller frame, we need to | 
| 1454     // flood it with breakpoints. | 1455     // flood it with breakpoints. | 
| 1455     if (!frames_it.done()) { | 1456     if (!frames_it.done()) { | 
| 1456       // Fill the function to return to with one-shot break points. | 1457       // Fill the function to return to with one-shot break points. | 
| 1457       JSFunction* function = frames_it.frame()->function(); | 1458       JSFunction* function = frames_it.frame()->function(); | 
| 1458       FloodWithOneShot(Handle<JSFunction>(function)); | 1459       FloodWithOneShot(Handle<JSFunction>(function)); | 
| 1459       // Set target frame pointer. | 1460       // Set target frame pointer. | 
| 1460       ActivateStepOut(frames_it.frame()); | 1461       ActivateStepOut(frames_it.frame()); | 
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1527           if (code != apply && code != call) break; | 1528           if (code != apply && code != call) break; | 
| 1528           fun = frame->GetExpression( | 1529           fun = frame->GetExpression( | 
| 1529               expressions_count - 1 - call_function_arg_count); | 1530               expressions_count - 1 - call_function_arg_count); | 
| 1530         } | 1531         } | 
| 1531       } | 1532       } | 
| 1532 | 1533 | 
| 1533       if (fun->IsJSFunction()) { | 1534       if (fun->IsJSFunction()) { | 
| 1534         Handle<JSFunction> js_function(JSFunction::cast(fun)); | 1535         Handle<JSFunction> js_function(JSFunction::cast(fun)); | 
| 1535         if (js_function->shared()->bound()) { | 1536         if (js_function->shared()->bound()) { | 
| 1536           Debug::FloodBoundFunctionWithOneShot(js_function); | 1537           Debug::FloodBoundFunctionWithOneShot(js_function); | 
| 1537         } else if (!js_function->IsNative()) { | 1538         } else if (!js_function->IsFromNativeScript()) { | 
| 1538           // Don't step into builtins. | 1539           // Don't step into builtins. | 
| 1539           // It will also compile target function if it's not compiled yet. | 1540           // It will also compile target function if it's not compiled yet. | 
| 1540           FloodWithOneShot(js_function); | 1541           FloodWithOneShot(js_function); | 
| 1541         } | 1542         } | 
| 1542       } | 1543       } | 
| 1543     } | 1544     } | 
| 1544 | 1545 | 
| 1545     // Fill the current function with one-shot break points even for step in on | 1546     // Fill the current function with one-shot break points even for step in on | 
| 1546     // a call target as the function called might be a native function for | 1547     // a call target as the function called might be a native function for | 
| 1547     // which step in will not stop. It also prepares for stepping in | 1548     // which step in will not stop. It also prepares for stepping in | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1669     } | 1670     } | 
| 1670     fp = it.frame()->fp(); | 1671     fp = it.frame()->fp(); | 
| 1671   } | 1672   } | 
| 1672 | 1673 | 
| 1673   // Flood the function with one-shot break points if it is called from where | 1674   // Flood the function with one-shot break points if it is called from where | 
| 1674   // step into was requested. | 1675   // step into was requested. | 
| 1675   if (fp == thread_local_.step_into_fp_) { | 1676   if (fp == thread_local_.step_into_fp_) { | 
| 1676     if (function->shared()->bound()) { | 1677     if (function->shared()->bound()) { | 
| 1677       // Handle Function.prototype.bind | 1678       // Handle Function.prototype.bind | 
| 1678       Debug::FloodBoundFunctionWithOneShot(function); | 1679       Debug::FloodBoundFunctionWithOneShot(function); | 
| 1679     } else if (!function->IsNative()) { | 1680     } else if (!function->IsFromNativeScript()) { | 
| 1680       // Don't allow step into functions in the native context. | 1681       // Don't allow step into functions in the native context. | 
| 1681       if (function->shared()->code() == | 1682       if (function->shared()->code() == | 
| 1682           isolate->builtins()->builtin(Builtins::kFunctionApply) || | 1683           isolate->builtins()->builtin(Builtins::kFunctionApply) || | 
| 1683           function->shared()->code() == | 1684           function->shared()->code() == | 
| 1684           isolate->builtins()->builtin(Builtins::kFunctionCall)) { | 1685           isolate->builtins()->builtin(Builtins::kFunctionCall)) { | 
| 1685         // Handle function.apply and function.call separately to flood the | 1686         // Handle function.apply and function.call separately to flood the | 
| 1686         // function to be called and not the code for Builtins::FunctionApply or | 1687         // function to be called and not the code for Builtins::FunctionApply or | 
| 1687         // Builtins::FunctionCall. The receiver of call/apply is the target | 1688         // Builtins::FunctionCall. The receiver of call/apply is the target | 
| 1688         // function. | 1689         // function. | 
| 1689         if (!holder.is_null() && holder->IsJSFunction()) { | 1690         if (!holder.is_null() && holder->IsJSFunction()) { | 
| 1690           Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder); | 1691           Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder); | 
| 1691           if (!js_function->IsNative()) { | 1692           if (!js_function->IsFromNativeScript()) { | 
| 1692             Debug::FloodWithOneShot(js_function); | 1693             Debug::FloodWithOneShot(js_function); | 
| 1693           } else if (js_function->shared()->bound()) { | 1694           } else if (js_function->shared()->bound()) { | 
| 1694             // Handle Function.prototype.bind | 1695             // Handle Function.prototype.bind | 
| 1695             Debug::FloodBoundFunctionWithOneShot(js_function); | 1696             Debug::FloodBoundFunctionWithOneShot(js_function); | 
| 1696           } | 1697           } | 
| 1697         } | 1698         } | 
| 1698       } else { | 1699       } else { | 
| 1699         Debug::FloodWithOneShot(function); | 1700         Debug::FloodWithOneShot(function); | 
| 1700       } | 1701       } | 
| 1701     } | 1702     } | 
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2023       // debug break slots and are not active or inlined into an active | 2024       // debug break slots and are not active or inlined into an active | 
| 2024       // function and mark them for lazy compilation. | 2025       // function and mark them for lazy compilation. | 
| 2025       HeapObject* obj = NULL; | 2026       HeapObject* obj = NULL; | 
| 2026       while (((obj = iterator.next()) != NULL)) { | 2027       while (((obj = iterator.next()) != NULL)) { | 
| 2027         if (obj->IsJSFunction()) { | 2028         if (obj->IsJSFunction()) { | 
| 2028           JSFunction* function = JSFunction::cast(obj); | 2029           JSFunction* function = JSFunction::cast(obj); | 
| 2029           SharedFunctionInfo* shared = function->shared(); | 2030           SharedFunctionInfo* shared = function->shared(); | 
| 2030 | 2031 | 
| 2031           if (!shared->allows_lazy_compilation()) continue; | 2032           if (!shared->allows_lazy_compilation()) continue; | 
| 2032           if (!shared->script()->IsScript()) continue; | 2033           if (!shared->script()->IsScript()) continue; | 
| 2033           if (function->IsNative()) continue; | 2034           if (function->IsFromNativeScript()) continue; | 
| 2034           if (shared->code()->gc_metadata() == active_code_marker) continue; | 2035           if (shared->code()->gc_metadata() == active_code_marker) continue; | 
| 2035 | 2036 | 
| 2036           if (shared->is_generator()) { | 2037           if (shared->is_generator()) { | 
| 2037             generator_functions.Add(Handle<JSFunction>(function, isolate_)); | 2038             generator_functions.Add(Handle<JSFunction>(function, isolate_)); | 
| 2038             continue; | 2039             continue; | 
| 2039           } | 2040           } | 
| 2040 | 2041 | 
| 2041           Code::Kind kind = function->code()->kind(); | 2042           Code::Kind kind = function->code()->kind(); | 
| 2042           if (kind == Code::FUNCTION && | 2043           if (kind == Code::FUNCTION && | 
| 2043               !function->code()->has_debug_break_slots()) { | 2044               !function->code()->has_debug_break_slots()) { | 
| (...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3371   logger_->DebugEvent("Put", message.text()); | 3372   logger_->DebugEvent("Put", message.text()); | 
| 3372 } | 3373 } | 
| 3373 | 3374 | 
| 3374 | 3375 | 
| 3375 void LockingCommandMessageQueue::Clear() { | 3376 void LockingCommandMessageQueue::Clear() { | 
| 3376   base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3377   base::LockGuard<base::Mutex> lock_guard(&mutex_); | 
| 3377   queue_.Clear(); | 3378   queue_.Clear(); | 
| 3378 } | 3379 } | 
| 3379 | 3380 | 
| 3380 } }  // namespace v8::internal | 3381 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|