Debugger: speed up setting break points in nested SFI.
If the shared function info is newly compiled when looking for it in the script (Debug::FindSharedFunctionInfoInScript), then we can bypass iterating the heap to find JSFunctions referencing it (Debug::PrepareFunctionForBreakpoints). BUG=v8:4553 LOG=N Review URL: https://codereview.chromium.org/1454673002 Cr-Commit-Position: refs/heads/master@{#32107}
This commit is contained in:
parent
eb25b8c54b
commit
de884f201a
@ -1377,6 +1377,7 @@ class SharedFunctionInfoFinder {
|
||||
target_position_(target_position) {}
|
||||
|
||||
void NewCandidate(SharedFunctionInfo* shared, JSFunction* closure = NULL) {
|
||||
if (!shared->IsSubjectToDebugging()) return;
|
||||
int start_position = shared->function_token_position();
|
||||
if (start_position == RelocInfo::kNoPosition) {
|
||||
start_position = shared->start_position();
|
||||
@ -1426,7 +1427,7 @@ class SharedFunctionInfoFinder {
|
||||
// cannot be compiled without context (need to find outer compilable SFI etc.)
|
||||
Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
|
||||
int position) {
|
||||
while (true) {
|
||||
for (int iteration = 0;; iteration++) {
|
||||
// Go through all shared function infos associated with this script to
|
||||
// find the inner most function containing this position.
|
||||
// If there is no shared function info for this script at all, there is
|
||||
@ -1444,7 +1445,18 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
|
||||
shared = finder.Result();
|
||||
if (shared == NULL) break;
|
||||
// We found it if it's already compiled and has debug code.
|
||||
if (shared->HasDebugCode()) return handle(shared);
|
||||
if (shared->HasDebugCode()) {
|
||||
Handle<SharedFunctionInfo> shared_handle(shared);
|
||||
// If the iteration count is larger than 1, we had to compile the outer
|
||||
// function in order to create this shared function info. So there can
|
||||
// be no JSFunction referencing it. We can anticipate creating a debug
|
||||
// info while bypassing PrepareFunctionForBreakpoints.
|
||||
if (iteration > 1) {
|
||||
AllowHeapAllocation allow_before_return;
|
||||
CreateDebugInfo(shared_handle);
|
||||
}
|
||||
return shared_handle;
|
||||
}
|
||||
}
|
||||
// If not, compile to reveal inner functions, if possible.
|
||||
if (shared->allows_lazy_compilation_without_context()) {
|
||||
@ -1509,6 +1521,13 @@ bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared,
|
||||
shared->code()->ClearInlineCaches();
|
||||
shared->ClearTypeFeedbackInfo();
|
||||
|
||||
CreateDebugInfo(shared);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Debug::CreateDebugInfo(Handle<SharedFunctionInfo> shared) {
|
||||
// Create the debug info object.
|
||||
DCHECK(shared->HasDebugCode());
|
||||
Handle<DebugInfo> debug_info = isolate_->factory()->NewDebugInfo(shared);
|
||||
@ -1517,8 +1536,6 @@ bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared,
|
||||
DebugInfoListNode* node = new DebugInfoListNode(*debug_info);
|
||||
node->set_next(debug_info_list_);
|
||||
debug_info_list_ = node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -424,6 +424,7 @@ class Debug {
|
||||
// function needs to be compiled already.
|
||||
bool EnsureDebugInfo(Handle<SharedFunctionInfo> shared,
|
||||
Handle<JSFunction> function);
|
||||
void CreateDebugInfo(Handle<SharedFunctionInfo> shared);
|
||||
static Handle<DebugInfo> GetDebugInfo(Handle<SharedFunctionInfo> shared);
|
||||
|
||||
template <typename C>
|
||||
|
Loading…
Reference in New Issue
Block a user