| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 Handle<Code> lazy_compile = | 1896 Handle<Code> lazy_compile = |
| 1897 Handle<Code>(isolate_->builtins()->builtin(Builtins::kLazyCompile)); | 1897 Handle<Code>(isolate_->builtins()->builtin(Builtins::kLazyCompile)); |
| 1898 | 1898 |
| 1899 // Keep the list of activated functions in a handlified list as it | 1899 // Keep the list of activated functions in a handlified list as it |
| 1900 // is used both in GC and non-GC code. | 1900 // is used both in GC and non-GC code. |
| 1901 List<Handle<JSFunction> > active_functions(100); | 1901 List<Handle<JSFunction> > active_functions(100); |
| 1902 | 1902 |
| 1903 { | 1903 { |
| 1904 // We are going to iterate heap to find all functions without | 1904 // We are going to iterate heap to find all functions without |
| 1905 // debug break slots. | 1905 // debug break slots. |
| 1906 isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 1906 isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
| 1907 "preparing for breakpoints"); |
| 1907 | 1908 |
| 1908 // Ensure no GC in this scope as we are going to use gc_metadata | 1909 // Ensure no GC in this scope as we are going to use gc_metadata |
| 1909 // field in the Code object to mark active functions. | 1910 // field in the Code object to mark active functions. |
| 1910 AssertNoAllocation no_allocation; | 1911 AssertNoAllocation no_allocation; |
| 1911 | 1912 |
| 1912 Object* active_code_marker = isolate_->heap()->the_hole_value(); | 1913 Object* active_code_marker = isolate_->heap()->the_hole_value(); |
| 1913 | 1914 |
| 1914 CollectActiveFunctionsFromThread(isolate_, | 1915 CollectActiveFunctionsFromThread(isolate_, |
| 1915 isolate_->thread_local_top(), | 1916 isolate_->thread_local_top(), |
| 1916 &active_functions, | 1917 &active_functions, |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 | 2223 |
| 2223 | 2224 |
| 2224 void Debug::CreateScriptCache() { | 2225 void Debug::CreateScriptCache() { |
| 2225 Heap* heap = isolate_->heap(); | 2226 Heap* heap = isolate_->heap(); |
| 2226 HandleScope scope(isolate_); | 2227 HandleScope scope(isolate_); |
| 2227 | 2228 |
| 2228 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets | 2229 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets |
| 2229 // rid of all the cached script wrappers and the second gets rid of the | 2230 // rid of all the cached script wrappers and the second gets rid of the |
| 2230 // scripts which are no longer referenced. The second also sweeps precisely, | 2231 // scripts which are no longer referenced. The second also sweeps precisely, |
| 2231 // which saves us doing yet another GC to make the heap iterable. | 2232 // which saves us doing yet another GC to make the heap iterable. |
| 2232 heap->CollectAllGarbage(Heap::kNoGCFlags); | 2233 heap->CollectAllGarbage(Heap::kNoGCFlags, "Debug::CreateScriptCache"); |
| 2233 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 2234 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
| 2235 "Debug::CreateScriptCache"); |
| 2234 | 2236 |
| 2235 ASSERT(script_cache_ == NULL); | 2237 ASSERT(script_cache_ == NULL); |
| 2236 script_cache_ = new ScriptCache(); | 2238 script_cache_ = new ScriptCache(); |
| 2237 | 2239 |
| 2238 // Scan heap for Script objects. | 2240 // Scan heap for Script objects. |
| 2239 int count = 0; | 2241 int count = 0; |
| 2240 HeapIterator iterator; | 2242 HeapIterator iterator; |
| 2241 AssertNoAllocation no_allocation; | 2243 AssertNoAllocation no_allocation; |
| 2242 | 2244 |
| 2243 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 2245 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2273 } | 2275 } |
| 2274 | 2276 |
| 2275 // If the script cache is not active just return an empty array. | 2277 // If the script cache is not active just return an empty array. |
| 2276 ASSERT(script_cache_ != NULL); | 2278 ASSERT(script_cache_ != NULL); |
| 2277 if (script_cache_ == NULL) { | 2279 if (script_cache_ == NULL) { |
| 2278 isolate_->factory()->NewFixedArray(0); | 2280 isolate_->factory()->NewFixedArray(0); |
| 2279 } | 2281 } |
| 2280 | 2282 |
| 2281 // Perform GC to get unreferenced scripts evicted from the cache before | 2283 // Perform GC to get unreferenced scripts evicted from the cache before |
| 2282 // returning the content. | 2284 // returning the content. |
| 2283 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 2285 isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 2286 "Debug::GetLoadedScripts"); |
| 2284 | 2287 |
| 2285 // Get the scripts from the cache. | 2288 // Get the scripts from the cache. |
| 2286 return script_cache_->GetScripts(); | 2289 return script_cache_->GetScripts(); |
| 2287 } | 2290 } |
| 2288 | 2291 |
| 2289 | 2292 |
| 2290 void Debug::AfterGarbageCollection() { | 2293 void Debug::AfterGarbageCollection() { |
| 2291 // Generate events for collected scripts. | 2294 // Generate events for collected scripts. |
| 2292 if (script_cache_ != NULL) { | 2295 if (script_cache_ != NULL) { |
| 2293 script_cache_->ProcessCollectedScripts(); | 2296 script_cache_->ProcessCollectedScripts(); |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3551 { | 3554 { |
| 3552 Locker locker; | 3555 Locker locker; |
| 3553 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3556 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
| 3554 } | 3557 } |
| 3555 } | 3558 } |
| 3556 } | 3559 } |
| 3557 | 3560 |
| 3558 #endif // ENABLE_DEBUGGER_SUPPORT | 3561 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3559 | 3562 |
| 3560 } } // namespace v8::internal | 3563 } } // namespace v8::internal |
| OLD | NEW |