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

Unified Diff: src/log.cc

Issue 269003: Fix a crash in Logger::LogCompiledFunctions due to a presence of scripts with disposed source. (Closed)
Patch Set: Fixed comments Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index d225c3b49515a4df9d3574fe6246d92bcc95d62d..1c82f8525c95f954e87091a7d3b964e7c6fe24aa 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -1070,37 +1070,33 @@ int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) {
}
-void Logger::LogCompiledFunctions() {
- HandleScope scope;
- Handle<SharedFunctionInfo>* sfis = NULL;
+static int EnumerateCompiledFunctions(Handle<SharedFunctionInfo>* sfis) {
+ AssertNoAllocation no_alloc;
int compiled_funcs_count = 0;
-
- {
- AssertNoAllocation no_alloc;
-
- HeapIterator iterator;
- while (iterator.has_next()) {
- HeapObject* obj = iterator.next();
- ASSERT(obj != NULL);
- if (obj->IsSharedFunctionInfo()
- && SharedFunctionInfo::cast(obj)->is_compiled()) {
- ++compiled_funcs_count;
- }
+ HeapIterator iterator;
+ while (iterator.has_next()) {
+ HeapObject* obj = iterator.next();
+ ASSERT(obj != NULL);
+ if (!obj->IsSharedFunctionInfo()) continue;
+ SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj);
+ if (sfi->is_compiled()
+ && (!sfi->script()->IsScript()
+ || Script::cast(sfi->script())->HasValidSource())) {
+ if (sfis != NULL)
+ sfis[compiled_funcs_count] = Handle<SharedFunctionInfo>(sfi);
+ ++compiled_funcs_count;
}
+ }
+ return compiled_funcs_count;
+}
- sfis = NewArray< Handle<SharedFunctionInfo> >(compiled_funcs_count);
- iterator.reset();
- int i = 0;
- while (iterator.has_next()) {
- HeapObject* obj = iterator.next();
- ASSERT(obj != NULL);
- if (obj->IsSharedFunctionInfo()
- && SharedFunctionInfo::cast(obj)->is_compiled()) {
- sfis[i++] = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(obj));
- }
- }
- }
+void Logger::LogCompiledFunctions() {
+ HandleScope scope;
+ const int compiled_funcs_count = EnumerateCompiledFunctions(NULL);
+ Handle<SharedFunctionInfo>* sfis =
+ NewArray< Handle<SharedFunctionInfo> >(compiled_funcs_count);
+ EnumerateCompiledFunctions(sfis);
// During iteration, there can be heap allocation due to
// GetScriptLineNumber call.
« no previous file with comments | « src/debug.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698