Reviewers: Yang,

Message:
Explanations inline.


https://codereview.chromium.org/11418138/diff/1/src/compiler.h
File src/compiler.h (right):

https://codereview.chromium.org/11418138/diff/1/src/compiler.h#newcode296
src/compiler.h:296: INLINE(void* operator new(size_t size)) { return
Malloced::New(size); }
We use a SmartPointer to delete CompilationInfoWithZone that are
allocated on the heap, and SmartPointer uses Malloced::Delete, so here
we use its counterpart to make valgrind happy.

https://codereview.chromium.org/11418138/diff/1/src/optimizing-compiler-thread.cc
File src/optimizing-compiler-thread.cc (right):

https://codereview.chromium.org/11418138/diff/1/src/optimizing-compiler-thread.cc#newcode130
src/optimizing-compiler-thread.cc:130: Handle<SharedFunctionInfo> shared
= compiler->info()->shared_info();
compiler->info() gets deallocated in InstallOptimizedCode, so access it
before this happens.

https://codereview.chromium.org/11418138/diff/1/src/optimizing-compiler-thread.h
File src/optimizing-compiler-thread.h (right):

https://codereview.chromium.org/11418138/diff/1/src/optimizing-compiler-thread.h#newcode48
src/optimizing-compiler-thread.h:48: thread_id_(0),
Initialize this to make valgrind happy.

Description:
Fix valgrind warnings.


BUG=


Please review this at https://codereview.chromium.org/11418138/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/compiler.h
  M src/optimizing-compiler-thread.h
  M src/optimizing-compiler-thread.cc


Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index af9459566dd06f862e38a7837d4c60ab4d62fabc..62eedc268fdf96843725228b9197a80221b73c23 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -293,6 +293,8 @@ class CompilationInfo {
 // Zone on construction and deallocates it on exit.
 class CompilationInfoWithZone: public CompilationInfo {
  public:
+  INLINE(void* operator new(size_t size)) { return Malloced::New(size); }
+
   explicit CompilationInfoWithZone(Handle<Script> script)
       : CompilationInfo(script, &zone_),
         zone_(script->GetIsolate()),
Index: src/optimizing-compiler-thread.cc
diff --git a/src/optimizing-compiler-thread.cc b/src/optimizing-compiler-thread.cc index d93f6714dc4c7ce8adaadc6835b5078021e6de8e..0d4e4a693a9a0d594146aec0ee2dea1dd12bcc44 100644
--- a/src/optimizing-compiler-thread.cc
+++ b/src/optimizing-compiler-thread.cc
@@ -127,8 +127,9 @@ Handle<SharedFunctionInfo>
   output_queue_semaphore_->Wait();
   OptimizingCompiler* compiler = NULL;
   output_queue_.Dequeue(&compiler);
+  Handle<SharedFunctionInfo> shared = compiler->info()->shared_info();
   Compiler::InstallOptimizedCode(compiler);
-  return compiler->info()->shared_info();
+  return shared;
 }


Index: src/optimizing-compiler-thread.h
diff --git a/src/optimizing-compiler-thread.h b/src/optimizing-compiler-thread.h index 8a39b39a47d9002058ef865531b04c660d014a9d..2d56d1a72ba26ee0daedf252cb6cc3111a0fe800 100644
--- a/src/optimizing-compiler-thread.h
+++ b/src/optimizing-compiler-thread.h
@@ -44,6 +44,9 @@ class OptimizingCompilerThread : public Thread {
  public:
   explicit OptimizingCompilerThread(Isolate *isolate) :
       Thread("OptimizingCompilerThread"),
+#ifdef DEBUG
+      thread_id_(0),
+#endif
       isolate_(isolate),
       stop_semaphore_(OS::CreateSemaphore(0)),
       input_queue_semaphore_(OS::CreateSemaphore(0)),
@@ -81,12 +84,16 @@ class OptimizingCompilerThread : public Thread {
 #endif

   ~OptimizingCompilerThread() {
-    delete input_queue_semaphore_;
     delete output_queue_semaphore_;  // Only used for manual mode.
+    delete input_queue_semaphore_;
     delete stop_semaphore_;
   }

  private:
+#ifdef DEBUG
+  int thread_id_;
+#endif
+
   Isolate* isolate_;
   Semaphore* stop_semaphore_;
   Semaphore* input_queue_semaphore_;
@@ -97,10 +104,6 @@ class OptimizingCompilerThread : public Thread {
   volatile Atomic32 queue_length_;
   int64_t time_spent_compiling_;
   int64_t time_spent_total_;
-
-#ifdef DEBUG
-  int thread_id_;
-#endif
 };

 } }  // namespace v8::internal


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to