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