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

Side by Side Diff: src/log.cc

Issue 519543002: [WIP] Added CodeEventListener to the sampler API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CallbackEvent also logs as code-creation, added coverage for that. Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/isolate.cc ('k') | src/mips/regexp-macro-assembler-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdarg.h> 5 #include <stdarg.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 tag = Logger::STORE_IC_TAG; 1858 tag = Logger::STORE_IC_TAG;
1859 break; 1859 break;
1860 case Code::KEYED_STORE_IC: 1860 case Code::KEYED_STORE_IC:
1861 description = "A keyed store IC from the snapshot"; 1861 description = "A keyed store IC from the snapshot";
1862 tag = Logger::KEYED_STORE_IC_TAG; 1862 tag = Logger::KEYED_STORE_IC_TAG;
1863 break; 1863 break;
1864 case Code::NUMBER_OF_KINDS: 1864 case Code::NUMBER_OF_KINDS:
1865 break; 1865 break;
1866 } 1866 }
1867 PROFILE(isolate_, CodeCreateEvent(tag, code_object, description)); 1867 PROFILE(isolate_, CodeCreateEvent(tag, code_object, description));
1868 isolate_->CodeCreateEvent(code_object, description);
1868 } 1869 }
1869 1870
1870 1871
1871 void Logger::LogCodeObjects() { 1872 void Logger::LogCodeObjects() {
1872 Heap* heap = isolate_->heap(); 1873 Heap* heap = isolate_->heap();
1873 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, 1874 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask,
1874 "Logger::LogCodeObjects"); 1875 "Logger::LogCodeObjects");
1875 HeapIterator iterator(heap); 1876 HeapIterator iterator(heap);
1876 DisallowHeapAllocation no_gc; 1877 DisallowHeapAllocation no_gc;
1877 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 1878 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
(...skipping 11 matching lines...) Expand all
1889 int column_num = 1890 int column_num =
1890 Script::GetColumnNumber(script, shared->start_position()) + 1; 1891 Script::GetColumnNumber(script, shared->start_position()) + 1;
1891 if (script->name()->IsString()) { 1892 if (script->name()->IsString()) {
1892 Handle<String> script_name(String::cast(script->name())); 1893 Handle<String> script_name(String::cast(script->name()));
1893 if (line_num > 0) { 1894 if (line_num > 0) {
1894 PROFILE(isolate_, 1895 PROFILE(isolate_,
1895 CodeCreateEvent( 1896 CodeCreateEvent(
1896 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), 1897 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script),
1897 *code, *shared, NULL, 1898 *code, *shared, NULL,
1898 *script_name, line_num, column_num)); 1899 *script_name, line_num, column_num));
1900 isolate_->CodeCreateEvent(*code, *shared, *script_name,
1901 line_num, column_num);
1899 } else { 1902 } else {
1900 // Can't distinguish eval and script here, so always use Script. 1903 // Can't distinguish eval and script here, so always use Script.
1901 PROFILE(isolate_, 1904 PROFILE(isolate_,
1902 CodeCreateEvent( 1905 CodeCreateEvent(
1903 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), 1906 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
1904 *code, *shared, NULL, *script_name)); 1907 *code, *shared, NULL, *script_name));
1908 isolate_->CodeCreateEvent(*code, *script_name);
1905 } 1909 }
1906 } else { 1910 } else {
1907 PROFILE(isolate_, 1911 PROFILE(isolate_,
1908 CodeCreateEvent( 1912 CodeCreateEvent(
1909 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), 1913 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script),
1910 *code, *shared, NULL, 1914 *code, *shared, NULL,
1911 isolate_->heap()->empty_string(), line_num, column_num)); 1915 isolate_->heap()->empty_string(), line_num, column_num));
1916 isolate_->CodeCreateEvent(*code, *shared,
1917 isolate_->heap()->empty_string(),
1918 line_num, column_num);
1912 } 1919 }
1913 } else if (shared->IsApiFunction()) { 1920 } else if (shared->IsApiFunction()) {
1914 // API function. 1921 // API function.
1915 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); 1922 FunctionTemplateInfo* fun_data = shared->get_api_func_data();
1916 Object* raw_call_data = fun_data->call_code(); 1923 Object* raw_call_data = fun_data->call_code();
1917 if (!raw_call_data->IsUndefined()) { 1924 if (!raw_call_data->IsUndefined()) {
1918 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); 1925 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data);
1919 Object* callback_obj = call_data->callback(); 1926 Object* callback_obj = call_data->callback();
1920 Address entry_point = v8::ToCData<Address>(callback_obj); 1927 Address entry_point = v8::ToCData<Address>(callback_obj);
1921 PROFILE(isolate_, CallbackEvent(*func_name, entry_point)); 1928 PROFILE(isolate_, CallbackEvent(*func_name, entry_point));
1929 isolate_->CodeCreateEvent(entry_point, "", *func_name);
1922 } 1930 }
1923 } else { 1931 } else {
1924 PROFILE(isolate_, 1932 PROFILE(isolate_,
1925 CodeCreateEvent( 1933 CodeCreateEvent(
1926 Logger::LAZY_COMPILE_TAG, *code, *shared, NULL, *func_name)); 1934 Logger::LAZY_COMPILE_TAG, *code, *shared, NULL, *func_name));
1935 isolate_->CodeCreateEvent(*code, *func_name);
1927 } 1936 }
1928 } 1937 }
1929 1938
1930 1939
1931 void Logger::LogCompiledFunctions() { 1940 void Logger::LogCompiledFunctions() {
1932 Heap* heap = isolate_->heap(); 1941 Heap* heap = isolate_->heap();
1933 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, 1942 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask,
1934 "Logger::LogCompiledFunctions"); 1943 "Logger::LogCompiledFunctions");
1935 HandleScope scope(isolate_); 1944 HandleScope scope(isolate_);
1936 const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL); 1945 const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL);
(...skipping 19 matching lines...) Expand all
1956 HeapIterator iterator(heap); 1965 HeapIterator iterator(heap);
1957 DisallowHeapAllocation no_gc; 1966 DisallowHeapAllocation no_gc;
1958 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 1967 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
1959 if (!obj->IsExecutableAccessorInfo()) continue; 1968 if (!obj->IsExecutableAccessorInfo()) continue;
1960 ExecutableAccessorInfo* ai = ExecutableAccessorInfo::cast(obj); 1969 ExecutableAccessorInfo* ai = ExecutableAccessorInfo::cast(obj);
1961 if (!ai->name()->IsName()) continue; 1970 if (!ai->name()->IsName()) continue;
1962 Address getter_entry = v8::ToCData<Address>(ai->getter()); 1971 Address getter_entry = v8::ToCData<Address>(ai->getter());
1963 Name* name = Name::cast(ai->name()); 1972 Name* name = Name::cast(ai->name());
1964 if (getter_entry != 0) { 1973 if (getter_entry != 0) {
1965 PROFILE(isolate_, GetterCallbackEvent(name, getter_entry)); 1974 PROFILE(isolate_, GetterCallbackEvent(name, getter_entry));
1975 isolate_->CodeCreateEvent(getter_entry, "get ", name);
1966 } 1976 }
1967 Address setter_entry = v8::ToCData<Address>(ai->setter()); 1977 Address setter_entry = v8::ToCData<Address>(ai->setter());
1968 if (setter_entry != 0) { 1978 if (setter_entry != 0) {
1969 PROFILE(isolate_, SetterCallbackEvent(name, setter_entry)); 1979 PROFILE(isolate_, SetterCallbackEvent(name, setter_entry));
1980 isolate_->CodeCreateEvent(setter_entry, "set ", name);
1970 } 1981 }
1971 } 1982 }
1972 } 1983 }
1973 1984
1974 1985
1975 static void AddIsolateIdIfNeeded(Isolate* isolate, StringStream* stream) { 1986 static void AddIsolateIdIfNeeded(Isolate* isolate, StringStream* stream) {
1976 if (FLAG_logfile_per_isolate) stream->Add("isolate-%p-", isolate); 1987 if (FLAG_logfile_per_isolate) stream->Add("isolate-%p-", isolate);
1977 } 1988 }
1978 1989
1979 1990
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 if (Log::InitLogAtStart()) { 2064 if (Log::InitLogAtStart()) {
2054 is_logging_ = true; 2065 is_logging_ = true;
2055 } 2066 }
2056 2067
2057 if (FLAG_prof) { 2068 if (FLAG_prof) {
2058 profiler_ = new Profiler(isolate); 2069 profiler_ = new Profiler(isolate);
2059 is_logging_ = true; 2070 is_logging_ = true;
2060 profiler_->Engage(); 2071 profiler_->Engage();
2061 } 2072 }
2062 2073
2074 // TODO(gholap): This one's for the new sampler API. (include/v8-sampler.h)
2075 // Call to IncreaseProfilingDepth causes the
2076 // SIGPROF signal handler to be installed on the VM thread.
2077 // Figure out whether there's a way to only optionally
2078 // do this based on a runtime flag.
2079 ticker_->IncreaseProfilingDepth();
2080
2063 if (FLAG_log_internal_timer_events || FLAG_prof) timer_.Start(); 2081 if (FLAG_log_internal_timer_events || FLAG_prof) timer_.Start();
2064 2082
2065 return true; 2083 return true;
2066 } 2084 }
2067 2085
2068 2086
2069 void Logger::SetCodeEventHandler(uint32_t options, 2087 void Logger::SetCodeEventHandler(uint32_t options,
2070 JitCodeEventHandler event_handler) { 2088 JitCodeEventHandler event_handler) {
2071 if (jit_logger_) { 2089 if (jit_logger_) {
2072 removeCodeEventListener(jit_logger_); 2090 removeCodeEventListener(jit_logger_);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 if (jit_logger_) { 2144 if (jit_logger_) {
2127 removeCodeEventListener(jit_logger_); 2145 removeCodeEventListener(jit_logger_);
2128 delete jit_logger_; 2146 delete jit_logger_;
2129 jit_logger_ = NULL; 2147 jit_logger_ = NULL;
2130 } 2148 }
2131 2149
2132 return log_->Close(); 2150 return log_->Close();
2133 } 2151 }
2134 2152
2135 } } // namespace v8::internal 2153 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/mips/regexp-macro-assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698