Commit 83207b93 authored by yangguo's avatar yangguo Committed by Commit bot

Debugger: ensure that functions with debug info have code with break slots.

This helps reasoning about setting break points. Functions that
have debug info is also guaranteed to be able to set break points.

R=ulan@chromium.org
BUG=v8:4132
LOG=N

Review URL: https://codereview.chromium.org/1227213003

Cr-Commit-Position: refs/heads/master@{#29698}
parent 3a0ee39c
...@@ -926,9 +926,6 @@ void Debug::ClearAllBreakPoints() { ...@@ -926,9 +926,6 @@ void Debug::ClearAllBreakPoints() {
void Debug::FloodWithOneShot(Handle<JSFunction> function, void Debug::FloodWithOneShot(Handle<JSFunction> function,
BreakLocatorType type) { BreakLocatorType type) {
// Do not ever break in native and extension functions.
if (!function->IsSubjectToDebugging()) return;
PrepareForBreakPoints(); PrepareForBreakPoints();
// Make sure the function is compiled and has set up the debug info. // Make sure the function is compiled and has set up the debug info.
...@@ -951,8 +948,7 @@ void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { ...@@ -951,8 +948,7 @@ void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) {
Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex),
isolate_); isolate_);
if (!bindee.is_null() && bindee->IsJSFunction() && if (!bindee.is_null() && bindee->IsJSFunction()) {
JSFunction::cast(*bindee)->IsSubjectToDebugging()) {
Handle<JSFunction> bindee_function(JSFunction::cast(*bindee)); Handle<JSFunction> bindee_function(JSFunction::cast(*bindee));
FloodWithOneShotGeneric(bindee_function); FloodWithOneShotGeneric(bindee_function);
} }
...@@ -1881,20 +1877,22 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, ...@@ -1881,20 +1877,22 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
// Ensures the debug information is present for shared. // Ensures the debug information is present for shared.
bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared,
Handle<JSFunction> function) { Handle<JSFunction> function) {
Isolate* isolate = shared->GetIsolate(); if (!shared->IsSubjectToDebugging()) return false;
// Return if we already have the debug info for shared. // Return if we already have the debug info for shared.
if (HasDebugInfo(shared)) { if (HasDebugInfo(shared)) {
DCHECK(shared->is_compiled()); DCHECK(shared->is_compiled());
DCHECK(shared->code()->has_debug_break_slots());
return true; return true;
} }
// There will be at least one break point when we are done. // There will be at least one break point when we are done.
has_break_points_ = true; has_break_points_ = true;
// Ensure function is compiled. Return false if this failed. if (function.is_null()) {
if (!function.is_null() && DCHECK(shared->is_compiled());
!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { DCHECK(shared->code()->has_debug_break_slots());
} else if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {
return false; return false;
} }
...@@ -1904,7 +1902,9 @@ bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, ...@@ -1904,7 +1902,9 @@ bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared,
shared->feedback_vector()->ClearICSlots(*shared); shared->feedback_vector()->ClearICSlots(*shared);
// Create the debug info object. // Create the debug info object.
Handle<DebugInfo> debug_info = isolate->factory()->NewDebugInfo(shared); DCHECK(shared->is_compiled());
DCHECK(shared->code()->has_debug_break_slots());
Handle<DebugInfo> debug_info = isolate_->factory()->NewDebugInfo(shared);
// Add debug info to the list. // Add debug info to the list.
DebugInfoListNode* node = new DebugInfoListNode(*debug_info); DebugInfoListNode* node = new DebugInfoListNode(*debug_info);
......
...@@ -5558,29 +5558,22 @@ void SharedFunctionInfo::TryReenableOptimization() { ...@@ -5558,29 +5558,22 @@ void SharedFunctionInfo::TryReenableOptimization() {
} }
bool JSFunction::IsBuiltin() { bool SharedFunctionInfo::IsSubjectToDebugging() {
return context()->global_object()->IsJSBuiltinsObject(); Object* script_obj = script();
if (script_obj->IsUndefined()) return false;
Script* script = Script::cast(script_obj);
Script::Type type = static_cast<Script::Type>(script->type()->value());
return type == Script::TYPE_NORMAL;
} }
bool JSFunction::IsFromNativeScript() { bool JSFunction::IsBuiltin() {
Object* script = shared()->script(); return context()->global_object()->IsJSBuiltinsObject();
bool native = script->IsScript() &&
Script::cast(script)->type()->value() == Script::TYPE_NATIVE;
DCHECK(!IsBuiltin() || native); // All builtins are also native.
return native;
}
bool JSFunction::IsFromExtensionScript() {
Object* script = shared()->script();
return script->IsScript() &&
Script::cast(script)->type()->value() == Script::TYPE_EXTENSION;
} }
bool JSFunction::IsSubjectToDebugging() { bool JSFunction::IsSubjectToDebugging() {
return !IsFromNativeScript() && !IsFromExtensionScript(); return shared()->IsSubjectToDebugging();
} }
......
...@@ -6858,6 +6858,9 @@ class SharedFunctionInfo: public HeapObject { ...@@ -6858,6 +6858,9 @@ class SharedFunctionInfo: public HeapObject {
reason)); reason));
} }
// Tells whether this function should be subject to debugging.
inline bool IsSubjectToDebugging();
// Check whether or not this function is inlineable. // Check whether or not this function is inlineable.
bool IsInlineable(); bool IsInlineable();
...@@ -7250,12 +7253,6 @@ class JSFunction: public JSObject { ...@@ -7250,12 +7253,6 @@ class JSFunction: public JSObject {
// Tells whether this function is builtin. // Tells whether this function is builtin.
inline bool IsBuiltin(); inline bool IsBuiltin();
// Tells whether this function is defined in a native script.
inline bool IsFromNativeScript();
// Tells whether this function is defined in an extension script.
inline bool IsFromExtensionScript();
// Tells whether this function should be subject to debugging. // Tells whether this function should be subject to debugging.
inline bool IsSubjectToDebugging(); inline bool IsSubjectToDebugging();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment