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

Unified Diff: src/d8.cc

Issue 7846022: Release memory of semaphores and thread pointers by using 'delete' instead of SmartPointer. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
« src/d8.h ('K') | « src/d8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 93b383d9acda6c77560a7cf459613263db59d29c..160ffa316edf90eac24a5fc62a040e979d82e134 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -968,6 +968,16 @@ void ShellThread::Run() {
#endif // V8_SHARED
+SourceGroup::~SourceGroup() {
+ delete next_semaphore_;
+ next_semaphore_ = NULL;
+ delete done_semaphore_;
+ done_semaphore_ = NULL;
+ delete thread_;
+ thread_ = NULL;
+}
+
+
void SourceGroup::ExitShell(int exit_code) {
// Use _exit instead of exit to avoid races between isolate
// threads and static destructors.
@@ -1037,7 +1047,7 @@ i::Thread::Options SourceGroup::GetThreadOptions() {
void SourceGroup::ExecuteInThread() {
Isolate* isolate = Isolate::New();
do {
- if (!next_semaphore_.is_empty()) next_semaphore_->Wait();
+ if (next_semaphore_ != NULL) next_semaphore_->Wait();
{
Isolate::Scope iscope(isolate);
Locker lock(isolate);
@@ -1049,15 +1059,15 @@ void SourceGroup::ExecuteInThread() {
}
context.Dispose();
}
- if (!done_semaphore_.is_empty()) done_semaphore_->Signal();
+ if (done_semaphore_ != NULL) done_semaphore_->Signal();
} while (!Shell::options.last_run);
isolate->Dispose();
}
void SourceGroup::StartExecuteInThread() {
- if (thread_.is_empty()) {
- thread_ = i::SmartPointer<i::Thread>(new IsolateThread(this));
+ if (thread_ == NULL) {
+ thread_ = new IsolateThread(this);
thread_->Start();
}
next_semaphore_->Signal();
@@ -1065,9 +1075,10 @@ void SourceGroup::StartExecuteInThread() {
void SourceGroup::WaitForThread() {
- if (thread_.is_empty()) return;
+ if (thread_ == NULL) return;
if (Shell::options.last_run) {
thread_->Join();
+ thread_ = NULL;
Vitaly Repeshko 2011/09/08 22:56:40 Ooops, didn't notice this edit. This looks wrong.
tfarina 2011/09/08 22:58:18 Double-free? It was here before the SmartPointer c
} else {
done_semaphore_->Wait();
}
« src/d8.h ('K') | « src/d8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698