OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1867 Handle<JSObject>(Debug::debug_context()->global()), | 1867 Handle<JSObject>(Debug::debug_context()->global()), |
1868 0, NULL, &caught_exception); | 1868 0, NULL, &caught_exception); |
1869 } | 1869 } |
1870 | 1870 |
1871 | 1871 |
1872 void Debug::CreateScriptCache() { | 1872 void Debug::CreateScriptCache() { |
1873 HandleScope scope; | 1873 HandleScope scope; |
1874 | 1874 |
1875 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets | 1875 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets |
1876 // rid of all the cached script wrappers and the second gets rid of the | 1876 // rid of all the cached script wrappers and the second gets rid of the |
1877 // scripts which are no longer referenced. | 1877 // scripts which are no longer referenced. |
Vyacheslav Egorov (Chromium)
2011/03/15 09:20:09
Comment is outdated add more about precise sweepin
Erik Corry
2011/03/17 13:39:17
Done.
| |
1878 Heap::CollectAllGarbage(false); | 1878 Heap::CollectAllGarbage(Heap::kNoGCFlags); |
1879 Heap::CollectAllGarbage(false); | 1879 Heap::CollectAllGarbage(Heap::kSweepPreciselyMask); |
1880 | 1880 |
1881 ASSERT(script_cache_ == NULL); | 1881 ASSERT(script_cache_ == NULL); |
1882 script_cache_ = new ScriptCache(); | 1882 script_cache_ = new ScriptCache(); |
1883 | 1883 |
1884 // Scan heap for Script objects. | 1884 // Scan heap for Script objects. |
1885 int count = 0; | 1885 int count = 0; |
1886 HeapIterator iterator; | 1886 HeapIterator iterator; |
1887 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1887 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
1888 if (obj->IsScript() && Script::cast(obj)->HasValidSource()) { | 1888 if (obj->IsScript() && Script::cast(obj)->HasValidSource()) { |
1889 script_cache_->Add(Handle<Script>(Script::cast(obj))); | 1889 script_cache_->Add(Handle<Script>(Script::cast(obj))); |
1890 count++; | 1890 count++; |
1891 } | 1891 } |
1892 } | 1892 } |
1893 } | 1893 } |
1894 | 1894 |
1895 | 1895 |
1896 void Debug::DestroyScriptCache() { | 1896 void Debug::DestroyScriptCache() { |
1897 // Get rid of the script cache if it was created. | 1897 // Get rid of the script cache if it was created. |
(...skipping 19 matching lines...) Expand all Loading... | |
1917 } | 1917 } |
1918 | 1918 |
1919 // If the script cache is not active just return an empty array. | 1919 // If the script cache is not active just return an empty array. |
1920 ASSERT(script_cache_ != NULL); | 1920 ASSERT(script_cache_ != NULL); |
1921 if (script_cache_ == NULL) { | 1921 if (script_cache_ == NULL) { |
1922 Factory::NewFixedArray(0); | 1922 Factory::NewFixedArray(0); |
1923 } | 1923 } |
1924 | 1924 |
1925 // Perform GC to get unreferenced scripts evicted from the cache before | 1925 // Perform GC to get unreferenced scripts evicted from the cache before |
1926 // returning the content. | 1926 // returning the content. |
1927 Heap::CollectAllGarbage(false); | 1927 Heap::CollectAllGarbage(Heap::kNoGCFlags); |
1928 | 1928 |
1929 // Get the scripts from the cache. | 1929 // Get the scripts from the cache. |
1930 return script_cache_->GetScripts(); | 1930 return script_cache_->GetScripts(); |
1931 } | 1931 } |
1932 | 1932 |
1933 | 1933 |
1934 void Debug::AfterGarbageCollection() { | 1934 void Debug::AfterGarbageCollection() { |
1935 // Generate events for collected scripts. | 1935 // Generate events for collected scripts. |
1936 if (script_cache_ != NULL) { | 1936 if (script_cache_ != NULL) { |
1937 script_cache_->ProcessCollectedScripts(); | 1937 script_cache_->ProcessCollectedScripts(); |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3076 { | 3076 { |
3077 Locker locker; | 3077 Locker locker; |
3078 Debugger::CallMessageDispatchHandler(); | 3078 Debugger::CallMessageDispatchHandler(); |
3079 } | 3079 } |
3080 } | 3080 } |
3081 } | 3081 } |
3082 | 3082 |
3083 #endif // ENABLE_DEBUGGER_SUPPORT | 3083 #endif // ENABLE_DEBUGGER_SUPPORT |
3084 | 3084 |
3085 } } // namespace v8::internal | 3085 } } // namespace v8::internal |
OLD | NEW |