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

Unified Diff: src/runtime.cc

Issue 291193002: Revert "Fix Heap::IsHeapIterable." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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/liveedit.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 3522609f4fb1c3d5f593c3bc437299fdd7c64de0..99dc6bfc406de1bc245c51fa302ab7d9ba32474c 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -13129,6 +13129,14 @@ RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
HandleScope scope(isolate);
ASSERT(args.length() == 3);
+ // First perform a full GC in order to avoid references from dead objects.
+ Heap* heap = isolate->heap();
+ heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugReferencedBy");
+ // The heap iterator reserves the right to do a GC to make the heap iterable.
+ // Due to the GC above we know it won't need to do that, but it seems cleaner
+ // to get the heap iterator constructed before we start having unprotected
+ // Object* locals that are not protected by handles.
+
// Check parameters.
CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, instance_filter, 1);
@@ -13146,27 +13154,21 @@ RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
// Get the number of referencing objects.
int count;
- // First perform a full GC in order to avoid dead objects and to make the heap
- // iterable.
- Heap* heap = isolate->heap();
- heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy");
- {
- HeapIterator heap_iterator(heap);
- count = DebugReferencedBy(&heap_iterator,
- *target, *instance_filter, max_references,
- NULL, 0, *arguments_function);
- }
+ HeapIterator heap_iterator(heap);
+ count = DebugReferencedBy(&heap_iterator,
+ *target, *instance_filter, max_references,
+ NULL, 0, *arguments_function);
// Allocate an array to hold the result.
Handle<FixedArray> instances = isolate->factory()->NewFixedArray(count);
// Fill the referencing objects.
- {
- HeapIterator heap_iterator(heap);
- count = DebugReferencedBy(&heap_iterator,
- *target, *instance_filter, max_references,
- *instances, count, *arguments_function);
- }
+ // AllocateFixedArray above does not make the heap non-iterable.
+ ASSERT(heap->IsHeapIterable());
+ HeapIterator heap_iterator2(heap);
+ count = DebugReferencedBy(&heap_iterator2,
+ *target, *instance_filter, max_references,
+ *instances, count, *arguments_function);
// Return result as JS array.
Handle<JSFunction> constructor(
@@ -13217,6 +13219,9 @@ RUNTIME_FUNCTION(Runtime_DebugConstructedBy) {
HandleScope scope(isolate);
ASSERT(args.length() == 2);
+ // First perform a full GC in order to avoid dead objects.
+ Heap* heap = isolate->heap();
+ heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy");
// Check parameters.
CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0);
@@ -13225,31 +13230,24 @@ RUNTIME_FUNCTION(Runtime_DebugConstructedBy) {
// Get the number of referencing objects.
int count;
- // First perform a full GC in order to avoid dead objects and to make the heap
- // iterable.
- Heap* heap = isolate->heap();
- heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy");
- {
- HeapIterator heap_iterator(heap);
- count = DebugConstructedBy(&heap_iterator,
- *constructor,
- max_references,
- NULL,
- 0);
- }
+ HeapIterator heap_iterator(heap);
+ count = DebugConstructedBy(&heap_iterator,
+ *constructor,
+ max_references,
+ NULL,
+ 0);
// Allocate an array to hold the result.
Handle<FixedArray> instances = isolate->factory()->NewFixedArray(count);
+ ASSERT(heap->IsHeapIterable());
// Fill the referencing objects.
- {
- HeapIterator heap_iterator2(heap);
- count = DebugConstructedBy(&heap_iterator2,
- *constructor,
- max_references,
- *instances,
- count);
- }
+ HeapIterator heap_iterator2(heap);
+ count = DebugConstructedBy(&heap_iterator2,
+ *constructor,
+ max_references,
+ *instances,
+ count);
// Return result as JS array.
Handle<JSFunction> array_function(
@@ -13381,6 +13379,8 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
int number;
Heap* heap = isolate->heap();
{
+ heap->EnsureHeapIsIterable();
+ DisallowHeapAllocation no_allocation;
HeapIterator heap_iterator(heap);
Script* scr = *script;
FixedArray* arr = *array;
@@ -13388,6 +13388,8 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
}
if (number > kBufferSize) {
array = isolate->factory()->NewFixedArray(number);
+ heap->EnsureHeapIsIterable();
+ DisallowHeapAllocation no_allocation;
HeapIterator heap_iterator(heap);
Script* scr = *script;
FixedArray* arr = *array;
@@ -14470,6 +14472,8 @@ static Handle<Object> Runtime_GetScriptFromScriptName(
Handle<Script> script;
Factory* factory = script_name->GetIsolate()->factory();
Heap* heap = script_name->GetHeap();
+ heap->EnsureHeapIsIterable();
+ DisallowHeapAllocation no_allocation_during_heap_iteration;
HeapIterator iterator(heap);
HeapObject* obj = NULL;
while (script.is_null() && ((obj = iterator.next()) != NULL)) {
« no previous file with comments | « src/liveedit.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698