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

Side by Side Diff: src/log.cc

Issue 267383002: Reland "Removed default Isolate." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/isolate.cc ('k') | src/mksnapshot.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 "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
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 (isolate->IsDefaultIsolate() || !FLAG_logfile_per_isolate) return; 1939 if (FLAG_logfile_per_isolate) stream->Add("isolate-%p-", isolate);
1940 stream->Add("isolate-%p-", isolate);
1941 } 1940 }
1942 1941
1943 1942
1944 static SmartArrayPointer<const char> PrepareLogFileName( 1943 static SmartArrayPointer<const char> PrepareLogFileName(
1945 Isolate* isolate, const char* file_name) { 1944 Isolate* isolate, const char* file_name) {
1946 if (strchr(file_name, '%') != NULL || !isolate->IsDefaultIsolate()) { 1945 HeapStringAllocator allocator;
1947 // If there's a '%' in the log file name we have to expand 1946 StringStream stream(&allocator);
1948 // placeholders. 1947 AddIsolateIdIfNeeded(isolate, &stream);
1949 HeapStringAllocator allocator; 1948 for (const char* p = file_name; *p; p++) {
1950 StringStream stream(&allocator); 1949 if (*p == '%') {
1951 AddIsolateIdIfNeeded(isolate, &stream); 1950 p++;
1952 for (const char* p = file_name; *p; p++) { 1951 switch (*p) {
1953 if (*p == '%') { 1952 case '\0':
1954 p++; 1953 // If there's a % at the end of the string we back up
1955 switch (*p) { 1954 // one character so we can escape the loop properly.
1956 case '\0': 1955 p--;
1957 // If there's a % at the end of the string we back up 1956 break;
1958 // one character so we can escape the loop properly. 1957 case 'p':
1959 p--; 1958 stream.Add("%d", OS::GetCurrentProcessId());
1960 break; 1959 break;
1961 case 'p': 1960 case 't': {
1962 stream.Add("%d", OS::GetCurrentProcessId()); 1961 // %t expands to the current time in milliseconds.
1963 break; 1962 double time = OS::TimeCurrentMillis();
1964 case 't': { 1963 stream.Add("%.0f", FmtElm(time));
1965 // %t expands to the current time in milliseconds. 1964 break;
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;
1979 } 1965 }
1980 } else { 1966 case '%':
1981 stream.Put(*p); 1967 // %% expands (contracts really) to %.
1968 stream.Put('%');
1969 break;
1970 default:
1971 // All other %'s expand to themselves.
1972 stream.Put('%');
1973 stream.Put(*p);
1974 break;
1982 } 1975 }
1976 } else {
1977 stream.Put(*p);
1983 } 1978 }
1984 return SmartArrayPointer<const char>(stream.ToCString());
1985 } 1979 }
1986 int length = StrLength(file_name); 1980 return SmartArrayPointer<const char>(stream.ToCString());
1987 char* str = NewArray<char>(length + 1);
1988 OS::MemCopy(str, file_name, length);
1989 str[length] = '\0';
1990 return SmartArrayPointer<const char>(str);
1991 } 1981 }
1992 1982
1993 1983
1994 bool Logger::SetUp(Isolate* isolate) { 1984 bool Logger::SetUp(Isolate* isolate) {
1995 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. 1985 // Tests and EnsureInitialize() can call this twice in a row. It's harmless.
1996 if (is_initialized_) return true; 1986 if (is_initialized_) return true;
1997 is_initialized_ = true; 1987 is_initialized_ = true;
1998 1988
1999 // --ll-prof implies --log-code and --log-snapshot-positions. 1989 // --ll-prof implies --log-code and --log-snapshot-positions.
2000 if (FLAG_ll_prof) { 1990 if (FLAG_ll_prof) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 if (jit_logger_) { 2089 if (jit_logger_) {
2100 removeCodeEventListener(jit_logger_); 2090 removeCodeEventListener(jit_logger_);
2101 delete jit_logger_; 2091 delete jit_logger_;
2102 jit_logger_ = NULL; 2092 jit_logger_ = NULL;
2103 } 2093 }
2104 2094
2105 return log_->Close(); 2095 return log_->Close();
2106 } 2096 }
2107 2097
2108 } } // namespace v8::internal 2098 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/mksnapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698