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

Side by Side Diff: src/log.cc

Issue 53089: Fixed test memory leaks (Closed)
Patch Set: Created 11 years, 9 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 // 401 //
402 // Logger class implementation. 402 // Logger class implementation.
403 // 403 //
404 Ticker* Logger::ticker_ = NULL; 404 Ticker* Logger::ticker_ = NULL;
405 char* Logger::message_buffer_ = NULL; 405 char* Logger::message_buffer_ = NULL;
406 FILE* Logger::logfile_ = NULL; 406 FILE* Logger::logfile_ = NULL;
407 Profiler* Logger::profiler_ = NULL; 407 Profiler* Logger::profiler_ = NULL;
408 Mutex* Logger::mutex_ = NULL; 408 Mutex* Logger::mutex_ = NULL;
409 VMState* Logger::current_state_ = NULL; 409 VMState* Logger::current_state_ = NULL;
410 VMState Logger::bottom_state_(OTHER);
410 SlidingStateWindow* Logger::sliding_state_window_ = NULL; 411 SlidingStateWindow* Logger::sliding_state_window_ = NULL;
411 412
412 #endif // ENABLE_LOGGING_AND_PROFILING 413 #endif // ENABLE_LOGGING_AND_PROFILING
413 414
414 415
415 void Logger::Preamble(const char* content) { 416 void Logger::Preamble(const char* content) {
416 #ifdef ENABLE_LOGGING_AND_PROFILING 417 #ifdef ENABLE_LOGGING_AND_PROFILING
417 if (logfile_ == NULL || !FLAG_log_code) return; 418 if (logfile_ == NULL || !FLAG_log_code) return;
418 LogMessageBuilder msg; 419 LogMessageBuilder msg;
419 msg.Append("%s", content); 420 msg.Append("%s", content);
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 } 1011 }
1011 SmartPointer<const char> expanded = stream.ToCString(); 1012 SmartPointer<const char> expanded = stream.ToCString();
1012 logfile_ = OS::FOpen(*expanded, "w"); 1013 logfile_ = OS::FOpen(*expanded, "w");
1013 } else { 1014 } else {
1014 logfile_ = OS::FOpen(FLAG_logfile, "w"); 1015 logfile_ = OS::FOpen(FLAG_logfile, "w");
1015 } 1016 }
1016 message_buffer_ = NewArray<char>(kMessageBufferSize); 1017 message_buffer_ = NewArray<char>(kMessageBufferSize);
1017 mutex_ = OS::CreateMutex(); 1018 mutex_ = OS::CreateMutex();
1018 } 1019 }
1019 1020
1020 current_state_ = new VMState(OTHER); 1021 current_state_ = &bottom_state_;
1021 1022
1022 // as log is initialized early with V8, we can assume that JS execution 1023 // as log is initialized early with V8, we can assume that JS execution
1023 // frames can never reach this point on stack 1024 // frames can never reach this point on stack
1024 int stack_var; 1025 int stack_var;
1025 ticker_ = new Ticker(1, reinterpret_cast<unsigned int>(&stack_var)); 1026 ticker_ = new Ticker(1, reinterpret_cast<unsigned int>(&stack_var));
1026 1027
1027 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { 1028 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) {
1028 sliding_state_window_ = new SlidingStateWindow(); 1029 sliding_state_window_ = new SlidingStateWindow();
1029 } 1030 }
1030 1031
(...skipping 14 matching lines...) Expand all
1045 1046
1046 void Logger::TearDown() { 1047 void Logger::TearDown() {
1047 #ifdef ENABLE_LOGGING_AND_PROFILING 1048 #ifdef ENABLE_LOGGING_AND_PROFILING
1048 // Stop the profiler before closing the file. 1049 // Stop the profiler before closing the file.
1049 if (profiler_ != NULL) { 1050 if (profiler_ != NULL) {
1050 profiler_->Disengage(); 1051 profiler_->Disengage();
1051 delete profiler_; 1052 delete profiler_;
1052 profiler_ = NULL; 1053 profiler_ = NULL;
1053 } 1054 }
1054 1055
1055 // Deleting the current_state_ has the side effect of assigning to it(!).
1056 while (current_state_) delete current_state_;
1057 delete sliding_state_window_; 1056 delete sliding_state_window_;
1058 1057
1059 delete ticker_; 1058 delete ticker_;
1060 1059
1061 if (logfile_ != NULL) { 1060 if (logfile_ != NULL) {
1062 fclose(logfile_); 1061 fclose(logfile_);
1063 logfile_ = NULL; 1062 logfile_ = NULL;
1064 delete mutex_; 1063 delete mutex_;
1065 mutex_ = NULL; 1064 mutex_ = NULL;
1066 DeleteArray(message_buffer_); 1065 DeleteArray(message_buffer_);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 } else { 1154 } else {
1156 // Are we leaving V8? 1155 // Are we leaving V8?
1157 if (previous_->state_ == EXTERNAL) Heap::Protect(); 1156 if (previous_->state_ == EXTERNAL) Heap::Protect();
1158 } 1157 }
1159 } 1158 }
1160 #endif 1159 #endif
1161 } 1160 }
1162 #endif 1161 #endif
1163 1162
1164 } } // namespace v8::internal 1163 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698