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

Side by Side Diff: src/runtime.cc

Issue 555072: Merge ObjectIterator::has_next and ObjectIterator::next methods.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mark-compact.cc ('k') | src/spaces.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7194 matching lines...) Expand 10 before | Expand all | Expand 10 after
7205 // compiled function and the actual requested break point might be in one of 7205 // compiled function and the actual requested break point might be in one of
7206 // these functions. 7206 // these functions.
7207 bool done = false; 7207 bool done = false;
7208 // The current candidate for the source position: 7208 // The current candidate for the source position:
7209 int target_start_position = RelocInfo::kNoPosition; 7209 int target_start_position = RelocInfo::kNoPosition;
7210 Handle<SharedFunctionInfo> target; 7210 Handle<SharedFunctionInfo> target;
7211 // The current candidate for the last function in script: 7211 // The current candidate for the last function in script:
7212 Handle<SharedFunctionInfo> last; 7212 Handle<SharedFunctionInfo> last;
7213 while (!done) { 7213 while (!done) {
7214 HeapIterator iterator; 7214 HeapIterator iterator;
7215 while (iterator.has_next()) { 7215 for (HeapObject* obj = iterator.next();
7216 HeapObject* obj = iterator.next(); 7216 obj != NULL; obj = iterator.next()) {
7217 ASSERT(obj != NULL);
7218 if (obj->IsSharedFunctionInfo()) { 7217 if (obj->IsSharedFunctionInfo()) {
7219 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(obj)); 7218 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(obj));
7220 if (shared->script() == *script) { 7219 if (shared->script() == *script) {
7221 // If the SharedFunctionInfo found has the requested script data and 7220 // If the SharedFunctionInfo found has the requested script data and
7222 // contains the source position it is a candidate. 7221 // contains the source position it is a candidate.
7223 int start_position = shared->function_token_position(); 7222 int start_position = shared->function_token_position();
7224 if (start_position == RelocInfo::kNoPosition) { 7223 if (start_position == RelocInfo::kNoPosition) {
7225 start_position = shared->start_position(); 7224 start_position = shared->start_position();
7226 } 7225 }
7227 if (start_position <= position && 7226 if (start_position <= position &&
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
7663 Object* instance_filter, int max_references, 7662 Object* instance_filter, int max_references,
7664 FixedArray* instances, int instances_size, 7663 FixedArray* instances, int instances_size,
7665 JSFunction* arguments_function) { 7664 JSFunction* arguments_function) {
7666 NoHandleAllocation ha; 7665 NoHandleAllocation ha;
7667 AssertNoAllocation no_alloc; 7666 AssertNoAllocation no_alloc;
7668 7667
7669 // Iterate the heap. 7668 // Iterate the heap.
7670 int count = 0; 7669 int count = 0;
7671 JSObject* last = NULL; 7670 JSObject* last = NULL;
7672 HeapIterator iterator; 7671 HeapIterator iterator;
7673 while (iterator.has_next() && 7672 HeapObject* heap_obj = NULL;
7673 while (((heap_obj = iterator.next()) != NULL) &&
7674 (max_references == 0 || count < max_references)) { 7674 (max_references == 0 || count < max_references)) {
7675 // Only look at all JSObjects. 7675 // Only look at all JSObjects.
7676 HeapObject* heap_obj = iterator.next();
7677 if (heap_obj->IsJSObject()) { 7676 if (heap_obj->IsJSObject()) {
7678 // Skip context extension objects and argument arrays as these are 7677 // Skip context extension objects and argument arrays as these are
7679 // checked in the context of functions using them. 7678 // checked in the context of functions using them.
7680 JSObject* obj = JSObject::cast(heap_obj); 7679 JSObject* obj = JSObject::cast(heap_obj);
7681 if (obj->IsJSContextExtensionObject() || 7680 if (obj->IsJSContextExtensionObject() ||
7682 obj->map()->constructor() == arguments_function) { 7681 obj->map()->constructor() == arguments_function) {
7683 continue; 7682 continue;
7684 } 7683 }
7685 7684
7686 // Check if the JS object has a reference to the object looked for. 7685 // Check if the JS object has a reference to the object looked for.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
7776 7775
7777 7776
7778 // Helper function used by Runtime_DebugConstructedBy below. 7777 // Helper function used by Runtime_DebugConstructedBy below.
7779 static int DebugConstructedBy(JSFunction* constructor, int max_references, 7778 static int DebugConstructedBy(JSFunction* constructor, int max_references,
7780 FixedArray* instances, int instances_size) { 7779 FixedArray* instances, int instances_size) {
7781 AssertNoAllocation no_alloc; 7780 AssertNoAllocation no_alloc;
7782 7781
7783 // Iterate the heap. 7782 // Iterate the heap.
7784 int count = 0; 7783 int count = 0;
7785 HeapIterator iterator; 7784 HeapIterator iterator;
7786 while (iterator.has_next() && 7785 HeapObject* heap_obj = NULL;
7786 while (((heap_obj = iterator.next()) != NULL) &&
7787 (max_references == 0 || count < max_references)) { 7787 (max_references == 0 || count < max_references)) {
7788 // Only look at all JSObjects. 7788 // Only look at all JSObjects.
7789 HeapObject* heap_obj = iterator.next();
7790 if (heap_obj->IsJSObject()) { 7789 if (heap_obj->IsJSObject()) {
7791 JSObject* obj = JSObject::cast(heap_obj); 7790 JSObject* obj = JSObject::cast(heap_obj);
7792 if (obj->map()->constructor() == constructor) { 7791 if (obj->map()->constructor() == constructor) {
7793 // Valid reference found add to instance array if supplied an update 7792 // Valid reference found add to instance array if supplied an update
7794 // count. 7793 // count.
7795 if (instances != NULL && count < instances_size) { 7794 if (instances != NULL && count < instances_size) {
7796 instances->set(count, obj); 7795 instances->set(count, obj);
7797 } 7796 }
7798 count++; 7797 count++;
7799 } 7798 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
7927 // for the requested break point. For lazily compiled functions several heap 7926 // for the requested break point. For lazily compiled functions several heap
7928 // traversals might be required rendering this operation as a rather slow 7927 // traversals might be required rendering this operation as a rather slow
7929 // operation. However for setting break points which is normally done through 7928 // operation. However for setting break points which is normally done through
7930 // some kind of user interaction the performance is not crucial. 7929 // some kind of user interaction the performance is not crucial.
7931 static Handle<Object> Runtime_GetScriptFromScriptName( 7930 static Handle<Object> Runtime_GetScriptFromScriptName(
7932 Handle<String> script_name) { 7931 Handle<String> script_name) {
7933 // Scan the heap for Script objects to find the script with the requested 7932 // Scan the heap for Script objects to find the script with the requested
7934 // script data. 7933 // script data.
7935 Handle<Script> script; 7934 Handle<Script> script;
7936 HeapIterator iterator; 7935 HeapIterator iterator;
7937 while (script.is_null() && iterator.has_next()) { 7936 HeapObject* obj = NULL;
7938 HeapObject* obj = iterator.next(); 7937 while (script.is_null() && ((obj = iterator.next()) != NULL)) {
7939 // If a script is found check if it has the script data requested. 7938 // If a script is found check if it has the script data requested.
7940 if (obj->IsScript()) { 7939 if (obj->IsScript()) {
7941 if (Script::cast(obj)->name()->IsString()) { 7940 if (Script::cast(obj)->name()->IsString()) {
7942 if (String::cast(Script::cast(obj)->name())->Equals(*script_name)) { 7941 if (String::cast(Script::cast(obj)->name())->Equals(*script_name)) {
7943 script = Handle<Script>(Script::cast(obj)); 7942 script = Handle<Script>(Script::cast(obj));
7944 } 7943 }
7945 } 7944 }
7946 } 7945 }
7947 } 7946 }
7948 7947
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
8164 } else { 8163 } else {
8165 // Handle last resort GC and make sure to allow future allocations 8164 // Handle last resort GC and make sure to allow future allocations
8166 // to grow the heap without causing GCs (if possible). 8165 // to grow the heap without causing GCs (if possible).
8167 Counters::gc_last_resort_from_js.Increment(); 8166 Counters::gc_last_resort_from_js.Increment();
8168 Heap::CollectAllGarbage(false); 8167 Heap::CollectAllGarbage(false);
8169 } 8168 }
8170 } 8169 }
8171 8170
8172 8171
8173 } } // namespace v8::internal 8172 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698