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 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 } | 1321 } |
1322 } | 1322 } |
1323 } | 1323 } |
1324 | 1324 |
1325 // We do not need to replace code to debug bytecode. | 1325 // We do not need to replace code to debug bytecode. |
1326 DCHECK(baseline_exists || functions.is_empty()); | 1326 DCHECK(baseline_exists || functions.is_empty()); |
1327 DCHECK(baseline_exists || suspended_generators.is_empty()); | 1327 DCHECK(baseline_exists || suspended_generators.is_empty()); |
1328 | 1328 |
1329 // We do not need to recompile to debug bytecode. | 1329 // We do not need to recompile to debug bytecode. |
1330 if (baseline_exists && !shared->code()->has_debug_break_slots()) { | 1330 if (baseline_exists && !shared->code()->has_debug_break_slots()) { |
1331 DCHECK(functions.length() > 0); | 1331 if (!Compiler::CompileDebugCode(shared)) return false; |
1332 if (!Compiler::CompileDebugCode(functions.first())) return false; | |
1333 } | 1332 } |
1334 | 1333 |
1335 for (Handle<JSFunction> const function : functions) { | 1334 for (Handle<JSFunction> const function : functions) { |
1336 function->ReplaceCode(shared->code()); | 1335 function->ReplaceCode(shared->code()); |
1337 JSFunction::EnsureLiterals(function); | 1336 JSFunction::EnsureLiterals(function); |
1338 } | 1337 } |
1339 | 1338 |
1340 for (Handle<JSGeneratorObject> const generator_obj : suspended_generators) { | 1339 for (Handle<JSGeneratorObject> const generator_obj : suspended_generators) { |
1341 int index = generator_obj->continuation(); | 1340 int index = generator_obj->continuation(); |
1342 int pc_offset = ComputePcOffsetFromContinuationIndex(shared->code(), index); | 1341 int pc_offset = ComputePcOffsetFromContinuationIndex(shared->code(), index); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 // function in order to create this shared function info. So there can | 1519 // function in order to create this shared function info. So there can |
1521 // be no JSFunction referencing it. We can anticipate creating a debug | 1520 // be no JSFunction referencing it. We can anticipate creating a debug |
1522 // info while bypassing PrepareFunctionForBreakpoints. | 1521 // info while bypassing PrepareFunctionForBreakpoints. |
1523 if (iteration > 1) { | 1522 if (iteration > 1) { |
1524 AllowHeapAllocation allow_before_return; | 1523 AllowHeapAllocation allow_before_return; |
1525 CreateDebugInfo(shared_handle); | 1524 CreateDebugInfo(shared_handle); |
1526 } | 1525 } |
1527 return shared_handle; | 1526 return shared_handle; |
1528 } | 1527 } |
1529 } | 1528 } |
1530 // If not, compile to reveal inner functions, if possible. | 1529 // If not, compile to reveal inner functions. |
1531 if (shared->allows_lazy_compilation()) { | |
1532 HandleScope scope(isolate_); | |
1533 if (!Compiler::CompileDebugCode(handle(shared))) break; | |
1534 continue; | |
1535 } | |
1536 | |
1537 // If not possible, comb the heap for the best suitable compile target. | |
1538 JSFunction* closure; | |
1539 { | |
1540 HeapIterator it(isolate_->heap()); | |
1541 SharedFunctionInfoFinder finder(position); | |
1542 while (HeapObject* object = it.next()) { | |
1543 JSFunction* candidate_closure = NULL; | |
1544 SharedFunctionInfo* candidate = NULL; | |
1545 if (object->IsJSFunction()) { | |
1546 candidate_closure = JSFunction::cast(object); | |
1547 candidate = candidate_closure->shared(); | |
1548 } else if (object->IsSharedFunctionInfo()) { | |
1549 candidate = SharedFunctionInfo::cast(object); | |
1550 if (!candidate->allows_lazy_compilation()) continue; | |
1551 } else { | |
1552 continue; | |
1553 } | |
1554 if (candidate->script() == *script) { | |
1555 finder.NewCandidate(candidate, candidate_closure); | |
1556 } | |
1557 } | |
1558 closure = finder.ResultClosure(); | |
1559 shared = finder.Result(); | |
1560 } | |
1561 if (shared == NULL) break; | |
1562 HandleScope scope(isolate_); | 1530 HandleScope scope(isolate_); |
1563 if (closure == NULL) { | 1531 if (!Compiler::CompileDebugCode(handle(shared))) break; |
1564 if (!Compiler::CompileDebugCode(handle(shared))) break; | |
1565 } else { | |
1566 if (!Compiler::CompileDebugCode(handle(closure))) break; | |
1567 } | |
1568 } | 1532 } |
1569 return isolate_->factory()->undefined_value(); | 1533 return isolate_->factory()->undefined_value(); |
1570 } | 1534 } |
1571 | 1535 |
1572 | 1536 |
1573 // Ensures the debug information is present for shared. | 1537 // Ensures the debug information is present for shared. |
1574 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, | 1538 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, |
1575 Handle<JSFunction> function) { | 1539 Handle<JSFunction> function) { |
1576 if (!shared->IsSubjectToDebugging()) return false; | 1540 if (!shared->IsSubjectToDebugging()) return false; |
1577 | 1541 |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 } | 2609 } |
2646 | 2610 |
2647 | 2611 |
2648 void LockingCommandMessageQueue::Clear() { | 2612 void LockingCommandMessageQueue::Clear() { |
2649 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2613 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2650 queue_.Clear(); | 2614 queue_.Clear(); |
2651 } | 2615 } |
2652 | 2616 |
2653 } // namespace internal | 2617 } // namespace internal |
2654 } // namespace v8 | 2618 } // namespace v8 |
OLD | NEW |