OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 bool Logger::IsProfilerSamplerActive() { | 1063 bool Logger::IsProfilerSamplerActive() { |
1064 return ticker_->IsActive(); | 1064 return ticker_->IsActive(); |
1065 } | 1065 } |
1066 | 1066 |
1067 | 1067 |
1068 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) { | 1068 int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) { |
1069 return Log::GetLogLines(from_pos, dest_buf, max_size); | 1069 return Log::GetLogLines(from_pos, dest_buf, max_size); |
1070 } | 1070 } |
1071 | 1071 |
1072 | 1072 |
| 1073 static int EnumerateCompiledFunctions(Handle<SharedFunctionInfo>* sfis) { |
| 1074 AssertNoAllocation no_alloc; |
| 1075 int compiled_funcs_count = 0; |
| 1076 HeapIterator iterator; |
| 1077 while (iterator.has_next()) { |
| 1078 HeapObject* obj = iterator.next(); |
| 1079 ASSERT(obj != NULL); |
| 1080 if (!obj->IsSharedFunctionInfo()) continue; |
| 1081 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); |
| 1082 if (sfi->is_compiled() |
| 1083 && (!sfi->script()->IsScript() |
| 1084 || Script::cast(sfi->script())->HasValidSource())) { |
| 1085 if (sfis != NULL) |
| 1086 sfis[compiled_funcs_count] = Handle<SharedFunctionInfo>(sfi); |
| 1087 ++compiled_funcs_count; |
| 1088 } |
| 1089 } |
| 1090 return compiled_funcs_count; |
| 1091 } |
| 1092 |
| 1093 |
1073 void Logger::LogCompiledFunctions() { | 1094 void Logger::LogCompiledFunctions() { |
1074 HandleScope scope; | 1095 HandleScope scope; |
1075 Handle<SharedFunctionInfo>* sfis = NULL; | 1096 const int compiled_funcs_count = EnumerateCompiledFunctions(NULL); |
1076 int compiled_funcs_count = 0; | 1097 Handle<SharedFunctionInfo>* sfis = |
1077 | 1098 NewArray< Handle<SharedFunctionInfo> >(compiled_funcs_count); |
1078 { | 1099 EnumerateCompiledFunctions(sfis); |
1079 AssertNoAllocation no_alloc; | |
1080 | |
1081 HeapIterator iterator; | |
1082 while (iterator.has_next()) { | |
1083 HeapObject* obj = iterator.next(); | |
1084 ASSERT(obj != NULL); | |
1085 if (obj->IsSharedFunctionInfo() | |
1086 && SharedFunctionInfo::cast(obj)->is_compiled()) { | |
1087 ++compiled_funcs_count; | |
1088 } | |
1089 } | |
1090 | |
1091 sfis = NewArray< Handle<SharedFunctionInfo> >(compiled_funcs_count); | |
1092 iterator.reset(); | |
1093 | |
1094 int i = 0; | |
1095 while (iterator.has_next()) { | |
1096 HeapObject* obj = iterator.next(); | |
1097 ASSERT(obj != NULL); | |
1098 if (obj->IsSharedFunctionInfo() | |
1099 && SharedFunctionInfo::cast(obj)->is_compiled()) { | |
1100 sfis[i++] = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(obj)); | |
1101 } | |
1102 } | |
1103 } | |
1104 | 1100 |
1105 // During iteration, there can be heap allocation due to | 1101 // During iteration, there can be heap allocation due to |
1106 // GetScriptLineNumber call. | 1102 // GetScriptLineNumber call. |
1107 for (int i = 0; i < compiled_funcs_count; ++i) { | 1103 for (int i = 0; i < compiled_funcs_count; ++i) { |
1108 Handle<SharedFunctionInfo> shared = sfis[i]; | 1104 Handle<SharedFunctionInfo> shared = sfis[i]; |
1109 Handle<String> name(String::cast(shared->name())); | 1105 Handle<String> name(String::cast(shared->name())); |
1110 Handle<String> func_name(name->length() > 0 ? | 1106 Handle<String> func_name(name->length() > 0 ? |
1111 *name : shared->inferred_name()); | 1107 *name : shared->inferred_name()); |
1112 if (shared->script()->IsScript()) { | 1108 if (shared->script()->IsScript()) { |
1113 Handle<Script> script(Script::cast(shared->script())); | 1109 Handle<Script> script(Script::cast(shared->script())); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 // Otherwise, if the sliding state window computation has not been | 1281 // Otherwise, if the sliding state window computation has not been |
1286 // started we do it now. | 1282 // started we do it now. |
1287 if (sliding_state_window_ == NULL) { | 1283 if (sliding_state_window_ == NULL) { |
1288 sliding_state_window_ = new SlidingStateWindow(); | 1284 sliding_state_window_ = new SlidingStateWindow(); |
1289 } | 1285 } |
1290 #endif | 1286 #endif |
1291 } | 1287 } |
1292 | 1288 |
1293 | 1289 |
1294 } } // namespace v8::internal | 1290 } } // namespace v8::internal |
OLD | NEW |