Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: src/debug/debug.cc

Issue 2547483002: Store SharedFunctionInfos of a Script in a FixedArray indexed by their ID (Closed)
Patch Set: updates Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 if (isolate_->concurrent_recompilation_enabled()) { 1237 if (isolate_->concurrent_recompilation_enabled()) {
1238 isolate_->optimizing_compile_dispatcher()->Flush(); 1238 isolate_->optimizing_compile_dispatcher()->Flush();
1239 } 1239 }
1240 1240
1241 List<Handle<JSFunction> > functions; 1241 List<Handle<JSFunction> > functions;
1242 1242
1243 // Flush all optimized code maps. Note that the below heap iteration does not 1243 // Flush all optimized code maps. Note that the below heap iteration does not
1244 // cover this, because the given function might have been inlined into code 1244 // cover this, because the given function might have been inlined into code
1245 // for which no JSFunction exists. 1245 // for which no JSFunction exists.
1246 { 1246 {
1247 SharedFunctionInfo::Iterator iterator(isolate_); 1247 SharedFunctionInfo::GlobalIterator iterator(isolate_);
1248 while (SharedFunctionInfo* shared = iterator.Next()) { 1248 while (SharedFunctionInfo* shared = iterator.Next()) {
1249 shared->ClearCodeFromOptimizedCodeMap(); 1249 shared->ClearCodeFromOptimizedCodeMap();
1250 } 1250 }
1251 } 1251 }
1252 1252
1253 // The native context also has a list of OSR'd optimized code. Clear it. 1253 // The native context also has a list of OSR'd optimized code. Clear it.
1254 isolate_->ClearOSROptimizedCode(); 1254 isolate_->ClearOSROptimizedCode();
1255 1255
1256 // Make sure we abort incremental marking. 1256 // Make sure we abort incremental marking.
1257 isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, 1257 isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); 1328 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS);
1329 GetBreakablePositions(&it, start_position, end_position, alignment, 1329 GetBreakablePositions(&it, start_position, end_position, alignment,
1330 positions); 1330 positions);
1331 } 1331 }
1332 } 1332 }
1333 } // namespace 1333 } // namespace
1334 1334
1335 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position, 1335 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
1336 int end_position, std::set<int>* positions) { 1336 int end_position, std::set<int>* positions) {
1337 while (true) { 1337 while (true) {
1338 if (!script->shared_function_infos()->IsWeakFixedArray()) return false;
1339
1340 WeakFixedArray* infos =
1341 WeakFixedArray::cast(script->shared_function_infos());
1342 HandleScope scope(isolate_); 1338 HandleScope scope(isolate_);
1343 List<Handle<SharedFunctionInfo>> candidates; 1339 List<Handle<SharedFunctionInfo>> candidates;
1344 { 1340 SharedFunctionInfo::ScriptIterator iterator(script);
1345 WeakFixedArray::Iterator iterator(infos); 1341 for (SharedFunctionInfo* info = iterator.Next(); info != nullptr;
1346 SharedFunctionInfo* info; 1342 info = iterator.Next()) {
1347 while ((info = iterator.Next<SharedFunctionInfo>())) { 1343 if (info->end_position() < start_position ||
1348 if (info->end_position() < start_position || 1344 info->start_position() >= end_position) {
1349 info->start_position() >= end_position) { 1345 continue;
1350 continue;
1351 }
1352 if (!info->IsSubjectToDebugging()) continue;
1353 if (!info->HasDebugCode() && !info->allows_lazy_compilation()) continue;
1354 candidates.Add(i::handle(info));
1355 } 1346 }
1347 if (!info->IsSubjectToDebugging()) continue;
1348 if (!info->HasDebugCode() && !info->allows_lazy_compilation()) continue;
1349 candidates.Add(i::handle(info));
1356 } 1350 }
1357 1351
1358 bool was_compiled = false; 1352 bool was_compiled = false;
1359 for (int i = 0; i < candidates.length(); ++i) { 1353 for (int i = 0; i < candidates.length(); ++i) {
1360 // Code that cannot be compiled lazily are internal and not debuggable. 1354 // Code that cannot be compiled lazily are internal and not debuggable.
1361 DCHECK(candidates[i]->allows_lazy_compilation()); 1355 DCHECK(candidates[i]->allows_lazy_compilation());
1362 if (!candidates[i]->HasDebugCode()) { 1356 if (!candidates[i]->HasDebugCode()) {
1363 if (!Compiler::CompileDebugCode(candidates[i])) { 1357 if (!Compiler::CompileDebugCode(candidates[i])) {
1364 return false; 1358 return false;
1365 } else { 1359 } else {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 // While we are at this, also ensure code with debug break slots so that we do 1449 // While we are at this, also ensure code with debug break slots so that we do
1456 // not have to compile a SFI without JSFunction, which is paifu for those that 1450 // not have to compile a SFI without JSFunction, which is paifu for those that
1457 // cannot be compiled without context (need to find outer compilable SFI etc.) 1451 // cannot be compiled without context (need to find outer compilable SFI etc.)
1458 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, 1452 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
1459 int position) { 1453 int position) {
1460 for (int iteration = 0;; iteration++) { 1454 for (int iteration = 0;; iteration++) {
1461 // Go through all shared function infos associated with this script to 1455 // Go through all shared function infos associated with this script to
1462 // find the inner most function containing this position. 1456 // find the inner most function containing this position.
1463 // If there is no shared function info for this script at all, there is 1457 // If there is no shared function info for this script at all, there is
1464 // no point in looking for it by walking the heap. 1458 // no point in looking for it by walking the heap.
1465 if (!script->shared_function_infos()->IsWeakFixedArray()) break;
1466 1459
1467 SharedFunctionInfo* shared; 1460 SharedFunctionInfo* shared;
1468 { 1461 {
1469 SharedFunctionInfoFinder finder(position); 1462 SharedFunctionInfoFinder finder(position);
1470 WeakFixedArray::Iterator iterator(script->shared_function_infos()); 1463 SharedFunctionInfo::ScriptIterator iterator(script);
1471 SharedFunctionInfo* candidate; 1464 for (SharedFunctionInfo* info = iterator.Next(); info != nullptr;
1472 while ((candidate = iterator.Next<SharedFunctionInfo>())) { 1465 info = iterator.Next()) {
1473 finder.NewCandidate(candidate); 1466 finder.NewCandidate(info);
1474 } 1467 }
1475 shared = finder.Result(); 1468 shared = finder.Result();
1476 if (shared == NULL) break; 1469 if (shared == NULL) break;
1477 // We found it if it's already compiled and has debug code. 1470 // We found it if it's already compiled and has debug code.
1478 if (shared->HasDebugCode()) { 1471 if (shared->HasDebugCode()) {
1479 Handle<SharedFunctionInfo> shared_handle(shared); 1472 Handle<SharedFunctionInfo> shared_handle(shared);
1480 // If the iteration count is larger than 1, we had to compile the outer 1473 // If the iteration count is larger than 1, we had to compile the outer
1481 // function in order to create this shared function info. So there can 1474 // function in order to create this shared function info. So there can
1482 // be no JSFunction referencing it. We can anticipate creating a debug 1475 // be no JSFunction referencing it. We can anticipate creating a debug
1483 // info while bypassing PrepareFunctionForBreakpoints. 1476 // info while bypassing PrepareFunctionForBreakpoints.
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 logger_->DebugEvent("Put", message.text()); 2494 logger_->DebugEvent("Put", message.text());
2502 } 2495 }
2503 2496
2504 void LockingCommandMessageQueue::Clear() { 2497 void LockingCommandMessageQueue::Clear() {
2505 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2498 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2506 queue_.Clear(); 2499 queue_.Clear();
2507 } 2500 }
2508 2501
2509 } // namespace internal 2502 } // namespace internal
2510 } // namespace v8 2503 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | src/debug/liveedit.h » ('j') | src/debug/liveedit.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698