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 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); | 1322 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); |
1323 GetBreakablePositions(&it, start_position, end_position, alignment, | 1323 GetBreakablePositions(&it, start_position, end_position, alignment, |
1324 positions); | 1324 positions); |
1325 } | 1325 } |
1326 } | 1326 } |
1327 } // namespace | 1327 } // namespace |
1328 | 1328 |
1329 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position, | 1329 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position, |
1330 int end_position, std::set<int>* positions) { | 1330 int end_position, std::set<int>* positions) { |
1331 while (true) { | 1331 while (true) { |
1332 if (!script->shared_function_infos()->IsWeakFixedArray()) return false; | 1332 FixedArray* infos = script->shared_function_infos(); |
1333 | |
1334 WeakFixedArray* infos = | |
1335 WeakFixedArray::cast(script->shared_function_infos()); | |
1336 HandleScope scope(isolate_); | 1333 HandleScope scope(isolate_); |
1337 List<Handle<SharedFunctionInfo>> candidates; | 1334 List<Handle<SharedFunctionInfo>> candidates; |
1338 { | 1335 for (int index = 0; index < infos->length(); ++index) { |
1339 WeakFixedArray::Iterator iterator(infos); | 1336 Object* raw = infos->get(index); |
1340 SharedFunctionInfo* info; | 1337 if (raw->IsSmi() || WeakCell::cast(raw)->cleared()) continue; |
1341 while ((info = iterator.Next<SharedFunctionInfo>())) { | 1338 SharedFunctionInfo* info = |
1342 if (info->end_position() < start_position || | 1339 SharedFunctionInfo::cast(WeakCell::cast(raw)->value()); |
1343 info->start_position() >= end_position) { | 1340 if (info->end_position() < start_position || |
1344 continue; | 1341 info->start_position() >= end_position) { |
1345 } | 1342 continue; |
1346 if (!info->IsSubjectToDebugging()) continue; | |
1347 if (!info->HasDebugCode() && !info->allows_lazy_compilation()) continue; | |
1348 candidates.Add(i::handle(info)); | |
1349 } | 1343 } |
| 1344 if (!info->IsSubjectToDebugging()) continue; |
| 1345 if (!info->HasDebugCode() && !info->allows_lazy_compilation()) continue; |
| 1346 candidates.Add(i::handle(info)); |
1350 } | 1347 } |
1351 | 1348 |
1352 bool was_compiled = false; | 1349 bool was_compiled = false; |
1353 for (int i = 0; i < candidates.length(); ++i) { | 1350 for (int i = 0; i < candidates.length(); ++i) { |
1354 // Code that cannot be compiled lazily are internal and not debuggable. | 1351 // Code that cannot be compiled lazily are internal and not debuggable. |
1355 DCHECK(candidates[i]->allows_lazy_compilation()); | 1352 DCHECK(candidates[i]->allows_lazy_compilation()); |
1356 if (!candidates[i]->HasDebugCode()) { | 1353 if (!candidates[i]->HasDebugCode()) { |
1357 if (!Compiler::CompileDebugCode(candidates[i])) { | 1354 if (!Compiler::CompileDebugCode(candidates[i])) { |
1358 return false; | 1355 return false; |
1359 } else { | 1356 } else { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 // While we are at this, also ensure code with debug break slots so that we do | 1445 // While we are at this, also ensure code with debug break slots so that we do |
1449 // not have to compile a SFI without JSFunction, which is paifu for those that | 1446 // not have to compile a SFI without JSFunction, which is paifu for those that |
1450 // cannot be compiled without context (need to find outer compilable SFI etc.) | 1447 // cannot be compiled without context (need to find outer compilable SFI etc.) |
1451 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, | 1448 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, |
1452 int position) { | 1449 int position) { |
1453 for (int iteration = 0;; iteration++) { | 1450 for (int iteration = 0;; iteration++) { |
1454 // Go through all shared function infos associated with this script to | 1451 // Go through all shared function infos associated with this script to |
1455 // find the inner most function containing this position. | 1452 // find the inner most function containing this position. |
1456 // If there is no shared function info for this script at all, there is | 1453 // If there is no shared function info for this script at all, there is |
1457 // no point in looking for it by walking the heap. | 1454 // no point in looking for it by walking the heap. |
1458 if (!script->shared_function_infos()->IsWeakFixedArray()) break; | |
1459 | 1455 |
1460 SharedFunctionInfo* shared; | 1456 SharedFunctionInfo* shared; |
1461 { | 1457 { |
1462 SharedFunctionInfoFinder finder(position); | 1458 SharedFunctionInfoFinder finder(position); |
1463 WeakFixedArray::Iterator iterator(script->shared_function_infos()); | 1459 FixedArray* infos = script->shared_function_infos(); |
1464 SharedFunctionInfo* candidate; | 1460 for (int index = 0; index < infos->length(); ++index) { |
1465 while ((candidate = iterator.Next<SharedFunctionInfo>())) { | 1461 Object* raw = infos->get(index); |
1466 finder.NewCandidate(candidate); | 1462 if (raw->IsSmi() || WeakCell::cast(raw)->cleared()) continue; |
| 1463 finder.NewCandidate( |
| 1464 SharedFunctionInfo::cast(WeakCell::cast(raw)->value())); |
1467 } | 1465 } |
1468 shared = finder.Result(); | 1466 shared = finder.Result(); |
1469 if (shared == NULL) break; | 1467 if (shared == NULL) break; |
1470 // We found it if it's already compiled and has debug code. | 1468 // We found it if it's already compiled and has debug code. |
1471 if (shared->HasDebugCode()) { | 1469 if (shared->HasDebugCode()) { |
1472 Handle<SharedFunctionInfo> shared_handle(shared); | 1470 Handle<SharedFunctionInfo> shared_handle(shared); |
1473 // If the iteration count is larger than 1, we had to compile the outer | 1471 // If the iteration count is larger than 1, we had to compile the outer |
1474 // function in order to create this shared function info. So there can | 1472 // function in order to create this shared function info. So there can |
1475 // be no JSFunction referencing it. We can anticipate creating a debug | 1473 // be no JSFunction referencing it. We can anticipate creating a debug |
1476 // info while bypassing PrepareFunctionForBreakpoints. | 1474 // info while bypassing PrepareFunctionForBreakpoints. |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 v8::Debug::ClientData* EventDetailsImpl::GetClientData() const { | 2123 v8::Debug::ClientData* EventDetailsImpl::GetClientData() const { |
2126 return client_data_; | 2124 return client_data_; |
2127 } | 2125 } |
2128 | 2126 |
2129 v8::Isolate* EventDetailsImpl::GetIsolate() const { | 2127 v8::Isolate* EventDetailsImpl::GetIsolate() const { |
2130 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); | 2128 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); |
2131 } | 2129 } |
2132 | 2130 |
2133 } // namespace internal | 2131 } // namespace internal |
2134 } // namespace v8 | 2132 } // namespace v8 |
OLD | NEW |