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

Unified Diff: src/runtime/runtime-liveedit.cc

Issue 1291043002: Debugger: remove duplicate heap iterations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@debuggerglobal
Patch Set: slight change 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 | « src/runtime/runtime-debug.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-liveedit.cc
diff --git a/src/runtime/runtime-liveedit.cc b/src/runtime/runtime-liveedit.cc
index 0ec484204f965fbd69c2fc33e2ef8f77dc7557d6..b52980ab9237378796808f9b8c016f2617177907 100644
--- a/src/runtime/runtime-liveedit.cc
+++ b/src/runtime/runtime-liveedit.cc
@@ -15,32 +15,6 @@
namespace v8 {
namespace internal {
-
-static int FindSharedFunctionInfosForScript(HeapIterator* iterator,
- Script* script,
- FixedArray* buffer) {
- DisallowHeapAllocation no_allocation;
- int counter = 0;
- int buffer_size = buffer->length();
- for (HeapObject* obj = iterator->next(); obj != NULL;
- obj = iterator->next()) {
- DCHECK(obj != NULL);
- if (!obj->IsSharedFunctionInfo()) {
- continue;
- }
- SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj);
- if (shared->script() != script) {
- continue;
- }
- if (counter < buffer_size) {
- buffer->set(counter, shared);
- }
- counter++;
- }
- return counter;
-}
-
-
// For a script finds all SharedFunctionInfo's in the heap that points
// to this script. Returns JSArray of SharedFunctionInfo wrapped
// in OpaqueReferences.
@@ -53,32 +27,29 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
RUNTIME_ASSERT(script_value->value()->IsScript());
Handle<Script> script = Handle<Script>(Script::cast(script_value->value()));
- const int kBufferSize = 32;
-
- Handle<FixedArray> array;
- array = isolate->factory()->NewFixedArray(kBufferSize);
- int number;
+ List<Handle<SharedFunctionInfo> > found;
Heap* heap = isolate->heap();
{
- HeapIterator heap_iterator(heap);
- Script* scr = *script;
- FixedArray* arr = *array;
- number = FindSharedFunctionInfosForScript(&heap_iterator, scr, arr);
- }
- if (number > kBufferSize) {
- array = isolate->factory()->NewFixedArray(number);
- HeapIterator heap_iterator(heap);
- Script* scr = *script;
- FixedArray* arr = *array;
- FindSharedFunctionInfosForScript(&heap_iterator, scr, arr);
+ HeapIterator iterator(heap);
+ HeapObject* heap_obj;
+ while ((heap_obj = iterator.next())) {
+ if (!heap_obj->IsSharedFunctionInfo()) continue;
+ SharedFunctionInfo* shared = SharedFunctionInfo::cast(heap_obj);
+ if (shared->script() != *script) continue;
+ found.Add(Handle<SharedFunctionInfo>(shared));
+ }
}
- Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(array);
- result->set_length(Smi::FromInt(number));
-
- LiveEdit::WrapSharedFunctionInfos(result);
-
- return *result;
+ Handle<FixedArray> result = isolate->factory()->NewFixedArray(found.length());
+ for (int i = 0; i < found.length(); ++i) {
+ Handle<SharedFunctionInfo> shared = found[i];
+ SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(isolate);
+ Handle<String> name(String::cast(shared->name()));
+ info_wrapper.SetProperties(name, shared->start_position(),
+ shared->end_position(), shared);
+ result->set(i, *info_wrapper.GetJSArray());
+ }
+ return *isolate->factory()->NewJSArrayWithElements(result);
}
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698