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 "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 // and there may not be a JSFunction referencing it. Find the SFI closest to | 1417 // and there may not be a JSFunction referencing it. Find the SFI closest to |
1418 // the given position, compile it to reveal possible inner SFIs and repeat. | 1418 // the given position, compile it to reveal possible inner SFIs and repeat. |
1419 // While we are at this, also ensure code with debug break slots so that we do | 1419 // While we are at this, also ensure code with debug break slots so that we do |
1420 // not have to compile a SFI without JSFunction, which is paifu for those that | 1420 // not have to compile a SFI without JSFunction, which is paifu for those that |
1421 // cannot be compiled without context (need to find outer compilable SFI etc.) | 1421 // cannot be compiled without context (need to find outer compilable SFI etc.) |
1422 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, | 1422 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, |
1423 int position) { | 1423 int position) { |
1424 while (true) { | 1424 while (true) { |
1425 // Go through all shared function infos associated with this script to | 1425 // Go through all shared function infos associated with this script to |
1426 // find the inner most function containing this position. | 1426 // find the inner most function containing this position. |
| 1427 // If there is no shared function info for this script at all, there is |
| 1428 // no point in looking for it by walking the heap. |
1427 if (!script->shared_function_infos()->IsWeakFixedArray()) break; | 1429 if (!script->shared_function_infos()->IsWeakFixedArray()) break; |
1428 WeakFixedArray* array = | |
1429 WeakFixedArray::cast(script->shared_function_infos()); | |
1430 | 1430 |
1431 SharedFunctionInfo* shared; | 1431 SharedFunctionInfo* shared; |
1432 { | 1432 { |
1433 SharedFunctionInfoFinder finder(position); | 1433 SharedFunctionInfoFinder finder(position); |
1434 for (int i = 0; i < array->Length(); i++) { | 1434 WeakFixedArray::Iterator iterator(script->shared_function_infos()); |
1435 Object* item = array->Get(i); | 1435 SharedFunctionInfo* candidate; |
1436 if (!item->IsSharedFunctionInfo()) continue; | 1436 while ((candidate = iterator.Next<SharedFunctionInfo>())) { |
1437 finder.NewCandidate(SharedFunctionInfo::cast(item)); | 1437 finder.NewCandidate(candidate); |
1438 } | 1438 } |
1439 shared = finder.Result(); | 1439 shared = finder.Result(); |
1440 if (shared == NULL) break; | 1440 if (shared == NULL) break; |
1441 // We found it if it's already compiled and has debug code. | 1441 // We found it if it's already compiled and has debug code. |
1442 if (shared->HasDebugCode()) return handle(shared); | 1442 if (shared->HasDebugCode()) return handle(shared); |
1443 } | 1443 } |
1444 // If not, compile to reveal inner functions, if possible. | 1444 // If not, compile to reveal inner functions, if possible. |
1445 if (shared->allows_lazy_compilation_without_context()) { | 1445 if (shared->allows_lazy_compilation_without_context()) { |
1446 HandleScope scope(isolate_); | 1446 HandleScope scope(isolate_); |
1447 if (!Compiler::CompileDebugCode(handle(shared))) break; | 1447 if (!Compiler::CompileDebugCode(handle(shared))) break; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 | 1601 |
1602 | 1602 |
1603 void Debug::ClearMirrorCache() { | 1603 void Debug::ClearMirrorCache() { |
1604 PostponeInterruptsScope postpone(isolate_); | 1604 PostponeInterruptsScope postpone(isolate_); |
1605 HandleScope scope(isolate_); | 1605 HandleScope scope(isolate_); |
1606 CallFunction("ClearMirrorCache", 0, NULL); | 1606 CallFunction("ClearMirrorCache", 0, NULL); |
1607 } | 1607 } |
1608 | 1608 |
1609 | 1609 |
1610 Handle<FixedArray> Debug::GetLoadedScripts() { | 1610 Handle<FixedArray> Debug::GetLoadedScripts() { |
1611 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 1611 isolate_->heap()->CollectAllGarbage(); |
1612 "Debug::GetLoadedScripts"); | |
1613 Factory* factory = isolate_->factory(); | 1612 Factory* factory = isolate_->factory(); |
1614 if (!factory->script_list()->IsWeakFixedArray()) { | 1613 if (!factory->script_list()->IsWeakFixedArray()) { |
1615 return factory->empty_fixed_array(); | 1614 return factory->empty_fixed_array(); |
1616 } | 1615 } |
1617 Handle<WeakFixedArray> array = | 1616 Handle<WeakFixedArray> array = |
1618 Handle<WeakFixedArray>::cast(factory->script_list()); | 1617 Handle<WeakFixedArray>::cast(factory->script_list()); |
1619 Handle<FixedArray> results = factory->NewFixedArray(array->Length()); | 1618 Handle<FixedArray> results = factory->NewFixedArray(array->Length()); |
1620 int length = 0; | 1619 int length = 0; |
1621 for (int i = 0; i < array->Length(); ++i) { | 1620 { |
1622 Object* item = array->Get(i); | 1621 Script::Iterator iterator(isolate_); |
1623 if (item->IsScript() && Script::cast(item)->HasValidSource()) { | 1622 Script* script; |
1624 results->set(length++, item); | 1623 while ((script = iterator.Next())) { |
| 1624 if (script->HasValidSource()) results->set(length++, script); |
1625 } | 1625 } |
1626 } | 1626 } |
1627 results->Shrink(length); | 1627 results->Shrink(length); |
1628 return results; | 1628 return results; |
1629 } | 1629 } |
1630 | 1630 |
1631 | 1631 |
1632 void Debug::GetStepinPositions(JavaScriptFrame* frame, StackFrame::Id frame_id, | 1632 void Debug::GetStepinPositions(JavaScriptFrame* frame, StackFrame::Id frame_id, |
1633 List<int>* results_out) { | 1633 List<int>* results_out) { |
1634 FrameSummary summary = GetFirstFrameSummary(frame); | 1634 FrameSummary summary = GetFirstFrameSummary(frame); |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 } | 2613 } |
2614 | 2614 |
2615 | 2615 |
2616 void LockingCommandMessageQueue::Clear() { | 2616 void LockingCommandMessageQueue::Clear() { |
2617 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2617 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2618 queue_.Clear(); | 2618 queue_.Clear(); |
2619 } | 2619 } |
2620 | 2620 |
2621 } // namespace internal | 2621 } // namespace internal |
2622 } // namespace v8 | 2622 } // namespace v8 |
OLD | NEW |