OLD | NEW |
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 "v8.h" | 7 #include "v8.h" |
8 | 8 |
9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
10 #include "code-stubs.h" | 10 #include "code-stubs.h" |
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 } | 1929 } |
1930 Address setter_entry = v8::ToCData<Address>(ai->setter()); | 1930 Address setter_entry = v8::ToCData<Address>(ai->setter()); |
1931 if (setter_entry != 0) { | 1931 if (setter_entry != 0) { |
1932 PROFILE(isolate_, SetterCallbackEvent(name, setter_entry)); | 1932 PROFILE(isolate_, SetterCallbackEvent(name, setter_entry)); |
1933 } | 1933 } |
1934 } | 1934 } |
1935 } | 1935 } |
1936 | 1936 |
1937 | 1937 |
1938 static void AddIsolateIdIfNeeded(Isolate* isolate, StringStream* stream) { | 1938 static void AddIsolateIdIfNeeded(Isolate* isolate, StringStream* stream) { |
1939 if (FLAG_logfile_per_isolate) stream->Add("isolate-%p-", isolate); | 1939 if (isolate->IsDefaultIsolate() || !FLAG_logfile_per_isolate) return; |
| 1940 stream->Add("isolate-%p-", isolate); |
1940 } | 1941 } |
1941 | 1942 |
1942 | 1943 |
1943 static SmartArrayPointer<const char> PrepareLogFileName( | 1944 static SmartArrayPointer<const char> PrepareLogFileName( |
1944 Isolate* isolate, const char* file_name) { | 1945 Isolate* isolate, const char* file_name) { |
1945 HeapStringAllocator allocator; | 1946 if (strchr(file_name, '%') != NULL || !isolate->IsDefaultIsolate()) { |
1946 StringStream stream(&allocator); | 1947 // If there's a '%' in the log file name we have to expand |
1947 AddIsolateIdIfNeeded(isolate, &stream); | 1948 // placeholders. |
1948 for (const char* p = file_name; *p; p++) { | 1949 HeapStringAllocator allocator; |
1949 if (*p == '%') { | 1950 StringStream stream(&allocator); |
1950 p++; | 1951 AddIsolateIdIfNeeded(isolate, &stream); |
1951 switch (*p) { | 1952 for (const char* p = file_name; *p; p++) { |
1952 case '\0': | 1953 if (*p == '%') { |
1953 // If there's a % at the end of the string we back up | 1954 p++; |
1954 // one character so we can escape the loop properly. | 1955 switch (*p) { |
1955 p--; | 1956 case '\0': |
1956 break; | 1957 // If there's a % at the end of the string we back up |
1957 case 'p': | 1958 // one character so we can escape the loop properly. |
1958 stream.Add("%d", OS::GetCurrentProcessId()); | 1959 p--; |
1959 break; | 1960 break; |
1960 case 't': { | 1961 case 'p': |
1961 // %t expands to the current time in milliseconds. | 1962 stream.Add("%d", OS::GetCurrentProcessId()); |
1962 double time = OS::TimeCurrentMillis(); | 1963 break; |
1963 stream.Add("%.0f", FmtElm(time)); | 1964 case 't': { |
1964 break; | 1965 // %t expands to the current time in milliseconds. |
| 1966 double time = OS::TimeCurrentMillis(); |
| 1967 stream.Add("%.0f", FmtElm(time)); |
| 1968 break; |
| 1969 } |
| 1970 case '%': |
| 1971 // %% expands (contracts really) to %. |
| 1972 stream.Put('%'); |
| 1973 break; |
| 1974 default: |
| 1975 // All other %'s expand to themselves. |
| 1976 stream.Put('%'); |
| 1977 stream.Put(*p); |
| 1978 break; |
1965 } | 1979 } |
1966 case '%': | 1980 } else { |
1967 // %% expands (contracts really) to %. | 1981 stream.Put(*p); |
1968 stream.Put('%'); | |
1969 break; | |
1970 default: | |
1971 // All other %'s expand to themselves. | |
1972 stream.Put('%'); | |
1973 stream.Put(*p); | |
1974 break; | |
1975 } | 1982 } |
1976 } else { | |
1977 stream.Put(*p); | |
1978 } | 1983 } |
| 1984 return SmartArrayPointer<const char>(stream.ToCString()); |
1979 } | 1985 } |
1980 return SmartArrayPointer<const char>(stream.ToCString()); | 1986 int length = StrLength(file_name); |
| 1987 char* str = NewArray<char>(length + 1); |
| 1988 OS::MemCopy(str, file_name, length); |
| 1989 str[length] = '\0'; |
| 1990 return SmartArrayPointer<const char>(str); |
1981 } | 1991 } |
1982 | 1992 |
1983 | 1993 |
1984 bool Logger::SetUp(Isolate* isolate) { | 1994 bool Logger::SetUp(Isolate* isolate) { |
1985 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. | 1995 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. |
1986 if (is_initialized_) return true; | 1996 if (is_initialized_) return true; |
1987 is_initialized_ = true; | 1997 is_initialized_ = true; |
1988 | 1998 |
1989 // --ll-prof implies --log-code and --log-snapshot-positions. | 1999 // --ll-prof implies --log-code and --log-snapshot-positions. |
1990 if (FLAG_ll_prof) { | 2000 if (FLAG_ll_prof) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 if (jit_logger_) { | 2099 if (jit_logger_) { |
2090 removeCodeEventListener(jit_logger_); | 2100 removeCodeEventListener(jit_logger_); |
2091 delete jit_logger_; | 2101 delete jit_logger_; |
2092 jit_logger_ = NULL; | 2102 jit_logger_ = NULL; |
2093 } | 2103 } |
2094 | 2104 |
2095 return log_->Close(); | 2105 return log_->Close(); |
2096 } | 2106 } |
2097 | 2107 |
2098 } } // namespace v8::internal | 2108 } } // namespace v8::internal |
OLD | NEW |