| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "log-utils.h" | 30 #include "log-utils.h" |
| 31 #include "string-stream.h" | 31 #include "string-stream.h" |
| 32 | 32 |
| 33 namespace v8 { | 33 namespace v8 { |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 37 | |
| 38 LogDynamicBuffer::LogDynamicBuffer( | 36 LogDynamicBuffer::LogDynamicBuffer( |
| 39 int block_size, int max_size, const char* seal, int seal_size) | 37 int block_size, int max_size, const char* seal, int seal_size) |
| 40 : block_size_(block_size), | 38 : block_size_(block_size), |
| 41 max_size_(max_size - (max_size % block_size_)), | 39 max_size_(max_size - (max_size % block_size_)), |
| 42 seal_(seal), | 40 seal_(seal), |
| 43 seal_size_(seal_size), | 41 seal_size_(seal_size), |
| 44 blocks_(max_size_ / block_size_ + 1), | 42 blocks_(max_size_ / block_size_ + 1), |
| 45 write_pos_(0), block_index_(0), block_write_pos_(0), is_sealed_(false) { | 43 write_pos_(0), block_index_(0), block_write_pos_(0), is_sealed_(false) { |
| 46 ASSERT(BlocksCount() > 0); | 44 ASSERT(BlocksCount() > 0); |
| 47 AllocateBlock(0); | 45 AllocateBlock(0); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 133 |
| 136 | 134 |
| 137 static void AddIsolateIdIfNeeded(StringStream* stream) { | 135 static void AddIsolateIdIfNeeded(StringStream* stream) { |
| 138 Isolate* isolate = Isolate::Current(); | 136 Isolate* isolate = Isolate::Current(); |
| 139 if (isolate->IsDefaultIsolate()) return; | 137 if (isolate->IsDefaultIsolate()) return; |
| 140 stream->Add("isolate-%p-", isolate); | 138 stream->Add("isolate-%p-", isolate); |
| 141 } | 139 } |
| 142 | 140 |
| 143 | 141 |
| 144 void Log::Initialize() { | 142 void Log::Initialize() { |
| 145 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 146 mutex_ = OS::CreateMutex(); | 143 mutex_ = OS::CreateMutex(); |
| 147 message_buffer_ = NewArray<char>(kMessageBufferSize); | 144 message_buffer_ = NewArray<char>(kMessageBufferSize); |
| 148 | 145 |
| 149 // --log-all enables all the log flags. | 146 // --log-all enables all the log flags. |
| 150 if (FLAG_log_all) { | 147 if (FLAG_log_all) { |
| 151 FLAG_log_runtime = true; | 148 FLAG_log_runtime = true; |
| 152 FLAG_log_api = true; | 149 FLAG_log_api = true; |
| 153 FLAG_log_code = true; | 150 FLAG_log_code = true; |
| 154 FLAG_log_gc = true; | 151 FLAG_log_gc = true; |
| 155 FLAG_log_suspect = true; | 152 FLAG_log_suspect = true; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 stream.Put(*p); | 212 stream.Put(*p); |
| 216 } | 213 } |
| 217 } | 214 } |
| 218 SmartPointer<const char> expanded = stream.ToCString(); | 215 SmartPointer<const char> expanded = stream.ToCString(); |
| 219 OpenFile(*expanded); | 216 OpenFile(*expanded); |
| 220 } else { | 217 } else { |
| 221 OpenFile(FLAG_logfile); | 218 OpenFile(FLAG_logfile); |
| 222 } | 219 } |
| 223 } | 220 } |
| 224 } | 221 } |
| 225 #endif | |
| 226 } | 222 } |
| 227 | 223 |
| 228 | 224 |
| 229 void Log::OpenStdout() { | 225 void Log::OpenStdout() { |
| 230 ASSERT(!IsEnabled()); | 226 ASSERT(!IsEnabled()); |
| 231 output_handle_ = stdout; | 227 output_handle_ = stdout; |
| 232 write_to_file_ = true; | 228 write_to_file_ = true; |
| 233 } | 229 } |
| 234 | 230 |
| 235 | 231 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 const int written = log_->write_to_file_ ? | 412 const int written = log_->write_to_file_ ? |
| 417 log_->WriteToFile(log_->message_buffer_, pos_) : | 413 log_->WriteToFile(log_->message_buffer_, pos_) : |
| 418 log_->WriteToMemory(log_->message_buffer_, pos_); | 414 log_->WriteToMemory(log_->message_buffer_, pos_); |
| 419 if (written != pos_) { | 415 if (written != pos_) { |
| 420 log_->stop(); | 416 log_->stop(); |
| 421 log_->logger_->LogFailure(); | 417 log_->logger_->LogFailure(); |
| 422 } | 418 } |
| 423 } | 419 } |
| 424 | 420 |
| 425 | 421 |
| 426 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 427 | |
| 428 } } // namespace v8::internal | 422 } } // namespace v8::internal |
| OLD | NEW |