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

Side by Side Diff: src/debug.cc

Issue 12217106: Don't use TLS for space iterators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed feedback. Created 7 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 | 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 // 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 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 // There will be at least one break point when we are done. 1998 // There will be at least one break point when we are done.
1999 has_break_points_ = true; 1999 has_break_points_ = true;
2000 2000
2001 // Keep the list of activated functions in a handlified list as it 2001 // Keep the list of activated functions in a handlified list as it
2002 // is used both in GC and non-GC code. 2002 // is used both in GC and non-GC code.
2003 List<Handle<JSFunction> > active_functions(100); 2003 List<Handle<JSFunction> > active_functions(100);
2004 2004
2005 { 2005 {
2006 // We are going to iterate heap to find all functions without 2006 // We are going to iterate heap to find all functions without
2007 // debug break slots. 2007 // debug break slots.
2008 isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, 2008 Heap* heap = isolate_->heap();
2009 "preparing for breakpoints"); 2009 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask,
2010 "preparing for breakpoints");
2010 2011
2011 // Ensure no GC in this scope as we are going to use gc_metadata 2012 // Ensure no GC in this scope as we are going to use gc_metadata
2012 // field in the Code object to mark active functions. 2013 // field in the Code object to mark active functions.
2013 AssertNoAllocation no_allocation; 2014 AssertNoAllocation no_allocation;
2014 2015
2015 Object* active_code_marker = isolate_->heap()->the_hole_value(); 2016 Object* active_code_marker = heap->the_hole_value();
2016 2017
2017 CollectActiveFunctionsFromThread(isolate_, 2018 CollectActiveFunctionsFromThread(isolate_,
2018 isolate_->thread_local_top(), 2019 isolate_->thread_local_top(),
2019 &active_functions, 2020 &active_functions,
2020 active_code_marker); 2021 active_code_marker);
2021 ActiveFunctionsCollector active_functions_collector(&active_functions, 2022 ActiveFunctionsCollector active_functions_collector(&active_functions,
2022 active_code_marker); 2023 active_code_marker);
2023 isolate_->thread_manager()->IterateArchivedThreads( 2024 isolate_->thread_manager()->IterateArchivedThreads(
2024 &active_functions_collector); 2025 &active_functions_collector);
2025 2026
2026 // Scan the heap for all non-optimized functions which have no 2027 // Scan the heap for all non-optimized functions which have no
2027 // debug break slots and are not active or inlined into an active 2028 // debug break slots and are not active or inlined into an active
2028 // function and mark them for lazy compilation. 2029 // function and mark them for lazy compilation.
2029 HeapIterator iterator; 2030 HeapIterator iterator(heap);
2030 HeapObject* obj = NULL; 2031 HeapObject* obj = NULL;
2031 while (((obj = iterator.next()) != NULL)) { 2032 while (((obj = iterator.next()) != NULL)) {
2032 if (obj->IsJSFunction()) { 2033 if (obj->IsJSFunction()) {
2033 JSFunction* function = JSFunction::cast(obj); 2034 JSFunction* function = JSFunction::cast(obj);
2034 SharedFunctionInfo* shared = function->shared(); 2035 SharedFunctionInfo* shared = function->shared();
2035 if (shared->allows_lazy_compilation() && 2036 if (shared->allows_lazy_compilation() &&
2036 shared->script()->IsScript() && 2037 shared->script()->IsScript() &&
2037 function->code()->kind() == Code::FUNCTION && 2038 function->code()->kind() == Code::FUNCTION &&
2038 !function->code()->has_debug_break_slots() && 2039 !function->code()->has_debug_break_slots() &&
2039 shared->code()->gc_metadata() != active_code_marker) { 2040 shared->code()->gc_metadata() != active_code_marker) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 // compiled function and the actual requested break point might be in one of 2115 // compiled function and the actual requested break point might be in one of
2115 // these functions. 2116 // these functions.
2116 // NOTE: The below fix-point iteration depends on all functions that cannot be 2117 // NOTE: The below fix-point iteration depends on all functions that cannot be
2117 // compiled lazily without a context to not be compiled at all. Compilation 2118 // compiled lazily without a context to not be compiled at all. Compilation
2118 // will be triggered at points where we do not need a context. 2119 // will be triggered at points where we do not need a context.
2119 bool done = false; 2120 bool done = false;
2120 // The current candidate for the source position: 2121 // The current candidate for the source position:
2121 int target_start_position = RelocInfo::kNoPosition; 2122 int target_start_position = RelocInfo::kNoPosition;
2122 Handle<JSFunction> target_function; 2123 Handle<JSFunction> target_function;
2123 Handle<SharedFunctionInfo> target; 2124 Handle<SharedFunctionInfo> target;
2125 Heap* heap = isolate_->heap();
2124 while (!done) { 2126 while (!done) {
2125 { // Extra scope for iterator and no-allocation. 2127 { // Extra scope for iterator and no-allocation.
2126 isolate_->heap()->EnsureHeapIsIterable(); 2128 heap->EnsureHeapIsIterable();
2127 AssertNoAllocation no_alloc_during_heap_iteration; 2129 AssertNoAllocation no_alloc_during_heap_iteration;
2128 HeapIterator iterator; 2130 HeapIterator iterator(heap);
2129 for (HeapObject* obj = iterator.next(); 2131 for (HeapObject* obj = iterator.next();
2130 obj != NULL; obj = iterator.next()) { 2132 obj != NULL; obj = iterator.next()) {
2131 bool found_next_candidate = false; 2133 bool found_next_candidate = false;
2132 Handle<JSFunction> function; 2134 Handle<JSFunction> function;
2133 Handle<SharedFunctionInfo> shared; 2135 Handle<SharedFunctionInfo> shared;
2134 if (obj->IsJSFunction()) { 2136 if (obj->IsJSFunction()) {
2135 function = Handle<JSFunction>(JSFunction::cast(obj)); 2137 function = Handle<JSFunction>(JSFunction::cast(obj));
2136 shared = Handle<SharedFunctionInfo>(function->shared()); 2138 shared = Handle<SharedFunctionInfo>(function->shared());
2137 ASSERT(shared->allows_lazy_compilation() || shared->is_compiled()); 2139 ASSERT(shared->allows_lazy_compilation() || shared->is_compiled());
2138 found_next_candidate = true; 2140 found_next_candidate = true;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 target_start_position = start_position; 2180 target_start_position = start_position;
2179 target_function = function; 2181 target_function = function;
2180 target = shared; 2182 target = shared;
2181 } 2183 }
2182 } 2184 }
2183 } 2185 }
2184 } 2186 }
2185 } // End for loop. 2187 } // End for loop.
2186 } // End no-allocation scope. 2188 } // End no-allocation scope.
2187 2189
2188 if (target.is_null()) { 2190 if (target.is_null()) return heap->undefined_value();
2189 return isolate_->heap()->undefined_value();
2190 }
2191 2191
2192 // There will be at least one break point when we are done. 2192 // There will be at least one break point when we are done.
2193 has_break_points_ = true; 2193 has_break_points_ = true;
2194 2194
2195 // If the candidate found is compiled we are done. 2195 // If the candidate found is compiled we are done.
2196 done = target->is_compiled(); 2196 done = target->is_compiled();
2197 if (!done) { 2197 if (!done) {
2198 // If the candidate is not compiled, compile it to reveal any inner 2198 // If the candidate is not compiled, compile it to reveal any inner
2199 // functions which might contain the requested source position. This 2199 // functions which might contain the requested source position. This
2200 // will compile all inner functions that cannot be compiled without a 2200 // will compile all inner functions that cannot be compiled without a
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 // which saves us doing yet another GC to make the heap iterable. 2454 // which saves us doing yet another GC to make the heap iterable.
2455 heap->CollectAllGarbage(Heap::kNoGCFlags, "Debug::CreateScriptCache"); 2455 heap->CollectAllGarbage(Heap::kNoGCFlags, "Debug::CreateScriptCache");
2456 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, 2456 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask,
2457 "Debug::CreateScriptCache"); 2457 "Debug::CreateScriptCache");
2458 2458
2459 ASSERT(script_cache_ == NULL); 2459 ASSERT(script_cache_ == NULL);
2460 script_cache_ = new ScriptCache(); 2460 script_cache_ = new ScriptCache();
2461 2461
2462 // Scan heap for Script objects. 2462 // Scan heap for Script objects.
2463 int count = 0; 2463 int count = 0;
2464 HeapIterator iterator; 2464 HeapIterator iterator(heap);
2465 AssertNoAllocation no_allocation; 2465 AssertNoAllocation no_allocation;
2466 2466
2467 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 2467 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
2468 if (obj->IsScript() && Script::cast(obj)->HasValidSource()) { 2468 if (obj->IsScript() && Script::cast(obj)->HasValidSource()) {
2469 script_cache_->Add(Handle<Script>(Script::cast(obj))); 2469 script_cache_->Add(Handle<Script>(Script::cast(obj)));
2470 count++; 2470 count++;
2471 } 2471 }
2472 } 2472 }
2473 } 2473 }
2474 2474
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
3781 { 3781 {
3782 Locker locker(reinterpret_cast<v8::Isolate*>(isolate)); 3782 Locker locker(reinterpret_cast<v8::Isolate*>(isolate));
3783 isolate->debugger()->CallMessageDispatchHandler(); 3783 isolate->debugger()->CallMessageDispatchHandler();
3784 } 3784 }
3785 } 3785 }
3786 } 3786 }
3787 3787
3788 #endif // ENABLE_DEBUGGER_SUPPORT 3788 #endif // ENABLE_DEBUGGER_SUPPORT
3789 3789
3790 } } // namespace v8::internal 3790 } } // 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