OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/optimizing-compiler-thread.h" | 5 #include "src/optimizing-compiler-thread.h" |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
10 #include "src/full-codegen.h" | 10 #include "src/full-codegen.h" |
11 #include "src/hydrogen.h" | 11 #include "src/hydrogen.h" |
12 #include "src/isolate.h" | 12 #include "src/isolate.h" |
13 #include "src/v8threads.h" | 13 #include "src/v8threads.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 class OptimizingCompilerThread::CompileTask : public v8::Task { | 18 class OptimizingCompilerThread::CompileTask : public v8::Task { |
19 public: | 19 public: |
20 CompileTask(Isolate* isolate, OptimizedCompileJob* job) | 20 CompileTask(Isolate* isolate, OptimizedCompileJob* job) |
21 : isolate_(isolate), job_(job) {} | 21 : isolate_(isolate), job_(job) {} |
22 | 22 |
23 virtual ~CompileTask() {} | 23 virtual ~CompileTask() {} |
24 | 24 |
25 private: | 25 private: |
26 // v8::Task overrides. | 26 // v8::Task overrides. |
27 virtual void Run() OVERRIDE { | 27 virtual void Run() OVERRIDE { |
28 Isolate::SetIsolateThreadLocals(isolate_, NULL); | |
29 DisallowHeapAllocation no_allocation; | 28 DisallowHeapAllocation no_allocation; |
30 DisallowHandleAllocation no_handles; | 29 DisallowHandleAllocation no_handles; |
31 DisallowHandleDereference no_deref; | 30 DisallowHandleDereference no_deref; |
32 | 31 |
33 // The function may have already been optimized by OSR. Simply continue. | 32 // The function may have already been optimized by OSR. Simply continue. |
34 OptimizedCompileJob::Status status = job_->OptimizeGraph(); | 33 OptimizedCompileJob::Status status = job_->OptimizeGraph(); |
35 USE(status); // Prevent an unused-variable error in release mode. | 34 USE(status); // Prevent an unused-variable error in release mode. |
36 DCHECK(status != OptimizedCompileJob::FAILED); | 35 DCHECK(status != OptimizedCompileJob::FAILED); |
37 | 36 |
38 // The function may have already been optimized by OSR. Simply continue. | 37 // The function may have already been optimized by OSR. Simply continue. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 71 } |
73 } | 72 } |
74 | 73 |
75 | 74 |
76 void OptimizingCompilerThread::Run() { | 75 void OptimizingCompilerThread::Run() { |
77 #ifdef DEBUG | 76 #ifdef DEBUG |
78 { base::LockGuard<base::Mutex> lock_guard(&thread_id_mutex_); | 77 { base::LockGuard<base::Mutex> lock_guard(&thread_id_mutex_); |
79 thread_id_ = ThreadId::Current().ToInteger(); | 78 thread_id_ = ThreadId::Current().ToInteger(); |
80 } | 79 } |
81 #endif | 80 #endif |
82 Isolate::SetIsolateThreadLocals(isolate_, NULL); | |
83 DisallowHeapAllocation no_allocation; | 81 DisallowHeapAllocation no_allocation; |
84 DisallowHandleAllocation no_handles; | 82 DisallowHandleAllocation no_handles; |
85 DisallowHandleDereference no_deref; | 83 DisallowHandleDereference no_deref; |
86 | 84 |
87 if (FLAG_job_based_recompilation) { | 85 if (FLAG_job_based_recompilation) { |
88 return; | 86 return; |
89 } | 87 } |
90 | 88 |
91 base::ElapsedTimer total_timer; | 89 base::ElapsedTimer total_timer; |
92 if (FLAG_trace_concurrent_recompilation) total_timer.Start(); | 90 if (FLAG_trace_concurrent_recompilation) total_timer.Start(); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 434 |
437 | 435 |
438 bool OptimizingCompilerThread::IsOptimizerThread() { | 436 bool OptimizingCompilerThread::IsOptimizerThread() { |
439 base::LockGuard<base::Mutex> lock_guard(&thread_id_mutex_); | 437 base::LockGuard<base::Mutex> lock_guard(&thread_id_mutex_); |
440 return ThreadId::Current().ToInteger() == thread_id_; | 438 return ThreadId::Current().ToInteger() == thread_id_; |
441 } | 439 } |
442 #endif | 440 #endif |
443 | 441 |
444 | 442 |
445 } } // namespace v8::internal | 443 } } // namespace v8::internal |
OLD | NEW |