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-job.h" | 5 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" |
6 | 6 |
7 #include "src/assert-scope.h" | 7 #include "src/assert-scope.h" |
8 #include "src/compilation-info.h" | 8 #include "src/compilation-info.h" |
9 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" | 9 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
11 #include "src/flags.h" | 11 #include "src/flags.h" |
12 #include "src/global-handles.h" | 12 #include "src/global-handles.h" |
13 #include "src/isolate.h" | 13 #include "src/isolate.h" |
14 #include "src/objects-inl.h" | 14 #include "src/objects-inl.h" |
15 #include "src/parsing/parse-info.h" | 15 #include "src/parsing/parse-info.h" |
16 #include "src/parsing/parser.h" | 16 #include "src/parsing/parser.h" |
17 #include "src/parsing/scanner-character-streams.h" | 17 #include "src/parsing/scanner-character-streams.h" |
18 #include "src/unicode-cache.h" | 18 #include "src/unicode-cache.h" |
19 #include "src/utils.h" | 19 #include "src/utils.h" |
20 #include "src/zone/zone.h" | 20 #include "src/zone/zone.h" |
21 | 21 |
22 namespace v8 { | 22 namespace v8 { |
23 namespace internal { | 23 namespace internal { |
24 | 24 |
25 CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate, | 25 CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate, |
26 CompilerDispatcherTracer* tracer, | 26 CompilerDispatcherTracer* tracer, |
27 Handle<SharedFunctionInfo> shared, | 27 Handle<SharedFunctionInfo> shared, |
28 size_t max_stack_size) | 28 size_t max_stack_size) |
29 : isolate_(isolate), | 29 : status_(CompileJobStatus::kInitial), |
| 30 isolate_(isolate), |
30 tracer_(tracer), | 31 tracer_(tracer), |
31 shared_(Handle<SharedFunctionInfo>::cast( | 32 shared_(Handle<SharedFunctionInfo>::cast( |
32 isolate_->global_handles()->Create(*shared))), | 33 isolate_->global_handles()->Create(*shared))), |
33 max_stack_size_(max_stack_size), | 34 max_stack_size_(max_stack_size), |
34 can_compile_on_background_thread_(false), | 35 can_compile_on_background_thread_(false), |
35 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { | 36 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { |
36 HandleScope scope(isolate_); | 37 HandleScope scope(isolate_); |
37 DCHECK(!shared_->outer_scope_info()->IsTheHole(isolate_)); | |
38 Handle<Script> script(Script::cast(shared_->script()), isolate_); | 38 Handle<Script> script(Script::cast(shared_->script()), isolate_); |
39 Handle<String> source(String::cast(script->source()), isolate_); | 39 Handle<String> source(String::cast(script->source()), isolate_); |
40 can_parse_on_background_thread_ = | 40 can_parse_on_background_thread_ = |
41 source->IsExternalTwoByteString() || source->IsExternalOneByteString(); | 41 source->IsExternalTwoByteString() || source->IsExternalOneByteString(); |
42 if (trace_compiler_dispatcher_jobs_) { | 42 if (trace_compiler_dispatcher_jobs_) { |
43 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this)); | 43 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this)); |
44 shared_->ShortPrint(); | 44 shared_->ShortPrint(); |
45 PrintF("\n"); | 45 PrintF("\n"); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
| 49 CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate, |
| 50 CompilerDispatcherTracer* tracer, |
| 51 Zone* zone, ParseInfo* parse_info, |
| 52 CompilationInfo* compile_info, |
| 53 CompilationJob* job, |
| 54 size_t max_stack_size) |
| 55 : status_(CompileJobStatus::kReadyToCompile), |
| 56 isolate_(isolate), |
| 57 tracer_(tracer), |
| 58 shared_(Handle<SharedFunctionInfo>::cast( |
| 59 isolate_->global_handles()->Create(*compile_info->shared_info()))), |
| 60 max_stack_size_(max_stack_size), |
| 61 zone_(zone), |
| 62 parse_info_(parse_info), |
| 63 compile_info_(compile_info), |
| 64 compile_job_(job), |
| 65 can_parse_on_background_thread_(false), |
| 66 can_compile_on_background_thread_( |
| 67 job->can_execute_on_background_thread()), |
| 68 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { |
| 69 DCHECK_EQ(zone, parse_info->zone()); |
| 70 DCHECK_EQ(parse_info, compile_info->parse_info()); |
| 71 if (trace_compiler_dispatcher_jobs_) { |
| 72 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this)); |
| 73 shared_->ShortPrint(); |
| 74 PrintF("\n"); |
| 75 } |
| 76 } |
| 77 |
49 CompilerDispatcherJob::~CompilerDispatcherJob() { | 78 CompilerDispatcherJob::~CompilerDispatcherJob() { |
50 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); | 79 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); |
51 DCHECK(status_ == CompileJobStatus::kInitial || | 80 DCHECK(status_ == CompileJobStatus::kInitial || |
52 status_ == CompileJobStatus::kDone); | 81 status_ == CompileJobStatus::kDone); |
53 i::GlobalHandles::Destroy(Handle<Object>::cast(shared_).location()); | 82 i::GlobalHandles::Destroy(Handle<Object>::cast(shared_).location()); |
54 } | 83 } |
55 | 84 |
56 bool CompilerDispatcherJob::IsAssociatedWith( | 85 bool CompilerDispatcherJob::IsAssociatedWith( |
57 Handle<SharedFunctionInfo> shared) const { | 86 Handle<SharedFunctionInfo> shared) const { |
58 return *shared_ == *shared; | 87 return *shared_ == *shared; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 return 0.0; | 357 return 0.0; |
329 } | 358 } |
330 | 359 |
331 void CompilerDispatcherJob::ShortPrint() { | 360 void CompilerDispatcherJob::ShortPrint() { |
332 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); | 361 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); |
333 shared_->ShortPrint(); | 362 shared_->ShortPrint(); |
334 } | 363 } |
335 | 364 |
336 } // namespace internal | 365 } // namespace internal |
337 } // namespace v8 | 366 } // namespace v8 |
OLD | NEW |