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

Unified Diff: src/log.cc

Issue 112036: Introduce Logger::LogCompiledFunctions that logs current map of compiled code. (Closed)
Patch Set: struct -> class Created 11 years, 7 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/log.h ('k') | test/cctest/test-log.cc » ('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 79cbfcf88f8a32a781690da5bdb499974531afbd..3d3cd2d262b9604502283bf10eee1db34026e977 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -1108,6 +1108,69 @@ int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) {
return Log::GetLogLines(from_pos, dest_buf, max_size);
}
+
+void Logger::LogCompiledFunctions() {
+ HandleScope scope;
+ Handle<SharedFunctionInfo>* sfis = NULL;
+ 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;
+ }
+ }
+
+ 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));
+ }
+ }
+ }
+
+ // During iteration, there can be heap allocation due to
+ // GetScriptLineNumber call.
+ for (int i = 0; i < compiled_funcs_count; ++i) {
+ Handle<SharedFunctionInfo> shared = sfis[i];
+ Handle<String> name(String::cast(shared->name()));
+ Handle<String> func_name(name->length() > 0 ?
+ *name : shared->inferred_name());
+ if (shared->script()->IsScript()) {
+ Handle<Script> script(Script::cast(shared->script()));
+ if (script->name()->IsString()) {
+ Handle<String> script_name(String::cast(script->name()));
+ int line_num = GetScriptLineNumber(script, shared->start_position());
+ if (line_num > 0) {
+ line_num += script->line_offset()->value() + 1;
+ LOG(CodeCreateEvent("LazyCompile", shared->code(), *func_name,
+ *script_name, line_num));
+ } else {
+ // Can't distinguish enum and script here, so always use Script.
+ LOG(CodeCreateEvent("Script", shared->code(), *script_name));
+ }
+ continue;
+ }
+ }
+ // If no script or script has no name.
+ LOG(CodeCreateEvent("LazyCompile", shared->code(), *func_name));
+ }
+
+ DeleteArray(sfis);
+}
+
#endif
« no previous file with comments | « src/log.h ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698