From e0508615a9b760a385471988d1bbee2d8c4b1373 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Wed, 16 Oct 2013 16:27:17 +0000 Subject: [PATCH] Fix leak in optimizing compiler thread. R=mvstanton@chromium.org BUG= Review URL: https://codereview.chromium.org/27473006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17247 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/optimizing-compiler-thread.cc | 13 +++++++++++++ src/optimizing-compiler-thread.h | 18 ++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/optimizing-compiler-thread.cc b/src/optimizing-compiler-thread.cc index fa2da9761a..e9c0254522 100644 --- a/src/optimizing-compiler-thread.cc +++ b/src/optimizing-compiler-thread.cc @@ -37,6 +37,19 @@ namespace v8 { namespace internal { +OptimizingCompilerThread::~OptimizingCompilerThread() { + ASSERT_EQ(0, input_queue_length_); + DeleteArray(input_queue_); + if (FLAG_concurrent_osr) { +#ifdef DEBUG + for (int i = 0; i < osr_buffer_capacity_; i++) { + CHECK_EQ(NULL, osr_buffer_[i]); + } +#endif + DeleteArray(osr_buffer_); + } +} + void OptimizingCompilerThread::Run() { #ifdef DEBUG diff --git a/src/optimizing-compiler-thread.h b/src/optimizing-compiler-thread.h index a9e108c5cb..754aecebf5 100644 --- a/src/optimizing-compiler-thread.h +++ b/src/optimizing-compiler-thread.h @@ -63,20 +63,14 @@ class OptimizingCompilerThread : public Thread { blocked_jobs_(0) { NoBarrier_Store(&stop_thread_, static_cast(CONTINUE)); input_queue_ = NewArray(input_queue_capacity_); - osr_buffer_ = NewArray(osr_buffer_capacity_); - // Mark OSR buffer slots as empty. - for (int i = 0; i < osr_buffer_capacity_; i++) osr_buffer_[i] = NULL; + if (FLAG_concurrent_osr) { + // Allocate and mark OSR buffer slots as empty. + osr_buffer_ = NewArray(osr_buffer_capacity_); + for (int i = 0; i < osr_buffer_capacity_; i++) osr_buffer_[i] = NULL; + } } - ~OptimizingCompilerThread() { - ASSERT_EQ(0, input_queue_length_); -#ifdef DEBUG - for (int i = 0; i < osr_buffer_capacity_; i++) { - CHECK_EQ(NULL, osr_buffer_[i]); - } -#endif - DeleteArray(osr_buffer_); - } + ~OptimizingCompilerThread(); void Run(); void Stop();