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

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 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS); 1325 BytecodeArrayBreakIterator it(debug_info, ALL_BREAK_LOCATIONS);
1326 GetBreakablePositions(&it, start_position, end_position, alignment, 1326 GetBreakablePositions(&it, start_position, end_position, alignment,
1327 positions); 1327 positions);
1328 } 1328 }
1329 } 1329 }
1330 } // namespace 1330 } // namespace
1331 1331
1332 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position, 1332 bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
1333 int end_position, std::set<int>* positions) { 1333 int end_position, std::set<int>* positions) {
1334 while (true) { 1334 while (true) {
1335 if (!script->shared_function_infos()->IsWeakFixedArray()) return false; 1335 FixedArray* infos = script->shared_function_infos();
1336
1337 WeakFixedArray* infos =
1338 WeakFixedArray::cast(script->shared_function_infos());
1339 HandleScope scope(isolate_); 1336 HandleScope scope(isolate_);
1340 List<Handle<SharedFunctionInfo>> candidates; 1337 List<Handle<SharedFunctionInfo>> candidates;
1341 { 1338 for (int index = 0; index < infos->length(); ++index) {
1342 WeakFixedArray::Iterator iterator(infos); 1339 Object* raw = infos->get(index);
1343 SharedFunctionInfo* info; 1340 if (raw->IsSmi() || WeakCell::cast(raw)->cleared()) continue;
Toon Verwaest 2016/12/06 21:10:14 I guess we should just install a cleared weak-cell
jochen (gone - plz use gerrit) 2016/12/07 15:57:00 I considered that, but it would create a lot of ov
Toon Verwaest 2016/12/08 07:31:30 Why? I presume we have a single preallocated clear
jochen (gone - plz use gerrit) 2016/12/08 12:31:14 no, we don't have that. The WeakCell currently has
1344 while ((info = iterator.Next<SharedFunctionInfo>())) { 1341 SharedFunctionInfo* info =
1345 if (info->end_position() < start_position || 1342 SharedFunctionInfo::cast(WeakCell::cast(raw)->value());
Toon Verwaest 2016/12/06 21:10:14 This actually makes me wonder if we shouldn't just
jochen (gone - plz use gerrit) 2016/12/07 15:57:00 if we do that, I think it should be a separate cle
Toon Verwaest 2016/12/08 07:31:30 Makes sense
1346 info->start_position() >= end_position) { 1343 if (info->end_position() < start_position ||
1347 continue; 1344 info->start_position() >= end_position) {
1348 } 1345 continue;
1349 if (!info->IsSubjectToDebugging()) continue;
1350 if (!info->HasDebugCode() && !info->allows_lazy_compilation()) continue;
1351 candidates.Add(i::handle(info));
1352 } 1346 }
1347 if (!info->IsSubjectToDebugging()) continue;
1348 if (!info->HasDebugCode() && !info->allows_lazy_compilation()) continue;
1349 candidates.Add(i::handle(info));
1353 } 1350 }
1354 1351
1355 bool was_compiled = false; 1352 bool was_compiled = false;
1356 for (int i = 0; i < candidates.length(); ++i) { 1353 for (int i = 0; i < candidates.length(); ++i) {
1357 // Code that cannot be compiled lazily are internal and not debuggable. 1354 // Code that cannot be compiled lazily are internal and not debuggable.
1358 DCHECK(candidates[i]->allows_lazy_compilation()); 1355 DCHECK(candidates[i]->allows_lazy_compilation());
1359 if (!candidates[i]->HasDebugCode()) { 1356 if (!candidates[i]->HasDebugCode()) {
1360 if (!Compiler::CompileDebugCode(candidates[i])) { 1357 if (!Compiler::CompileDebugCode(candidates[i])) {
1361 return false; 1358 return false;
1362 } else { 1359 } else {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 // 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
1453 // 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
1454 // 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.)
1455 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, 1452 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
1456 int position) { 1453 int position) {
1457 for (int iteration = 0;; iteration++) { 1454 for (int iteration = 0;; iteration++) {
1458 // Go through all shared function infos associated with this script to 1455 // Go through all shared function infos associated with this script to
1459 // find the inner most function containing this position. 1456 // find the inner most function containing this position.
1460 // 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
1461 // no point in looking for it by walking the heap. 1458 // no point in looking for it by walking the heap.
1462 if (!script->shared_function_infos()->IsWeakFixedArray()) break;
1463 1459
1464 SharedFunctionInfo* shared; 1460 SharedFunctionInfo* shared;
1465 { 1461 {
1466 SharedFunctionInfoFinder finder(position); 1462 SharedFunctionInfoFinder finder(position);
1467 WeakFixedArray::Iterator iterator(script->shared_function_infos()); 1463 FixedArray* infos = script->shared_function_infos();
1468 SharedFunctionInfo* candidate; 1464 for (int index = 0; index < infos->length(); ++index) {
Toon Verwaest 2016/12/06 21:10:14 Given that we iterate at least 3 times, does it ma
jochen (gone - plz use gerrit) 2016/12/07 15:57:00 done.
1469 while ((candidate = iterator.Next<SharedFunctionInfo>())) { 1465 Object* raw = infos->get(index);
1470 finder.NewCandidate(candidate); 1466 if (raw->IsSmi() || WeakCell::cast(raw)->cleared()) continue;
1467 finder.NewCandidate(
1468 SharedFunctionInfo::cast(WeakCell::cast(raw)->value()));
1471 } 1469 }
1472 shared = finder.Result(); 1470 shared = finder.Result();
1473 if (shared == NULL) break; 1471 if (shared == NULL) break;
1474 // We found it if it's already compiled and has debug code. 1472 // We found it if it's already compiled and has debug code.
1475 if (shared->HasDebugCode()) { 1473 if (shared->HasDebugCode()) {
1476 Handle<SharedFunctionInfo> shared_handle(shared); 1474 Handle<SharedFunctionInfo> shared_handle(shared);
1477 // If the iteration count is larger than 1, we had to compile the outer 1475 // If the iteration count is larger than 1, we had to compile the outer
1478 // function in order to create this shared function info. So there can 1476 // function in order to create this shared function info. So there can
1479 // be no JSFunction referencing it. We can anticipate creating a debug 1477 // be no JSFunction referencing it. We can anticipate creating a debug
1480 // info while bypassing PrepareFunctionForBreakpoints. 1478 // info while bypassing PrepareFunctionForBreakpoints.
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 logger_->DebugEvent("Put", message.text()); 2507 logger_->DebugEvent("Put", message.text());
2510 } 2508 }
2511 2509
2512 void LockingCommandMessageQueue::Clear() { 2510 void LockingCommandMessageQueue::Clear() {
2513 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2511 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2514 queue_.Clear(); 2512 queue_.Clear();
2515 } 2513 }
2516 2514
2517 } // namespace internal 2515 } // namespace internal
2518 } // namespace v8 2516 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | src/debug/liveedit.h » ('j') | src/debug/liveedit.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698