Chromium Code Reviews| Index: src/debug/debug.cc |
| diff --git a/src/debug/debug.cc b/src/debug/debug.cc |
| index 711f54d9ff2c043f0ea3f55c20da6485fc9caa14..2744501c3b7089ee497e1cc4e15bb5abcc861f62 100644 |
| --- a/src/debug/debug.cc |
| +++ b/src/debug/debug.cc |
| @@ -1352,6 +1352,84 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) { |
| return true; |
| } |
| +bool Debug::FindBreakablePositions(Handle<DebugInfo> debug_info, |
| + int start_position, int end_position, |
| + BreakPositionAlignment alignment, |
| + std::vector<int>& offsets) { |
| + int statement_position; |
| + int position; |
| + if (debug_info->HasDebugCode()) { |
| + CodeBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); |
| + it.SkipToPosition(start_position, alignment); |
| + while (!it.Done() && it.position() < end_position && |
| + it.position() >= start_position) { |
| + statement_position = it.statement_position(); |
| + position = it.position(); |
| + offsets.push_back(alignment == STATEMENT_ALIGNED ? statement_position |
| + : position); |
| + it.Next(); |
| + } |
| + } else { |
| + DCHECK(debug_info->HasDebugBytecodeArray()); |
| + BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); |
|
Yang
2016/11/02 13:51:15
This is just duplicate code. Can we either use vir
kozy
2016/11/03 01:15:02
Done.
|
| + it.SkipToPosition(start_position, alignment); |
| + while (!it.Done() && it.position() < end_position && |
| + it.position() >= start_position) { |
| + statement_position = it.statement_position(); |
| + position = it.position(); |
| + offsets.push_back(alignment == STATEMENT_ALIGNED ? statement_position |
| + : position); |
| + it.Next(); |
| + } |
| + } |
| + return true; |
| +} |
| + |
| +bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position, |
| + int end_position, |
| + std::vector<int>& offsets) { |
| + for (int iteration = 0;; iteration++) { |
| + std::vector<int> current; |
| + if (!script->shared_function_infos()->IsWeakFixedArray()) break; |
| + WeakFixedArray::Iterator iterator(script->shared_function_infos()); |
| + SharedFunctionInfo* candidate; |
| + bool should_restart = false; |
| + while ((candidate = iterator.Next<SharedFunctionInfo>())) { |
| + if (!candidate) break; |
|
Yang
2016/11/02 13:51:15
this seems redundant.
kozy
2016/11/03 01:15:02
Removed.
|
| + if (candidate->end_position() < start_position || |
| + candidate->start_position() >= end_position) |
| + continue; |
| + if (candidate->HasDebugCode()) { |
| + Handle<SharedFunctionInfo> shared_handle(candidate); |
| + if (!shared_handle->IsSubjectToDebugging()) continue; |
| + if (!shared_handle->HasDebugInfo()) { |
| + AllowHeapAllocation allow_before_return; |
|
Yang
2016/11/02 13:51:15
This is not safe. Once GC happens, the weak fixed
kozy
2016/11/03 01:15:02
Thank you!
Done.
|
| + CreateDebugInfo(shared_handle); |
| + } |
| + Handle<DebugInfo> debug_info(shared_handle->GetDebugInfo()); |
| + if (!FindBreakablePositions(debug_info, start_position, end_position, |
| + STATEMENT_ALIGNED, current)) |
| + return false; |
| + continue; |
| + } |
| + if (candidate->allows_lazy_compilation()) { |
| + HandleScope scope(isolate_); |
| + AllowHeapAllocation allow_before_return; |
| + if (!Compiler::CompileDebugCode(handle(candidate))) { |
| + return false; |
| + } else { |
| + should_restart = true; |
| + } |
| + break; |
| + } |
| + } |
| + if (should_restart) continue; |
| + offsets.swap(current); |
| + return true; |
| + } |
| + return true; |
| +} |
| + |
| void Debug::RecordAsyncFunction(Handle<JSGeneratorObject> generator_object) { |
| if (last_step_action() <= StepOut) return; |
| if (!IsAsyncFunction(generator_object->function()->shared()->kind())) return; |