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, | |
| 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 ? it.statement_position() | |
| 1364 : it.position()); | |
| 1365 it.Next(); | |
| 1366 } | |
| 1367 } | |
| 1368 } // namespace | |
| 1369 | |
| 1370 void Debug::FindBreakablePositions(Handle<DebugInfo> debug_info, | |
| 1371 int start_position, int end_position, | |
| 1372 BreakPositionAlignment alignment, | |
| 1373 std::vector<int>& positions) { | |
|
Yang
2016/11/03 08:03:26
I've seen you do this elsewhere, but maybe we shou
kozy
2016/11/03 17:26:45
Changed to pointer.
| |
| 1374 if (debug_info->HasDebugCode()) { | |
| 1375 CodeBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); | |
| 1376 GetBreakablePositions(it, start_position, end_position, alignment, | |
| 1377 positions); | |
| 1378 } else { | |
| 1379 DCHECK(debug_info->HasDebugBytecodeArray()); | |
| 1380 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); | |
| 1381 GetBreakablePositions(it, start_position, end_position, alignment, | |
| 1382 positions); | |
| 1383 } | |
| 1384 } | |
| 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 Handle<FixedArray> candidates = | |
|
Yang
2016/11/03 08:03:26
Can we simply use a List<Handle<>> here?
kozy
2016/11/03 17:26:45
Done.
| |
| 1396 isolate_->factory()->NewFixedArray(infos->Length()); | |
| 1397 int length = 0; | |
| 1398 { | |
| 1399 WeakFixedArray::Iterator iterator(infos); | |
| 1400 SharedFunctionInfo* info; | |
| 1401 while ((info = iterator.Next<SharedFunctionInfo>())) { | |
| 1402 if (info->end_position() < start_position || | |
| 1403 info->start_position() >= end_position) { | |
| 1404 continue; | |
| 1405 } | |
| 1406 if (!info->IsSubjectToDebugging()) continue; | |
| 1407 if (!info->HasDebugCode() && !info->allows_lazy_compilation()) continue; | |
| 1408 candidates->set(length++, info); | |
| 1409 } | |
| 1410 } | |
| 1411 candidates->Shrink(length); | |
| 1412 | |
| 1413 bool was_compiled = false; | |
| 1414 for (int i = 0; i < length; ++i) { | |
| 1415 SharedFunctionInfo* info = SharedFunctionInfo::cast(candidates->get(i)); | |
| 1416 Handle<SharedFunctionInfo> info_handle(info); | |
| 1417 if (!info_handle->HasDebugCode()) { | |
| 1418 if (!Compiler::CompileDebugCode(info_handle)) { | |
| 1419 return false; | |
| 1420 } else { | |
| 1421 was_compiled = true; | |
| 1422 } | |
| 1423 } | |
| 1424 if (!info_handle->HasDebugInfo()) CreateDebugInfo(info_handle); | |
| 1425 } | |
| 1426 if (was_compiled) continue; | |
| 1427 | |
| 1428 for (int i = 0; i < length; ++i) { | |
| 1429 SharedFunctionInfo* info = SharedFunctionInfo::cast(candidates->get(i)); | |
| 1430 HandleScope scope(isolate_); | |
| 1431 Handle<SharedFunctionInfo> info_handle(info); | |
| 1432 CHECK(info->HasDebugInfo()); | |
| 1433 Handle<DebugInfo> debug_info(info_handle->GetDebugInfo()); | |
| 1434 FindBreakablePositions(debug_info, start_position, end_position, | |
| 1435 STATEMENT_ALIGNED, positions); | |
| 1436 } | |
| 1437 return true; | |
| 1438 } | |
| 1439 UNREACHABLE(); | |
| 1440 return false; | |
| 1441 } | |
| 1442 | |
| 1355 void Debug::RecordAsyncFunction(Handle<JSGeneratorObject> generator_object) { | 1443 void Debug::RecordAsyncFunction(Handle<JSGeneratorObject> generator_object) { |
| 1356 if (last_step_action() <= StepOut) return; | 1444 if (last_step_action() <= StepOut) return; |
| 1357 if (!IsAsyncFunction(generator_object->function()->shared()->kind())) return; | 1445 if (!IsAsyncFunction(generator_object->function()->shared()->kind())) return; |
| 1358 DCHECK(!has_suspended_generator()); | 1446 DCHECK(!has_suspended_generator()); |
| 1359 thread_local_.suspended_generator_ = *generator_object; | 1447 thread_local_.suspended_generator_ = *generator_object; |
| 1360 ClearStepping(); | 1448 ClearStepping(); |
| 1361 } | 1449 } |
| 1362 | 1450 |
| 1363 class SharedFunctionInfoFinder { | 1451 class SharedFunctionInfoFinder { |
| 1364 public: | 1452 public: |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2563 } | 2651 } |
| 2564 | 2652 |
| 2565 | 2653 |
| 2566 void LockingCommandMessageQueue::Clear() { | 2654 void LockingCommandMessageQueue::Clear() { |
| 2567 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2655 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 2568 queue_.Clear(); | 2656 queue_.Clear(); |
| 2569 } | 2657 } |
| 2570 | 2658 |
| 2571 } // namespace internal | 2659 } // namespace internal |
| 2572 } // namespace v8 | 2660 } // namespace v8 |
| OLD | NEW |