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

Side by Side Diff: src/debug.cc

Issue 299813002: Revert "Fix Heap::IsHeapIterable." (again) (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/heap.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "api.h" 7 #include "api.h"
8 #include "arguments.h" 8 #include "arguments.h"
9 #include "bootstrapper.h" 9 #include "bootstrapper.h"
10 #include "code-stubs.h" 10 #include "code-stubs.h"
(...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 // We could perhaps avoid this list and instead re-use the GC metadata 2034 // We could perhaps avoid this list and instead re-use the GC metadata
2035 // links. 2035 // links.
2036 List<Handle<JSFunction> > generator_functions; 2036 List<Handle<JSFunction> > generator_functions;
2037 2037
2038 { 2038 {
2039 // We are going to iterate heap to find all functions without 2039 // We are going to iterate heap to find all functions without
2040 // debug break slots. 2040 // debug break slots.
2041 Heap* heap = isolate_->heap(); 2041 Heap* heap = isolate_->heap();
2042 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, 2042 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask,
2043 "preparing for breakpoints"); 2043 "preparing for breakpoints");
2044 HeapIterator iterator(heap);
2045 2044
2046 // Ensure no GC in this scope as we are going to use gc_metadata 2045 // Ensure no GC in this scope as we are going to use gc_metadata
2047 // field in the Code object to mark active functions. 2046 // field in the Code object to mark active functions.
2048 DisallowHeapAllocation no_allocation; 2047 DisallowHeapAllocation no_allocation;
2049 2048
2050 Object* active_code_marker = heap->the_hole_value(); 2049 Object* active_code_marker = heap->the_hole_value();
2051 2050
2052 CollectActiveFunctionsFromThread(isolate_, 2051 CollectActiveFunctionsFromThread(isolate_,
2053 isolate_->thread_local_top(), 2052 isolate_->thread_local_top(),
2054 &active_functions, 2053 &active_functions,
2055 active_code_marker); 2054 active_code_marker);
2056 ActiveFunctionsCollector active_functions_collector(&active_functions, 2055 ActiveFunctionsCollector active_functions_collector(&active_functions,
2057 active_code_marker); 2056 active_code_marker);
2058 isolate_->thread_manager()->IterateArchivedThreads( 2057 isolate_->thread_manager()->IterateArchivedThreads(
2059 &active_functions_collector); 2058 &active_functions_collector);
2060 2059
2061 // Scan the heap for all non-optimized functions which have no 2060 // Scan the heap for all non-optimized functions which have no
2062 // debug break slots and are not active or inlined into an active 2061 // debug break slots and are not active or inlined into an active
2063 // function and mark them for lazy compilation. 2062 // function and mark them for lazy compilation.
2063 HeapIterator iterator(heap);
2064 HeapObject* obj = NULL; 2064 HeapObject* obj = NULL;
2065 while (((obj = iterator.next()) != NULL)) { 2065 while (((obj = iterator.next()) != NULL)) {
2066 if (obj->IsJSFunction()) { 2066 if (obj->IsJSFunction()) {
2067 JSFunction* function = JSFunction::cast(obj); 2067 JSFunction* function = JSFunction::cast(obj);
2068 SharedFunctionInfo* shared = function->shared(); 2068 SharedFunctionInfo* shared = function->shared();
2069 2069
2070 if (!shared->allows_lazy_compilation()) continue; 2070 if (!shared->allows_lazy_compilation()) continue;
2071 if (!shared->script()->IsScript()) continue; 2071 if (!shared->script()->IsScript()) continue;
2072 if (function->IsBuiltin()) continue; 2072 if (function->IsBuiltin()) continue;
2073 if (shared->code()->gc_metadata() == active_code_marker) continue; 2073 if (shared->code()->gc_metadata() == active_code_marker) continue;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 // NOTE: The below fix-point iteration depends on all functions that cannot be 2178 // NOTE: The below fix-point iteration depends on all functions that cannot be
2179 // compiled lazily without a context to not be compiled at all. Compilation 2179 // compiled lazily without a context to not be compiled at all. Compilation
2180 // will be triggered at points where we do not need a context. 2180 // will be triggered at points where we do not need a context.
2181 bool done = false; 2181 bool done = false;
2182 // The current candidate for the source position: 2182 // The current candidate for the source position:
2183 int target_start_position = RelocInfo::kNoPosition; 2183 int target_start_position = RelocInfo::kNoPosition;
2184 Handle<JSFunction> target_function; 2184 Handle<JSFunction> target_function;
2185 Handle<SharedFunctionInfo> target; 2185 Handle<SharedFunctionInfo> target;
2186 Heap* heap = isolate_->heap(); 2186 Heap* heap = isolate_->heap();
2187 while (!done) { 2187 while (!done) {
2188 { // Extra scope for iterator. 2188 { // Extra scope for iterator and no-allocation.
2189 heap->EnsureHeapIsIterable();
2190 DisallowHeapAllocation no_alloc_during_heap_iteration;
2189 HeapIterator iterator(heap); 2191 HeapIterator iterator(heap);
2190 for (HeapObject* obj = iterator.next(); 2192 for (HeapObject* obj = iterator.next();
2191 obj != NULL; obj = iterator.next()) { 2193 obj != NULL; obj = iterator.next()) {
2192 bool found_next_candidate = false; 2194 bool found_next_candidate = false;
2193 Handle<JSFunction> function; 2195 Handle<JSFunction> function;
2194 Handle<SharedFunctionInfo> shared; 2196 Handle<SharedFunctionInfo> shared;
2195 if (obj->IsJSFunction()) { 2197 if (obj->IsJSFunction()) {
2196 function = Handle<JSFunction>(JSFunction::cast(obj)); 2198 function = Handle<JSFunction>(JSFunction::cast(obj));
2197 shared = Handle<SharedFunctionInfo>(function->shared()); 2199 shared = Handle<SharedFunctionInfo>(function->shared());
2198 ASSERT(shared->allows_lazy_compilation() || shared->is_compiled()); 2200 ASSERT(shared->allows_lazy_compilation() || shared->is_compiled());
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 2510
2509 void Debug::CreateScriptCache() { 2511 void Debug::CreateScriptCache() {
2510 Heap* heap = isolate_->heap(); 2512 Heap* heap = isolate_->heap();
2511 HandleScope scope(isolate_); 2513 HandleScope scope(isolate_);
2512 2514
2513 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets 2515 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets
2514 // rid of all the cached script wrappers and the second gets rid of the 2516 // rid of all the cached script wrappers and the second gets rid of the
2515 // scripts which are no longer referenced. The second also sweeps precisely, 2517 // scripts which are no longer referenced. The second also sweeps precisely,
2516 // which saves us doing yet another GC to make the heap iterable. 2518 // which saves us doing yet another GC to make the heap iterable.
2517 heap->CollectAllGarbage(Heap::kNoGCFlags, "Debug::CreateScriptCache"); 2519 heap->CollectAllGarbage(Heap::kNoGCFlags, "Debug::CreateScriptCache");
2520 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask,
2521 "Debug::CreateScriptCache");
2518 2522
2519 ASSERT(script_cache_ == NULL); 2523 ASSERT(script_cache_ == NULL);
2520 script_cache_ = new ScriptCache(isolate_); 2524 script_cache_ = new ScriptCache(isolate_);
2521 2525
2522 // Scan heap for Script objects. 2526 // Scan heap for Script objects.
2523 int count = 0; 2527 int count = 0;
2524 HeapIterator iterator(heap); 2528 HeapIterator iterator(heap);
2529 DisallowHeapAllocation no_allocation;
2525 2530
2526 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 2531 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
2527 if (obj->IsScript() && Script::cast(obj)->HasValidSource()) { 2532 if (obj->IsScript() && Script::cast(obj)->HasValidSource()) {
2528 script_cache_->Add(Handle<Script>(Script::cast(obj))); 2533 script_cache_->Add(Handle<Script>(Script::cast(obj)));
2529 count++; 2534 count++;
2530 } 2535 }
2531 } 2536 }
2532 } 2537 }
2533 2538
2534 2539
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
3539 logger_->DebugEvent("Put", message.text()); 3544 logger_->DebugEvent("Put", message.text());
3540 } 3545 }
3541 3546
3542 3547
3543 void LockingCommandMessageQueue::Clear() { 3548 void LockingCommandMessageQueue::Clear() {
3544 LockGuard<Mutex> lock_guard(&mutex_); 3549 LockGuard<Mutex> lock_guard(&mutex_);
3545 queue_.Clear(); 3550 queue_.Clear();
3546 } 3551 }
3547 3552
3548 } } // namespace v8::internal 3553 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698