Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/compiler-dispatcher/compiler-dispatcher.h" | 5 #include "src/compiler-dispatcher/compiler-dispatcher.h" |
| 6 | 6 |
| 7 #include "include/v8-platform.h" | 7 #include "include/v8-platform.h" |
| 8 #include "include/v8.h" | 8 #include "include/v8.h" |
| 9 #include "src/base/platform/time.h" | 9 #include "src/base/platform/time.h" |
| 10 #include "src/cancelable-task.h" | 10 #include "src/cancelable-task.h" |
| 11 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" | 11 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" |
| 12 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" | 12 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" |
| 13 #include "src/objects-inl.h" | 13 #include "src/objects-inl.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 enum class ExceptionHandling { kSwallow, kThrow }; | 20 enum class ExceptionHandling { kSwallow, kThrow }; |
| 21 | 21 |
| 22 bool DoNextStepOnMainThread(Isolate* isolate, CompilerDispatcherJob* job, | 22 bool DoNextStepOnMainThread(Isolate* isolate, CompilerDispatcherJob* job, |
| 23 ExceptionHandling exception_handling) { | 23 ExceptionHandling exception_handling) { |
| 24 DCHECK(ThreadId::Current().Equals(isolate->thread_id())); | 24 DCHECK(ThreadId::Current().Equals(isolate->thread_id())); |
| 25 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | |
|
jochen (gone - plz use gerrit)
2017/01/04 08:23:22
turns out that we only create a pending exception,
| |
| 26 switch (job->status()) { | 25 switch (job->status()) { |
| 27 case CompileJobStatus::kInitial: | 26 case CompileJobStatus::kInitial: |
| 28 job->PrepareToParseOnMainThread(); | 27 job->PrepareToParseOnMainThread(); |
| 29 break; | 28 break; |
| 30 | 29 |
| 31 case CompileJobStatus::kReadyToParse: | 30 case CompileJobStatus::kReadyToParse: |
| 32 job->Parse(); | 31 job->Parse(); |
| 33 break; | 32 break; |
| 34 | 33 |
| 35 case CompileJobStatus::kParsed: | 34 case CompileJobStatus::kParsed: |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 46 | 45 |
| 47 case CompileJobStatus::kCompiled: | 46 case CompileJobStatus::kCompiled: |
| 48 job->FinalizeCompilingOnMainThread(); | 47 job->FinalizeCompilingOnMainThread(); |
| 49 break; | 48 break; |
| 50 | 49 |
| 51 case CompileJobStatus::kFailed: | 50 case CompileJobStatus::kFailed: |
| 52 case CompileJobStatus::kDone: | 51 case CompileJobStatus::kDone: |
| 53 break; | 52 break; |
| 54 } | 53 } |
| 55 | 54 |
| 56 if (exception_handling == ExceptionHandling::kThrow && | 55 if (job->status() == CompileJobStatus::kFailed) { |
| 57 try_catch.HasCaught()) { | 56 DCHECK(isolate->has_pending_exception()); |
| 58 DCHECK(job->status() == CompileJobStatus::kFailed); | 57 if (exception_handling == ExceptionHandling::kSwallow) { |
| 59 try_catch.ReThrow(); | 58 isolate->clear_pending_exception(); |
| 59 } | |
| 60 } else { | |
| 61 DCHECK(!isolate->has_pending_exception()); | |
| 60 } | 62 } |
|
vogelheim
2017/01/04 10:08:49
nitpick: Hmm... How about:
DCHECK_EQ(job->status(
jochen (gone - plz use gerrit)
2017/01/04 10:23:18
will do in a follow-up
| |
| 61 return job->status() != CompileJobStatus::kFailed; | 63 return job->status() != CompileJobStatus::kFailed; |
| 62 } | 64 } |
| 63 | 65 |
| 64 bool IsFinished(CompilerDispatcherJob* job) { | 66 bool IsFinished(CompilerDispatcherJob* job) { |
| 65 return job->status() == CompileJobStatus::kDone || | 67 return job->status() == CompileJobStatus::kDone || |
| 66 job->status() == CompileJobStatus::kFailed; | 68 job->status() == CompileJobStatus::kFailed; |
| 67 } | 69 } |
| 68 | 70 |
| 69 bool CanRunOnAnyThread(CompilerDispatcherJob* job) { | 71 bool CanRunOnAnyThread(CompilerDispatcherJob* job) { |
| 70 return (job->status() == CompileJobStatus::kReadyToParse && | 72 return (job->status() == CompileJobStatus::kReadyToParse && |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 lock.reset(); | 381 lock.reset(); |
| 380 DoNextStepOnMainThread(isolate_, job->second.get(), | 382 DoNextStepOnMainThread(isolate_, job->second.get(), |
| 381 ExceptionHandling::kSwallow); | 383 ExceptionHandling::kSwallow); |
| 382 } | 384 } |
| 383 } | 385 } |
| 384 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); | 386 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); |
| 385 } | 387 } |
| 386 | 388 |
| 387 } // namespace internal | 389 } // namespace internal |
| 388 } // namespace v8 | 390 } // namespace v8 |
| OLD | NEW |