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

Unified Diff: src/debug/debug.cc

Issue 1300333003: Introduce SharedFunctionInfo::Iterator and Script::Iterator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix rebase Created 5 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index 2bda0a7137a12323e2f112be99bc07b4d452fb29..6a491384440a7c000e5ee70d04c7a14a7215f98e 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -1424,17 +1424,17 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
while (true) {
// Go through all shared function infos associated with this script to
// find the inner most function containing this position.
+ // If there is no shared function info for this script at all, there is
+ // no point in looking for it by walking the heap.
if (!script->shared_function_infos()->IsWeakFixedArray()) break;
- WeakFixedArray* array =
- WeakFixedArray::cast(script->shared_function_infos());
SharedFunctionInfo* shared;
{
SharedFunctionInfoFinder finder(position);
- for (int i = 0; i < array->Length(); i++) {
- Object* item = array->Get(i);
- if (!item->IsSharedFunctionInfo()) continue;
- finder.NewCandidate(SharedFunctionInfo::cast(item));
+ WeakFixedArray::Iterator iterator(script->shared_function_infos());
+ SharedFunctionInfo* candidate;
+ while ((candidate = iterator.Next<SharedFunctionInfo>())) {
+ finder.NewCandidate(candidate);
}
shared = finder.Result();
if (shared == NULL) break;
@@ -1608,8 +1608,7 @@ void Debug::ClearMirrorCache() {
Handle<FixedArray> Debug::GetLoadedScripts() {
- isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags,
- "Debug::GetLoadedScripts");
+ isolate_->heap()->CollectAllGarbage();
Factory* factory = isolate_->factory();
if (!factory->script_list()->IsWeakFixedArray()) {
return factory->empty_fixed_array();
@@ -1618,10 +1617,11 @@ Handle<FixedArray> Debug::GetLoadedScripts() {
Handle<WeakFixedArray>::cast(factory->script_list());
Handle<FixedArray> results = factory->NewFixedArray(array->Length());
int length = 0;
- for (int i = 0; i < array->Length(); ++i) {
- Object* item = array->Get(i);
- if (item->IsScript() && Script::cast(item)->HasValidSource()) {
- results->set(length++, item);
+ {
+ Script::Iterator iterator(isolate_);
+ Script* script;
+ while ((script = iterator.Next())) {
+ if (script->HasValidSource()) results->set(length++, script);
}
}
results->Shrink(length);
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698