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/compilation-info.h" | 11 #include "src/compilation-info.h" |
12 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" | 12 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" |
13 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" | 13 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" |
14 #include "src/flags.h" | 14 #include "src/flags.h" |
15 #include "src/objects-inl.h" | 15 #include "src/objects-inl.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 enum class ExceptionHandling { kSwallow, kThrow }; | 22 enum class ExceptionHandling { kSwallow, kThrow }; |
23 | 23 |
24 bool DoNextStepOnMainThread(Isolate* isolate, CompilerDispatcherJob* job, | 24 bool DoNextStepOnMainThread(Isolate* isolate, CompilerDispatcherJob* job, |
25 ExceptionHandling exception_handling) { | 25 ExceptionHandling exception_handling) { |
26 DCHECK(ThreadId::Current().Equals(isolate->thread_id())); | 26 DCHECK(ThreadId::Current().Equals(isolate->thread_id())); |
| 27 |
| 28 // Ensure we are in the correct context for the job. |
| 29 SaveContext save(isolate); |
| 30 isolate->set_context(job->context()); |
| 31 |
27 switch (job->status()) { | 32 switch (job->status()) { |
28 case CompileJobStatus::kInitial: | 33 case CompileJobStatus::kInitial: |
29 job->PrepareToParseOnMainThread(); | 34 job->PrepareToParseOnMainThread(); |
30 break; | 35 break; |
31 | 36 |
32 case CompileJobStatus::kReadyToParse: | 37 case CompileJobStatus::kReadyToParse: |
33 job->Parse(); | 38 job->Parse(); |
34 break; | 39 break; |
35 | 40 |
36 case CompileJobStatus::kParsed: | 41 case CompileJobStatus::kParsed: |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 lock.reset(); | 707 lock.reset(); |
703 DoNextStepOnMainThread(isolate_, job->second.get(), | 708 DoNextStepOnMainThread(isolate_, job->second.get(), |
704 ExceptionHandling::kSwallow); | 709 ExceptionHandling::kSwallow); |
705 } | 710 } |
706 } | 711 } |
707 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); | 712 if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded(); |
708 } | 713 } |
709 | 714 |
710 } // namespace internal | 715 } // namespace internal |
711 } // namespace v8 | 716 } // namespace v8 |
OLD | NEW |