OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 | 56 |
57 class ScopedLoggerInitializer { | 57 class ScopedLoggerInitializer { |
58 public: | 58 public: |
59 explicit ScopedLoggerInitializer(bool prof_lazy) | 59 explicit ScopedLoggerInitializer(bool prof_lazy) |
60 : saved_log_(i::FLAG_log), | 60 : saved_log_(i::FLAG_log), |
61 saved_prof_lazy_(i::FLAG_prof_lazy), | 61 saved_prof_lazy_(i::FLAG_prof_lazy), |
62 saved_prof_(i::FLAG_prof), | 62 saved_prof_(i::FLAG_prof), |
| 63 saved_prof_auto_(i::FLAG_prof_auto), |
63 temp_file_(NULL), | 64 temp_file_(NULL), |
64 // Need to run this prior to creating the scope. | 65 // Need to run this prior to creating the scope. |
65 trick_to_run_init_flags_(init_flags_(prof_lazy)), | 66 trick_to_run_init_flags_(init_flags_(prof_lazy)), |
66 scope_(v8::Isolate::GetCurrent()), | 67 scope_(v8::Isolate::GetCurrent()), |
67 env_(v8::Context::New(v8::Isolate::GetCurrent())), | 68 env_(v8::Context::New(v8::Isolate::GetCurrent())), |
68 logger_(i::Isolate::Current()->logger()) { | 69 logger_(i::Isolate::Current()->logger()) { |
69 env_->Enter(); | 70 env_->Enter(); |
70 } | 71 } |
71 | 72 |
72 ~ScopedLoggerInitializer() { | 73 ~ScopedLoggerInitializer() { |
73 env_->Exit(); | 74 env_->Exit(); |
74 logger_->TearDown(); | 75 logger_->TearDown(); |
75 if (temp_file_ != NULL) fclose(temp_file_); | 76 if (temp_file_ != NULL) fclose(temp_file_); |
76 i::FLAG_prof_lazy = saved_prof_lazy_; | 77 i::FLAG_prof_lazy = saved_prof_lazy_; |
77 i::FLAG_prof = saved_prof_; | 78 i::FLAG_prof = saved_prof_; |
| 79 i::FLAG_prof_auto = saved_prof_auto_; |
78 i::FLAG_log = saved_log_; | 80 i::FLAG_log = saved_log_; |
79 } | 81 } |
80 | 82 |
81 v8::Handle<v8::Context>& env() { return env_; } | 83 v8::Handle<v8::Context>& env() { return env_; } |
82 | 84 |
83 Logger* logger() { return logger_; } | 85 Logger* logger() { return logger_; } |
84 | 86 |
85 FILE* StopLoggingGetTempFile() { | 87 FILE* StopLoggingGetTempFile() { |
86 temp_file_ = logger_->TearDown(); | 88 temp_file_ = logger_->TearDown(); |
87 CHECK_NE(NULL, temp_file_); | 89 CHECK_NE(NULL, temp_file_); |
88 fflush(temp_file_); | 90 fflush(temp_file_); |
89 rewind(temp_file_); | 91 rewind(temp_file_); |
90 return temp_file_; | 92 return temp_file_; |
91 } | 93 } |
92 | 94 |
93 private: | 95 private: |
94 static bool init_flags_(bool prof_lazy) { | 96 static bool init_flags_(bool prof_lazy) { |
95 i::FLAG_log = true; | 97 i::FLAG_log = true; |
96 i::FLAG_prof = true; | 98 i::FLAG_prof = true; |
97 i::FLAG_prof_lazy = prof_lazy; | 99 i::FLAG_prof_lazy = prof_lazy; |
| 100 i::FLAG_prof_auto = false; |
98 i::FLAG_logfile = i::Log::kLogToTemporaryFile; | 101 i::FLAG_logfile = i::Log::kLogToTemporaryFile; |
99 return prof_lazy; | 102 return prof_lazy; |
100 } | 103 } |
101 | 104 |
102 const bool saved_log_; | 105 const bool saved_log_; |
103 const bool saved_prof_lazy_; | 106 const bool saved_prof_lazy_; |
104 const bool saved_prof_; | 107 const bool saved_prof_; |
| 108 const bool saved_prof_auto_; |
105 FILE* temp_file_; | 109 FILE* temp_file_; |
106 const bool trick_to_run_init_flags_; | 110 const bool trick_to_run_init_flags_; |
107 v8::HandleScope scope_; | 111 v8::HandleScope scope_; |
108 v8::Handle<v8::Context> env_; | 112 v8::Handle<v8::Context> env_; |
109 Logger* logger_; | 113 Logger* logger_; |
110 | 114 |
111 DISALLOW_COPY_AND_ASSIGN(ScopedLoggerInitializer); | 115 DISALLOW_COPY_AND_ASSIGN(ScopedLoggerInitializer); |
112 }; | 116 }; |
113 | 117 |
114 } // namespace | 118 } // namespace |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 v8::Local<v8::String> s = result->ToString(); | 563 v8::Local<v8::String> s = result->ToString(); |
560 i::ScopedVector<char> data(s->Utf8Length() + 1); | 564 i::ScopedVector<char> data(s->Utf8Length() + 1); |
561 CHECK_NE(NULL, data.start()); | 565 CHECK_NE(NULL, data.start()); |
562 s->WriteUtf8(data.start()); | 566 s->WriteUtf8(data.start()); |
563 printf("%s\n", data.start()); | 567 printf("%s\n", data.start()); |
564 // Make sure that our output is written prior crash due to CHECK failure. | 568 // Make sure that our output is written prior crash due to CHECK failure. |
565 fflush(stdout); | 569 fflush(stdout); |
566 CHECK(false); | 570 CHECK(false); |
567 } | 571 } |
568 } | 572 } |
OLD | NEW |