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

Side by Side Diff: src/runtime.cc

Issue 18857: Skip the context extension object when locating objects referenced from anoth... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 10 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 | « no previous file | test/mjsunit/debug-referenced-by.js » ('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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 5718 matching lines...) Expand 10 before | Expand all | Expand 10 after
5729 Handle<JSObject> result = Factory::NewJSObject(Top::array_function()); 5729 Handle<JSObject> result = Factory::NewJSObject(Top::array_function());
5730 Handle<JSArray>::cast(result)->SetContent(*instances); 5730 Handle<JSArray>::cast(result)->SetContent(*instances);
5731 return *result; 5731 return *result;
5732 } 5732 }
5733 5733
5734 5734
5735 // Helper function used by Runtime_DebugReferencedBy below. 5735 // Helper function used by Runtime_DebugReferencedBy below.
5736 static int DebugReferencedBy(JSObject* target, 5736 static int DebugReferencedBy(JSObject* target,
5737 Object* instance_filter, int max_references, 5737 Object* instance_filter, int max_references,
5738 FixedArray* instances, int instances_size, 5738 FixedArray* instances, int instances_size,
5739 JSFunction* context_extension_function,
5740 JSFunction* arguments_function) { 5739 JSFunction* arguments_function) {
5741 NoHandleAllocation ha; 5740 NoHandleAllocation ha;
5742 AssertNoAllocation no_alloc; 5741 AssertNoAllocation no_alloc;
5743 5742
5744 // Iterate the heap. 5743 // Iterate the heap.
5745 int count = 0; 5744 int count = 0;
5746 JSObject* last = NULL; 5745 JSObject* last = NULL;
5747 HeapIterator iterator; 5746 HeapIterator iterator;
5748 while (iterator.has_next() && 5747 while (iterator.has_next() &&
5749 (max_references == 0 || count < max_references)) { 5748 (max_references == 0 || count < max_references)) {
5750 // Only look at all JSObjects. 5749 // Only look at all JSObjects.
5751 HeapObject* heap_obj = iterator.next(); 5750 HeapObject* heap_obj = iterator.next();
5752 if (heap_obj->IsJSObject()) { 5751 if (heap_obj->IsJSObject()) {
5753 // Skip context extension objects and argument arrays as these are 5752 // Skip context extension objects and argument arrays as these are
5754 // checked in the context of functions using them. 5753 // checked in the context of functions using them.
5755 JSObject* obj = JSObject::cast(heap_obj); 5754 JSObject* obj = JSObject::cast(heap_obj);
5756 if (obj->map()->constructor() == context_extension_function || 5755 if (obj->IsJSContextExtensionObject() ||
5757 obj->map()->constructor() == arguments_function) { 5756 obj->map()->constructor() == arguments_function) {
5758 continue; 5757 continue;
5759 } 5758 }
5760 5759
5761 // Check if the JS object has a reference to the object looked for. 5760 // Check if the JS object has a reference to the object looked for.
5762 if (obj->ReferencesObject(target)) { 5761 if (obj->ReferencesObject(target)) {
5763 // Check instance filter if supplied. This is normally used to avoid 5762 // Check instance filter if supplied. This is normally used to avoid
5764 // references from mirror objects (see Runtime_IsInPrototypeChain). 5763 // references from mirror objects (see Runtime_IsInPrototypeChain).
5765 if (!instance_filter->IsUndefined()) { 5764 if (!instance_filter->IsUndefined()) {
5766 Object* V = obj; 5765 Object* V = obj;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5815 5814
5816 // Check parameters. 5815 // Check parameters.
5817 CONVERT_CHECKED(JSObject, target, args[0]); 5816 CONVERT_CHECKED(JSObject, target, args[0]);
5818 Object* instance_filter = args[1]; 5817 Object* instance_filter = args[1];
5819 RUNTIME_ASSERT(instance_filter->IsUndefined() || 5818 RUNTIME_ASSERT(instance_filter->IsUndefined() ||
5820 instance_filter->IsJSObject()); 5819 instance_filter->IsJSObject());
5821 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); 5820 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]);
5822 RUNTIME_ASSERT(max_references >= 0); 5821 RUNTIME_ASSERT(max_references >= 0);
5823 5822
5824 // Get the constructor function for context extension and arguments array. 5823 // Get the constructor function for context extension and arguments array.
5825 JSFunction* context_extension_function =
5826 Top::context()->global_context()->context_extension_function();
5827 JSObject* arguments_boilerplate = 5824 JSObject* arguments_boilerplate =
5828 Top::context()->global_context()->arguments_boilerplate(); 5825 Top::context()->global_context()->arguments_boilerplate();
5829 JSFunction* arguments_function = 5826 JSFunction* arguments_function =
5830 JSFunction::cast(arguments_boilerplate->map()->constructor()); 5827 JSFunction::cast(arguments_boilerplate->map()->constructor());
5831 5828
5832 // Get the number of referencing objects. 5829 // Get the number of referencing objects.
5833 int count; 5830 int count;
5834 count = DebugReferencedBy(target, instance_filter, max_references, 5831 count = DebugReferencedBy(target, instance_filter, max_references,
5835 NULL, 0, 5832 NULL, 0, arguments_function);
5836 context_extension_function, arguments_function);
5837 5833
5838 // Allocate an array to hold the result. 5834 // Allocate an array to hold the result.
5839 Object* object = Heap::AllocateFixedArray(count); 5835 Object* object = Heap::AllocateFixedArray(count);
5840 if (object->IsFailure()) return object; 5836 if (object->IsFailure()) return object;
5841 FixedArray* instances = FixedArray::cast(object); 5837 FixedArray* instances = FixedArray::cast(object);
5842 5838
5843 // Fill the referencing objects. 5839 // Fill the referencing objects.
5844 count = DebugReferencedBy(target, instance_filter, max_references, 5840 count = DebugReferencedBy(target, instance_filter, max_references,
5845 instances, count, 5841 instances, count, arguments_function);
5846 context_extension_function, arguments_function);
5847 5842
5848 // Return result as JS array. 5843 // Return result as JS array.
5849 Object* result = 5844 Object* result =
5850 Heap::AllocateJSObject( 5845 Heap::AllocateJSObject(
5851 Top::context()->global_context()->array_function()); 5846 Top::context()->global_context()->array_function());
5852 if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances); 5847 if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances);
5853 return result; 5848 return result;
5854 } 5849 }
5855 5850
5856 5851
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
6094 } else { 6089 } else {
6095 // Handle last resort GC and make sure to allow future allocations 6090 // Handle last resort GC and make sure to allow future allocations
6096 // to grow the heap without causing GCs (if possible). 6091 // to grow the heap without causing GCs (if possible).
6097 Counters::gc_last_resort_from_js.Increment(); 6092 Counters::gc_last_resort_from_js.Increment();
6098 Heap::CollectAllGarbage(); 6093 Heap::CollectAllGarbage();
6099 } 6094 }
6100 } 6095 }
6101 6096
6102 6097
6103 } } // namespace v8::internal 6098 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/debug-referenced-by.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698