Chromium Code Reviews| 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/debug/debug.h" | 5 #include "src/debug/debug.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1345 } | 1345 } |
| 1346 | 1346 |
| 1347 // Update PCs on the stack to point to recompiled code. | 1347 // Update PCs on the stack to point to recompiled code. |
| 1348 RedirectActiveFunctions redirect_visitor(*shared); | 1348 RedirectActiveFunctions redirect_visitor(*shared); |
| 1349 redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top()); | 1349 redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top()); |
| 1350 isolate_->thread_manager()->IterateArchivedThreads(&redirect_visitor); | 1350 isolate_->thread_manager()->IterateArchivedThreads(&redirect_visitor); |
| 1351 | 1351 |
| 1352 return true; | 1352 return true; |
| 1353 } | 1353 } |
| 1354 | 1354 |
| 1355 namespace { | |
| 1356 template <typename Iterator> | |
| 1357 void GetBreakablePositions(Iterator& it, int start_position, int end_position, | |
|
Yang
2016/11/04 12:22:58
The iterator is still passed by &-reference.
kozy
2016/11/04 14:48:38
Done.
| |
| 1358 BreakPositionAlignment alignment, | |
| 1359 std::vector<int>* positions) { | |
| 1360 it.SkipToPosition(start_position, alignment); | |
| 1361 while (!it.Done() && it.position() < end_position && | |
| 1362 it.position() >= start_position) { | |
| 1363 positions->push_back(alignment == STATEMENT_ALIGNED | |
| 1364 ? it.statement_position() | |
| 1365 : it.position()); | |
| 1366 it.Next(); | |
| 1367 } | |
| 1368 } | |
| 1369 | |
| 1370 void FindBreakablePositions(Handle<DebugInfo> debug_info, int start_position, | |
| 1371 int end_position, BreakPositionAlignment alignment, | |
| 1372 std::vector<int>* positions) { | |
| 1373 if (debug_info->HasDebugCode()) { | |
| 1374 CodeBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); | |
| 1375 GetBreakablePositions(it, start_position, end_position, alignment, | |
| 1376 positions); | |
| 1377 } else { | |
| 1378 DCHECK(debug_info->HasDebugBytecodeArray()); | |
| 1379 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); | |
| 1380 GetBreakablePositions(it, start_position, end_position, alignment, | |
| 1381 positions); | |
| 1382 } | |
| 1383 } | |
| 1384 } // namespace | |
| 1385 | |
| 1386 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position, | |
| 1387 int end_position, | |
| 1388 std::vector<int>* positions) { | |
| 1389 while (true) { | |
| 1390 if (!script->shared_function_infos()->IsWeakFixedArray()) return false; | |
| 1391 | |
| 1392 WeakFixedArray* infos = | |
| 1393 WeakFixedArray::cast(script->shared_function_infos()); | |
| 1394 HandleScope scope(isolate_); | |
| 1395 List<Handle<SharedFunctionInfo>> candidates; | |
| 1396 { | |
| 1397 WeakFixedArray::Iterator iterator(infos); | |
| 1398 SharedFunctionInfo* info; | |
| 1399 while ((info = iterator.Next<SharedFunctionInfo>())) { | |
| 1400 if (info->end_position() < start_position || | |
| 1401 info->start_position() >= end_position) { | |
| 1402 continue; | |
| 1403 } | |
| 1404 if (!info->IsSubjectToDebugging()) continue; | |
| 1405 if (!info->HasDebugCode() && !info->allows_lazy_compilation()) continue; | |
| 1406 candidates.Add(i::handle(info)); | |
| 1407 } | |
| 1408 } | |
| 1409 | |
| 1410 bool was_compiled = false; | |
| 1411 for (int i = 0; i < candidates.length(); ++i) { | |
| 1412 if (!candidates[i]->HasDebugCode()) { | |
| 1413 if (!Compiler::CompileDebugCode(candidates[i])) { | |
| 1414 return false; | |
| 1415 } else { | |
| 1416 was_compiled = true; | |
| 1417 } | |
| 1418 } | |
| 1419 if (!candidates[i]->HasDebugInfo()) CreateDebugInfo(candidates[i]); | |
| 1420 } | |
| 1421 if (was_compiled) continue; | |
| 1422 | |
| 1423 for (int i = 0; i < candidates.length(); ++i) { | |
| 1424 CHECK(candidates[i]->HasDebugInfo()); | |
| 1425 Handle<DebugInfo> debug_info(candidates[i]->GetDebugInfo()); | |
| 1426 FindBreakablePositions(debug_info, start_position, end_position, | |
| 1427 STATEMENT_ALIGNED, positions); | |
| 1428 } | |
| 1429 return true; | |
| 1430 } | |
| 1431 UNREACHABLE(); | |
| 1432 return false; | |
| 1433 } | |
| 1434 | |
| 1355 void Debug::RecordAsyncFunction(Handle<JSGeneratorObject> generator_object) { | 1435 void Debug::RecordAsyncFunction(Handle<JSGeneratorObject> generator_object) { |
| 1356 if (last_step_action() <= StepOut) return; | 1436 if (last_step_action() <= StepOut) return; |
| 1357 if (!IsAsyncFunction(generator_object->function()->shared()->kind())) return; | 1437 if (!IsAsyncFunction(generator_object->function()->shared()->kind())) return; |
| 1358 DCHECK(!has_suspended_generator()); | 1438 DCHECK(!has_suspended_generator()); |
| 1359 thread_local_.suspended_generator_ = *generator_object; | 1439 thread_local_.suspended_generator_ = *generator_object; |
| 1360 ClearStepping(); | 1440 ClearStepping(); |
| 1361 } | 1441 } |
| 1362 | 1442 |
| 1363 class SharedFunctionInfoFinder { | 1443 class SharedFunctionInfoFinder { |
| 1364 public: | 1444 public: |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2563 } | 2643 } |
| 2564 | 2644 |
| 2565 | 2645 |
| 2566 void LockingCommandMessageQueue::Clear() { | 2646 void LockingCommandMessageQueue::Clear() { |
| 2567 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2647 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 2568 queue_.Clear(); | 2648 queue_.Clear(); |
| 2569 } | 2649 } |
| 2570 | 2650 |
| 2571 } // namespace internal | 2651 } // namespace internal |
| 2572 } // namespace v8 | 2652 } // namespace v8 |
| OLD | NEW |